Changeset 79 for xmms-musepack/trunk


Ignore:
Timestamp:
10/28/06 23:38:21 (18 years ago)
Author:
r2d
Message:
  • made changes to be able to use libmpcdec (zorg's branch)
Location:
xmms-musepack/trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • xmms-musepack/trunk/src/libmpc.cpp

    r38 r79  
    326326static void mpcGetSongInfo(char* p_Filename, char** p_Title, int* p_Length)
    327327{
    328     FILE* input = fopen(p_Filename, "rb");
    329     if(input)
    330     {
     328        mpc_reader reader;
     329        if (mpc_reader_init_stdio(&reader, p_Filename) == MPC_STATUS_OK) {
    331330        MpcInfo tags = getTags(p_Filename);
    332331        *p_Title = mpcGenerateTitle(tags, p_Filename);
    333332        freeTags(tags);
    334333        mpc_streaminfo info;
    335         mpc_reader_file reader;
    336         mpc_reader_setup_file_reader(&reader, input);
    337         mpc_streaminfo_read(&info, &reader.reader);
     334                mpc_streaminfo_init(&info, &reader);
    338335        *p_Length = static_cast<int> (1000 * mpc_streaminfo_get_length(&info));
    339         fclose(input);
    340     }
    341     else
    342     {
     336                mpc_reader_exit_stdio(&reader);
     337    } else {
    343338        char* temp = g_strdup_printf("[xmms-musepack] mpcGetSongInfo is unable to open %s\n", p_Filename);
    344339        perror(temp);
     
    526521        GtkWidget* albumGainLabel = mpcGtkLabel(infoVbox);
    527522
    528         FILE* input = fopen(p_Filename, "rb");
    529         if(input)
    530         {
     523                mpc_reader reader;
     524                if (mpc_reader_init_stdio(&reader, p_Filename) == MPC_STATUS_OK) {
    531525            mpc_streaminfo info;
    532             mpc_reader_file reader;
    533             mpc_reader_setup_file_reader(&reader, input);
    534             mpc_streaminfo_read(&info, &reader.reader);
     526                        mpc_streaminfo_init(&info, &reader);
    535527
    536528            int time = static_cast<int> (mpc_streaminfo_get_length(&info));
     
    567559            free(entry);
    568560            freeTags(tags);
    569             fclose(input);
     561                        mpc_reader_exit_stdio(&reader);
    570562        }
    571563        else
     
    754746    lockAcquire();
    755747    const char* filename = static_cast<const char*> (data);
    756     FILE* input = fopen(filename, "rb");
    757     if (!input)
    758     {
     748        mpc_reader reader;
     749        if (mpc_reader_init_stdio(&reader, filename) != MPC_STATUS_OK) {
    759750        mpcDecoder.isError = g_strdup_printf("[xmms-musepack] decodeStream is unable to open %s", filename);
    760         return endThread(input, true);
    761     }
    762 
    763     mpc_reader_file reader;
    764     mpc_reader_setup_file_reader(&reader, input);
     751        return endThread(0, true);
     752    }
    765753
    766754    mpc_streaminfo info;
    767     if (mpc_streaminfo_read(&info, &reader.reader) != ERROR_CODE_OK)
    768     {
     755        if (mpc_streaminfo_init(&info, &reader) != MPC_STATUS_OK) {
    769756        mpcDecoder.isError = g_strdup_printf("[xmms-musepack] decodeStream is unable to read %s", filename);
    770         return endThread(input, true);
     757                mpc_reader_exit_stdio(&reader);
     758        return endThread(0, true);
    771759    }
    772760
     
    781769    MpcPlugin.set_info(track.display, track.length, track.bitrate, track.sampleFreq, track.channels);
    782770
    783     mpc_decoder decoder;
    784     mpc_decoder_setup(&decoder, &reader.reader);
    785     if (!mpc_decoder_initialize(&decoder, &info))
    786     {
     771    mpc_decoder * decoder;
     772        if (mpc_decoder_init(&decoder, &reader, &info) != MPC_STATUS_OK) {
    787773        mpcDecoder.isError = g_strdup_printf("[xmms-musepack] decodeStream is unable to initialize decoder on %s", filename);
    788         return endThread(input, true);
    789     }
    790 
    791     mpc_decoder_set_seeking(&decoder, &info, pluginConfig.fastSeek);
    792     setReplaygain(info, decoder);
     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);
    793780
    794781    MPC_SAMPLE_FORMAT sampleBuffer[MPC_DECODER_BUFFER_LENGTH];
     
    797784    if (!MpcPlugin.output->open_audio(FMT_S16_LE, track.sampleFreq, track.channels))
    798785    {
    799         mpcDecoder.isError = g_strdup_printf("[xmms-musepack] decodeStream is unable to open an audio output");
    800         return endThread(input, true);
     786                mpcDecoder.isError = g_strdup_printf("[xmms-musepack] decodeStream is unable to open an audio output");
     787                mpc_reader_exit_stdio(&reader);
     788        return endThread(0, true);
    801789    }
    802790    else
     
    812800        if (getOffset() != -1)
    813801        {
    814             mpc_decoder_seek_seconds(&decoder, mpcDecoder.offset);
     802            mpc_decoder_seek_seconds(decoder, mpcDecoder.offset);
    815803            setOffset(-1);
    816804        }
     
    821809        if (!mpcDecoder.isPause &&  iFree >= ((1152 * 4) << iPlaying))
    822810        {
    823             unsigned status = processBuffer(sampleBuffer, xmmsBuffer, decoder);
     811            unsigned status = processBuffer(sampleBuffer, xmmsBuffer, *decoder);
    824812            if (status == (unsigned) (-1))
    825813            {
    826                 mpcDecoder.isError = g_strdup_printf("[xmms-musepack] error from internal decoder on %s", filename);
    827                 return endThread(input, true);
     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);
    828817            }
    829818            else if (status == 0)
    830819            {
    831820                //mpcDecoder.isError = g_strdup_printf("[xmms-musepack] null output from internal decoder on %s", filename);
    832                 return endThread(input, true);
     821                                mpc_reader_exit_stdio(&reader);
     822                return endThread(0, true);
    833823            }
    834824            lockRelease();
     
    849839            xmms_usleep(10000);
    850840        }
    851     }
    852     return endThread(input, false);
     841        }
     842        mpc_reader_exit_stdio(&reader);
     843    return endThread(0, false);
    853844}
    854845
  • xmms-musepack/trunk/src/libmpc.h

    r38 r79  
    5656#include <iconv.h>
    5757
     58#undef FALSE
     59#undef TRUE
    5860//libmpcdec headers
    5961#include <mpcdec/mpcdec.h>
     
    109111{
    110112    char*      isError;
    111     double     offset;   
     113    double     offset;
    112114    bool       isOutput;
    113115    bool       isAlive;
Note: See TracChangeset for help on using the changeset viewer.