Playing "silence" to an AudioQueue (with VBR format)
Playing "silence" to an AudioQueue (with VBR format)
- Subject: Playing "silence" to an AudioQueue (with VBR format)
- From: Neil Clayton <email@hidden>
- Date: Wed, 23 Jan 2008 15:51:06 +1300
- Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys
I've successfully got a playthru working between two AudioQueues, in
PCM.
I've two callbacks. One for an input queue and the other for an output
queue. The input callback receives data and copies it to an internal
array, which the output callback can then use to feed the output queue.
For VBR - I've got it "kind of working" - I hear a little audio
(perhaps 1-2 seconds), before it stops.
It appears to be because the output callback (to the speakers) is
called more often than the input callback, and sometimes no data is
available because the input callback is called perhaps only twice a
second.
In this case (no data to present to the output queue), I attempt to
queue an empty AudioQueueBuffer, but receive
kAudioQueueErr_BufferEmpty as a result.
- (void) handleOutputBuffer:(AudioQueueRef)inAQ bufferRef:
(AudioQueueBufferRef)inBuffer {
// Suck off the next element of our queue
OSStatus err = noErr;
if([packetBuffer count] > 0) {
Intermediate *packet = nil;
@synchronized(packetBuffer) {
packet = [packetBuffer objectAtIndex:0];
[packetBuffer removeObject:packet];
}
@try {
[packet copyBufferTo:inBuffer];
err = AudioQueueEnqueueBuffer(queue, inBuffer, numPackets,
packet.packetDescriptions);
} @finally {
[packet release];
}
} else {
// Give the buffer back - we can't do anything (we have no data)
err = AudioQueueEnqueueBuffer(queue, inBuffer, 0, nil);
}
if(err) {
[self log:@"Error while enqueing, %ld", err];
}
}
What is the recommended (or any way would be nice) way to send silence
and correctly enqueue the buffer if the output format isn't PCM?
I've tried setting the first byte of the buffer to zero, with a size
of one (this works for the PCM case) - and while this doesn't return
an error, after I do this the output proc for the queue is no longer
called (I presume I've confused it's internal state somehow).
--
Regards,
Neil Clayton
_______________________________________________
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