From: Alexander Monakov Date: Fri, 17 Dec 2010 23:39:47 +0000 (+0300) Subject: Move playing stuff to the right wrapper :) X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=268b3df2ac5060f7e137edea425953b2a2d3d9ca;p=lugaru.git Move playing stuff to the right wrapper :) --- diff --git a/Source/OpenGL_Windows.cpp b/Source/OpenGL_Windows.cpp index 49e877e..5dbf5c4 100644 --- a/Source/OpenGL_Windows.cpp +++ b/Source/OpenGL_Windows.cpp @@ -771,61 +771,6 @@ int main(int argc, char **argv) // -------------------------------------------------------------------------- -extern int channels[100]; -extern OPENAL_STREAM * strm[20]; - -extern "C" void PlaySoundEx(int chan, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused) -{ - const OPENAL_SAMPLE * currSample = OPENAL_GetCurrentSample(channels[chan]); - if (currSample && currSample == samp[chan]) - { - if (OPENAL_GetPaused(channels[chan])) - { - OPENAL_StopSound(channels[chan]); - channels[chan] = OPENAL_FREE; - } - else if (OPENAL_IsPlaying(channels[chan])) - { - int loop_mode = OPENAL_GetLoopMode(channels[chan]); - if (loop_mode & OPENAL_LOOP_OFF) - { - channels[chan] = OPENAL_FREE; - } - } - } - else - { - channels[chan] = OPENAL_FREE; - } - - channels[chan] = OPENAL_PlaySoundEx(channels[chan], sptr, dsp, startpaused); - if (channels[chan] < 0) - { - channels[chan] = OPENAL_PlaySoundEx(OPENAL_FREE, sptr, dsp, startpaused); - } -} - -extern "C" void PlayStreamEx(int chan, OPENAL_STREAM *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused) -{ - const OPENAL_SAMPLE * currSample = OPENAL_GetCurrentSample(channels[chan]); - if (currSample && currSample == OPENAL_Stream_GetSample(sptr)) - { - OPENAL_StopSound(channels[chan]); - OPENAL_Stream_Stop(sptr); - } - else - { - OPENAL_Stream_Stop(sptr); - channels[chan] = OPENAL_FREE; - } - - channels[chan] = OPENAL_Stream_PlayEx(channels[chan], sptr, dsp, startpaused); - if (channels[chan] < 0) - { - channels[chan] = OPENAL_Stream_PlayEx(OPENAL_FREE, sptr, dsp, startpaused); - } -} - bool LoadImage(const char * fname, TGAImageRec & tex) { diff --git a/Source/openal_wrapper.cpp b/Source/openal_wrapper.cpp index 82ba31f..bd46990 100644 --- a/Source/openal_wrapper.cpp +++ b/Source/openal_wrapper.cpp @@ -26,6 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include "openal_wrapper.h" +#include "Sounds.h" // NOTE: // FMOD uses a Left Handed Coordinate system, OpenAL uses a Right Handed @@ -632,5 +633,60 @@ AL_API signed char OPENAL_SetOutput(int outputtype) return true; } +extern int channels[100]; +extern OPENAL_STREAM * strm[20]; + +extern "C" void PlaySoundEx(int chan, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused) +{ + const OPENAL_SAMPLE * currSample = OPENAL_GetCurrentSample(channels[chan]); + if (currSample && currSample == samp[chan]) + { + if (OPENAL_GetPaused(channels[chan])) + { + OPENAL_StopSound(channels[chan]); + channels[chan] = OPENAL_FREE; + } + else if (OPENAL_IsPlaying(channels[chan])) + { + int loop_mode = OPENAL_GetLoopMode(channels[chan]); + if (loop_mode & OPENAL_LOOP_OFF) + { + channels[chan] = OPENAL_FREE; + } + } + } + else + { + channels[chan] = OPENAL_FREE; + } + + channels[chan] = OPENAL_PlaySoundEx(channels[chan], sptr, dsp, startpaused); + if (channels[chan] < 0) + { + channels[chan] = OPENAL_PlaySoundEx(OPENAL_FREE, sptr, dsp, startpaused); + } +} + +extern "C" void PlayStreamEx(int chan, OPENAL_STREAM *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused) +{ + const OPENAL_SAMPLE * currSample = OPENAL_GetCurrentSample(channels[chan]); + if (currSample && currSample == OPENAL_Stream_GetSample(sptr)) + { + OPENAL_StopSound(channels[chan]); + OPENAL_Stream_Stop(sptr); + } + else + { + OPENAL_Stream_Stop(sptr); + channels[chan] = OPENAL_FREE; + } + + channels[chan] = OPENAL_Stream_PlayEx(channels[chan], sptr, dsp, startpaused); + if (channels[chan] < 0) + { + channels[chan] = OPENAL_Stream_PlayEx(OPENAL_FREE, sptr, dsp, startpaused); + } +} + #endif