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.c104
1 files changed, 69 insertions, 35 deletions
diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c
index 28ce95ea8d1..c2dbb518837 100644
--- a/source/blender/blenkernel/intern/sound.c
+++ b/source/blender/blenkernel/intern/sound.c
@@ -95,7 +95,8 @@ 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;
}
@@ -105,19 +106,22 @@ struct bSound* sound_new_file(struct Main *bmain, const char *filename)
void sound_free(struct bSound* sound)
{
- if (sound->packedfile) {
+ if (sound->packedfile)
+ {
freePackedFile(sound->packedfile);
sound->packedfile = NULL;
}
#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;
}
@@ -137,8 +141,10 @@ static void sound_sync_callback(void* data, int mode, float time)
struct Scene* scene;
scene = bmain->scene.first;
- while (scene) {
- if (scene->audio.flag & AUDIO_SYNC) {
+ while (scene)
+ {
+ if (scene->audio.flag & AUDIO_SYNC)
+ {
if (mode)
sound_play_scene(scene);
else
@@ -276,7 +282,8 @@ 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);
free_libblock(&bmain->sound, sound);
@@ -305,7 +312,8 @@ 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;
sound->playback_handle = sound->handle;
@@ -314,13 +322,16 @@ void sound_delete_cache(struct bSound* sound)
void sound_load(struct Main *bmain, struct bSound* sound)
{
- if (sound) {
- if (sound->cache) {
+ if (sound)
+ {
+ if (sound->cache)
+ {
AUD_unload(sound->cache);
sound->cache = NULL;
}
- if (sound->handle) {
+ if (sound->handle)
+ {
AUD_unload(sound->handle);
sound->handle = NULL;
sound->playback_handle = NULL;
@@ -330,7 +341,7 @@ void sound_load(struct Main *bmain, struct bSound* sound)
// XXX unused currently
#if 0
- switch (sound->type)
+ switch(sound->type)
{
case SOUND_TYPE_FILE:
#endif
@@ -365,13 +376,15 @@ void sound_load(struct Main *bmain, struct bSound* sound)
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);
}
@@ -544,12 +557,14 @@ void sound_play_scene(struct Scene *scene)
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);
}
@@ -562,7 +577,8 @@ 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)
@@ -580,10 +596,12 @@ 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;
}
@@ -598,8 +616,10 @@ void sound_seek_scene(struct Main *bmain, struct Scene *scene)
}
}
- if (scene->audio.flag & AUDIO_SCRUB && !animation_playing) {
- if (scene->audio.flag & AUDIO_SYNC) {
+ if (scene->audio.flag & AUDIO_SCRUB && !animation_playing)
+ {
+ if (scene->audio.flag & AUDIO_SYNC)
+ {
AUD_seek(scene->sound_scene_handle, CFRA / FPS);
AUD_seekSequencer(scene->sound_scene_handle, CFRA / FPS);
}
@@ -628,7 +648,8 @@ 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)
return AUD_getSequencerPosition(scene->sound_scene_handle);
else
@@ -647,7 +668,8 @@ 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);
}
@@ -661,7 +683,8 @@ 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;
@@ -686,16 +709,23 @@ 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->adt) {
- for (track = ob->adt->nla_tracks.first; track; track = track->next) {
- for (strip = track->strips.first; strip; strip = strip->next) {
- if (strip->type == NLASTRIP_TYPE_SOUND) {
+ if (ob->type == OB_SPEAKER)
+ {
+ if (ob->adt)
+ {
+ for (track = ob->adt->nla_tracks.first; track; track = track->next)
+ {
+ for (strip = track->strips.first; strip; strip = strip->next)
+ {
+ 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)
AUD_moveSequence(strip->speaker_handle, strip->start / FPS, -1, 0);
else {
@@ -704,13 +734,15 @@ 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,
speaker->volume_min, speaker->distance_max,
@@ -733,11 +765,13 @@ void sound_update_scene(struct Scene* scene)
}
}
- while ((handle = AUD_getSet(scene->speaker_handles))) {
+ while ((handle = AUD_getSet(scene->speaker_handles)))
+ {
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);
AUD_setSequencerAnimData(scene->sound_scene, AUD_AP_ORIENTATION, CFRA, quat, 1);