Changeset 455


Ignore:
Timestamp:
11/07/09 20:03:01 (15 years ago)
Author:
r2d
Message:

changes for audacious (don't know if it works, old changes)

Location:
bmp-musepack/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • bmp-musepack/trunk/configure.ac

    r34 r455  
    1212AC_PROG_INSTALL
    1313
     14CXXFLAGS="-O3 -fomit-frame-pointer"
     15
    1416AC_HEADER_STDC
    1517AC_CHECK_HEADERS([fcntl.h stdlib.h string.h unistd.h wchar.h])
     
    2022AC_TYPE_SIZE_T
    2123
    22 PKG_CHECK_MODULES(BEEP, [bmp >= 0.9.7],
     24PKG_CHECK_MODULES(AUDACIOUS, [audclient >= 1.0.0],
    2325        [],
    24         [AC_MSG_ERROR([BMP >= 0.9.7 development package not installed])]
     26        [AC_MSG_ERROR([AUDACIOUS >= 1.0.0 development package not installed])]
    2527)
    2628
    27 BEEP_PLUGIN_DIR=`pkg-config --variable input_plugin_dir bmp`
    28 AC_SUBST(BEEP_PLUGIN_DIR)
     29AUD_PLUGIN_DIR=`pkg-config --variable input_plugin_dir audacious`
     30AC_SUBST(AUD_PLUGIN_DIR)
    2931
    3032PKG_CHECK_MODULES(GTK, [gtk+-2.0 >= 2.4.0],
     
    3840)
    3941
    40 CXXFLAGS="$CXXFLAGS -O3 -fomit-frame-pointer"
    41 AC_CHECK_HEADERS(mpcdec/config_types.h,,AC_MSG_ERROR([*** Libmpcdec not installed - please install first ***]))
     42AC_CHECK_HEADERS(mpc/mpc_types.h,,AC_MSG_ERROR([*** Libmpcdec not installed - please install first ***]))
    4243
    4344AC_DEFUN([AC_HAVE_TAGLIB],
  • bmp-musepack/trunk/src/Makefile.am

    r34 r455  
    33lib_LTLIBRARIES = libmpc.la
    44
    5 libdir = @BEEP_PLUGIN_DIR@
     5libdir = @AUD_PLUGIN_DIR@
    66
    7 INCLUDES = @GLIB_2_0_CFLAGS@ @BEEP_CFLAGS@ @GTK_CFLAGS@ @TAGLIB_CFLAGS@ -DVERSION=\"@VERSION@\"
     7INCLUDES = @GLIB_2_0_CFLAGS@ @AUDACIOUS_CFLAGS@ @GTK_CFLAGS@ @TAGLIB_CFLAGS@ -DVERSION=\"@VERSION@\"
    88libmpc_la_LIBADD = @PTHREAD_LIBS@ @GLIB_2_0_LIBS@ @BEEP_LIBS@ @GTK_LIBS@ @TAGLIB_LIBS@
    99
  • bmp-musepack/trunk/src/libmpc.cpp

    r34 r455  
    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
     
    111111    {
    112112        char* titleText      = g_strdup_printf("Musepack Decoder Plugin %s", VERSION);
    113         char* contentText = "Plugin code by\nBenoit Amiaux\nMartin Spuler\nKuniklo\n\nGet latest version at http://musepack.net\n";
    114         char* buttonText  = "Nevermind";
     113        const char* contentText = "Plugin code by\nBenoit Amiaux\nMartin Spuler\nKuniklo\n\nGet latest version at http://musepack.net\n";
     114            const char* buttonText  = "Nevermind";
    115115        aboutBox = xmms_show_message(titleText, contentText, buttonText, FALSE, NULL, NULL);
    116116        widgets.aboutBox = aboutBox;
     
    313313static void mpcGetSongInfo(char* p_Filename, char** p_Title, int* p_Length)
    314314{
    315     FILE* input = fopen(p_Filename, "rb");
    316     if(input)
    317     {
     315        mpc_reader reader;
     316        mpc_demux * demux;
     317        if (mpc_reader_init_stdio(&reader, p_Filename) == MPC_STATUS_OK && (demux = mpc_demux_init(&reader))) {
    318318        MpcInfo tags = getTags(p_Filename);
    319319        *p_Title = mpcGenerateTitle(tags, p_Filename);
    320320        freeTags(tags);
    321         mpc_streaminfo info;
    322         mpc_reader_file reader;
    323         mpc_reader_setup_file_reader(&reader, input);
    324         mpc_streaminfo_read(&info, &reader.reader);
    325         *p_Length = static_cast<int> (1000 * mpc_streaminfo_get_length(&info));
    326         fclose(input);
    327     }
    328     else
    329     {
     321                mpc_streaminfo info;
     322                mpc_demux_get_info(demux, &info);
     323                *p_Length = static_cast<int> (1000 * mpc_streaminfo_get_length(&info));
     324                mpc_demux_exit(demux);
     325                mpc_reader_exit_stdio(&reader);
     326    } else {
    330327        char* temp = g_strdup_printf("[xmms-musepack] mpcGetSongInfo is unable to open %s\n", p_Filename);
    331328        perror(temp);
     
    474471        GtkWidget* streamLabel    = mpcGtkLabel(infoVbox);
    475472        GtkWidget* encoderLabel   = mpcGtkLabel(infoVbox);
    476         GtkWidget* profileLabel   = mpcGtkLabel(infoVbox);
     473                GtkWidget* profileLabel   = mpcGtkLabel(infoVbox);
     474                GtkWidget* pnsLabel       = mpcGtkLabel(infoVbox);
     475                GtkWidget* gaplessLabel   = mpcGtkLabel(infoVbox);
    477476        GtkWidget* bitrateLabel   = mpcGtkLabel(infoVbox);
    478477        GtkWidget* rateLabel      = mpcGtkLabel(infoVbox);
     
    485484        GtkWidget* albumGainLabel = mpcGtkLabel(infoVbox);
    486485
    487         FILE* input = fopen(p_Filename, "rb");
    488         if(input)
    489         {
     486                mpc_reader reader;
     487                mpc_demux * demux;
     488                if (mpc_reader_init_stdio(&reader, p_Filename) == MPC_STATUS_OK && (demux = mpc_demux_init(&reader))) {
    490489            mpc_streaminfo info;
    491             mpc_reader_file reader;
    492             mpc_reader_setup_file_reader(&reader, input);
    493             mpc_streaminfo_read(&info, &reader.reader);
     490                        mpc_demux_get_info(demux, &info);
    494491
    495492            int time = static_cast<int> (mpc_streaminfo_get_length(&info));
     
    499496            mpcGtkPrintLabel(streamLabel,    "Streamversion %d", info.stream_version);
    500497            mpcGtkPrintLabel(encoderLabel,   "Encoder: \%s", info.encoder);
    501             mpcGtkPrintLabel(profileLabel,   "Profile: \%s", info.profile_name);
     498                        mpcGtkPrintLabel(profileLabel,   "Profile: \%s (q=%0.2f)", info.profile_name, info.profile - 5);
     499                        mpcGtkPrintLabel(pnsLabel,       "PNS: \%s", info.pns == 0xFF ? "unknow" : info.pns ? "on" : "off");
     500                        mpcGtkPrintLabel(gaplessLabel,   "Gapless: \%s", info.is_true_gapless ? "on" : "off");
    502501            mpcGtkPrintLabel(bitrateLabel,   "Average bitrate: \%6.1f kbps", info.average_bitrate * 1.e-3);
    503502            mpcGtkPrintLabel(rateLabel,      "Samplerate: \%d Hz", info.sample_freq);
    504503            mpcGtkPrintLabel(channelsLabel,  "Channels: \%d", info.channels);
    505             mpcGtkPrintLabel(lengthLabel,    "Length: \%d:\%.2d", minutes, seconds);
     504                        mpcGtkPrintLabel(lengthLabel,    "Length: \%d:\%.2d (%u samples)", minutes, seconds, (mpc_uint32_t)mpc_streaminfo_get_length_samples(&info));
    506505            mpcGtkPrintLabel(fileSizeLabel,  "File size: \%d Bytes", info.total_file_length);
    507             mpcGtkPrintLabel(trackPeakLabel, "Track Peak: \%5u", info.peak_title);
    508             mpcGtkPrintLabel(trackGainLabel, "Track Gain: \%-+2.2f dB", 0.01 * info.gain_title);
    509             mpcGtkPrintLabel(albumPeakLabel, "Album Peak: \%5u", info.peak_album);
    510             mpcGtkPrintLabel(albumGainLabel, "Album Gain: \%-+5.2f dB", 0.01 * info.gain_album);
     506                        mpcGtkPrintLabel(trackPeakLabel, "Track Peak: \%2.2f dB", info.peak_title / 256.);
     507                        mpcGtkPrintLabel(trackGainLabel, "Track Gain: \%2.2f dB", info.gain_title / 256.);
     508                        mpcGtkPrintLabel(albumPeakLabel, "Album Peak: \%2.2f dB", info.peak_album / 256.);
     509                        mpcGtkPrintLabel(albumGainLabel, "Album Gain: \%2.2f dB", info.gain_album / 256.);
    511510
    512511            MpcInfo tags = getTags(p_Filename);
     
    526525            free(entry);
    527526            freeTags(tags);
    528             fclose(input);
     527                        mpc_demux_exit(demux);
     528                        mpc_reader_exit_stdio(&reader);
    529529        }
    530530        else
     
    709709{
    710710    lockAcquire();
    711     char* filename = static_cast<char*> (data);
    712     FILE* input = fopen(filename, "rb");
    713     if (!input)
    714     {
     711        const char* filename = static_cast<const char*> (data);
     712        mpc_reader reader;
     713        if (mpc_reader_init_stdio(&reader, filename) != MPC_STATUS_OK) {
    715714        mpcDecoder.isError = g_strdup_printf("[xmms-musepack] decodeStream is unable to open %s", filename);
    716         return endThread(filename, input, true);
    717     }
    718 
    719     mpc_reader_file reader;
    720     mpc_reader_setup_file_reader(&reader, input);
    721 
    722     mpc_streaminfo info;
    723     if (mpc_streaminfo_read(&info, &reader.reader) != ERROR_CODE_OK)
    724     {
    725         mpcDecoder.isError = g_strdup_printf("[xmms-musepack] decodeStream is unable to read %s", filename);
    726         return endThread(filename, input, true);
    727     }
    728 
    729     MpcInfo tags     = getTags(filename);
    730     track.display    = mpcGenerateTitle(tags, filename);
    731     track.length     = static_cast<int> (1000 * mpc_streaminfo_get_length(&info));
    732     track.bitrate    = static_cast<int> (info.average_bitrate);
    733     track.sampleFreq = info.sample_freq;
    734     track.channels   = info.channels;
     715        return endThread(filename, 0, true);
     716        }
     717
     718        mpc_demux * demux = 0;
     719        demux = mpc_demux_init(&reader);
     720
     721        if ( demux == 0 ) {
     722                mpcDecoder.isError = g_strdup_printf("[xmms-musepack] decodeStream is unable to initialize decoder on %s", filename);
     723                mpc_reader_exit_stdio(&reader);
     724                return endThread(filename, 0, true);
     725        }
     726
     727        mpc_streaminfo info;
     728        mpc_demux_get_info(demux, &info);
     729        MpcInfo tags     = getTags(filename);
     730        track.display    = mpcGenerateTitle(tags, filename);
     731        track.length     = static_cast<int> (1000 * mpc_streaminfo_get_length(&info));
     732        track.bitrate    = static_cast<int> (info.average_bitrate);
     733        track.sampleFreq = info.sample_freq;
     734        track.channels   = info.channels;
    735735    freeTags(tags);
    736736
    737737    MpcPlugin.set_info(track.display, track.length, track.bitrate, track.sampleFreq, track.channels);
    738738
    739     mpc_decoder decoder;
    740     mpc_decoder_setup(&decoder, &reader.reader);
    741     if (!mpc_decoder_initialize(&decoder, &info))
    742     {
    743         mpcDecoder.isError = g_strdup_printf("[xmms-musepack] decodeStream is unable to initialize decoder on %s", filename);
    744         return endThread(filename, input, true);
    745     }
    746 
    747     setReplaygain(info, decoder);
     739    setReplaygain(demux);
    748740
    749741    MPC_SAMPLE_FORMAT sampleBuffer[MPC_DECODER_BUFFER_LENGTH];
     
    752744    if (!MpcPlugin.output->open_audio(FMT_S16_LE, track.sampleFreq, track.channels))
    753745    {
    754         mpcDecoder.isError = g_strdup_printf("[xmms-musepack] decodeStream is unable to open an audio output");
    755         return endThread(filename, input, true);
     746                mpcDecoder.isError = g_strdup_printf("[xmms-musepack] decodeStream is unable to open an audio output");
     747                mpc_reader_exit_stdio(&reader);
     748        return endThread(filename, 0, true);
    756749    }
    757750    else
     
    762755    lockRelease();
    763756
    764     int counter = 2 * track.sampleFreq / 3;
     757        int counter = 2 * track.sampleFreq / 3;
     758        int status = 0;
    765759    while (isAlive())
    766760    {
    767761        if (getOffset() != -1)
    768762        {
    769             mpc_decoder_seek_seconds(&decoder, mpcDecoder.offset);
     763                        mpc_demux_seek_second(demux, mpcDecoder.offset);
    770764            setOffset(-1);
     765                        status = 0;
    771766        }
    772767
     
    774769        short iPlaying = MpcPlugin.output->buffer_playing()? 1 : 0;
    775770        int iFree = MpcPlugin.output->buffer_free();
    776         if (!mpcDecoder.isPause &&  iFree >= ((1152 * 4) << iPlaying))
     771        if (!mpcDecoder.isPause &&  iFree >= ((1152 * 4) << iPlaying) && status != -1)
    777772        {
    778             unsigned status = processBuffer(sampleBuffer, xmmsBuffer, decoder);
    779             if (status == (unsigned) (-1))
    780             {
    781                 mpcDecoder.isError = g_strdup_printf("[xmms-musepack] error from internal decoder on %s", filename);
    782                 return endThread(filename, input, true);
    783             }
    784             else if (status == 0)
    785             {
    786                 //mpcDecoder.isError = g_strdup_printf("[xmms-musepack] null output from internal decoder on %s", filename);
    787                 return endThread(filename, input, true);
    788             }
    789             lockRelease();
    790 
    791             if(pluginConfig.dynamicBitrate)
    792             {
    793                 counter -= status;
    794                 if(counter < 0)
    795                 {
    796                     MpcPlugin.set_info(track.display, track.length, track.bitrate, track.sampleFreq, track.channels);
    797                     counter = 2 * track.sampleFreq / 3;
    798                 }
    799             }
     773                        status = processBuffer(sampleBuffer, xmmsBuffer, *demux);
     774                        lockRelease();
     775
     776                        if(pluginConfig.dynamicBitrate) {
     777                                counter -= status;
     778                                if(counter < 0) {
     779                                        MpcPlugin.set_info(track.display, track.length, track.bitrate, track.sampleFreq, track.channels);
     780                                        counter = 2 * track.sampleFreq / 3;
     781                                }
     782                        }
    800783        }
    801784        else
    802785        {
    803             lockRelease();
    804             xmms_usleep(10000);
    805         }
    806     }
    807     return endThread(filename, input, false);
    808 }
    809 
    810 static int processBuffer(MPC_SAMPLE_FORMAT* sampleBuffer, char* xmmsBuffer, mpc_decoder& decoder)
    811 {
    812     mpc_uint32_t vbrAcc = 0;
    813     mpc_uint32_t vbrUpd = 0;
    814 
    815     unsigned status  = mpc_decoder_decode(&decoder, sampleBuffer, &vbrAcc, &vbrUpd);
    816     copyBuffer(sampleBuffer, xmmsBuffer, status);
     786                        lockRelease();
     787                        if (mpcDecoder.isPause == FALSE && status == -1 &&
     788                                                 MpcPlugin.output->buffer_playing() == FALSE)
     789                                break;
     790            xmms_usleep(100000);
     791                }
     792        }
     793        mpc_demux_exit(demux);
     794        mpc_reader_exit_stdio(&reader);
     795    return endThread(filename, 0, false);
     796}
     797
     798static int processBuffer(MPC_SAMPLE_FORMAT* sampleBuffer, char* xmmsBuffer, mpc_demux& demux)
     799{
     800        mpc_frame_info info;
     801
     802        info.buffer = sampleBuffer;
     803        mpc_demux_decode(&demux, &info);
     804
     805        if (info.bits == -1) return -1; // end of stream
     806
     807    copyBuffer(sampleBuffer, xmmsBuffer, info.samples * track.channels);
    817808
    818809    if (pluginConfig.dynamicBitrate)
    819810    {
    820         track.bitrate = static_cast<int> (vbrUpd * track.sampleFreq / 1152);
     811        track.bitrate = static_cast<int> (info.bits * track.sampleFreq / 1152);
    821812    }
    822813
    823814    if (pluginConfig.isEq)
    824815    {
    825         iir(xmmsBuffer, 4 * status);
    826     }
    827 
    828     MpcPlugin.add_vis_pcm(MpcPlugin.output->written_time(), FMT_S16_LE, track.channels, status * 4, xmmsBuffer);
    829     MpcPlugin.output->write_audio(xmmsBuffer, status * 4);
    830     return status;
    831 }
    832 
    833 static void setReplaygain(mpc_streaminfo& info, mpc_decoder& decoder)
    834 {
    835     if(!pluginConfig.replaygain && !pluginConfig.clipPrevention)
    836         return;
    837 
    838     int peak    = pluginConfig.albumGain ? info.peak_album : info.peak_title;
    839     double gain = pluginConfig.albumGain ? info.gain_album : info.gain_title;
    840 
    841     if(!peak)
    842         peak = 32767;
    843     if(!gain)
    844         gain = 1.;
    845 
    846     double clip = 32767. / peak;
    847     gain = exp((M_LN10 / 2000.) * gain);
    848 
    849     if(pluginConfig.clipPrevention && !pluginConfig.replaygain)
    850         gain = clip;
    851     else if(pluginConfig.replaygain && pluginConfig.clipPrevention)
    852         if(clip < gain)
    853             gain = clip;
    854 
    855     mpc_decoder_scale_output(&decoder, gain);
     816                iir(xmmsBuffer, 4 * info.samples);
     817    }
     818
     819        MpcPlugin.add_vis_pcm(MpcPlugin.output->written_time(), FMT_S16_LE, track.channels, info.samples * 2 * track.channels, xmmsBuffer);
     820        MpcPlugin.output->write_audio(xmmsBuffer, info.samples * 2 * track.channels);
     821        return info.samples;
     822}
     823
     824static void setReplaygain(mpc_demux * d)
     825{
     826        mpc_set_replay_level(d, MPC_OLD_GAIN_REF, pluginConfig.replaygain,
     827                                                 !pluginConfig.albumGain, pluginConfig.clipPrevention);
    856828}
    857829
  • bmp-musepack/trunk/src/libmpc.h

    r34 r455  
    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
     
    3939extern "C"
    4040{
    41 #include <bmp/plugin.h>
    42 #include <bmp/util.h>
    43 #include <bmp/configdb.h>
    44 #include <bmp/titlestring.h>
     41#include <audacious/plugin.h>
     42#include <audacious/util.h>
     43#include <audacious/configdb.h>
     44#include <audacious/strings.h>
    4545}
    4646
     
    5454
    5555//libmpcdec headers
    56 #include <mpcdec/mpcdec.h>
     56#include <mpc/mpcdec.h>
    5757
    5858//GTK+ headers
     
    160160static void       lockRelease();
    161161static void*      decodeStream(void*);
    162 static int        processBuffer(MPC_SAMPLE_FORMAT*, char*, mpc_decoder&);
     162static int        processBuffer(MPC_SAMPLE_FORMAT*, char*, mpc_demux&);
    163163static void*      endThread(char*, FILE*, bool);
    164164static bool       isAlive();
     
    167167static void       setOffset(double);
    168168static bool       isPause();
    169 static void       setReplaygain(mpc_streaminfo&, mpc_decoder&);
     169static void       setReplaygain(mpc_demux *);
    170170
    171171#ifdef MPC_FIXED_POINT
     
    186186    int clipMax    = (1 << (pSize - 1)) - 1;
    187187    int floatScale =  1 << (pSize - 1);
    188     for (unsigned n = 0; n < 2 * pLength; n++)
     188    for (unsigned n = 0; n < pLength; n++)
    189189    {
    190190        int val;
Note: See TracChangeset for help on using the changeset viewer.