Index: mp3.cpp =================================================================== --- mp3.cpp (revision 52194) +++ mp3.cpp (working copy) @@ -83,9 +83,13 @@ int readBuffer(int16 *buffer, const int numSamples); bool endOfData() const { return _state == MP3_STATE_EOS; } - bool isStereo() const { return MAD_NCHANNELS(&_frame.header) == 2; } int getRate() const { return _frame.header.samplerate; } + // We return true for stereo always because MPEG audio files can + // change the number of channels at any time. In mono samples, + // we just duplicate the sample for the second channel. + bool isStereo() const { return true; } + bool seek(const Timestamp &where); Timestamp getLength() const { return _length; } protected: @@ -327,10 +331,17 @@ while (samples < len) { *buffer++ = (int16)scale_sample(_synth.pcm.samples[0][_posInFrame]); samples++; + if (MAD_NCHANNELS(&_frame.header) == 2) { *buffer++ = (int16)scale_sample(_synth.pcm.samples[1][_posInFrame]); samples++; + } else { + // For mono, just duplicate the sample for both channels + // See above for more details + *buffer = *(buffer - 1); + buffer++; } + _posInFrame++; } if (_posInFrame >= _synth.pcm.length) {