svn merge -r39781:39792 https://svn.blender.org/svnroot/bf-blender/trunk/blender...
[blender-staging.git] / source / blender / blenkernel / intern / sound.c
1 /** \file blender/blenkernel/intern/sound.c
2  *  \ingroup bke
3  */
4 /**
5  * sound.c (mar-2001 nzc)
6  *
7  * $Id$
8  */
9
10 #include <string.h>
11 #include <stdlib.h>
12
13 #include "MEM_guardedalloc.h"
14
15 #include "BLI_blenlib.h"
16 #include "BLI_math.h"
17
18 #include "DNA_anim_types.h"
19 #include "DNA_object_types.h"
20 #include "DNA_scene_types.h"
21 #include "DNA_sequence_types.h"
22 #include "DNA_packedFile_types.h"
23 #include "DNA_screen_types.h"
24 #include "DNA_sound_types.h"
25 #include "DNA_speaker_types.h"
26
27 #ifdef WITH_AUDASPACE
28 #  include "AUD_C-API.h"
29 #endif
30
31 #include "BKE_utildefines.h"
32 #include "BKE_global.h"
33 #include "BKE_main.h"
34 #include "BKE_sound.h"
35 #include "BKE_context.h"
36 #include "BKE_library.h"
37 #include "BKE_packedFile.h"
38 #include "BKE_animsys.h"
39 #include "BKE_sequencer.h"
40 #include "BKE_scene.h"
41
42 // evil global ;-)
43 static int sound_cfra;
44
45 struct bSound* sound_new_file(struct Main *bmain, const char *filename)
46 {
47         bSound* sound = NULL;
48
49         char str[FILE_MAX];
50         char *path;
51
52         int len;
53
54         strcpy(str, filename);
55
56         path = /*bmain ? bmain->name :*/ G.main->name;
57
58         BLI_path_abs(str, path);
59
60         len = strlen(filename);
61         while(len > 0 && filename[len-1] != '/' && filename[len-1] != '\\')
62                 len--;
63
64         sound = alloc_libblock(&bmain->sound, ID_SO, filename+len);
65         BLI_strncpy(sound->name, filename, FILE_MAX);
66 // XXX unused currently sound->type = SOUND_TYPE_FILE;
67
68         sound_load(bmain, sound);
69
70         if(!sound->playback_handle)
71         {
72                 free_libblock(&bmain->sound, sound);
73                 sound = NULL;
74         }
75
76         return sound;
77 }
78
79 void sound_free(struct bSound* sound)
80 {
81         if (sound->packedfile)
82         {
83                 freePackedFile(sound->packedfile);
84                 sound->packedfile = NULL;
85         }
86
87 #ifdef WITH_AUDASPACE
88         if(sound->handle)
89         {
90                 AUD_unload(sound->handle);
91                 sound->handle = NULL;
92                 sound->playback_handle = NULL;
93         }
94
95         if(sound->cache)
96         {
97                 AUD_unload(sound->cache);
98                 sound->cache = NULL;
99         }
100
101         sound_free_waveform(sound);
102 #endif // WITH_AUDASPACE
103 }
104
105 #ifdef WITH_AUDASPACE
106
107 static int force_device = -1;
108
109 #ifdef WITH_JACK
110 static void sound_sync_callback(void* data, int mode, float time)
111 {
112         struct Main* bmain = (struct Main*)data;
113         struct Scene* scene;
114
115         scene = bmain->scene.first;
116         while(scene)
117         {
118                 if(scene->audio.flag & AUDIO_SYNC)
119                 {
120                         if(mode)
121                                 sound_play_scene(scene);
122                         else
123                                 sound_stop_scene(scene);
124                         if(scene->sound_scene_handle)
125                                 AUD_seek(scene->sound_scene_handle, time);
126                 }
127                 scene = scene->id.next;
128         }
129 }
130 #endif
131
132 int sound_define_from_str(const char *str)
133 {
134         if (BLI_strcaseeq(str, "NULL"))
135                 return AUD_NULL_DEVICE;
136         if (BLI_strcaseeq(str, "SDL"))
137                 return AUD_SDL_DEVICE;
138         if (BLI_strcaseeq(str, "OPENAL"))
139                 return AUD_OPENAL_DEVICE;
140         if (BLI_strcaseeq(str, "JACK"))
141                 return AUD_JACK_DEVICE;
142
143         return -1;
144 }
145
146 void sound_force_device(int device)
147 {
148         force_device = device;
149 }
150
151 void sound_init_once(void)
152 {
153         AUD_initOnce();
154 }
155
156 void sound_init(struct Main *bmain)
157 {
158         AUD_DeviceSpecs specs;
159         int device, buffersize;
160
161         device = U.audiodevice;
162         buffersize = U.mixbufsize;
163         specs.channels = U.audiochannels;
164         specs.format = U.audioformat;
165         specs.rate = U.audiorate;
166
167         if(force_device >= 0)
168                 device = force_device;
169
170         if(buffersize < 128)
171                 buffersize = AUD_DEFAULT_BUFFER_SIZE;
172
173         if(specs.rate < AUD_RATE_8000)
174                 specs.rate = AUD_RATE_44100;
175
176         if(specs.format <= AUD_FORMAT_INVALID)
177                 specs.format = AUD_FORMAT_S16;
178
179         if(specs.channels <= AUD_CHANNELS_INVALID)
180                 specs.channels = AUD_CHANNELS_STEREO;
181
182         if(!AUD_init(device, specs, buffersize))
183                 AUD_init(AUD_NULL_DEVICE, specs, buffersize);
184
185         sound_init_main(bmain);
186 }
187
188 void sound_init_main(struct Main *bmain)
189 {
190 #ifdef WITH_JACK
191         AUD_setSyncCallback(sound_sync_callback, bmain);
192 #else
193         (void)bmain; /* unused */
194 #endif
195 }
196
197 void sound_exit(void)
198 {
199         AUD_exit();
200 }
201
202 // XXX unused currently
203 #if 0
204 struct bSound* sound_new_buffer(struct bContext *C, struct bSound *source)
205 {
206         bSound* sound = NULL;
207
208         char name[25];
209         strcpy(name, "buf_");
210         strcpy(name + 4, source->id.name);
211
212         sound = alloc_libblock(&CTX_data_main(C)->sound, ID_SO, name);
213
214         sound->child_sound = source;
215         sound->type = SOUND_TYPE_BUFFER;
216
217         sound_load(CTX_data_main(C), sound);
218
219         if(!sound->playback_handle)
220         {
221                 free_libblock(&CTX_data_main(C)->sound, sound);
222                 sound = NULL;
223         }
224
225         return sound;
226 }
227
228 struct bSound* sound_new_limiter(struct bContext *C, struct bSound *source, float start, float end)
229 {
230         bSound* sound = NULL;
231
232         char name[25];
233         strcpy(name, "lim_");
234         strcpy(name + 4, source->id.name);
235
236         sound = alloc_libblock(&CTX_data_main(C)->sound, ID_SO, name);
237
238         sound->child_sound = source;
239         sound->start = start;
240         sound->end = end;
241         sound->type = SOUND_TYPE_LIMITER;
242
243         sound_load(CTX_data_main(C), sound);
244
245         if(!sound->playback_handle)
246         {
247                 free_libblock(&CTX_data_main(C)->sound, sound);
248                 sound = NULL;
249         }
250
251         return sound;
252 }
253 #endif
254
255 void sound_delete(struct bContext *C, struct bSound* sound)
256 {
257         if(sound)
258         {
259                 sound_free(sound);
260
261                 free_libblock(&CTX_data_main(C)->sound, sound);
262         }
263 }
264
265 void sound_cache(struct bSound* sound)
266 {
267         sound->flags |= SOUND_FLAGS_CACHING;
268         if(sound->cache)
269                 AUD_unload(sound->cache);
270
271         sound->cache = AUD_bufferSound(sound->handle);
272         sound->playback_handle = sound->cache;
273 }
274
275 void sound_cache_notifying(struct Main* main, struct bSound* sound)
276 {
277         sound_cache(sound);
278         sound_update_sequencer(main, sound);
279 }
280
281 void sound_delete_cache(struct bSound* sound)
282 {
283         sound->flags &= ~SOUND_FLAGS_CACHING;
284         if(sound->cache)
285         {
286                 AUD_unload(sound->cache);
287                 sound->cache = NULL;
288                 sound->playback_handle = sound->handle;
289         }
290 }
291
292 void sound_load(struct Main *bmain, struct bSound* sound)
293 {
294         if(sound)
295         {
296                 if(sound->cache)
297                 {
298                         AUD_unload(sound->cache);
299                         sound->cache = NULL;
300                 }
301
302                 if(sound->handle)
303                 {
304                         AUD_unload(sound->handle);
305                         sound->handle = NULL;
306                         sound->playback_handle = NULL;
307                 }
308
309 // XXX unused currently
310 #if 0
311                 switch(sound->type)
312                 {
313                 case SOUND_TYPE_FILE:
314 #endif
315                 {
316                         char fullpath[FILE_MAX];
317                         char *path;
318
319                         /* load sound */
320                         PackedFile* pf = sound->packedfile;
321
322                         /* dont modify soundact->sound->name, only change a copy */
323                         BLI_strncpy(fullpath, sound->name, sizeof(fullpath));
324
325                         if(sound->id.lib)
326                                 path = sound->id.lib->filepath;
327                         else
328                                 path = bmain->name;
329
330                         BLI_path_abs(fullpath, path);
331
332                         /* but we need a packed file then */
333                         if (pf)
334                                 sound->handle = AUD_loadBuffer((unsigned char*) pf->data, pf->size);
335                         /* or else load it from disk */
336                         else
337                                 sound->handle = AUD_load(fullpath);
338                 }
339 // XXX unused currently
340 #if 0
341                         break;
342                 }
343                 case SOUND_TYPE_BUFFER:
344                         if(sound->child_sound && sound->child_sound->handle)
345                                 sound->handle = AUD_bufferSound(sound->child_sound->handle);
346                         break;
347                 case SOUND_TYPE_LIMITER:
348                         if(sound->child_sound && sound->child_sound->handle)
349                                 sound->handle = AUD_limitSound(sound->child_sound, sound->start, sound->end);
350                         break;
351                 }
352 #endif
353                 if(sound->flags & SOUND_FLAGS_MONO)
354                 {
355                         void* handle = AUD_monoSound(sound->handle);
356                         AUD_unload(sound->handle);
357                         sound->handle = handle;
358                 }
359
360                 if(sound->flags & SOUND_FLAGS_CACHING)
361                 {
362                         sound->cache = AUD_bufferSound(sound->handle);
363                 }
364
365                 if(sound->cache)
366                         sound->playback_handle = sound->cache;
367                 else
368                         sound->playback_handle = sound->handle;
369
370                 sound_update_sequencer(bmain, sound);
371         }
372 }
373
374 AUD_Device* sound_mixdown(struct Scene *scene, AUD_DeviceSpecs specs, int start, float volume)
375 {
376         return AUD_openMixdownDevice(specs, scene->sound_scene, volume, start / FPS);
377 }
378
379 void sound_create_scene(struct Scene *scene)
380 {
381         scene->sound_scene = AUD_createSequencer(FPS, scene->audio.flag & AUDIO_MUTE);
382         AUD_updateSequencerData(scene->sound_scene, scene->audio.speed_of_sound,
383                                                         scene->audio.doppler_factor, scene->audio.distance_model);
384         scene->sound_scene_handle = NULL;
385         scene->sound_scrub_handle = NULL;
386         scene->speaker_handles = NULL;
387 }
388
389 void sound_destroy_scene(struct Scene *scene)
390 {
391         if(scene->sound_scene_handle)
392                 AUD_stop(scene->sound_scene_handle);
393         if(scene->sound_scrub_handle)
394                 AUD_stop(scene->sound_scrub_handle);
395         if(scene->sound_scene)
396                 AUD_destroySequencer(scene->sound_scene);
397         if(scene->speaker_handles)
398                 AUD_destroySet(scene->speaker_handles);
399 }
400
401 void sound_mute_scene(struct Scene *scene, int muted)
402 {
403         if(scene->sound_scene)
404                 AUD_setSequencerMuted(scene->sound_scene, muted);
405 }
406
407 void sound_update_fps(struct Scene *scene)
408 {
409         if(scene->sound_scene)
410                 AUD_setSequencerFPS(scene->sound_scene, FPS);
411 }
412
413 void sound_update_scene_listener(struct Scene *scene)
414 {
415         AUD_updateSequencerData(scene->sound_scene, scene->audio.speed_of_sound,
416                                                         scene->audio.doppler_factor, scene->audio.distance_model);
417 }
418
419 void* sound_scene_add_scene_sound(struct Scene *scene, struct Sequence* sequence, int startframe, int endframe, int frameskip)
420 {
421         if(scene != sequence->scene)
422                 return AUD_addSequence(scene->sound_scene, sequence->scene->sound_scene, startframe / FPS, endframe / FPS, frameskip / FPS);
423         return NULL;
424 }
425
426 void* sound_add_scene_sound(struct Scene *scene, struct Sequence* sequence, int startframe, int endframe, int frameskip)
427 {
428         void* handle = AUD_addSequence(scene->sound_scene, sequence->sound->playback_handle, startframe / FPS, endframe / FPS, frameskip / FPS);
429         AUD_muteSequence(handle, (sequence->flag & SEQ_MUTE) != 0);
430         AUD_setSequenceAnimData(handle, AUD_AP_VOLUME, CFRA, &sequence->volume, 0);
431         AUD_setSequenceAnimData(handle, AUD_AP_PITCH, CFRA, &sequence->pitch, 0);
432         AUD_setSequenceAnimData(handle, AUD_AP_PANNING, CFRA, &sequence->pan, 0);
433         return handle;
434 }
435
436 void sound_remove_scene_sound(struct Scene *scene, void* handle)
437 {
438         AUD_removeSequence(scene->sound_scene, handle);
439 }
440
441 void sound_mute_scene_sound(void* handle, char mute)
442 {
443         AUD_muteSequence(handle, mute);
444 }
445
446 void sound_move_scene_sound(struct Scene *scene, void* handle, int startframe, int endframe, int frameskip)
447 {
448         AUD_moveSequence(handle, startframe / FPS, endframe / FPS, frameskip / FPS);
449 }
450
451 void sound_update_scene_sound(void* handle, struct bSound* sound)
452 {
453         AUD_updateSequenceSound(handle, sound->playback_handle);
454 }
455
456 void sound_set_cfra(int cfra)
457 {
458         sound_cfra = cfra;
459 }
460
461 void sound_set_scene_volume(struct Scene *scene, float volume)
462 {
463         AUD_setSequencerAnimData(scene->sound_scene, AUD_AP_VOLUME, CFRA, &volume, (scene->audio.flag & AUDIO_VOLUME_ANIMATED) != 0);
464 }
465
466 void sound_set_scene_sound_volume(void* handle, float volume, char animated)
467 {
468         AUD_setSequenceAnimData(handle, AUD_AP_VOLUME, sound_cfra, &volume, animated);
469 }
470
471 void sound_set_scene_sound_pitch(void* handle, float pitch, char animated)
472 {
473         AUD_setSequenceAnimData(handle, AUD_AP_PITCH, sound_cfra, &pitch, animated);
474 }
475
476 void sound_set_scene_sound_pan(void* handle, float pan, char animated)
477 {
478         AUD_setSequenceAnimData(handle, AUD_AP_PANNING, sound_cfra, &pan, animated);
479 }
480
481 void sound_update_sequencer(struct Main* main, struct bSound* sound)
482 {
483         struct Scene* scene;
484
485         for(scene = main->scene.first; scene; scene = scene->id.next)
486                 seq_update_sound(scene, sound);
487 }
488
489 static void sound_start_play_scene(struct Scene *scene)
490 {
491         if(scene->sound_scene_handle)
492                 AUD_stop(scene->sound_scene_handle);
493
494         AUD_setSequencerDeviceSpecs(scene->sound_scene);
495
496         if((scene->sound_scene_handle = AUD_play(scene->sound_scene, 1)))
497                 AUD_setLoop(scene->sound_scene_handle, -1);
498 }
499
500 void sound_play_scene(struct Scene *scene)
501 {
502         AUD_Status status;
503         AUD_lock();
504
505         status = scene->sound_scene_handle ? AUD_getStatus(scene->sound_scene_handle) : AUD_STATUS_INVALID;
506
507         if(status == AUD_STATUS_INVALID)
508                 sound_start_play_scene(scene);
509
510         if(!scene->sound_scene_handle)
511         {
512                 AUD_unlock();
513                 return;
514         }
515
516         if(status != AUD_STATUS_PLAYING)
517         {
518                 AUD_seek(scene->sound_scene_handle, CFRA / FPS);
519                 AUD_resume(scene->sound_scene_handle);
520         }
521
522         if(scene->audio.flag & AUDIO_SYNC)
523                 AUD_startPlayback();
524
525         AUD_unlock();
526 }
527
528 void sound_stop_scene(struct Scene *scene)
529 {
530         if(scene->sound_scene_handle)
531         {
532                 AUD_pause(scene->sound_scene_handle);
533
534                 if(scene->audio.flag & AUDIO_SYNC)
535                         AUD_stopPlayback();
536         }
537 }
538
539 void sound_seek_scene(struct bContext *C)
540 {
541         struct Scene *scene = CTX_data_scene(C);
542         AUD_Status status;
543
544         AUD_lock();
545
546         status = scene->sound_scene_handle ? AUD_getStatus(scene->sound_scene_handle) : AUD_STATUS_INVALID;
547
548         if(status == AUD_STATUS_INVALID)
549         {
550                 sound_start_play_scene(scene);
551
552                 if(!scene->sound_scene_handle)
553                 {
554                         AUD_unlock();
555                         return;
556                 }
557
558                 AUD_pause(scene->sound_scene_handle);
559         }
560
561         if(scene->audio.flag & AUDIO_SCRUB && !CTX_wm_screen(C)->animtimer)
562         {
563                 if(scene->audio.flag & AUDIO_SYNC)
564                 {
565                         AUD_seek(scene->sound_scene_handle, CFRA / FPS);
566                         AUD_seekSequencer(scene->sound_scene_handle, CFRA / FPS);
567                 }
568                 else
569                         AUD_seek(scene->sound_scene_handle, CFRA / FPS);
570                 AUD_resume(scene->sound_scene_handle);
571                 if(scene->sound_scrub_handle && AUD_getStatus(scene->sound_scrub_handle) != AUD_STATUS_INVALID)
572                         AUD_seek(scene->sound_scrub_handle, 0);
573                 else
574                 {
575                         if(scene->sound_scrub_handle)
576                                 AUD_stop(scene->sound_scrub_handle);
577                         scene->sound_scrub_handle = AUD_pauseAfter(scene->sound_scene_handle, 1 / FPS);
578                 }
579         }
580         else
581         {
582                 if(scene->audio.flag & AUDIO_SYNC)
583                         AUD_seekSequencer(scene->sound_scene_handle, CFRA / FPS);
584                 else
585                 {
586                         if(status == AUD_STATUS_PLAYING)
587                                 AUD_seek(scene->sound_scene_handle, CFRA / FPS);
588                 }
589         }
590
591         AUD_unlock();
592 }
593
594 float sound_sync_scene(struct Scene *scene)
595 {
596         if(scene->sound_scene_handle)
597         {
598                 if(scene->audio.flag & AUDIO_SYNC)
599                         return AUD_getSequencerPosition(scene->sound_scene_handle);
600                 else
601                         return AUD_getPosition(scene->sound_scene_handle);
602         }
603         return 0.0f;
604 }
605
606 int sound_scene_playing(struct Scene *scene)
607 {
608         if(scene->audio.flag & AUDIO_SYNC)
609                 return AUD_doesPlayback();
610         else
611                 return -1;
612 }
613
614 void sound_free_waveform(struct bSound* sound)
615 {
616         if(sound->waveform)
617         {
618                 MEM_freeN(((SoundWaveform*)sound->waveform)->data);
619                 MEM_freeN(sound->waveform);
620         }
621
622         sound->waveform = NULL;
623 }
624
625 void sound_read_waveform(struct bSound* sound)
626 {
627         AUD_SoundInfo info;
628
629         info = AUD_getInfo(sound->playback_handle);
630
631         if(info.length > 0)
632         {
633                 SoundWaveform* waveform = MEM_mallocN(sizeof(SoundWaveform), "SoundWaveform");
634                 int length = info.length * SOUND_WAVE_SAMPLES_PER_SECOND;
635
636                 waveform->data = MEM_mallocN(length * sizeof(float) * 3, "SoundWaveform.samples");
637                 waveform->length = AUD_readSound(sound->playback_handle, waveform->data, length, SOUND_WAVE_SAMPLES_PER_SECOND);
638
639                 sound_free_waveform(sound);
640                 sound->waveform = waveform;
641         }
642 }
643
644 int sound_get_channels(struct bSound* sound)
645 {
646         AUD_SoundInfo info;
647
648         info = AUD_getInfo(sound->playback_handle);
649
650         return info.specs.channels;
651 }
652
653 void sound_update_scene(struct Scene* scene)
654 {
655         Object* ob;
656         Base* base;
657         NlaTrack* track;
658         NlaStrip* strip;
659         Speaker* speaker;
660         Scene* sce_it;
661
662         void* new_set = AUD_createSet();
663         void* handle;
664         float quat[4];
665
666         for(SETLOOPER(scene, sce_it, base))
667         {
668                 ob = base->object;
669                 if(ob->type == OB_SPEAKER)
670                 {
671                         if(ob->adt)
672                         {
673                                 for(track = ob->adt->nla_tracks.first; track; track = track->next)
674                                 {
675                                         for(strip = track->strips.first; strip; strip = strip->next)
676                                         {
677                                                 if(strip->type == NLASTRIP_TYPE_SOUND)
678                                                 {
679                                                         speaker = (Speaker*)ob->data;
680
681                                                         if(AUD_removeSet(scene->speaker_handles, strip->speaker_handle))
682                                                         {
683                                                                 if(speaker->sound)
684                                                                         AUD_moveSequence(strip->speaker_handle, strip->start / FPS, -1, 0);
685                                                                 else
686                                                                 {
687                                                                         AUD_removeSequence(scene->sound_scene, strip->speaker_handle);
688                                                                         strip->speaker_handle = NULL;
689                                                                 }
690                                                         }
691                                                         else
692                                                         {
693                                                                 if(speaker->sound)
694                                                                 {
695                                                                         strip->speaker_handle = AUD_addSequence(scene->sound_scene, speaker->sound->playback_handle, strip->start / FPS, -1, 0);
696                                                                         AUD_setRelativeSequence(strip->speaker_handle, 0);
697                                                                 }
698                                                         }
699
700                                                         if(strip->speaker_handle)
701                                                         {
702                                                                 AUD_addSet(new_set, strip->speaker_handle);
703                                                                 AUD_updateSequenceData(strip->speaker_handle, speaker->volume_max,
704                                                                                                            speaker->volume_min, speaker->distance_max,
705                                                                                                            speaker->distance_reference, speaker->attenuation,
706                                                                                                            speaker->cone_angle_outer, speaker->cone_angle_inner,
707                                                                                                            speaker->cone_volume_outer);
708
709                                                                 mat4_to_quat(quat, ob->obmat);
710                                                                 AUD_setSequenceAnimData(strip->speaker_handle, AUD_AP_LOCATION, CFRA, ob->obmat[3], 1);
711                                                                 AUD_setSequenceAnimData(strip->speaker_handle, AUD_AP_ORIENTATION, CFRA, quat, 1);
712                                                                 AUD_setSequenceAnimData(strip->speaker_handle, AUD_AP_VOLUME, CFRA, &speaker->volume, 1);
713                                                                 AUD_setSequenceAnimData(strip->speaker_handle, AUD_AP_PITCH, CFRA, &speaker->pitch, 1);
714                                                                 AUD_updateSequenceSound(strip->speaker_handle, speaker->sound->playback_handle);
715                                                                 AUD_muteSequence(strip->speaker_handle, ((strip->flag & NLASTRIP_FLAG_MUTED) != 0) || ((speaker->flag & SPK_MUTED) != 0));
716                                                         }
717                                                 }
718                                         }
719                                 }
720                         }
721                 }
722         }
723
724         while((handle = AUD_getSet(scene->speaker_handles)))
725         {
726                 AUD_removeSequence(scene->sound_scene, handle);
727         }
728
729         if(scene->camera)
730         {
731                 mat4_to_quat(quat, scene->camera->obmat);
732                 AUD_setSequencerAnimData(scene->sound_scene, AUD_AP_LOCATION, CFRA, scene->camera->obmat[3], 1);
733                 AUD_setSequencerAnimData(scene->sound_scene, AUD_AP_ORIENTATION, CFRA, quat, 1);
734         }
735
736         AUD_destroySet(scene->speaker_handles);
737         scene->speaker_handles = new_set;
738 }
739
740 void* sound_get_factory(void* sound)
741 {
742         return ((struct bSound*) sound)->playback_handle;
743 }
744
745 #else // WITH_AUDASPACE
746
747 #include "BLI_utildefines.h"
748
749 int sound_define_from_str(const char *UNUSED(str)) { return -1;}
750 void sound_force_device(int UNUSED(device)) {}
751 void sound_init_once(void) {}
752 void sound_init(struct Main *UNUSED(bmain)) {}
753 void sound_exit(void) {}
754 void sound_cache(struct bSound* UNUSED(sound)) { }
755 void sound_delete_cache(struct bSound* UNUSED(sound)) {}
756 void sound_load(struct Main *UNUSED(bmain), struct bSound* UNUSED(sound)) {}
757 void sound_create_scene(struct Scene *UNUSED(scene)) {}
758 void sound_destroy_scene(struct Scene *UNUSED(scene)) {}
759 void sound_mute_scene(struct Scene *UNUSED(scene), int UNUSED(muted)) {}
760 void* sound_scene_add_scene_sound(struct Scene *UNUSED(scene), struct Sequence* UNUSED(sequence), int UNUSED(startframe), int UNUSED(endframe), int UNUSED(frameskip)) { return NULL; }
761 void* sound_add_scene_sound(struct Scene *UNUSED(scene), struct Sequence* UNUSED(sequence), int UNUSED(startframe), int UNUSED(endframe), int UNUSED(frameskip)) { return NULL; }
762 void sound_remove_scene_sound(struct Scene *UNUSED(scene), void* UNUSED(handle)) {}
763 void sound_mute_scene_sound(void* UNUSED(handle), char UNUSED(mute)) {}
764 void sound_move_scene_sound(struct Scene *UNUSED(scene), void* UNUSED(handle), int UNUSED(startframe), int UNUSED(endframe), int UNUSED(frameskip)) {}
765 static void sound_start_play_scene(struct Scene *UNUSED(scene)) {}
766 void sound_play_scene(struct Scene *UNUSED(scene)) {}
767 void sound_stop_scene(struct Scene *UNUSED(scene)) {}
768 void sound_seek_scene(struct bContext *UNUSED(C)) {}
769 float sound_sync_scene(struct Scene *UNUSED(scene)) { return 0.0f; }
770 int sound_scene_playing(struct Scene *UNUSED(scene)) { return -1; }
771 int sound_read_sound_buffer(struct bSound* UNUSED(sound), float* UNUSED(buffer), int UNUSED(length), float UNUSED(start), float UNUSED(end)) { return 0; }
772 int sound_get_channels(struct bSound* UNUSED(sound)) { return 1; }
773
774 #endif // WITH_AUDASPACE