Changeset 103


Ignore:
Timestamp:
11/08/06 00:05:52 (15 years ago)
Author:
r2d
Message:
  • changes to follow libmpcdec work in progress
  • can read sv7 & sv8
  • seek broken (not implemented in libmpcdec)
Location:
xmms-musepack/branches/r2d/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • xmms-musepack/branches/r2d/src/config.h.in

    r34 r103  
    1313#undef HAVE_MEMORY_H
    1414
    15 /* Define to 1 if you have the <mpcdec/config_types.h> header file. */
    16 #undef HAVE_MPCDEC_CONFIG_TYPES_H
     15/* Define to 1 if you have the <mpcdec/mpc_types.h> header file. */
     16#undef HAVE_MPCDEC_MPC_TYPES_H
    1717
    1818/* Define to 1 if stdbool.h conforms to C99. */
  • xmms-musepack/branches/r2d/src/libmpc.cpp

    r79 r103  
    22 * Copyright (c) 2005, The Musepack Development Team
    33 * All rights reserved.
    4  * 
     4 *
    55 * Redistribution and use in source and binary forms, with or without
    66 * modification, are permitted provided that the following conditions are
    77 * met:
    8  * 
     8 *
    99 *     * Redistributions of source code must retain the above copyright
    1010 *       notice, this list of conditions and the following disclaimer.
    11  * 
     11 *
    1212 *     * Redistributions in binary form must reproduce the above
    1313 *       copyright notice, this list of conditions and the following
    1414 *       disclaimer in the documentation and/or other materials provided
    1515 *       with the distribution.
    16  * 
     16 *
    1717 *     * Neither the name of the The Musepack Development Team nor the
    1818 *       names of its contributors may be used to endorse or promote
    1919 *       products derived from this software without specific prior
    2020 *       written permission.
    21  * 
     21 *
    2222 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    2323 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     
    327327{
    328328        mpc_reader reader;
    329         if (mpc_reader_init_stdio(&reader, p_Filename) == MPC_STATUS_OK) {
     329        mpc_demux * demux;
     330        if (mpc_reader_init_stdio(&reader, p_Filename) == MPC_STATUS_OK && (demux = mpc_demux_init(&reader))) {
    330331        MpcInfo tags = getTags(p_Filename);
    331332        *p_Title = mpcGenerateTitle(tags, p_Filename);
    332333        freeTags(tags);
    333         mpc_streaminfo info;
    334                 mpc_streaminfo_init(&info, &reader);
    335         *p_Length = static_cast<int> (1000 * mpc_streaminfo_get_length(&info));
     334                mpc_streaminfo info;
     335                mpc_demux_get_info(demux, &info);
     336                *p_Length = static_cast<int> (1000 * mpc_streaminfo_get_length(&info));
     337                mpc_demux_exit(demux);
    336338                mpc_reader_exit_stdio(&reader);
    337339    } else {
     
    522524
    523525                mpc_reader reader;
    524                 if (mpc_reader_init_stdio(&reader, p_Filename) == MPC_STATUS_OK) {
     526                mpc_demux * demux;
     527                if (mpc_reader_init_stdio(&reader, p_Filename) == MPC_STATUS_OK && (demux = mpc_demux_init(&reader))) {
    525528            mpc_streaminfo info;
    526                         mpc_streaminfo_init(&info, &reader);
     529                        mpc_demux_get_info(demux, &info);
    527530
    528531            int time = static_cast<int> (mpc_streaminfo_get_length(&info));
     
    559562            free(entry);
    560563            freeTags(tags);
     564                        mpc_demux_exit(demux);
    561565                        mpc_reader_exit_stdio(&reader);
    562566        }
     
    750754        mpcDecoder.isError = g_strdup_printf("[xmms-musepack] decodeStream is unable to open %s", filename);
    751755        return endThread(0, true);
    752     }
    753 
    754     mpc_streaminfo info;
    755         if (mpc_streaminfo_init(&info, &reader) != MPC_STATUS_OK) {
    756         mpcDecoder.isError = g_strdup_printf("[xmms-musepack] decodeStream is unable to read %s", filename);
     756        }
     757
     758        mpc_demux * demux = 0;
     759        demux = mpc_demux_init(&reader);
     760
     761        if ( demux == 0 ) {
     762                mpcDecoder.isError = g_strdup_printf("[xmms-musepack] decodeStream is unable to initialize decoder on %s", filename);
    757763                mpc_reader_exit_stdio(&reader);
    758         return endThread(0, true);
    759     }
    760 
     764                return endThread(0, true);
     765        }
     766
     767        mpc_streaminfo info;
     768        mpc_demux_get_info(demux, &info);
    761769    MpcInfo tags     = getTags(filename);
    762770    track.display    = mpcGenerateTitle(tags, filename);
    763     track.length     = static_cast<int> (1000 * mpc_streaminfo_get_length(&info));
    764     track.bitrate    = static_cast<int> (info.average_bitrate);
    765     track.sampleFreq = info.sample_freq;
    766     track.channels   = info.channels;
     771        track.length     = static_cast<int> (1000 * mpc_streaminfo_get_length(&info));
     772        track.bitrate    = static_cast<int> (info.average_bitrate);
     773        track.sampleFreq = info.sample_freq;
     774        track.channels   = info.channels;
    767775    freeTags(tags);
    768776
    769777    MpcPlugin.set_info(track.display, track.length, track.bitrate, track.sampleFreq, track.channels);
    770778
    771     mpc_decoder * decoder;
    772         if (mpc_decoder_init(&decoder, &reader, &info) != MPC_STATUS_OK) {
    773         mpcDecoder.isError = g_strdup_printf("[xmms-musepack] decodeStream is unable to initialize decoder on %s", filename);
    774                 mpc_reader_exit_stdio(&reader);
    775         return endThread(0, true);
    776     }
    777 
    778         mpc_decoder_set_seeking(decoder, &info, pluginConfig.fastSeek);
    779     setReplaygain(info, *decoder);
     779//      mpc_decoder_set_seeking(decoder, &info, pluginConfig.fastSeek);
     780//     setReplaygain(info, *decoder);
    780781
    781782    MPC_SAMPLE_FORMAT sampleBuffer[MPC_DECODER_BUFFER_LENGTH];
     
    795796    lockRelease();
    796797
    797     int counter = 2 * track.sampleFreq / 3;
     798        int counter = 2 * track.sampleFreq / 3;
     799        unsigned status = 1;
    798800    while (isAlive())
    799801    {
    800802        if (getOffset() != -1)
    801803        {
    802             mpc_decoder_seek_seconds(decoder, mpcDecoder.offset);
     804//             mpc_decoder_seek_seconds(decoder, mpcDecoder.offset);
    803805            setOffset(-1);
    804806        }
     
    807809        short iPlaying = MpcPlugin.output->buffer_playing()? 1 : 0;
    808810        int iFree = MpcPlugin.output->buffer_free();
    809         if (!mpcDecoder.isPause &&  iFree >= ((1152 * 4) << iPlaying))
     811        if (!mpcDecoder.isPause &&  iFree >= ((1152 * 4) << iPlaying) && status != 0)
    810812        {
    811             unsigned status = processBuffer(sampleBuffer, xmmsBuffer, *decoder);
    812             if (status == (unsigned) (-1))
    813             {
    814                                 mpcDecoder.isError = g_strdup_printf("[xmms-musepack] error from internal decoder on %s", filename);
    815                                 mpc_reader_exit_stdio(&reader);
    816                 return endThread(0, true);
    817             }
    818             else if (status == 0)
    819             {
    820                 //mpcDecoder.isError = g_strdup_printf("[xmms-musepack] null output from internal decoder on %s", filename);
    821                                 mpc_reader_exit_stdio(&reader);
    822                 return endThread(0, true);
    823             }
    824             lockRelease();
    825 
    826             if(pluginConfig.dynamicBitrate)
    827             {
    828                 counter -= status;
    829                 if(counter < 0)
    830                 {
    831                     MpcPlugin.set_info(track.display, track.length, track.bitrate, track.sampleFreq, track.channels);
    832                     counter = 2 * track.sampleFreq / 3;
    833                 }
    834             }
     813                        status = processBuffer(sampleBuffer, xmmsBuffer, *demux);
     814                        lockRelease();
     815
     816                        if(pluginConfig.dynamicBitrate) {
     817                                counter -= status;
     818                                if(counter < 0) {
     819                                        MpcPlugin.set_info(track.display, track.length, track.bitrate, track.sampleFreq, track.channels);
     820                                        counter = 2 * track.sampleFreq / 3;
     821                                }
     822                        }
    835823        }
    836824        else
    837825        {
    838             lockRelease();
     826                        lockRelease();
     827                        if (!mpcDecoder.isPause && status == 0 && MpcPlugin.output->output_time() == 0)
     828                                break;
    839829            xmms_usleep(10000);
    840         }
     830                }
    841831        }
     832        mpc_demux_exit(demux);
    842833        mpc_reader_exit_stdio(&reader);
    843834    return endThread(0, false);
    844835}
    845836
    846 static int processBuffer(MPC_SAMPLE_FORMAT* sampleBuffer, char* xmmsBuffer, mpc_decoder& decoder)
     837static int processBuffer(MPC_SAMPLE_FORMAT* sampleBuffer, char* xmmsBuffer, mpc_demux& demux)
    847838{
    848839    mpc_uint32_t vbrAcc = 0;
    849840    mpc_uint32_t vbrUpd = 0;
    850 
    851     unsigned status  = mpc_decoder_decode(&decoder, sampleBuffer, &vbrAcc, &vbrUpd);
    852     copyBuffer(sampleBuffer, xmmsBuffer, status);
     841        mpc_frame_info info;
     842
     843        info.buffer = sampleBuffer;
     844        mpc_demux_decode(&demux, &info);
     845    copyBuffer(sampleBuffer, xmmsBuffer, info.samples);
    853846
    854847    if (pluginConfig.dynamicBitrate)
     
    859852    if (pluginConfig.isEq)
    860853    {
    861         iir(xmmsBuffer, 4 * status);
    862     }
    863 
    864     MpcPlugin.add_vis_pcm(MpcPlugin.output->written_time(), FMT_S16_LE, track.channels, status * 4, xmmsBuffer);
    865     MpcPlugin.output->write_audio(xmmsBuffer, status * 4);
    866     return status;
     854                iir(xmmsBuffer, 4 * info.samples);
     855    }
     856
     857        MpcPlugin.add_vis_pcm(MpcPlugin.output->written_time(), FMT_S16_LE, track.channels, info.samples * 4, xmmsBuffer);
     858        MpcPlugin.output->write_audio(xmmsBuffer, info.samples * 4);
     859        return info.samples;
    867860}
    868861
  • xmms-musepack/branches/r2d/src/libmpc.h

    r79 r103  
    22 * Copyright (c) 2005, The Musepack Development Team
    33 * All rights reserved.
    4  * 
     4 *
    55 * Redistribution and use in source and binary forms, with or without
    66 * modification, are permitted provided that the following conditions are
    77 * met:
    8  * 
     8 *
    99 *     * Redistributions of source code must retain the above copyright
    1010 *       notice, this list of conditions and the following disclaimer.
    11  * 
     11 *
    1212 *     * Redistributions in binary form must reproduce the above
    1313 *       copyright notice, this list of conditions and the following
    1414 *       disclaimer in the documentation and/or other materials provided
    1515 *       with the distribution.
    16  * 
     16 *
    1717 *     * Neither the name of the The Musepack Development Team nor the
    1818 *       names of its contributors may be used to endorse or promote
    1919 *       products derived from this software without specific prior
    2020 *       written permission.
    21  * 
     21 *
    2222 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    2323 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     
    170170static void       lockRelease();
    171171static void*      decodeStream(void*);
    172 static int        processBuffer(MPC_SAMPLE_FORMAT*, char*, mpc_decoder&);
     172static int        processBuffer(MPC_SAMPLE_FORMAT*, char*, mpc_demux&);
    173173static void*      endThread(FILE*, bool);
    174174static bool       isAlive();
Note: See TracChangeset for help on using the changeset viewer.