- 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 2d5d8dad7a8bc8d97941d3a2f2e98050329d9bd6..3232e2677b53ea255afa38a2ba0a868e40be2ac8 100644 (file)
 #include <config.h>
 #endif
 
+static int sound_disabled = 0;
+
+void sound_disable()
+{
+       sound_disabled = 1;
+}
+
 void sound_init()
 {
-       AUD_Specs specs;
+       AUD_DeviceSpecs specs;
        int device, buffersize;
 
        device = U.audiodevice;
@@ -42,6 +49,9 @@ void sound_init()
        specs.format = U.audioformat;
        specs.rate = U.audiorate;
 
+       if (sound_disabled)
+               device = 0;
+
        if(buffersize < 128)
                buffersize = AUD_DEFAULT_BUFFER_SIZE;
 
@@ -340,7 +350,7 @@ void sound_update_playing(struct bContext *C)
 
        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)
                        {
@@ -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)
@@ -421,7 +433,7 @@ void sound_scrub(struct bContext *C)
        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();
 
@@ -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;
@@ -453,6 +465,8 @@ AUD_Device* sound_mixdown(struct Scene *scene, AUD_Specs specs, int start, int e
 
        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)
@@ -466,7 +480,9 @@ AUD_Device* sound_mixdown(struct Scene *scene, AUD_Specs specs, int start, int e
                                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);