music crash fixes
git-svn-id: https://clonekeenplus.svn.sourceforge.net/svnroot/clonekeenplus/cgenius/trunk@121 4df4b0f3-56ce-47cb-b001-ed939b7d65a6
This commit is contained in:
@@ -12,10 +12,13 @@
|
||||
|
||||
CMusic::CMusic() {
|
||||
playmode = PLAY_MODE_STOP;
|
||||
music_buffer = NULL;
|
||||
music_pos = 0;
|
||||
music_len = 0;
|
||||
}
|
||||
|
||||
CMusic::~CMusic() {
|
||||
// TODO Auto-generated destructor stub
|
||||
unload();
|
||||
}
|
||||
|
||||
int CMusic::load(SDL_AudioSpec AudioSpec, char *musicfile)
|
||||
@@ -101,7 +104,8 @@ void CMusic::unload(void)
|
||||
|
||||
void CMusic::play(void)
|
||||
{
|
||||
playmode = PLAY_MODE_PLAY;
|
||||
if(music_buffer)
|
||||
playmode = PLAY_MODE_PLAY;
|
||||
}
|
||||
|
||||
void CMusic::stop(void)
|
||||
@@ -111,10 +115,13 @@ void CMusic::stop(void)
|
||||
|
||||
Uint8 *CMusic::passBuffer(int length) // length only refers to the part(buffer) that has to be played
|
||||
{
|
||||
if(length < music_len-music_pos)
|
||||
if(!music_buffer)
|
||||
return NULL;
|
||||
|
||||
if(length < music_len - music_pos)
|
||||
{
|
||||
music_pos += length;
|
||||
return music_buffer+music_pos-length;
|
||||
return music_buffer + music_pos - length;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -179,8 +179,7 @@ void CSound::callback(void *unused, Uint8 *stream, int len)
|
||||
|
||||
if (g_pMusicPlayer->playing() == PLAY_MODE_PLAY)
|
||||
{
|
||||
// TODO: this crashes for me
|
||||
//SDL_MixAudio(stream, g_pMusicPlayer->passBuffer(len), len, SDL_MIX_MAXVOLUME);
|
||||
SDL_MixAudio(stream, g_pMusicPlayer->passBuffer(len), len, SDL_MIX_MAXVOLUME);
|
||||
}
|
||||
|
||||
for( i=0 ; i < m_mixing_channels ; i++ )
|
||||
|
||||
Reference in New Issue
Block a user