- change max threads from 8 to 64, need to keep an eye on stack memory use here.
[blender.git] / source / blender / blenkernel / intern / sound.c
index 06ef8a23142d76fa8720c24d9dbf454bf5ee566f..3232e2677b53ea255afa38a2ba0a868e40be2ac8 100644 (file)
 #include <config.h>
 #endif
 
 #include <config.h>
 #endif
 
+static int sound_disabled = 0;
+
+void sound_disable()
+{
+       sound_disabled = 1;
+}
+
 void sound_init()
 {
 void sound_init()
 {
-       AUD_Specs specs;
+       AUD_DeviceSpecs specs;
        int device, buffersize;
 
        device = U.audiodevice;
        int device, buffersize;
 
        device = U.audiodevice;
@@ -42,6 +49,9 @@ void sound_init()
        specs.format = U.audioformat;
        specs.rate = U.audiorate;
 
        specs.format = U.audioformat;
        specs.rate = U.audiorate;
 
+       if (sound_disabled)
+               device = 0;
+
        if(buffersize < 128)
                buffersize = AUD_DEFAULT_BUFFER_SIZE;
 
        if(buffersize < 128)
                buffersize = AUD_DEFAULT_BUFFER_SIZE;
 
@@ -250,12 +260,12 @@ void sound_free(struct bSound* sound)
 
 void sound_unlink(struct bContext *C, struct bSound* sound)
 {
 
 void sound_unlink(struct bContext *C, struct bSound* sound)
 {
-       bSound *snd;
        Scene *scene;
        SoundHandle *handle;
 
 // XXX unused currently
 #if 0
        Scene *scene;
        SoundHandle *handle;
 
 // XXX unused currently
 #if 0
+       bSound *snd;
        for(snd = CTX_data_main(C)->sound.first; snd; snd = snd->id.next)
        {
                if(snd->child_sound == sound)
        for(snd = CTX_data_main(C)->sound.first; snd; snd = snd->id.next)
        {
                if(snd->child_sound == sound)
@@ -340,7 +350,7 @@ void sound_update_playing(struct bContext *C)
 
        for(handle = scene->sound_handles.first; handle; handle = handle->next)
        {
 
        for(handle = scene->sound_handles.first; handle; handle = handle->next)
        {
-               if(cfra < handle->startframe || cfra >= handle->endframe || handle->mute)
+               if(cfra < handle->startframe || cfra >= handle->endframe || handle->mute || (scene->audio.flag & AUDIO_MUTE))
                {
                        if(handle->state == AUD_STATUS_PLAYING)
                        {
                {
                        if(handle->state == AUD_STATUS_PLAYING)
                        {
@@ -384,6 +394,8 @@ void sound_update_playing(struct bContext *C)
                                }
                        }
 
                                }
                        }
 
+                       AUD_setSoundVolume(handle->handle, handle->volume);
+                       
                        if(action & 1)
                        {
                                if(handle->state == AUD_STATUS_INVALID)
                        if(action & 1)
                        {
                                if(handle->state == AUD_STATUS_INVALID)
@@ -421,7 +433,7 @@ void sound_scrub(struct bContext *C)
        int cfra = CFRA;
        float fps = FPS;
 
        int cfra = CFRA;
        float fps = FPS;
 
-       if(scene->r.audio.flag & AUDIO_SCRUB && !CTX_wm_screen(C)->animtimer)
+       if(scene->audio.flag & AUDIO_SCRUB && !CTX_wm_screen(C)->animtimer)
        {
                AUD_lock();
 
        {
                AUD_lock();
 
@@ -443,7 +455,7 @@ void sound_scrub(struct bContext *C)
        }
 }
 
        }
 }
 
-AUD_Device* sound_mixdown(struct Scene *scene, AUD_Specs specs, int start, int end)
+AUD_Device* sound_mixdown(struct Scene *scene, AUD_DeviceSpecs specs, int start, int end, float volume)
 {
        AUD_Device* mixdown = AUD_openReadDevice(specs);
        SoundHandle *handle;
 {
        AUD_Device* mixdown = AUD_openReadDevice(specs);
        SoundHandle *handle;
@@ -453,6 +465,8 @@ AUD_Device* sound_mixdown(struct Scene *scene, AUD_Specs specs, int start, int e
 
        end++;
 
 
        end++;
 
+       AUD_setDeviceVolume(mixdown, volume);
+
        for(handle = scene->sound_handles.first; handle; handle = handle->next)
        {
                if(start < handle->endframe && end > handle->startframe && !handle->mute && handle->source && handle->source->handle)
        for(handle = scene->sound_handles.first; handle; handle = handle->next)
        {
                if(start < handle->endframe && end > handle->startframe && !handle->mute && handle->source && handle->source->handle)
@@ -466,7 +480,9 @@ AUD_Device* sound_mixdown(struct Scene *scene, AUD_Specs specs, int start, int e
                                frameskip -= s;
                                s = 0;
                        }
                                frameskip -= s;
                                s = 0;
                        }
-
+                       
+                       AUD_setSoundVolume(handle->handle, handle->volume);
+                       
                        limiter = AUD_limitSound(handle->source->handle, frameskip / fps, e / fps);
                        delayer = AUD_delaySound(limiter, s / fps);
 
                        limiter = AUD_limitSound(handle->source->handle, frameskip / fps, e / fps);
                        delayer = AUD_delaySound(limiter, s / fps);