From 5c9cf81cf98c99e52064b0cd45be3b2eaba9e40c Mon Sep 17 00:00:00 2001 From: Joerg Mueller Date: Sat, 31 Jul 2010 10:03:08 +0000 Subject: Audaspace: * Fixed some compiler warnings * Implemented device looping * Note: Scrubbing in the sequencer is broken atm --- source/blender/blenkernel/intern/sound.c | 10 +++------- source/gameengine/Ketsji/KX_SoundActuator.cpp | 23 +++++++++-------------- 2 files changed, 12 insertions(+), 21 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index ca39355976b..17ff6615ee7 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -381,10 +381,8 @@ void sound_move_scene_sound(struct Scene *scene, void* handle, int startframe, i void sound_start_play_scene(struct Scene *scene) { - AUD_Sound* sound; - sound = AUD_loopSound(scene->sound_scene); - scene->sound_scene_handle = AUD_play(sound, 1); - AUD_unload(sound); + scene->sound_scene_handle = AUD_play(scene->sound_scene, 1); + AUD_setLoop(scene->sound_scene_handle, -1); } void sound_play_scene(struct Scene *scene) @@ -397,8 +395,6 @@ void sound_play_scene(struct Scene *scene) if(status == AUD_STATUS_INVALID) sound_start_play_scene(scene); - AUD_setLoop(scene->sound_scene_handle, -1, -1); - if(status != AUD_STATUS_PLAYING) { AUD_seek(scene->sound_scene_handle, CFRA / FPS); @@ -436,7 +432,7 @@ void sound_seek_scene(struct bContext *C) if(scene->audio.flag & AUDIO_SCRUB && !CTX_wm_screen(C)->animtimer) { - AUD_setLoop(scene->sound_scene_handle, -1, 1 / FPS); + // AUD_XXX TODO: fix scrubbing, it currently doesn't stop playing if(scene->audio.flag & AUDIO_SYNC) AUD_seekSequencer(scene->sound_scene_handle, CFRA / FPS); else diff --git a/source/gameengine/Ketsji/KX_SoundActuator.cpp b/source/gameengine/Ketsji/KX_SoundActuator.cpp index c3ef36dfe11..09ad567117f 100644 --- a/source/gameengine/Ketsji/KX_SoundActuator.cpp +++ b/source/gameengine/Ketsji/KX_SoundActuator.cpp @@ -76,23 +76,20 @@ void KX_SoundActuator::play() // this is the sound that will be played and not deleted afterwards AUD_Sound* sound = m_sound; - // this sounds are for temporary stacked sounds, will be deleted if not NULL + // this sound is for temporary stacked sounds, will be deleted if not NULL AUD_Sound* sound2 = NULL; - AUD_Sound* sound3 = NULL; + + bool loop = false; switch (m_type) { case KX_SOUNDACT_LOOPBIDIRECTIONAL: case KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP: - // create a ping pong sound on sound2 stacked on the orignal sound - sound2 = AUD_pingpongSound(sound); - // create a loop sound on sound3 stacked on the pingpong sound and let that one play (save it to sound) - sound = sound3 = AUD_loopSound(sound2); - break; + sound = sound2 = AUD_pingpongSound(sound); + // fall through case KX_SOUNDACT_LOOPEND: case KX_SOUNDACT_LOOPSTOP: - // create a loop sound on sound2 stacked on the pingpong sound and let that one play (save it to sound) - sound = sound2 = AUD_loopSound(sound); + loop = true; break; case KX_SOUNDACT_PLAYSTOP: case KX_SOUNDACT_PLAYEND: @@ -118,14 +115,12 @@ void KX_SoundActuator::play() else m_handle = AUD_play(sound, 0); + if(loop) + AUD_setLoop(m_handle, -1); AUD_setSoundPitch(m_handle, m_pitch); AUD_setSoundVolume(m_handle, m_volume); m_isplaying = true; - // now we unload the pingpong and loop sounds, as we don't need them anymore - // the started sound will continue playing like it was created, don't worry! - if(sound3) - AUD_unload(sound3); if(sound2) AUD_unload(sound2); } @@ -185,7 +180,7 @@ bool KX_SoundActuator::Update(double curtime, bool frame) case KX_SOUNDACT_LOOPBIDIRECTIONAL: { // stop the looping so that the sound stops when it finished - AUD_setLoop(m_handle, 0, -1); + AUD_setLoop(m_handle, 0); break; } default: -- cgit v1.2.3