Doing playthru, using AudioQueue
Doing playthru, using AudioQueue
- Subject: Doing playthru, using AudioQueue
- From: Neil Clayton <email@hidden>
- Date: Tue, 22 Jan 2008 22:21:17 +1300
- Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys
Hi,
I'm attempting to construct a playthru using AudioQueue as opposed to
CoreAudio, simply because ... it's simpler.
I've got recording to a file going (compressed, CAF format) - which
plays back in QT just fine. Qt then shows me it's AAC, or whatever
format I've chosen.
I *believe* I've setup the AudioQueue to play back OK, but I am
getting a -50 back from my handler:
- (void) handleInputBuffer:(AudioQueueRef)inAQ
bufferRef:(AudioQueueBufferRef)inBuffer
timeStamp:(const AudioTimeStamp*)timeStamp
numPackets:(UInt32)numPackets
packetDesc:(const AudioStreamPacketDescription*)packetDesc {
OSStatus err = noErr;
if(numPackets > 0) {
if(fileID) {
err = AudioFileWritePackets(fileID,
false,
inBuffer->mAudioDataByteSize,
packetDesc,
recordBuffer.currentPacket,
&numPackets,
inBuffer->mAudioData);
}
if(err == noErr) {
recordBuffer.currentPacket += numPackets;
// If we have playthru - shove it there as well
if(playbackBuffer) {
err = AudioQueueEnqueueBuffer(playbackBuffer.queue, inBuffer,
numPackets, packetDesc);
if(err != noErr) {
[self log:@"Couldn't playthru, %ld", err];
}
}
}
}
if(playthru) {
[recordBuffer enqueue:inBuffer];
}
}
In this case what I'm attempting to do is receive the audio packets /
data from one AudioQueue and record them. I'd like to then pass the
same packets to my Playback Buffer, which is setup to output to some
other device. The playback buffer appears to be setup correctly to
receive AAC (or whatever format I choose) data. This is using code
similar to that in aqplay.cpp.
Thus, my logging shows:
2008-01-22 22:12:15.113 CoreAudioRecorder[15791:813] [Main] [AQBuffer]
- Using device Built-in Line Output, with format: AAC, 44100 Khz, 2
channels
2008-01-22 22:12:15.117 CoreAudioRecorder[15791:813] [Main] [AQBuffer]
- New stream description after making queue: AAC, 44100 Khz, 2 channels
2008-01-22 22:12:15.120 CoreAudioRecorder[15791:813] [Main] [AQBuffer]
- Setup cookie on PlaybackBuff:Built-in Line Output (AAC, 44100 Khz, 2
channels) OK
2008-01-22 22:12:15.121 CoreAudioRecorder[15791:813] [Main] [AQBuffer]
- PlaybackBuff:Built-in Line Output (AAC, 44100 Khz, 2 channels) ready
to rock
2008-01-22 22:12:15.134 CoreAudioRecorder[15791:813] [Main]
[Controller] - Playthru setup for Soundflower (16ch) -> Built-in Line
Output
It seems like it's quite probably invalid for me to pass one buffer
from an input queue to an output queue (I'm guessing here). If
this is indeed the case, what's the recommended way to copy the
contents from one of these buffers to the playback buffers (given that
the formats are the same)? Just memcpy or would that be a "bad
idea" (tm)?
--
Regards,
Neil Clayton, http://shinywhitebox.com
_______________________________________________
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