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:
+11
-4
@@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user