Streaming to AudioQueue without having random access to data?
Streaming to AudioQueue without having random access to data?
- Subject: Streaming to AudioQueue without having random access to data?
- From: Jens Alfke <email@hidden>
- Date: Thu, 14 Feb 2008 10:59:26 -0800
I'm trying to use an AudioQueue to play already-encoded audio data
that's being received over a TCP stream. I'm adapting the aqplay.cpp
sample by replacing its AudioFileOpen call with
AudioFileOpenWithCallbacks, and implementing callbacks that read bytes
from the socket.
The problem is that the read proc requires random access to the "file"
— it takes a 'position' parameter. But obviously I can't seek a socket
stream. My first thought was that, since MP3 and AAC can be streamed
just fine, the AudioFile code wouldn't do anything but ask for chunks
in sequential order. But that's not the case.
When I try this on local MP3 files, I see my callback first being
called about nine times on small chunks at the beginning of the file;
but then it gets a request for 4 bytes at a position that's 128 bytes
before the EOF. And that pattern repeats: most of the requests are
advancing steadily through the file, but about every tenth is a
duplicate request for those same 4 bytes at EOF-128. The stack trace
for these always looks like:
#2 0x92df7c87 in Seekable_DataSource::ReadBytes ()
#3 0x92e5cb2c in GetFPosForNextSyncWordDS ()
#4 0x92e5d00f in ValidateSyncDS ()
#5 0x92e5ddec in MPEGAudioFile::ParseAudioFile ()
Is there any way to avoid this? When I hook my code up to a file
descriptor that comes from a socket, not a local file, it's going to
fail when asked for data at the end of the file.
Theoretically, I don't need to use an AudioFile at all. In most cases
the AudioQueue's callback just wants me to copy raw bytes into its
buffer. But what do I do with VBR? In that case
AudioQueueEnqueueBuffer needs an array of packet descriptions, and I
have no idea how to determine those on my own without AudioFile.
Thanks,
—Jens _______________________________________________
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