• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Getting wrong data format for stream
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting wrong data format for stream


  • Subject: Re: Getting wrong data format for stream
  • From: Brian Willoughby <email@hidden>
  • Date: Tue, 21 Jul 2009 18:53:04 -0700


On Jul 21, 2009, at 14:03, Tom Harrington wrote:
I'm using Audio File Stream Services to play streaming audio from a web site.

The stream in question is MP3, 44100Hz, 112kbps, from a shoutcast
server (more details on request).  When I create the stream I provide
a file type hint of kAudioFileMP3Type.

Periodically, maybe one out of 8 times, I get bogus data for
kAudioFileStreamProperty_DataFormat.  It'll have an incorrect sample
rate (usually 32000Hz or 48000Hz) and a format of MP1
(kAudioFormatMPEGLayer1).  Playback then fails-- since I'm on iPhone,
AudioQueueNewOutput() returns kAudioFormatUnknownFormatError.

I look up the format by waiting for
kAudioFileStreamProperty_ReadyToProducePackets and then doing:

AudioStreamBasicDescription dataFormat;
UInt32 propertySize = sizeof(AudioStreamBasicDescription);
OSStatus audioStatus = AudioFileStreamGetProperty(inAudioFileStream,
kAudioFileStreamProperty_DataFormat, &propertySize, &dataFormat);

When I get bogus data, audioStatus is 0, but the returned format is
bogus.  What can I do to deal with this?


If you know for certain that the data is MP3, then you should probably discard bytes until you find an MP3 start of stream tag any time that you start from scratch, and even when the stream is interrupted. Don't discard entire network packets, because the MP3 packets are probably not aligned with the network packets. Just skip bytes. MP3 streaming has a byte pattern which is unique to help locate the start of a packet inside a continuous stream.

Brian Willoughby
Sound Consulting

_______________________________________________
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


References: 
 >Getting wrong data format for stream (From: Tom Harrington <email@hidden>)

  • Prev by Date: Re: Getting wrong data format for stream
  • Next by Date: Re: how to access HAL buffer timestamps when using AUHAL?
  • Previous by thread: Re: Getting wrong data format for stream
  • Next by thread: Mapping from AudiodeviceID to kIOUSBDeviceInterfaceID
  • Index(es):
    • Date
    • Thread