@@ -19,7 +19,7 @@ pub enum AudioFormat {
1919 /// Linear PCM; a non-compressed audio data format with one frame per packet.
2020 ///
2121 /// **Available** in OS X v10.0 and later.
22- LinearPCM ( Option < LinearPCMFlags > ) , // = 1819304813,
22+ LinearPCM ( LinearPCMFlags ) , // = 1819304813,
2323 /// An AC-3 codec.
2424 ///
2525 /// **Available** in OS X v10.2 and later.
@@ -28,27 +28,27 @@ pub enum AudioFormat {
2828 /// audio interface.
2929 ///
3030 /// **Available** in OS X v10.2 and later.
31- F60958AC3 ( Option < StandardFlags > ) , // = 1667326771,
31+ F60958AC3 ( StandardFlags ) , // = 1667326771,
3232 /// Apple's implementation of the IMA 4:1 ADPCM codec.
3333 ///
3434 /// **Available** in OS X v10.2 and later.
3535 AppleIMA4 , // = 1768775988,
3636 /// MPEG-4 AAC codec.
3737 ///
3838 /// **Available** in OS X v10.2 and later.
39- MPEG4AAC ( Option < Mpeg4ObjectId > ) , // = 1633772320,
39+ MPEG4AAC ( Mpeg4ObjectId ) , // = 1633772320,
4040 /// MPEG-4 CELP codec.
4141 ///
4242 /// **Available** in OS X v10.2 and later.
43- MPEG4CELP ( Option < Mpeg4ObjectId > ) , // = 1667591280,
43+ MPEG4CELP ( Mpeg4ObjectId ) , // = 1667591280,
4444 /// MPEG-4 HVXC codec.
4545 ///
4646 /// **Available** in OS X v10.2 and later.
47- MPEG4HVXC ( Option < Mpeg4ObjectId > ) , // = 1752594531,
47+ MPEG4HVXC ( Mpeg4ObjectId ) , // = 1752594531,
4848 /// MPEG-4 TwinVQ codec.
4949 ///
5050 /// **Available** in OS X v10.2 and later.
51- MPEG4TwinVQ ( Option < Mpeg4ObjectId > ) , // = 1953986161,
51+ MPEG4TwinVQ ( Mpeg4ObjectId ) , // = 1953986161,
5252 /// MACE 3:1.
5353 ///
5454 /// **Available** in OS X v10.3 and later.
@@ -92,7 +92,7 @@ pub enum AudioFormat {
9292 /// A stream of IOAudioTimeStamp structures.
9393 ///
9494 /// **Available** in OS X v10.2 and later.
95- TimeCode ( Option < AudioTimeStampFlags > ) , // = 1953066341,
95+ TimeCode ( AudioTimeStampFlags ) , // = 1953066341,
9696 /// A stream of MIDIPacketList structures where the time stamps in the MIDIPacket structures
9797 /// are sample offsets in the stream. The `sample_rate` field in the **StreamFormat** structure
9898 /// is used to describe how time is passed in this kind of stream.
@@ -122,7 +122,7 @@ pub enum AudioFormat {
122122 /// Apple Lossless format.
123123 ///
124124 /// **Available** in OS X v10.3 and later.
125- AppleLossless , // = 1634492771,
125+ AppleLossless ( AppleLosslessFlags ) , // = 1634492771,
126126 /// MPEG-4 High Efficiency AAC audio object.
127127 ///
128128 /// **Available** in OS X v10.5 and later.
@@ -183,14 +183,14 @@ impl AudioFormat {
183183 /// Convert from the FFI C format and flags to a typesafe Rust enum representation.
184184 pub fn from_format_and_flag ( format : libc:: c_uint , flag : Option < u32 > ) -> Option < AudioFormat > {
185185 match ( format, flag) {
186- ( 1819304813 , Some ( i) ) => Some ( AudioFormat :: LinearPCM ( LinearPCMFlags :: from_bits ( i) ) ) ,
186+ ( 1819304813 , Some ( i) ) => Some ( AudioFormat :: LinearPCM ( LinearPCMFlags :: from_bits_truncate ( i) ) ) ,
187187 ( 1633889587 , _) => Some ( AudioFormat :: AC3 ) ,
188- ( 1667326771 , Some ( i) ) => Some ( AudioFormat :: F60958AC3 ( StandardFlags :: from_bits ( i) ) ) ,
188+ ( 1667326771 , Some ( i) ) => Some ( AudioFormat :: F60958AC3 ( StandardFlags :: from_bits_truncate ( i) ) ) ,
189189 ( 1768775988 , _) => Some ( AudioFormat :: AppleIMA4 ) ,
190- ( 1633772320 , Some ( i) ) => Some ( AudioFormat :: MPEG4AAC ( Mpeg4ObjectId :: from_u32 ( i) ) ) ,
191- ( 1667591280 , Some ( i) ) => Some ( AudioFormat :: MPEG4CELP ( Mpeg4ObjectId :: from_u32 ( i) ) ) ,
192- ( 1752594531 , Some ( i) ) => Some ( AudioFormat :: MPEG4HVXC ( Mpeg4ObjectId :: from_u32 ( i) ) ) ,
193- ( 1953986161 , Some ( i) ) => Some ( AudioFormat :: MPEG4TwinVQ ( Mpeg4ObjectId :: from_u32 ( i) ) ) ,
190+ ( 1633772320 , Some ( i) ) => Some ( AudioFormat :: MPEG4AAC ( Mpeg4ObjectId :: from_u32 ( i) . expect ( "Unknown Mpeg4ObjectId" ) ) ) ,
191+ ( 1667591280 , Some ( i) ) => Some ( AudioFormat :: MPEG4CELP ( Mpeg4ObjectId :: from_u32 ( i) . expect ( "Unknown Mpeg4ObjectId" ) ) ) ,
192+ ( 1752594531 , Some ( i) ) => Some ( AudioFormat :: MPEG4HVXC ( Mpeg4ObjectId :: from_u32 ( i) . expect ( "Unknown Mpeg4ObjectId" ) ) ) ,
193+ ( 1953986161 , Some ( i) ) => Some ( AudioFormat :: MPEG4TwinVQ ( Mpeg4ObjectId :: from_u32 ( i) . expect ( "Unknown Mpeg4ObjectId" ) ) ) ,
194194 ( 1296122675 , _) => Some ( AudioFormat :: MACE3 ) ,
195195 ( 1296122678 , _) => Some ( AudioFormat :: MACE6 ) ,
196196 ( 1970037111 , _) => Some ( AudioFormat :: ULaw ) ,
@@ -201,10 +201,10 @@ impl AudioFormat {
201201 ( 778924081 , _) => Some ( AudioFormat :: MPEGLayer1 ) ,
202202 ( 778924082 , _) => Some ( AudioFormat :: MPEGLayer2 ) ,
203203 ( 778924083 , _) => Some ( AudioFormat :: MPEGLayer3 ) ,
204- ( 1953066341 , Some ( i) ) => Some ( AudioFormat :: TimeCode ( AudioTimeStampFlags :: from_bits ( i) ) ) ,
204+ ( 1953066341 , Some ( i) ) => Some ( AudioFormat :: TimeCode ( AudioTimeStampFlags :: from_bits_truncate ( i) ) ) ,
205205 ( 1835623529 , _) => Some ( AudioFormat :: MIDIStream ) ,
206206 ( 1634760307 , _) => Some ( AudioFormat :: ParameterValueStream ) ,
207- ( 1634492771 , _ ) => Some ( AudioFormat :: AppleLossless ) ,
207+ ( 1634492771 , Some ( i ) ) => Some ( AudioFormat :: AppleLossless ( AppleLosslessFlags :: from_bits_truncate ( i ) ) ) ,
208208 ( 1633772392 , _) => Some ( AudioFormat :: MPEG4AAC_HE ) ,
209209 ( 1633772396 , _) => Some ( AudioFormat :: MPEG4AAC_LD ) ,
210210 ( 1633772389 , _) => Some ( AudioFormat :: MPEG4AAC_ELD ) ,
@@ -226,14 +226,14 @@ impl AudioFormat {
226226 /// Convert from the Rust enum to the C format and flag.
227227 pub fn to_format_and_flag ( & self ) -> ( libc:: c_uint , Option < u32 > ) {
228228 match * self {
229- AudioFormat :: LinearPCM ( flag) => ( 1819304813 , flag . map ( |flag| flag. bits ( ) ) ) ,
229+ AudioFormat :: LinearPCM ( flag) => ( 1819304813 , Some ( flag. bits ( ) ) ) ,
230230 AudioFormat :: AC3 => ( 1633889587 , None ) ,
231- AudioFormat :: F60958AC3 ( flag) => ( 1667326771 , flag . map ( |flag| flag. bits ( ) ) ) ,
231+ AudioFormat :: F60958AC3 ( flag) => ( 1667326771 , Some ( flag. bits ( ) ) ) ,
232232 AudioFormat :: AppleIMA4 => ( 1768775988 , None ) ,
233- AudioFormat :: MPEG4AAC ( flag) => ( 1633772320 , flag . map ( |flag| flag as u32 ) ) ,
234- AudioFormat :: MPEG4CELP ( flag) => ( 1667591280 , flag . map ( |flag| flag as u32 ) ) ,
235- AudioFormat :: MPEG4HVXC ( flag) => ( 1752594531 , flag . map ( |flag| flag as u32 ) ) ,
236- AudioFormat :: MPEG4TwinVQ ( flag) => ( 1953986161 , flag . map ( |flag| flag as u32 ) ) ,
233+ AudioFormat :: MPEG4AAC ( flag) => ( 1633772320 , Some ( flag as u32 ) ) ,
234+ AudioFormat :: MPEG4CELP ( flag) => ( 1667591280 , Some ( flag as u32 ) ) ,
235+ AudioFormat :: MPEG4HVXC ( flag) => ( 1752594531 , Some ( flag as u32 ) ) ,
236+ AudioFormat :: MPEG4TwinVQ ( flag) => ( 1953986161 , Some ( flag as u32 ) ) ,
237237 AudioFormat :: MACE3 => ( 1296122675 , None ) ,
238238 AudioFormat :: MACE6 => ( 1296122678 , None ) ,
239239 AudioFormat :: ULaw => ( 1970037111 , None ) ,
@@ -244,10 +244,10 @@ impl AudioFormat {
244244 AudioFormat :: MPEGLayer1 => ( 778924081 , None ) ,
245245 AudioFormat :: MPEGLayer2 => ( 778924082 , None ) ,
246246 AudioFormat :: MPEGLayer3 => ( 778924083 , None ) ,
247- AudioFormat :: TimeCode ( flag) => ( 1953066341 , flag . map ( |flag| flag. bits ( ) ) ) ,
247+ AudioFormat :: TimeCode ( flag) => ( 1953066341 , Some ( flag. bits ( ) ) ) ,
248248 AudioFormat :: MIDIStream => ( 1835623529 , None ) ,
249249 AudioFormat :: ParameterValueStream => ( 1634760307 , None ) ,
250- AudioFormat :: AppleLossless => ( 1634492771 , None ) ,
250+ AudioFormat :: AppleLossless ( flag ) => ( 1634492771 , Some ( flag . bits ( ) ) ) ,
251251 AudioFormat :: MPEG4AAC_HE => ( 1633772392 , None ) ,
252252 AudioFormat :: MPEG4AAC_LD => ( 1633772396 , None ) ,
253253 AudioFormat :: MPEG4AAC_ELD => ( 1633772389 , None ) ,
@@ -312,10 +312,6 @@ pub mod standard_flags {
312312 /// Clear if the samples for each frame are laid out contiguously and the frames laid out
313313 /// end to end.
314314 ///
315- /// In the original API, this flag affects the use of AudioStreamBasicDescription and
316- /// AudioBufferList structures, however in this Rust implementation we aim to make this
317- /// behaviour type safe so that you need not worry about this.
318- ///
319315 /// **Available** in OS X v10.2 and later.
320316 const IS_NON_INTERLEAVED = 32 ,
321317 /// Set to indicate when a format is nonmixable.
@@ -501,4 +497,3 @@ pub mod audio_time_stamp_flags {
501497 }
502498 }
503499}
504-
0 commit comments