Re: How Do I Use NSCoding with Core Audio Data Types?
Re: How Do I Use NSCoding with Core Audio Data Types?
- Subject: Re: How Do I Use NSCoding with Core Audio Data Types?
- From: Kyle Sluder <email@hidden>
- Date: Fri, 21 Jun 2013 18:04:39 -0700
On Fri, Jun 21, 2013, at 05:04 PM, n ketter wrote:
> I've created a class that contains three properties that are Core Audio
> types:
>
> @interface AudioFilePlayer : NSObject <NSCoding>
>
> @property (assign) AudioUnit mAudioUnit;
> @property (assign) AUNode mNode;
> @property (assign) AudioStreamBasicDescription mStreamFormat;
>
> @end
>
> My app holds an array of objects of type AudioFilePlayer and I want to
> archive and unarchive them using NSCoding. I've written the
> encodeWithCoder: and initWithCoder: methods as follows:
You can't just willy-nilly archive raw bytes to disk and expect decoding
them to make any sense. AudioUnits and AUNodes are pointers into living
objects in an AU graph.
On the other hand, an AudioStreamBasicDescription is just a compendium
of values describing a particular file format, so it is okay to write
those values to disk. However, writing raw C structs to disk is a risky
proposition; you have to worry about padding, alignment, and endianness.
--Kyle Sluder
_______________________________________________
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