• 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
trouble creating working Apple Lossless file under iOS 3.2
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

trouble creating working Apple Lossless file under iOS 3.2


  • Subject: trouble creating working Apple Lossless file under iOS 3.2
  • From: Christopher Penrose <email@hidden>
  • Date: Thu, 4 Nov 2010 23:09:02 -0700

I am able to create Apple Lossless files with my iPad app under iOS 3.2 using either an m4a or caf transport.  I receive no errors from the API.  The problem is that they are unplayable -- they lock Finder, Quicktime Player, iTunes, and afplay for about 10 seconds.   Upon inspection with afinfo they look normal to me (I haven't found an indication that a channel layout is needed for ALAC files to be playable).  I am passing audio buffers to ExtAudioFileWrite ()which are in iOS canonical format (which might be the issue perhaps, but AIFF and WAV work fine using them).

% afinfo hobo.caf
File:           hobo.caf
File type ID:   caff
Data format:     2 ch,  44100 Hz, 'alac' (0x00000003) from 24-bit source, 4096 frames/packet
                no channel layout.
estimated duration: 12.423 sec
audio bytes: 1784876
audio packets: 134
audio 547840 valid frames + 0 priming + 1024 remainder = 548864
bit rate: 1147286 bits per second
packet size upper bound: 15781
audio data file offset: 12288
optimized
----

% afplay hobo.caf
Error: start audio output unit (-536870185)

% ls -alt hobo.caf
-rw-r--r--  1 penrose  admin  1797164 Nov  4 22:40 hobo.caf



I use the following code fragment to configure the ASBD for Apple Lossless:


	// clear output audio format ASBD

	bzero(&performOutputFormat, sizeof(AudioStreamBasicDescription));

	// adjust format id for Apple Lossless codec

	performOutputFormat.mFormatID = kAudioFormatAppleLossless;
	performOutputFormat.mSampleRate = performClientFormat.mSampleRate;
	performOutputFormat.mChannelsPerFrame = performClientFormat.mChannelsPerFrame;

	// adjust format flags for Apple Lossless codec

	performOutputFormat.mFormatFlags = kAppleLosslessFormatFlag_24BitSourceData;


	// trust the AudioFormat API to hopefully fill out the rest.

    	UInt32 size = sizeof(performOutputFormat);
    	OSStatus err = AudioFormatGetProperty(kAudioFormatProperty_FormatInfo, 0, NULL, &size, &performOutputFormat);

	// whine about failure should it occur

	if (err != noErr) {

		[STButler alertPanelTitle:@"Audio Export Error" message:
				@"Failure to get format requirements for Apple Lossless codec."];
	}


I open the file for writing with:

	err = ExtAudioFileCreateWithURL (cfFileUrl, fileType, &performOutputFormat, NULL, kAudioFileFlags_EraseFile, &recordPerformAudioFileRef);


I write buffers to the the audiofileref once it is opened using:

		OSStatus err = ExtAudioFileWrite(recordPerformAudioFileRef, bufferCount, currentAudioBuffer);


I have used the same code base to write playable AIFF and WAV files without issue.   I am not sure what I have neglected here.  Thanks for any input.

Christopher

 _______________________________________________
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

  • Follow-Ups:
    • Re: trouble creating working Apple Lossless file under iOS 3.2
      • From: Ian Esten <email@hidden>
References: 
 >afinfo (From: email@hidden <email@hidden>)
 >Re: afinfo (From: Jean-Daniel Dupas <email@hidden>)
 >Re: afinfo (From: Robert Martin <email@hidden>)

  • Prev by Date: Re: afinfo
  • Next by Date: Re: afinfo
  • Previous by thread: Re: afinfo
  • Next by thread: Re: trouble creating working Apple Lossless file under iOS 3.2
  • Index(es):
    • Date
    • Thread