Changeset 1050
- Timestamp:
- 10/31/07 13:20:44 (15 months ago)
- Files:
-
- 1 modified
-
trunk/Audio/Decoders/MPEGDecoder.m (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Audio/Decoders/MPEGDecoder.m
r1046 r1050 700 700 _samplesToSkipInNextFrame = 0; 701 701 _samplesDecoded = 0; 702 703 // Zero the buffers 704 unsigned i; 705 for(i = 0; i < _bufferList->mNumberBuffers; ++i) 706 _bufferList->mBuffers[i].mDataByteSize = 0; 707 702 708 703 mad_stream_buffer(&_mad_stream, NULL, 0); 709 704 } 710 705 // Mark any buffered audio as read 706 else 707 _currentFrame += _bufferList->mBuffers[0].mDataByteSize / sizeof(float); 708 709 // Zero the buffers 710 unsigned i; 711 for(i = 0; i < _bufferList->mNumberBuffers; ++i) 712 _bufferList->mBuffers[i].mDataByteSize = 0; 713 711 714 for(;;) { 712 715 // All requested frames were skipped or read … … 758 761 } 759 762 760 // Decode the header only of the MPEG frame for speed761 int result = mad_ header_decode(&_mad_frame.header, &_mad_stream);763 // Decode the MPEG frame 764 int result = mad_frame_decode(&_mad_frame, &_mad_stream); 762 765 if(-1 == result) { 763 766 if(MAD_RECOVERABLE(_mad_stream.error)) { … … 828 831 // If this MPEG frame contains the desired seek frame, synthesize its audio to PCM 829 832 if(_samplesDecoded + (sampleCount - startingSample) > frame) { 830 // Finish decoding the MPEG frame831 result = mad_frame_decode(&_mad_frame, &_mad_stream);832 if(-1 == result) {833 if(MAD_RECOVERABLE(_mad_stream.error)) {834 #if DEBUG835 NSLog(@"Recoverable frame level error (%s)", mad_stream_errorstr(&_mad_stream));836 #endif837 continue;838 }839 else {840 #if DEBUG841 NSLog(@"Unrecoverable frame level error (%s)", mad_stream_errorstr(&_mad_stream));842 #endif843 break;844 }845 }846 847 833 // Synthesize the frame into PCM 848 834 mad_synth_frame(&_mad_synth, &_mad_frame); … … 870 856 871 857 // Only a portion of the frame was skipped- the rest was synthesized and stored in our buffers 872 _samplesDecoded += additionalSamplesToSkip; 858 _samplesDecoded += (sampleCount - startingSample); 859 _currentFrame += additionalSamplesToSkip; 873 860 } 874 861 // The entire frame was skipped 875 else 876 _samplesDecoded += (sampleCount - startingSample); 862 else { 863 _samplesDecoded += (sampleCount - startingSample); 864 _currentFrame += (sampleCount - startingSample); 865 } 877 866 } 878 879 _currentFrame = _samplesDecoded;880 867 881 868 return [self currentFrame];
