Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Moon013

macrumors newbie
Original poster
Jul 14, 2008
23
0
Hi, I am quite new to this, so guess there's where the problem is.

Okay, I got an app which has a looping background music, and upon exit game, the music will stop. And goes into game again, the background should start playing again. The problem is it won't start playing the 2nd time it goes into game. Thats how i do it:

(I use the crash landing soundEngine)

<I load the sound in my init>

SoundEngine_Initialize(44100);
SoundEngine_SetListenerPosition(0.0, 0.0, 1.0);

//SoundEngine_LoadBackgroundMusicTrack([[bundle pathForResource:mad:"levelOne" ofType:mad:"mp3"] UTF8String], NO, YES);

<play the sound upon clicking playGame>
SoundEngine_StartBackgroundMusic();

<Stop the sound upon exit>
SoundEngine_StopBackgroundMusic(NO);

Am i missing out something? Sound played for the first time only. I tried putting the loading of the sound in the playGame function; load and play the background music. This actually enables the sound to playback when clicking playGame the 2nd time. But somehow it produces a bit of a delay in iPhone to start the game because of this. What i wanted is actually load once, and able to toggle between play and stop throughout. Need desperate help, thanks in advance.
 

CommanderData

macrumors 6502
Dec 1, 2007
250
3
I know that SoundEngine uses POSIX threads... not sure if you're properly handling the second thread? Is it joinable? If so, are you joining back up before termination (pthread_join)? Finally, are you absolutely sure that stopmusic is executing?
 

Moon013

macrumors newbie
Original poster
Jul 14, 2008
23
0
I am sure stop music is executing. The music stopped when code executed. Regarding the threads, I don't know anything about it unfortunately...I didn't touched any threads handling stuff..
 

CommanderData

macrumors 6502
Dec 1, 2007
250
3
I am sure stop music is executing. The music stopped when code executed. Regarding the threads, I don't know anything about it unfortunately...I didn't touched any threads handling stuff..

Now, that's not exactly what you said. You said that *when the game is exited* the music stops playing. That does not actually mean that your stop music call is executing. Have you verified that by adding NSLog statements to the beginning and end of the stop music code to make sure it's fully executing? I'm curious to know if that thread is getting lost and left in memory when your main app terminates...
 

Moon013

macrumors newbie
Original poster
Jul 14, 2008
23
0
I did a printf and I am sure its being called. However, there is a error message when that particular stop function is called:

Error enqueuing new buffer: -66632

Guess something's not right :confused:
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.