]> git.tdb.fi Git - libs/al.git/blobdiff - source/mp3decoder.cpp
Add utility functions for manipulating formats
[libs/al.git] / source / mp3decoder.cpp
index 8ddad47032ee08eae3155ec133747773f9546726..00fc9181bd69a2a2d6318d7d13153c3a71fce363 100644 (file)
@@ -55,7 +55,7 @@ Mp3Decoder::Mp3Decoder(IO::Seekable &io):
        try
        {
                decode_frame();
-               format = (priv->frame.header.mode==MAD_MODE_SINGLE_CHANNEL ? MONO16 : STEREO16);
+               format = create_format(2, MAD_NCHANNELS(&priv->frame.header));
                freq = priv->frame.header.samplerate;
        }
        catch(...)
@@ -92,7 +92,7 @@ void Mp3Decoder::rewind()
 
 unsigned Mp3Decoder::read(char *buf, unsigned len)
 {
-       unsigned nchan = (format==STEREO16 ? 2 : 1);
+       unsigned nchan = get_n_channels(format);
        mad_pcm &pcm = priv->synth.pcm;
 
        unsigned pos = 0;