Changeset 1380

Show
Ignore:
Timestamp:
07/30/08 21:00:19 (4 months ago)
Author:
stephen_booth
Message:

Don't automatically convert ALAC to 16-bits, but preserve the input bit depth
Fixes #42

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/Decoders/CoreAudioDecoder.m

    r1292 r1380  
    4949                _pcmFormat.mFormatFlags                 = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsBigEndian | kAudioFormatFlagIsPacked; 
    5050                 
    51                 // Preserve mSampleRate and mChannelsPerFrame 
    52                 _pcmFormat.mBitsPerChannel              = (0 == _pcmFormat.mBitsPerChannel ? 16 : _pcmFormat.mBitsPerChannel); 
     51                // For alac the source bit depth is encoded in the format flag 
     52                if(kAudioFormatAppleLossless == _sourceFormat.mFormatID) { 
     53                        switch (_sourceFormat.mFormatFlags) { 
     54                                case kAppleLosslessFormatFlag_16BitSourceData: 
     55                                        _pcmFormat.mBitsPerChannel = 16; 
     56                                        break; 
     57//                              case kAppleLosslessFormatFlag_20BitSourceData: 
     58//                                      _pcmFormat.mBitsPerChannel = 20; 
     59//                                      break; 
     60                                case kAppleLosslessFormatFlag_24BitSourceData: 
     61                                        _pcmFormat.mBitsPerChannel = 24; 
     62                                        break; 
     63                                case kAppleLosslessFormatFlag_32BitSourceData: 
     64                                        _pcmFormat.mBitsPerChannel = 32; 
     65                                        break; 
     66                                         
     67// FIXME: How to handle 20-bit files? 
     68                                default: 
     69                                        _pcmFormat.mBitsPerChannel = 16; 
     70                                        break; 
     71                        }        
     72                } 
     73                else 
     74                        // Preserve mSampleRate and mChannelsPerFrame 
     75                        _pcmFormat.mBitsPerChannel      = (0 == _pcmFormat.mBitsPerChannel ? 16 : _pcmFormat.mBitsPerChannel); 
    5376                 
    5477                _pcmFormat.mBytesPerPacket              = (_pcmFormat.mBitsPerChannel / 8) * _pcmFormat.mChannelsPerFrame;