Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenkernel/intern/sound.c')
-rw-r--r--source/blender/blenkernel/intern/sound.c139
1 files changed, 71 insertions, 68 deletions
diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c
index f5b677203f6..594c7a9a2f3 100644
--- a/source/blender/blenkernel/intern/sound.c
+++ b/source/blender/blenkernel/intern/sound.c
@@ -95,7 +95,7 @@ struct bSound* sound_new_file(struct Main *bmain, const char *filename)
sound_load(bmain, sound);
- if(!sound->playback_handle)
+ if (!sound->playback_handle)
{
free_libblock(&bmain->sound, sound);
sound = NULL;
@@ -113,14 +113,14 @@ void sound_free(struct bSound* sound)
}
#ifdef WITH_AUDASPACE
- if(sound->handle)
+ if (sound->handle)
{
AUD_unload(sound->handle);
sound->handle = NULL;
sound->playback_handle = NULL;
}
- if(sound->cache)
+ if (sound->cache)
{
AUD_unload(sound->cache);
sound->cache = NULL;
@@ -143,13 +143,13 @@ static void sound_sync_callback(void* data, int mode, float time)
scene = bmain->scene.first;
while(scene)
{
- if(scene->audio.flag & AUDIO_SYNC)
+ if (scene->audio.flag & AUDIO_SYNC)
{
- if(mode)
+ if (mode)
sound_play_scene(scene);
else
sound_stop_scene(scene);
- if(scene->sound_scene_handle)
+ if (scene->sound_scene_handle)
AUD_seek(scene->sound_scene_handle, time);
}
scene = scene->id.next;
@@ -192,22 +192,22 @@ void sound_init(struct Main *bmain)
specs.format = U.audioformat;
specs.rate = U.audiorate;
- if(force_device >= 0)
+ if (force_device >= 0)
device = force_device;
- if(buffersize < 128)
+ if (buffersize < 128)
buffersize = AUD_DEFAULT_BUFFER_SIZE;
- if(specs.rate < AUD_RATE_8000)
+ if (specs.rate < AUD_RATE_8000)
specs.rate = AUD_RATE_44100;
- if(specs.format <= AUD_FORMAT_INVALID)
+ if (specs.format <= AUD_FORMAT_INVALID)
specs.format = AUD_FORMAT_S16;
- if(specs.channels <= AUD_CHANNELS_INVALID)
+ if (specs.channels <= AUD_CHANNELS_INVALID)
specs.channels = AUD_CHANNELS_STEREO;
- if(!AUD_init(device, specs, buffersize))
+ if (!AUD_init(device, specs, buffersize))
AUD_init(AUD_NULL_DEVICE, specs, buffersize);
sound_init_main(bmain);
@@ -244,7 +244,7 @@ struct bSound* sound_new_buffer(struct Main *bmain, struct bSound *source)
sound_load(bmain, sound);
- if(!sound->playback_handle)
+ if (!sound->playback_handle)
{
free_libblock(&bmain->sound, sound);
sound = NULL;
@@ -270,7 +270,7 @@ struct bSound* sound_new_limiter(struct Main *bmain, struct bSound *source, floa
sound_load(bmain, sound);
- if(!sound->playback_handle)
+ if (!sound->playback_handle)
{
free_libblock(&bmain->sound, sound);
sound = NULL;
@@ -282,7 +282,7 @@ struct bSound* sound_new_limiter(struct Main *bmain, struct bSound *source, floa
void sound_delete(struct Main *bmain, struct bSound* sound)
{
- if(sound)
+ if (sound)
{
sound_free(sound);
@@ -293,11 +293,11 @@ void sound_delete(struct Main *bmain, struct bSound* sound)
void sound_cache(struct bSound* sound)
{
sound->flags |= SOUND_FLAGS_CACHING;
- if(sound->cache)
+ if (sound->cache)
AUD_unload(sound->cache);
sound->cache = AUD_bufferSound(sound->handle);
- if(sound->cache)
+ if (sound->cache)
sound->playback_handle = sound->cache;
else
sound->playback_handle = sound->handle;
@@ -312,7 +312,7 @@ void sound_cache_notifying(struct Main* main, struct bSound* sound)
void sound_delete_cache(struct bSound* sound)
{
sound->flags &= ~SOUND_FLAGS_CACHING;
- if(sound->cache)
+ if (sound->cache)
{
AUD_unload(sound->cache);
sound->cache = NULL;
@@ -322,15 +322,15 @@ void sound_delete_cache(struct bSound* sound)
void sound_load(struct Main *bmain, struct bSound* sound)
{
- if(sound)
+ if (sound)
{
- if(sound->cache)
+ if (sound->cache)
{
AUD_unload(sound->cache);
sound->cache = NULL;
}
- if(sound->handle)
+ if (sound->handle)
{
AUD_unload(sound->handle);
sound->handle = NULL;
@@ -367,28 +367,28 @@ void sound_load(struct Main *bmain, struct bSound* sound)
break;
}
case SOUND_TYPE_BUFFER:
- if(sound->child_sound && sound->child_sound->handle)
+ if (sound->child_sound && sound->child_sound->handle)
sound->handle = AUD_bufferSound(sound->child_sound->handle);
break;
case SOUND_TYPE_LIMITER:
- if(sound->child_sound && sound->child_sound->handle)
+ if (sound->child_sound && sound->child_sound->handle)
sound->handle = AUD_limitSound(sound->child_sound, sound->start, sound->end);
break;
}
#endif
- if(sound->flags & SOUND_FLAGS_MONO)
+ if (sound->flags & SOUND_FLAGS_MONO)
{
void* handle = AUD_monoSound(sound->handle);
AUD_unload(sound->handle);
sound->handle = handle;
}
- if(sound->flags & SOUND_FLAGS_CACHING)
+ if (sound->flags & SOUND_FLAGS_CACHING)
{
sound->cache = AUD_bufferSound(sound->handle);
}
- if(sound->cache)
+ if (sound->cache)
sound->playback_handle = sound->cache;
else
sound->playback_handle = sound->handle;
@@ -414,25 +414,25 @@ void sound_create_scene(struct Scene *scene)
void sound_destroy_scene(struct Scene *scene)
{
- if(scene->sound_scene_handle)
+ if (scene->sound_scene_handle)
AUD_stop(scene->sound_scene_handle);
- if(scene->sound_scrub_handle)
+ if (scene->sound_scrub_handle)
AUD_stop(scene->sound_scrub_handle);
- if(scene->sound_scene)
+ if (scene->sound_scene)
AUD_destroySequencer(scene->sound_scene);
- if(scene->speaker_handles)
+ if (scene->speaker_handles)
AUD_destroySet(scene->speaker_handles);
}
void sound_mute_scene(struct Scene *scene, int muted)
{
- if(scene->sound_scene)
+ if (scene->sound_scene)
AUD_setSequencerMuted(scene->sound_scene, muted);
}
void sound_update_fps(struct Scene *scene)
{
- if(scene->sound_scene)
+ if (scene->sound_scene)
AUD_setSequencerFPS(scene->sound_scene, FPS);
}
@@ -444,7 +444,7 @@ void sound_update_scene_listener(struct Scene *scene)
void* sound_scene_add_scene_sound(struct Scene *scene, struct Sequence* sequence, int startframe, int endframe, int frameskip)
{
- if(scene != sequence->scene)
+ if (scene != sequence->scene)
return AUD_addSequence(scene->sound_scene, sequence->scene->sound_scene, startframe / FPS, endframe / FPS, frameskip / FPS);
return NULL;
}
@@ -531,18 +531,19 @@ void sound_update_sequencer(struct Main* main, struct bSound* sound)
{
struct Scene* scene;
- for(scene = main->scene.first; scene; scene = scene->id.next)
+ for (scene = main->scene.first; scene; scene = scene->id.next) {
seq_update_sound(scene, sound);
+ }
}
static void sound_start_play_scene(struct Scene *scene)
{
- if(scene->sound_scene_handle)
+ if (scene->sound_scene_handle)
AUD_stop(scene->sound_scene_handle);
AUD_setSequencerDeviceSpecs(scene->sound_scene);
- if((scene->sound_scene_handle = AUD_play(scene->sound_scene, 1)))
+ if ((scene->sound_scene_handle = AUD_play(scene->sound_scene, 1)))
AUD_setLoop(scene->sound_scene_handle, -1);
}
@@ -553,22 +554,22 @@ void sound_play_scene(struct Scene *scene)
status = scene->sound_scene_handle ? AUD_getStatus(scene->sound_scene_handle) : AUD_STATUS_INVALID;
- if(status == AUD_STATUS_INVALID)
+ if (status == AUD_STATUS_INVALID)
sound_start_play_scene(scene);
- if(!scene->sound_scene_handle)
+ if (!scene->sound_scene_handle)
{
AUD_unlock();
return;
}
- if(status != AUD_STATUS_PLAYING)
+ if (status != AUD_STATUS_PLAYING)
{
AUD_seek(scene->sound_scene_handle, CFRA / FPS);
AUD_resume(scene->sound_scene_handle);
}
- if(scene->audio.flag & AUDIO_SYNC)
+ if (scene->audio.flag & AUDIO_SYNC)
AUD_startPlayback();
AUD_unlock();
@@ -576,11 +577,11 @@ void sound_play_scene(struct Scene *scene)
void sound_stop_scene(struct Scene *scene)
{
- if(scene->sound_scene_handle)
+ if (scene->sound_scene_handle)
{
AUD_pause(scene->sound_scene_handle);
- if(scene->audio.flag & AUDIO_SYNC)
+ if (scene->audio.flag & AUDIO_SYNC)
AUD_stopPlayback();
}
}
@@ -595,11 +596,11 @@ void sound_seek_scene(struct Main *bmain, struct Scene *scene)
status = scene->sound_scene_handle ? AUD_getStatus(scene->sound_scene_handle) : AUD_STATUS_INVALID;
- if(status == AUD_STATUS_INVALID)
+ if (status == AUD_STATUS_INVALID)
{
sound_start_play_scene(scene);
- if(!scene->sound_scene_handle)
+ if (!scene->sound_scene_handle)
{
AUD_unlock();
return;
@@ -609,13 +610,15 @@ void sound_seek_scene(struct Main *bmain, struct Scene *scene)
}
animation_playing = 0;
- for(screen=bmain->screen.first; screen; screen=screen->id.next)
- if(screen->animtimer)
+ for (screen=bmain->screen.first; screen; screen=screen->id.next) {
+ if (screen->animtimer) {
animation_playing = 1;
+ }
+ }
- if(scene->audio.flag & AUDIO_SCRUB && !animation_playing)
+ if (scene->audio.flag & AUDIO_SCRUB && !animation_playing)
{
- if(scene->audio.flag & AUDIO_SYNC)
+ if (scene->audio.flag & AUDIO_SYNC)
{
AUD_seek(scene->sound_scene_handle, CFRA / FPS);
AUD_seekSequencer(scene->sound_scene_handle, CFRA / FPS);
@@ -623,22 +626,22 @@ void sound_seek_scene(struct Main *bmain, struct Scene *scene)
else
AUD_seek(scene->sound_scene_handle, CFRA / FPS);
AUD_resume(scene->sound_scene_handle);
- if(scene->sound_scrub_handle && AUD_getStatus(scene->sound_scrub_handle) != AUD_STATUS_INVALID)
+ if (scene->sound_scrub_handle && AUD_getStatus(scene->sound_scrub_handle) != AUD_STATUS_INVALID)
AUD_seek(scene->sound_scrub_handle, 0);
else
{
- if(scene->sound_scrub_handle)
+ if (scene->sound_scrub_handle)
AUD_stop(scene->sound_scrub_handle);
scene->sound_scrub_handle = AUD_pauseAfter(scene->sound_scene_handle, 1 / FPS);
}
}
else
{
- if(scene->audio.flag & AUDIO_SYNC)
+ if (scene->audio.flag & AUDIO_SYNC)
AUD_seekSequencer(scene->sound_scene_handle, CFRA / FPS);
else
{
- if(status == AUD_STATUS_PLAYING)
+ if (status == AUD_STATUS_PLAYING)
AUD_seek(scene->sound_scene_handle, CFRA / FPS);
}
}
@@ -648,9 +651,9 @@ void sound_seek_scene(struct Main *bmain, struct Scene *scene)
float sound_sync_scene(struct Scene *scene)
{
- if(scene->sound_scene_handle)
+ if (scene->sound_scene_handle)
{
- if(scene->audio.flag & AUDIO_SYNC)
+ if (scene->audio.flag & AUDIO_SYNC)
return AUD_getSequencerPosition(scene->sound_scene_handle);
else
return AUD_getPosition(scene->sound_scene_handle);
@@ -660,7 +663,7 @@ float sound_sync_scene(struct Scene *scene)
int sound_scene_playing(struct Scene *scene)
{
- if(scene->audio.flag & AUDIO_SYNC)
+ if (scene->audio.flag & AUDIO_SYNC)
return AUD_doesPlayback();
else
return -1;
@@ -668,7 +671,7 @@ int sound_scene_playing(struct Scene *scene)
void sound_free_waveform(struct bSound* sound)
{
- if(sound->waveform)
+ if (sound->waveform)
{
MEM_freeN(((SoundWaveform*)sound->waveform)->data);
MEM_freeN(sound->waveform);
@@ -683,7 +686,7 @@ void sound_read_waveform(struct bSound* sound)
info = AUD_getInfo(sound->playback_handle);
- if(info.length > 0)
+ if (info.length > 0)
{
SoundWaveform* waveform = MEM_mallocN(sizeof(SoundWaveform), "SoundWaveform");
int length = info.length * SOUND_WAVE_SAMPLES_PER_SECOND;
@@ -709,24 +712,24 @@ void sound_update_scene(struct Scene* scene)
void* handle;
float quat[4];
- for(SETLOOPER(scene, sce_it, base))
+ for (SETLOOPER(scene, sce_it, base))
{
ob = base->object;
- if(ob->type == OB_SPEAKER)
+ if (ob->type == OB_SPEAKER)
{
- if(ob->adt)
+ if (ob->adt)
{
- for(track = ob->adt->nla_tracks.first; track; track = track->next)
+ for (track = ob->adt->nla_tracks.first; track; track = track->next)
{
- for(strip = track->strips.first; strip; strip = strip->next)
+ for (strip = track->strips.first; strip; strip = strip->next)
{
- if(strip->type == NLASTRIP_TYPE_SOUND)
+ if (strip->type == NLASTRIP_TYPE_SOUND)
{
speaker = (Speaker*)ob->data;
- if(AUD_removeSet(scene->speaker_handles, strip->speaker_handle))
+ if (AUD_removeSet(scene->speaker_handles, strip->speaker_handle))
{
- if(speaker->sound)
+ if (speaker->sound)
AUD_moveSequence(strip->speaker_handle, strip->start / FPS, -1, 0);
else
{
@@ -736,14 +739,14 @@ void sound_update_scene(struct Scene* scene)
}
else
{
- if(speaker->sound)
+ if (speaker->sound)
{
strip->speaker_handle = AUD_addSequence(scene->sound_scene, speaker->sound->playback_handle, strip->start / FPS, -1, 0);
AUD_setRelativeSequence(strip->speaker_handle, 0);
}
}
- if(strip->speaker_handle)
+ if (strip->speaker_handle)
{
AUD_addSet(new_set, strip->speaker_handle);
AUD_updateSequenceData(strip->speaker_handle, speaker->volume_max,
@@ -772,7 +775,7 @@ void sound_update_scene(struct Scene* scene)
AUD_removeSequence(scene->sound_scene, handle);
}
- if(scene->camera)
+ if (scene->camera)
{
mat4_to_quat(quat, scene->camera->obmat);
AUD_setSequencerAnimData(scene->sound_scene, AUD_AP_LOCATION, CFRA, scene->camera->obmat[3], 1);