Commit d18a8243 authored by Gerhard Stein's avatar Gerhard Stein

More channel code for SDL_Mixer

parent 497e383c
......@@ -235,15 +235,19 @@ bool CExeFile::readMainPythonScript(const unsigned int episode,
bool CExeFile::Supported()
{
if(mIsPythonScript)
return true;
if(mIsPythonScript) return true;
if( m_supportmap.find(m_datasize) == m_supportmap.end())
return false;
if( m_supportmap.find(m_datasize) ==
m_supportmap.end())
{
return false;
}
if( m_supportmap[m_datasize].find(m_episode) == m_supportmap[m_datasize].end() )
if( m_supportmap[m_datasize].find(m_episode) ==
m_supportmap[m_datasize].end() )
{
return false;
}
return m_supportmap[m_datasize][m_episode];
}
......
......@@ -17,29 +17,30 @@
#include <SDL_mixer.h>
#endif
int CSoundChannel::mTotNumChannels = 0;
CSoundChannel::
CSoundChannel(const SDL_AudioSpec &AudioSpec) :
m_AudioSpec(AudioSpec)
{
stopSound();
mId = mTotNumChannels;
mTotNumChannels++;
}
void CSoundChannel::stopSound()
CSoundChannel::
~CSoundChannel()
{
mTotNumChannels--;
}
void
CSoundChannel::
stopSound()
{
#if defined(USE_SDLMIXER)
mpCurrentSndSlot = nullptr;
mBalance = 0;
mSoundPtr = 0;
mSoundPaused = true;
mSoundPlaying = false;
#else
SDL_LockAudio();
#endif
mpCurrentSndSlot = nullptr;
mBalance = 0;
......@@ -47,6 +48,7 @@ void CSoundChannel::stopSound()
mSoundPaused = true;
mSoundPlaying = false;
#if defined(USE_SDLMIXER)
SDL_UnlockAudio();
#endif
}
......@@ -65,7 +67,7 @@ void CSoundChannel::setupSound( CSoundSlot &SndSlottoPlay,
// play sample on first free unreserved channel
// play it exactly once through
if(Mix_PlayChannel(0, waveChunk, 0) == -1)
if(Mix_PlayChannel(mId, waveChunk, 0) == -1)
{
gLogging.ftextOut("Mix_PlayChannel: %s\n", Mix_GetError());
}
......
......@@ -49,6 +49,8 @@ class CSoundChannel
public:
CSoundChannel(const SDL_AudioSpec &AudioSpec);
virtual ~CSoundChannel();
void stopSound();
bool isPlaying() { return mSoundPlaying; }
bool isForcedPlaying() { return (mSoundPlaying && mSoundForced); }
......@@ -86,6 +88,9 @@ private:
short mBalance; // This variable is used for stereo sound, and to calculate where the sound must be played!
SDL_AudioSpec m_AudioSpec;
static int mTotNumChannels;
int mId = 0;
};
#endif /* CSOUNDCHANNEL_H_ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment