Multithreaded debugging help (audio recording eg).
Multithreaded debugging help (audio recording eg).
- Subject: Multithreaded debugging help (audio recording eg).
- From: Darren Minifie <email@hidden>
- Date: Fri, 22 May 2009 23:09:08 -0700
Hi Everyone
I am working through the audio queue services tutorial, recording pcm audio
to a file. I have the example working as it is supposed to. The next thing
I want to do is examine each audio packet (each sample) and see what it's
16-bit value is. Now, I know that at 44100 samples / sec, doing an NSLog to
see the sample value is probably going to cause problems, although the
behaviour I'm seeing has me thinking I may have some sort of Thread
problem. AudioQueue runs in its own thread and calls my callback function
for each queued buffer. I want to print out the packets (samples) in the
buffer. The snippet of printing code I have is this:
====begin====
for(int i = 0; i<inNumPackets; i++){
if(i % 1000 == 0){
NSLog(@"\t packet: %d value: %x ", pAqData->mCurrentPacket,
((UInt16*)(inBuffer->mAudioData))[i] );
}
pAqData->mCurrentPacket++;
}
====end=====
To keep this brief, I wanted to see the value of every 1000'th sample. The
strange thing is that the value always comes back 0:
2009-05-22 23:00:48.118 CR[2719:3103] packet: 1000 value: 0
2009-05-22 23:00:48.122 CR[2719:3103] packet: 2000 value: 0
2009-05-22 23:00:48.126 CR[2719:3103] packet: 3000 value: 0
2009-05-22 23:00:48.127 CR[2719:3103] packet: 4000 value: 0
In fact, I can replace "inBuffer" (which I know exists because the progam
does successfully write to a file) with any data structure defined within
the callback and everytime the output prints 0x0, which I interpret as a
NULL pointer. In other words, i can change the code to:
====begin====
for(int i = 0; i<inNumPackets; i++){
if(i % 1000 == 0){
NSLog(@"\t packet: %d value: %p ", pAqData->mCurrentPacket,
&pAqData );
}
pAqData->mCurrentPacket++;
}
====end=====
and still get 0x0 as the output. Finally, when i try to set breakpoints in
the callback, they never trigger the debugger. I'm guessing this is because
the callback is executing in another thread.
My questions:
1. For the audio people, would this be how I could process each sample's
value (as attempted within the code)?
2. Any advice on my debugging attempts? Why are all my Logs printing as
0x0? Why does the debugger not fire on breakpoints in the callback?
thanks a lot for your help.
--
Darren Minifie
Computer Science Master's Candidate
My Rants: www.noisyair.com
My Band: www.ohsnapmusic.com
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden