Re: Reseting an AudioQueue
Re: Reseting an AudioQueue
- Subject: Re: Reseting an AudioQueue
- From: Nitzan Wilnai <email@hidden>
- Date: Sat, 4 Oct 2008 15:42:34 -0700 (PDT)
Ok,
So I have a few questions about how AudioQueue handles the different AudioQueueBufferRefs.
1. When my QueueCallback function is called automatically when a song finishes playing, is the AudioQueueBufferRef pointing to the next enqueued buffer?
2. For changing audio buffers, is the following the best solution?
a) For each track I load, save their AudioQueueBufferRef in an array mBuffers[]. I realize I need to load all tracks into memory at all time but luckily I think I can spare the memory for simplicity sake.
b) Create another AudioQueueBufferRef mCurrentBuffer, point it to the first track (mCurrentBuffer = mBuffres[0] and enqueue mCurrentBuffer.
c) I am assuming that now automagically when I called AudioQueuePrime() and AudioQueueStart() it will start looping my first track, which mCurrentBuffer is pointing to.
d) Now, when I want to change tracks, can I just point mCurrentBuffer at the next AudioQueueRef in my mBuffers array?
Or do I have have to dequeue mCurrentBuffer, point it at the next AudioQueueBuffer in my mBuffers array and enqueue it again?
3. For either one, assuming one of them works, do I have to do anything extra to make it start from the beginning of the buffer?
Thanks,
Nitzan
----- Original Message ----
From: K. Staring <email@hidden>
To: CoreAudio API <email@hidden>
Sent: Friday, October 3, 2008 10:33:49 AM
Subject: Re: Reseting an AudioQueue
Actually, the NDA is lifted for you when you sign the new agreement,
which hasn't materialized yet..
So on stationary Leopard, when you run this, you control the buffers
and the function filling them, I presume you set them up with
SetupQueue(). It's not a direct answer to your question, and it
depends on your implementation (haven't looked at that SoundEngine
class), but why not let your callback function know you want it to
fill the buffers with another song? That way, the the change of music
is as instant as the size (and thus the duration) of the buffers you
feed your AudioQueue.
Kind regards,
Khamba Staring
On Oct 3, 2008, at 6:57 PM, Nitzan Wilnai wrote:
> I sent this before but unfortunately that was 2 days before the NDA
> was lifted.
>
> I am using the SoundEngine class from the CrashLanding demo to play
> sound effects and background music in my iPhone game.
>
> I want to loop a specific music track each level, then when the
> level changes I want to immediately stop the current track and start
> looping the next track.
>
> Therefore I made a few changes to SoundEngine and everything seems
> to work, except that after changing the background music track a few
> times (5-6) the game crashes while trying to read packets from the
> next track.
>
> My changes are:
>
> I added a new function:
> SetCurrentTrackIndex( int newTrackIndex )
> {
> BackgroundTrackMgr *THIS = this;
>
> AudioQueuePause( mQueue );
> AudioQueueFlush( mQueue );
> AudioQueueDispose( mQueue, true );
>
> THIS->mCurrentTrackIndex = newTrackIndex;
>
> THIS->SetupQueue( CurFileInfo );
> THIS->SetupBuffers( CurFileInfo );
> THIS->Start();
> }
>
> And in QueueCallback()
> I changed:
> theNextFileIndex =
> (THIS->mCurrentFileIndex < THIS->mBGFileInfo.size()-1) ?
> THIS->mCurrentFileIndex+1 : 0;
> to
> theNextFileIndex = THIS->mCurrentTrackIndex;
>
>
> Does anyone have any idea why after calling SetCurrentTrackIndex()
> 5-6 times the game will crash?
> What am I doing wrong?
> Is there a better way to loop a specific audio track and then
> immediately switch to a new track?
>
> When it crashes, one of 3 things happen:
> 1. The debugger tells me it had an invalid frame within a frame and
> nothing is displayed.
> 2. I get the following stack trace:
>
> #0 0x05938c65 in SMACMP4sdecDispatch
> #1 0x059f61b2 in ACMP4AACLowComplexityEncoderEntry
> #2 0x05915301 in dyld_stub_vsnprintf
> #3 0x05915181 in dyld_stub_vsnprintf
> #4 0x05914fc7 in dyld_stub_vsnprintf
> #5 0x05914f91 in dyld_stub_vsnprintf
> #6 0x05914e13 in dyld_stub_vsnprintf
> #7 0x0590ab88 in dyld_stub_vsnprintf
> #8 0x90d9bded in CallComponentDispatch
> #9 0x94248bb3 in AudioCodecProduceOutputPackets
> #10 0x3154bd77 in CodecConverter::DecoderFillBuffer
> #11 0x31542b8a in AudioConverterChain::RenderOutput
> #12 0x315429dc in BufferedAudioConverter::FillBuffer
> #13 0x31558993 in AudioConverterFillComplexBuffer
> #14 0x315959bf in AudioQueueObject::ConvertOutput
> #15 0x31597a9d in AudioQueueObject::RunConverter
> #16 0x31597f1d in AQConverterManager::AQConverterThread::RunLoop
> #17 0x3159d5e9 in GenericRunLoopThread::Entry
> #18 0x3158589a in CAPThread::Entry
> #19 0x958536f5 in _pthread_start
> #20 0x958535b2 in thread_start
> 3. I get this stack trace:
>
> #0 0x3146117c in memmove
> #1 0x3482433c in Cached_DataSource::ReadBytes
> #2 0x348745fc in MP4AudioFile::ReadPackets
> #3 0x3481dabc in AudioFileReadPackets
> #4 0x000354f6 in BackgroundTrackMgr::QueueCallback at
> SoundEngine.cpp:605
> #5 0x00035d20 in BackgroundTrackMgr::SetupBuffers at SoundEngine.cpp:
> 793
> #6 0x000363cc in BackgroundTrackMgr::Reset at SoundEngine.cpp:970
> #7 0x0002f93c in SoundEngine_ResetBackgroundMusicTrack at
> SoundEngine.cpp:1771
>
> The Assembly line in ReadBytes() is:
> 0x3482433c <+1160> ldr r2, [sp, #40]
> r2 is 0x657
> sp is <variable not found>
> I even tried these changes in CrashLanding (modified the code to
> load some music tracks and change between them) and the same crashes
> appear.
>
> Any help would be greatly appreciated.
>
> Thanks.
>
> Nitzan Wilnai
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Coreaudio-api mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden