| 169 | | //begin our passthrough hack |
|---|
| 170 | | static int sample_rates[] = {48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000, 6000, 5512, 4000}; |
|---|
| 171 | | for (int sample_index = 0; sample_index < 12; sample_index ++) |
|---|
| 172 | | { |
|---|
| 173 | | CAStreamBasicDescription theOutputFormat(sample_rates[sample_index], kAudioFormatLinearPCM, 0, 1, 0, 2, 16, kIntPCMOutFormatFlag); |
|---|
| 174 | | AddOutputFormat(theOutputFormat); |
|---|
| | 170 | for (int channels = 1; channels <= 6; channels++) { |
|---|
| | 171 | // This decoder only takes an A/52 or AC-3 stream as it's input |
|---|
| | 172 | CAStreamBasicDescription theInputFormat1(sample_rates[sample_index], kAudioFormatAC3, 0, 256*6, 0, channels, 0, 0); |
|---|
| | 173 | AddInputFormat(theInputFormat1); |
|---|
| | 174 | CAStreamBasicDescription theInputFormat2(sample_rates[sample_index], kAudioFormatAVIAC3, 0, 256*6, 0, channels, 0, 0); |
|---|
| | 175 | AddInputFormat(theInputFormat2); |
|---|
| | 176 | |
|---|
| | 177 | // if two channel mode is engaged and we are not passing through, only set output for 2 channels |
|---|
| | 178 | if(!passthrough && TwoChannelMode && channels != 2) |
|---|
| | 179 | continue; |
|---|
| | 180 | // Output 16-Bit Ints |
|---|
| | 181 | CAStreamBasicDescription theOutputFormat1(sample_rates[sample_index], kAudioFormatLinearPCM, 0, 1, 0, channels, 16, kIntPCMOutFormatFlag); |
|---|
| | 182 | AddOutputFormat(theOutputFormat1); |
|---|
| | 183 | |
|---|
| 177 | | // 32 bit int |
|---|
| 178 | | CAStreamBasicDescription theOutputFormat1(sample_rates[sample_index], kAudioFormatLinearPCM, 0, 1, 0, 2, 32, kIntPCMOutFormatFlag); |
|---|
| 179 | | AddOutputFormat(theOutputFormat1); |
|---|
| 180 | | // 32 bit float |
|---|
| 181 | | CAStreamBasicDescription theOutputFormat2(sample_rates[sample_index], kAudioFormatLinearPCM, 0, 1, 0, 2, 32, kFloatPCMOutFormatFlag); |
|---|
| 182 | | AddOutputFormat(theOutputFormat2); |
|---|
| 183 | | } |
|---|
| 184 | | for (int channels = 1; channels <= 6; channels++) { |
|---|
| 185 | | // This decoder only takes an A/52 or AC-3 stream as it's input |
|---|
| 186 | | CAStreamBasicDescription theInputFormat1(sample_rates[sample_index], kAudioFormatAC3, 0, 256*6, 0, channels, 0, 0); |
|---|
| 187 | | AddInputFormat(theInputFormat1); |
|---|
| 188 | | CAStreamBasicDescription theInputFormat2(sample_rates[sample_index], kAudioFormatAVIAC3, 0, 256*6, 0, channels, 0, 0); |
|---|
| 189 | | AddInputFormat(theInputFormat2); |
|---|
| 190 | | } |
|---|
| 191 | | } |
|---|
| 192 | | } |
|---|
| 193 | | else |
|---|
| 194 | | { |
|---|
| 195 | | static int sample_rates[] = {48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000, 6000, 5512, 4000}; |
|---|
| 196 | | for (int sample_index = 0; sample_index < 12; sample_index ++) |
|---|
| 197 | | { |
|---|
| 198 | | for (int channels = 1; channels <= 6; channels++) { |
|---|
| 199 | | // This decoder only takes an A/52 or AC-3 stream as it's input |
|---|
| 200 | | CAStreamBasicDescription theInputFormat1(sample_rates[sample_index], kAudioFormatAC3, 0, 256*6, 0, channels, 0, 0); |
|---|
| 201 | | AddInputFormat(theInputFormat1); |
|---|
| 202 | | CAStreamBasicDescription theInputFormat2(sample_rates[sample_index], kAudioFormatAVIAC3, 0, 256*6, 0, channels, 0, 0); |
|---|
| 203 | | AddInputFormat(theInputFormat2); |
|---|
| 204 | | |
|---|
| 205 | | // Output 16-Bit Ints |
|---|
| 206 | | CAStreamBasicDescription theOutputFormat1(sample_rates[sample_index], kAudioFormatLinearPCM, 0, 1, 0, channels, 16, kIntPCMOutFormatFlag); |
|---|
| 207 | | AddOutputFormat(theOutputFormat1); |
|---|
| 208 | | |
|---|
| 605 | | memcpy(myOutputData, p_sync_be, 6); |
|---|
| | 583 | memcpy(myOutputData, p_sync_be, 4); |
|---|
| | 584 | myOutputData[frameSize] = input_data[5] & 0x7; |
|---|
| | 585 | myOutputData[frameSize+1] = p_sync_be[5]; |
|---|
| | 586 | myOutputData[frameSize+2] = (bytes_to_read >> 4) & 0xff; |
|---|
| | 587 | myOutputData[frameSize+3] = (bytes_to_read << 4) & 0xff; |
|---|
| | 588 | unsigned int i; |
|---|
| | 589 | int frameNumber; |
|---|
| | 590 | for(i=0, frameNumber = 2; i<bytes_to_read; i+=4, frameNumber++) |
|---|
| | 591 | { |
|---|
| | 592 | int offset = frameNumber * frameSize; |
|---|
| | 593 | memcpy(&myOutputData[offset], input_data, 4); |
|---|
| | 594 | } |
|---|
| | 595 | |
|---|
| | 596 | memcpy(myOutputData, p_sync_be, 4); |
|---|
| 613 | | memcpy(myOutputData, p_sync_le, 6); |
|---|
| 614 | | myOutputData[5] = input_data[5] & 0x7; |
|---|
| 615 | | myOutputData[6] = (bytes_to_read << 4) & 0xff; |
|---|
| 616 | | myOutputData[7] = (bytes_to_read >> 4) & 0xff; |
|---|
| | 604 | memcpy(myOutputData, p_sync_le, 4); |
|---|
| | 605 | myOutputData[frameSize] = p_sync_le[4]; |
|---|
| | 606 | myOutputData[frameSize+1] = input_data[5] & 0x7; |
|---|
| | 607 | myOutputData[frameSize+2] = (bytes_to_read << 4) & 0xff; |
|---|
| | 608 | myOutputData[frameSize+3] = (bytes_to_read >> 4) & 0xff; |
|---|