From 435f1da1de18bafe57e43e47fd8a6fc69fd8bab7 Mon Sep 17 00:00:00 2001 From: trialuser02 Date: Sat, 16 Jan 2010 15:33:17 +0000 Subject: updated audio engine git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@1503 90c681e8-e032-0410-971d-27865f9a5e38 --- src/plugins/Effect/bs2b/bs2bplugin.cpp | 29 +++--- src/plugins/Effect/bs2b/bs2bplugin.h | 7 +- src/plugins/Effect/ladspa/ladspahelper.cpp | 12 +-- src/plugins/Effect/ladspa/ladspahelper.h | 4 +- src/plugins/Effect/ladspa/ladspahost.cpp | 5 +- src/plugins/Effect/ladspa/ladspahost.h | 3 +- src/plugins/Effect/srconverter/srconverter.cpp | 39 ++++---- src/plugins/Effect/srconverter/srconverter.h | 6 +- src/plugins/Input/aac/decoder_aac.cpp | 2 +- src/plugins/Input/cdaudio/decoder_cdaudio.cpp | 2 +- .../Input/cdaudio/decodercdaudiofactory.cpp | 5 +- .../cdaudio/translations/cdaudio_plugin_cs.ts | 10 +- .../cdaudio/translations/cdaudio_plugin_de.ts | 10 +- .../cdaudio/translations/cdaudio_plugin_it.ts | 10 +- .../cdaudio/translations/cdaudio_plugin_lt.ts | 10 +- .../cdaudio/translations/cdaudio_plugin_pl.ts | 10 +- .../cdaudio/translations/cdaudio_plugin_ru.ts | 10 +- .../cdaudio/translations/cdaudio_plugin_tr.ts | 10 +- .../cdaudio/translations/cdaudio_plugin_uk_UA.ts | 10 +- .../cdaudio/translations/cdaudio_plugin_zh_CN.ts | 10 +- .../cdaudio/translations/cdaudio_plugin_zh_TW.ts | 10 +- src/plugins/Input/cue/decoder_cue.cpp | 10 +- src/plugins/Input/ffmpeg/decoder_ffmpeg.cpp | 4 +- src/plugins/Input/flac/decoder_flac.cpp | 58 ++++++----- src/plugins/Input/mad/decoder_mad.cpp | 2 +- src/plugins/Input/mad/settingsdialog.h | 4 +- src/plugins/Input/modplug/decoder_modplug.cpp | 4 +- src/plugins/Input/mpc/decoder_mpc.cpp | 2 +- src/plugins/Input/sndfile/decoder_sndfile.cpp | 2 +- src/plugins/Input/vorbis/decoder_vorbis.cpp | 2 +- src/plugins/Input/wavpack/decoder_wavpack.cpp | 25 +++-- src/plugins/Output/alsa/outputalsa.cpp | 36 +++---- src/plugins/Output/alsa/outputalsa.h | 5 +- src/plugins/Output/alsa/settingsdialog.ui | 9 ++ .../Output/alsa/translations/alsa_plugin_cs.ts | 22 ++--- .../Output/alsa/translations/alsa_plugin_de.ts | 22 ++--- .../Output/alsa/translations/alsa_plugin_it.ts | 22 ++--- .../Output/alsa/translations/alsa_plugin_lt.ts | 22 ++--- .../Output/alsa/translations/alsa_plugin_pl.ts | 22 ++--- .../Output/alsa/translations/alsa_plugin_ru.ts | 22 ++--- .../Output/alsa/translations/alsa_plugin_tr.ts | 22 ++--- .../Output/alsa/translations/alsa_plugin_uk_UA.ts | 22 ++--- .../Output/alsa/translations/alsa_plugin_zh_CN.ts | 22 ++--- .../Output/alsa/translations/alsa_plugin_zh_TW.ts | 22 ++--- src/plugins/Output/jack/outputjack.cpp | 10 +- src/plugins/Output/jack/outputjack.h | 2 +- src/plugins/Output/oss/outputoss.cpp | 21 ++-- src/plugins/Output/oss/outputoss.h | 4 +- src/plugins/Output/pulseaudio/CMakeLists.txt | 2 +- src/plugins/Output/pulseaudio/outputpulseaudio.cpp | 20 ++-- src/plugins/Output/pulseaudio/outputpulseaudio.h | 4 +- src/plugins/Visual/analyzer/analyzer.cpp | 26 ++--- src/plugins/Visual/analyzer/analyzer.h | 8 +- src/plugins/Visual/projectm/projectmplugin.cpp | 8 +- src/plugins/Visual/projectm/projectmplugin.h | 4 +- src/qmmp/audioparameters.cpp | 38 +++++-- src/qmmp/audioparameters.h | 9 +- src/qmmp/buffer.h | 16 +-- src/qmmp/decoder.cpp | 4 +- src/qmmp/decoder.h | 4 +- src/qmmp/effect.cpp | 12 +-- src/qmmp/effect.h | 17 ++-- src/qmmp/output.cpp | 110 ++++++++++++++++++--- src/qmmp/output.h | 20 ++-- src/qmmp/qmmp.cpp | 7 -- src/qmmp/qmmp.h | 16 ++- src/qmmp/qmmpaudioengine.cpp | 77 ++++----------- src/qmmp/qmmpaudioengine.h | 3 +- src/qmmp/recycler.cpp | 14 +-- src/qmmp/recycler.h | 3 +- src/qmmp/replaygain.cpp | 14 +-- src/qmmp/replaygain.h | 4 +- src/qmmp/visual.h | 9 +- src/ui/mainvisual.cpp | 37 ++++--- src/ui/mainvisual.h | 12 ++- src/ui/shadedvisual.cpp | 26 ++--- src/ui/shadedvisual.h | 4 +- src/ui/translations/qmmp_cs.ts | 60 +++++------ src/ui/translations/qmmp_de.ts | 60 +++++------ src/ui/translations/qmmp_it.ts | 60 +++++------ src/ui/translations/qmmp_lt.ts | 60 +++++------ src/ui/translations/qmmp_pl_PL.ts | 60 +++++------ src/ui/translations/qmmp_pt_BR.ts | 58 +++++------ src/ui/translations/qmmp_ru.ts | 60 +++++------ src/ui/translations/qmmp_tr.ts | 60 +++++------ src/ui/translations/qmmp_uk_UA.ts | 60 +++++------ src/ui/translations/qmmp_zh_CN.ts | 60 +++++------ src/ui/translations/qmmp_zh_TW.ts | 60 +++++------ 88 files changed, 952 insertions(+), 868 deletions(-) (limited to 'src') diff --git a/src/plugins/Effect/bs2b/bs2bplugin.cpp b/src/plugins/Effect/bs2b/bs2bplugin.cpp index d2ced9bb9..b9f0bda94 100644 --- a/src/plugins/Effect/bs2b/bs2bplugin.cpp +++ b/src/plugins/Effect/bs2b/bs2bplugin.cpp @@ -32,6 +32,7 @@ Bs2bPlugin::Bs2bPlugin() : Effect() m_bs2b_handler = bs2b_open(); QSettings settings(Qmmp::configFile(), QSettings::IniFormat); bs2b_set_level(m_bs2b_handler, settings.value("bs2b/level", BS2B_DEFAULT_CLEVEL).toUInt()); + m_chan = 0; } Bs2bPlugin::~Bs2bPlugin() @@ -43,35 +44,33 @@ Bs2bPlugin::~Bs2bPlugin() #define CASE_BS2B(bitsPerSample, dataType, functionToCall, samples, out_data) \ case bitsPerSample: \ { \ - dataType * data = reinterpret_cast(*out_data); \ + dataType * data = reinterpret_cast(out_data); \ functionToCall(m_bs2b_handler, data, samples); \ } \ break; -ulong Bs2bPlugin::process(char *in_data, const ulong size, char **out_data) +void Bs2bPlugin::applyEffect(Buffer *b) { - memcpy(*out_data, in_data, size); - if (channels() != 2) - return size; - - uint samples = size / (bitsPerSample() / 8) / 2; + if(m_chan != 2) + return; + uint samples = b->nbytes / audioParameters().sampleSize() / 2; m_mutex.lock(); - switch (bitsPerSample()) + switch (format()) { - CASE_BS2B(8, int8_t, bs2b_cross_feed_s8, samples, out_data) - CASE_BS2B(16, int16_t, bs2b_cross_feed_s16le, samples, out_data) - CASE_BS2B(24, bs2b_int24_t, bs2b_cross_feed_s24, samples, out_data) - CASE_BS2B(32, int32_t, bs2b_cross_feed_s32le, samples, out_data) + CASE_BS2B(Qmmp::PCM_S8, int8_t, bs2b_cross_feed_s8, samples, b->data) + CASE_BS2B(Qmmp::PCM_S16LE, int16_t, bs2b_cross_feed_s16le, samples, b->data) + //CASE_BS2B(Qmmp::PCM_S24LE, bs2b_int24_t, bs2b_cross_feed_s24le, samples, out_data) + CASE_BS2B(Qmmp::PCM_S32LE, int32_t, bs2b_cross_feed_s32le, samples, b->data) default: ; // noop } m_mutex.unlock(); - return size; } -void Bs2bPlugin::configure(quint32 freq, int chan, int res) +void Bs2bPlugin::configure(quint32 freq, int chan, Qmmp::AudioFormat format) { - Effect::configure(freq, chan, res); + m_chan = chan; + Effect::configure(freq, chan, format); bs2b_set_srate(m_bs2b_handler,freq); } diff --git a/src/plugins/Effect/bs2b/bs2bplugin.h b/src/plugins/Effect/bs2b/bs2bplugin.h index 93ad482bb..0070d0f6e 100644 --- a/src/plugins/Effect/bs2b/bs2bplugin.h +++ b/src/plugins/Effect/bs2b/bs2bplugin.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2009 by Ilya Kotov * + * Copyright (C) 2010 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -35,13 +35,14 @@ public: virtual ~Bs2bPlugin(); - ulong process(char *in_data, const ulong size, char **out_data); - void configure(quint32 freq, int chan, int res); + void applyEffect(Buffer *b); + void configure(quint32 freq, int chan, Qmmp::AudioFormat format); void setCrossfeedLevel(uint32_t level); static Bs2bPlugin* instance(); private: t_bs2bdp m_bs2b_handler; + int m_chan; QMutex m_mutex; static Bs2bPlugin *m_instance; }; diff --git a/src/plugins/Effect/ladspa/ladspahelper.cpp b/src/plugins/Effect/ladspa/ladspahelper.cpp index af683beca..ca34106f3 100644 --- a/src/plugins/Effect/ladspa/ladspahelper.cpp +++ b/src/plugins/Effect/ladspa/ladspahelper.cpp @@ -31,15 +31,13 @@ LADSPAHelper::LADSPAHelper() : Effect() LADSPAHelper::~LADSPAHelper() {} -ulong LADSPAHelper::process(char *in_data, const ulong size, char **out_data) +void LADSPAHelper::applyEffect(Buffer *b) { - LADSPAHost::instance()->applyEffect((qint16 *) in_data, size); - memcpy(*out_data, in_data, size); - return size; + LADSPAHost::instance()->applyEffect((qint16 *)b->data, b->nbytes); } -void LADSPAHelper::configure(quint32 freq, int chan, int res) +void LADSPAHelper::configure(quint32 freq, int chan, Qmmp::AudioFormat format) { - LADSPAHost::instance()->configure(freq,chan,res); - Effect::configure(freq, chan, res); + LADSPAHost::instance()->configure(freq,chan,format); + Effect::configure(freq, chan, format); } diff --git a/src/plugins/Effect/ladspa/ladspahelper.h b/src/plugins/Effect/ladspa/ladspahelper.h index 53983fa17..18a44dafd 100644 --- a/src/plugins/Effect/ladspa/ladspahelper.h +++ b/src/plugins/Effect/ladspa/ladspahelper.h @@ -32,8 +32,8 @@ public: LADSPAHelper(); virtual ~LADSPAHelper(); - ulong process(char *in_data, const ulong size, char **out_data); - void configure(quint32 freq, int chan, int res); + void applyEffect(Buffer *b); + void configure(quint32 freq, int chan, Qmmp::AudioFormat format); }; #endif // LADSPAHELPER_H diff --git a/src/plugins/Effect/ladspa/ladspahost.cpp b/src/plugins/Effect/ladspa/ladspahost.cpp index d9eef5281..2e84fe205 100644 --- a/src/plugins/Effect/ladspa/ladspahost.cpp +++ b/src/plugins/Effect/ladspa/ladspahost.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include "ladspahost.h" #ifndef PATH_MAX @@ -56,10 +57,10 @@ LADSPAHost::~LADSPAHost() } } -void LADSPAHost::configure(quint32 freq, int chan, int res) +void LADSPAHost::configure(quint32 freq, int chan, Qmmp::AudioFormat format) { m_chan = chan; - m_prec = res; + m_prec = AudioParameters::sampleSize(format); m_freq = freq; foreach(LADSPAEffect *e, m_effects) { diff --git a/src/plugins/Effect/ladspa/ladspahost.h b/src/plugins/Effect/ladspa/ladspahost.h index f97e54c08..2a35d7bbc 100644 --- a/src/plugins/Effect/ladspa/ladspahost.h +++ b/src/plugins/Effect/ladspa/ladspahost.h @@ -24,6 +24,7 @@ #include #include #include +#include #include "ladspa.h" class QWidget; @@ -83,7 +84,7 @@ public: virtual ~LADSPAHost(); int applyEffect(qint16 *d, int length); - void configure(quint32 freq, int chan, int res); + void configure(quint32 freq, int chan, Qmmp::AudioFormat format); QList plugins(); QList runningPlugins(); LADSPAEffect *addPlugin(LADSPAPlugin * plugin); diff --git a/src/plugins/Effect/srconverter/srconverter.cpp b/src/plugins/Effect/srconverter/srconverter.cpp index 8a31bb18f..95c912cb6 100644 --- a/src/plugins/Effect/srconverter/srconverter.cpp +++ b/src/plugins/Effect/srconverter/srconverter.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2007 by Ilya Kotov * + * Copyright (C) 2007-2010 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -50,32 +50,32 @@ SRConverter::~SRConverter() m_src_data.output_frames = 0; if (m_isSrcAlloc) { - free(m_srcIn); - free(m_srcOut); - free(m_wOut); + delete [] m_srcIn; + delete [] m_srcOut; + delete [] m_wOut; m_isSrcAlloc = FALSE; } } -ulong SRConverter::process(char *in_data, const ulong size, char **out_data) +void SRConverter::applyEffect(Buffer *b) { if (m_isSrcAlloc) { - free(m_srcIn); - free(m_srcOut); - free(m_wOut); + delete [] m_srcIn; + delete [] m_srcOut; + delete [] m_wOut; m_isSrcAlloc = FALSE; } ulong wbytes = 0; - if (m_src_state && size > 0) + if (m_src_state && b->nbytes > 0) { - int lrLength = size/2; + int lrLength = b->nbytes/2; int overLrLength= (int)floor(lrLength*(m_src_data.src_ratio+1)); - m_srcIn = (float*) malloc(sizeof(float)*lrLength); - m_srcOut = (float*) malloc(sizeof(float)*overLrLength); - m_wOut = (short int*) malloc(sizeof(short int)*overLrLength); - src_short_to_float_array((short int*)in_data, m_srcIn, lrLength); + m_srcIn = new float [lrLength]; + m_srcOut = new float [overLrLength]; + m_wOut = new short[overLrLength]; + src_short_to_float_array((short *)b->data, m_srcIn, lrLength); m_isSrcAlloc = TRUE; m_src_data.data_in = m_srcIn; m_src_data.data_out = m_srcOut; @@ -90,14 +90,15 @@ ulong SRConverter::process(char *in_data, const ulong size, char **out_data) { src_float_to_short_array(m_srcOut, m_wOut, m_src_data.output_frames_gen*2); wbytes = m_src_data.output_frames_gen*4; - *out_data = new char[wbytes]; - memcpy(*out_data, (char*) m_wOut, wbytes); + delete [] b->data; + b->data = (unsigned char *) m_wOut; + b->nbytes = wbytes; + m_wOut = 0; } } - return wbytes; } -void SRConverter::configure(quint32 freq, int chan, int res) +void SRConverter::configure(quint32 freq, int chan, Qmmp::AudioFormat format) { freeSRC(); uint rate = freq; @@ -111,7 +112,7 @@ void SRConverter::configure(quint32 freq, int chan, int res) else qDebug("SRConverter: src_new(): %s", src_strerror(m_srcError)); } - Effect::configure(m_overSamplingFs, chan, res); + Effect::configure(m_overSamplingFs, chan, format); } void SRConverter::freeSRC() diff --git a/src/plugins/Effect/srconverter/srconverter.h b/src/plugins/Effect/srconverter/srconverter.h index bb4c2913c..5bc4b4ad1 100644 --- a/src/plugins/Effect/srconverter/srconverter.h +++ b/src/plugins/Effect/srconverter/srconverter.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2007 by Ilya Kotov * + * Copyright (C) 2007-2010 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -33,8 +33,8 @@ public: SRConverter(); virtual ~SRConverter(); - ulong process(char *in_data, const ulong size, char **out_data); - void configure(quint32 freq, int chan, int res); + void applyEffect(Buffer *b); + void configure(quint32 freq, int chan, Qmmp::AudioFormat format); private: void freeSRC(); diff --git a/src/plugins/Input/aac/decoder_aac.cpp b/src/plugins/Input/aac/decoder_aac.cpp index fef00a206..6b65685f1 100644 --- a/src/plugins/Input/aac/decoder_aac.cpp +++ b/src/plugins/Input/aac/decoder_aac.cpp @@ -142,7 +142,7 @@ bool DecoderAAC::initialize() memmove(m_input_buf, m_input_buf + res, m_input_at - res); m_input_at -= res; - configure(freq, chan, 16); + configure(freq, chan, Qmmp::PCM_S16LE); qDebug("DecoderAAC: initialize succes"); return TRUE; } diff --git a/src/plugins/Input/cdaudio/decoder_cdaudio.cpp b/src/plugins/Input/cdaudio/decoder_cdaudio.cpp index 6fa6e2e02..201d6ff63 100644 --- a/src/plugins/Input/cdaudio/decoder_cdaudio.cpp +++ b/src/plugins/Input/cdaudio/decoder_cdaudio.cpp @@ -251,7 +251,7 @@ bool DecoderCDAudio::initialize() } qDebug("DecoderCDAudio: using cd audio capable drive \"%s\"", QUrl(m_url).path().toAscii().constData()); } - configure(44100, 2, 16); + configure(44100, 2, Qmmp::PCM_S16LE); m_bitrate = 1411; m_totalTime = tracks[track_at].info.length() * 1000; m_first_sector = tracks[track_at].first_sector; diff --git a/src/plugins/Input/cdaudio/decodercdaudiofactory.cpp b/src/plugins/Input/cdaudio/decodercdaudiofactory.cpp index 2e1b3d00f..ae88ea6e6 100644 --- a/src/plugins/Input/cdaudio/decodercdaudiofactory.cpp +++ b/src/plugins/Input/cdaudio/decodercdaudiofactory.cpp @@ -58,11 +58,14 @@ Decoder *DecoderCDAudioFactory::create(const QString &url, QIODevice *input) QList DecoderCDAudioFactory::createPlayList(const QString &fileName, bool useMetaData) { + qDebug("create!!"); Q_UNUSED(useMetaData); QList list; QList tracks = DecoderCDAudio::generateTrackList(QUrl(fileName).path()); foreach(CDATrack t, tracks) - list << new FileInfo(t.info); + { + list << new FileInfo(t.info); + } return list; } diff --git a/src/plugins/Input/cdaudio/translations/cdaudio_plugin_cs.ts b/src/plugins/Input/cdaudio/translations/cdaudio_plugin_cs.ts index 7c6ea1d30..26681d3a9 100644 --- a/src/plugins/Input/cdaudio/translations/cdaudio_plugin_cs.ts +++ b/src/plugins/Input/cdaudio/translations/cdaudio_plugin_cs.ts @@ -9,27 +9,27 @@ Modul pro zvuková CD - + About CD Audio Plugin O modulu pro zvuková CD - + Qmmp CD Audio Plugin Modul Qmmp pro zvuková CD - + Writen by: Ilya Kotov <forkotov02@hotmail.ru> Autor: Ilja Kotov <forkotov02@hotmail.ru> - + Usage: open cdda:/// using Add URL dialog or command line Použití: otevřete cdda:/// v dialogu Přidat URL nebo z příkazové řádky - + Compiled against libcdio version: Přeloženo s libcdio verze: diff --git a/src/plugins/Input/cdaudio/translations/cdaudio_plugin_de.ts b/src/plugins/Input/cdaudio/translations/cdaudio_plugin_de.ts index 3fed87e02..9ed0049af 100644 --- a/src/plugins/Input/cdaudio/translations/cdaudio_plugin_de.ts +++ b/src/plugins/Input/cdaudio/translations/cdaudio_plugin_de.ts @@ -9,27 +9,27 @@ CD-Audio-Modul - + About CD Audio Plugin Über CD-Audio-Modul - + Qmmp CD Audio Plugin Qmmp CD-Audio-Modul - + Writen by: Ilya Kotov <forkotov02@hotmail.ru> Autor: Ilya Kotov <forkotov02@hotmail.ru> - + Usage: open cdda:/// using Add URL dialog or command line Verwendung: Geben Sie cdda:/// in den „URL hinzufügen“-Dialog oder in die Befehlszeile ein - + Compiled against libcdio version: Kompiliert gegen libcdio-Version: diff --git a/src/plugins/Input/cdaudio/translations/cdaudio_plugin_it.ts b/src/plugins/Input/cdaudio/translations/cdaudio_plugin_it.ts index dede31eb3..95e211c92 100644 --- a/src/plugins/Input/cdaudio/translations/cdaudio_plugin_it.ts +++ b/src/plugins/Input/cdaudio/translations/cdaudio_plugin_it.ts @@ -9,27 +9,27 @@ Modulo CD-Audio - + About CD Audio Plugin Informazioni sul modulo CD-Audio - + Qmmp CD Audio Plugin Modulo CD-Audio per Qmmp - + Writen by: Ilya Kotov <forkotov02@hotmail.ru> Autore: Ilya Kotov <forkotov02@hotmail.ru> - + Usage: open cdda:/// using Add URL dialog or command line Uso: aprire cdda:// nella finestra di dialgo degli URL, o via linea di comando - + Compiled against libcdio version: Compilato con libcdio, versione: diff --git a/src/plugins/Input/cdaudio/translations/cdaudio_plugin_lt.ts b/src/plugins/Input/cdaudio/translations/cdaudio_plugin_lt.ts index 270d9d579..47655c182 100644 --- a/src/plugins/Input/cdaudio/translations/cdaudio_plugin_lt.ts +++ b/src/plugins/Input/cdaudio/translations/cdaudio_plugin_lt.ts @@ -9,27 +9,27 @@ CD Audio Įskiepis - + About CD Audio Plugin Apie CD Audio įskiepį - + Qmmp CD Audio Plugin Apie CD Audio Qmmp įskiepį - + Writen by: Ilya Kotov <forkotov02@hotmail.ru> Sukūrė: Ilya Kotov <forkotov02@hotmail.ru> - + Usage: open cdda:/// using Add URL dialog or command line Naudojimas: atverti cdda:/// naudojant Prideti interneto adresą arba komandinė eilutę - + Compiled against libcdio version: Surinkta iš libcdio versijos : diff --git a/src/plugins/Input/cdaudio/translations/cdaudio_plugin_pl.ts b/src/plugins/Input/cdaudio/translations/cdaudio_plugin_pl.ts index 61049c20b..7cd11622d 100644 --- a/src/plugins/Input/cdaudio/translations/cdaudio_plugin_pl.ts +++ b/src/plugins/Input/cdaudio/translations/cdaudio_plugin_pl.ts @@ -9,27 +9,27 @@ Wtyczka CD Audio - + About CD Audio Plugin O wtyczce CD Audio - + Qmmp CD Audio Plugin Wtyczka CD Audio dla Qmmp - + Compiled against libcdio version: Skompilowane przy użyciu biblioteki libcdio w wersji: - + Writen by: Ilya Kotov <forkotov02@hotmail.ru> Autor: Ilya Kotov <forkotov02@hotmail.ru> - + Usage: open cdda:/// using Add URL dialog or command line Instrukcja: otwórz cdda:/// używając Dodaj URL lib z linii poleceń diff --git a/src/plugins/Input/cdaudio/translations/cdaudio_plugin_ru.ts b/src/plugins/Input/cdaudio/translations/cdaudio_plugin_ru.ts index 488bba2d1..d100fdb97 100644 --- a/src/plugins/Input/cdaudio/translations/cdaudio_plugin_ru.ts +++ b/src/plugins/Input/cdaudio/translations/cdaudio_plugin_ru.ts @@ -9,27 +9,27 @@ Модуль CD Audio - + About CD Audio Plugin О Модуле CD Audio - + Qmmp CD Audio Plugin Модуль CD Audio для Qmmp - + Writen by: Ilya Kotov <forkotov02@hotmail.ru> Разработчик: Илья Котов <forkotov02@hotmail.ru> - + Usage: open cdda:/// using Add URL dialog or command line Использование: откройте cdda:/// с помощью диалога добавления URL или командной строки - + Compiled against libcdio version: Собрано с libcdio версии: diff --git a/src/plugins/Input/cdaudio/translations/cdaudio_plugin_tr.ts b/src/plugins/Input/cdaudio/translations/cdaudio_plugin_tr.ts index 7a04a718d..a9803ab79 100644 --- a/src/plugins/Input/cdaudio/translations/cdaudio_plugin_tr.ts +++ b/src/plugins/Input/cdaudio/translations/cdaudio_plugin_tr.ts @@ -9,27 +9,27 @@ CD Ses Eklentisi - + About CD Audio Plugin CD Ses Eklentisi Hakkında - + Qmmp CD Audio Plugin Qmmp CD Ses Eklentisi - + Compiled against libcdio version: Derlendiği libcdio sürümü: - + Writen by: Ilya Kotov <forkotov02@hotmail.ru> Yazan: Ilya Kotov <forkotov02@hotmail.ru> - + Usage: open cdda:/// using Add URL dialog or command line Kullanımı: komut satırından veya URL Ekle diyaloğundan open cdda:/// şeklindedir diff --git a/src/plugins/Input/cdaudio/translations/cdaudio_plugin_uk_UA.ts b/src/plugins/Input/cdaudio/translations/cdaudio_plugin_uk_UA.ts index b0506d4dc..847b09aca 100644 --- a/src/plugins/Input/cdaudio/translations/cdaudio_plugin_uk_UA.ts +++ b/src/plugins/Input/cdaudio/translations/cdaudio_plugin_uk_UA.ts @@ -9,27 +9,27 @@ Модуль AudioCD - + About CD Audio Plugin Про модуль AudioCD - + Qmmp CD Audio Plugin Модуль AudioCD для Qmmp - + Writen by: Ilya Kotov <forkotov02@hotmail.ru> Розробник: Ілля Котов <forkotov02@hotmail.ru> - + Usage: open cdda:/// using Add URL dialog or command line Використання: відкрийте cdda:/// використовуючи діалог "Додати адресу" чи командний рядок - + Compiled against libcdio version: Зібрано з libcdio версії: diff --git a/src/plugins/Input/cdaudio/translations/cdaudio_plugin_zh_CN.ts b/src/plugins/Input/cdaudio/translations/cdaudio_plugin_zh_CN.ts index 806ecb21e..b4e9a5aad 100644 --- a/src/plugins/Input/cdaudio/translations/cdaudio_plugin_zh_CN.ts +++ b/src/plugins/Input/cdaudio/translations/cdaudio_plugin_zh_CN.ts @@ -9,27 +9,27 @@ CD 音频插件 - + About CD Audio Plugin 关于 CD 音频插件 - + Qmmp CD Audio Plugin Qmmp CD 音频插件 - + Writen by: Ilya Kotov <forkotov02@hotmail.ru> 作者:Ilya Kotov <forkotov02@hotmail.ru> - + Usage: open cdda:/// using Add URL dialog or command line 用法:open cdda:/// 使用添加 URL 对话或命令行 - + Compiled against libcdio version: 编译依赖 libcdio 版本: diff --git a/src/plugins/Input/cdaudio/translations/cdaudio_plugin_zh_TW.ts b/src/plugins/Input/cdaudio/translations/cdaudio_plugin_zh_TW.ts index 0b4f60b65..c6e7c7af8 100644 --- a/src/plugins/Input/cdaudio/translations/cdaudio_plugin_zh_TW.ts +++ b/src/plugins/Input/cdaudio/translations/cdaudio_plugin_zh_TW.ts @@ -9,27 +9,27 @@ CD 聲訊插件 - + About CD Audio Plugin 關於 CD 聲訊插件 - + Qmmp CD Audio Plugin Qmmp CD 聲訊插件 - + Writen by: Ilya Kotov <forkotov02@hotmail.ru> 作者:Ilya Kotov <forkotov02@hotmail.ru> - + Usage: open cdda:/// using Add URL dialog or command line 用法:open cdda:/// 使用添加 URL會話或命令行 - + Compiled against libcdio version: 編譯依賴 libcdio 版本: diff --git a/src/plugins/Input/cue/decoder_cue.cpp b/src/plugins/Input/cue/decoder_cue.cpp index f5cb53929..238134873 100644 --- a/src/plugins/Input/cue/decoder_cue.cpp +++ b/src/plugins/Input/cue/decoder_cue.cpp @@ -105,14 +105,14 @@ bool DecoderCUE::initialize() configure(m_decoder->audioParameters().sampleRate(), m_decoder->audioParameters().channels(), - m_decoder->audioParameters().bits()); + m_decoder->audioParameters().format()); setReplayGainInfo(m_decoder->replayGainInfo()); length_in_bytes = audioParameters().sampleRate() * audioParameters().channels() * - audioParameters().bits() * m_length/8000; + audioParameters().format() * m_length/8000; m_totalBytes = 0; - m_sz = audioParameters().bits() * audioParameters().channels()/8; + m_sz = audioParameters().sampleSize(); StateHandler::instance()->dispatch(m_parser->info(m_track)->metaData()); return TRUE; @@ -128,7 +128,7 @@ void DecoderCUE::seek(qint64 pos) m_decoder->seek(m_offset + pos); m_totalBytes = audioParameters().sampleRate() * audioParameters().channels() * - audioParameters().bits() * pos/8000; + audioParameters().sampleSize() * pos/1000; } qint64 DecoderCUE::read(char *data, qint64 size) @@ -197,7 +197,7 @@ void DecoderCUE::next() m_offset = m_parser->offset(m_track); length_in_bytes = audioParameters().sampleRate() * audioParameters().channels() * - audioParameters().bits() * m_length/8000; + audioParameters().sampleSize() * m_length/1000; StateHandler::instance()->dispatch(m_parser->info(m_track)->metaData()); m_totalBytes = 0; } diff --git a/src/plugins/Input/ffmpeg/decoder_ffmpeg.cpp b/src/plugins/Input/ffmpeg/decoder_ffmpeg.cpp index 4ec673839..28b7134d9 100644 --- a/src/plugins/Input/ffmpeg/decoder_ffmpeg.cpp +++ b/src/plugins/Input/ffmpeg/decoder_ffmpeg.cpp @@ -169,8 +169,8 @@ bool DecoderFFmpeg::initialize() return FALSE; } m_totalTime = input()->isSequential() ? 0 : ic->duration * 1000 / AV_TIME_BASE; - m_output_buf = new uint8_t[AVCODEC_MAX_AUDIO_FRAME_SIZE*sizeof(int16_t) + Qmmp::globalBufferSize()]; - configure(c->sample_rate, c->channels, 16); + m_output_buf = new uint8_t[AVCODEC_MAX_AUDIO_FRAME_SIZE*sizeof(int16_t) + QMMP_BUFFER_SIZE]; + configure(c->sample_rate, c->channels, Qmmp::PCM_S16LE); m_bitrate = c->bit_rate; qDebug("DecoderFFmpeg: initialize succes"); return TRUE; diff --git a/src/plugins/Input/flac/decoder_flac.cpp b/src/plugins/Input/flac/decoder_flac.cpp index 51ee170f7..50f679956 100644 --- a/src/plugins/Input/flac/decoder_flac.cpp +++ b/src/plugins/Input/flac/decoder_flac.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2006-2009 by Ilya Kotov * + * Copyright (C) 2006-2010 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -28,17 +28,15 @@ #include #include #include - #include #include #include #include - #include #include #include #include - +#include "replaygainreader.h" #include "cueparser.h" #include "decoder_flac.h" @@ -56,11 +54,10 @@ static size_t pack_pcm_signed (FLAC__byte *data, unsigned bytes_per_sample; unsigned incr; - if (bps == 24) - bps = 32; /* we encode to 32-bit words */ + if(bps == 24) // we encode to 32-bit words + bps = 32; bytes_per_sample = bps / 8; incr = bytes_per_sample * channels; - for (channel = 0; channel < channels; channel++) { samples = wide_samples; @@ -77,21 +74,18 @@ static size_t pack_pcm_signed (FLAC__byte *data, data[0] = sample; break; case 16: - data[1] = (FLAC__byte)(sample >> 8); - data[0] = (FLAC__byte)sample; + data[1] = (FLAC__byte)(sample >> 8) & 0xff; + data[0] = (FLAC__byte)sample & 0xff; break; case 32: - data[3] = (FLAC__byte)(sample >> 16); - data[2] = (FLAC__byte)(sample >> 8); - data[1] = (FLAC__byte)sample; + data[3] = (FLAC__byte)(sample >> 16) & 0xff; + data[2] = (FLAC__byte)(sample >> 8) & 0xff; + data[1] = (FLAC__byte)sample & 0xff; data[0] = 0; - break; } - data += incr; } } - return wide_samples * channels * bytes_per_sample; } @@ -324,6 +318,8 @@ bool DecoderFLAC::initialize() data()->input->open(QIODevice::ReadOnly); QMap metaData = m_parser->info(m_track)->metaData(); StateHandler::instance()->dispatch(metaData); //send metadata + ReplayGainReader rg(p); + setReplayGainInfo(rg.replayGainInfo()); } else { @@ -376,10 +372,26 @@ bool DecoderFLAC::initialize() data()->ok = 0; return FALSE; } - if (data()->bits_per_sample == 24) - configure(data()->sample_rate, data()->channels, 32); - else - configure(data()->sample_rate, data()->channels, data()->bits_per_sample); + switch(data()->bits_per_sample) + { + case 8: + configure(data()->sample_rate, data()->channels, Qmmp::PCM_S8); + break; + case 16: + configure(data()->sample_rate, data()->channels, Qmmp::PCM_S16LE); + break; + case 24: + case 32: + configure(data()->sample_rate, data()->channels, Qmmp::PCM_S32LE); + break; + default: + return FALSE; + } + if(!m_path.contains("://")) + { + ReplayGainReader rg(m_path); + setReplayGainInfo(rg.replayGainInfo()); + } if(m_parser) { @@ -387,11 +399,11 @@ bool DecoderFLAC::initialize() m_offset = m_parser->offset(m_track); length_in_bytes = audioParameters().sampleRate() * audioParameters().channels() * - audioParameters().bits() * m_length/8000; + audioParameters().sampleSize() * m_length/1000; seek(0); } m_totalBytes = 0; - m_sz = audioParameters().bits() * audioParameters().channels()/8; + m_sz = audioParameters().sampleSize() * audioParameters().channels(); qDebug("DecoderFLAC: initialize succes"); return TRUE; @@ -413,7 +425,7 @@ void DecoderFLAC::seek(qint64 time) { m_totalBytes = audioParameters().sampleRate() * audioParameters().channels() * - audioParameters().bits() * time/8000; + audioParameters().sampleSize() * time/1000; if(m_parser) time += m_offset; FLAC__uint64 target_sample = FLAC__uint64(time * data()->total_samples /data()->length); @@ -502,7 +514,7 @@ void DecoderFLAC::next() m_length = m_parser->length(m_track); length_in_bytes = audioParameters().sampleRate() * audioParameters().channels() * - audioParameters().bits() * m_length/8000; + audioParameters().sampleSize() * m_length/1000; StateHandler::instance()->dispatch(m_parser->info(m_track)->metaData()); m_totalBytes = 0; } diff --git a/src/plugins/Input/mad/decoder_mad.cpp b/src/plugins/Input/mad/decoder_mad.cpp index 1e4fea68f..7ae79a580 100644 --- a/src/plugins/Input/mad/decoder_mad.cpp +++ b/src/plugins/Input/mad/decoder_mad.cpp @@ -96,7 +96,7 @@ bool DecoderMAD::initialize() mad_frame_mute (&frame); stream.next_frame = 0; stream.sync = 0; - configure(m_freq, m_channels, 16); + configure(m_freq, m_channels, Qmmp::PCM_S16LE); m_inited = TRUE; return TRUE; } diff --git a/src/plugins/Input/mad/settingsdialog.h b/src/plugins/Input/mad/settingsdialog.h index 2ad1ed188..dd1279728 100644 --- a/src/plugins/Input/mad/settingsdialog.h +++ b/src/plugins/Input/mad/settingsdialog.h @@ -1,6 +1,6 @@ /*************************************************************************** - * Copyright (C) 2006 by Ilya Kotov * - * forkotov02@hotmail.ru * + * Copyright (C) 2009 by Ilya Kotov * + * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * diff --git a/src/plugins/Input/modplug/decoder_modplug.cpp b/src/plugins/Input/modplug/decoder_modplug.cpp index b2f6866e5..6a9acb581 100644 --- a/src/plugins/Input/modplug/decoder_modplug.cpp +++ b/src/plugins/Input/modplug/decoder_modplug.cpp @@ -95,7 +95,7 @@ bool DecoderModPlug::initialize() m_soundFile->Create((uchar*) m_input_buf.data(), m_input_buf.size()); m_bitrate = m_soundFile->GetNumChannels(); m_totalTime = (qint64) m_soundFile->GetSongTime() * 1000; - configure(m_freq, m_chan, m_bps); + configure(m_freq, m_chan, (m_bps == 8 ? Qmmp::PCM_S8 : Qmmp::PCM_S16LE)); return TRUE; } @@ -111,7 +111,7 @@ int DecoderModPlug::bitrate() qint64 DecoderModPlug::read(char *audio, qint64 maxSize) { - long len = m_soundFile->Read (audio, qMin((qint64)Buffer::size(), maxSize)) * m_sampleSize; + long len = m_soundFile->Read (audio, qMin((qint64)QMMP_BLOCK_SIZE, maxSize)) * m_sampleSize; if (m_usePreamp) { { diff --git a/src/plugins/Input/mpc/decoder_mpc.cpp b/src/plugins/Input/mpc/decoder_mpc.cpp index b093b6910..82ba36694 100644 --- a/src/plugins/Input/mpc/decoder_mpc.cpp +++ b/src/plugins/Input/mpc/decoder_mpc.cpp @@ -190,7 +190,7 @@ bool DecoderMPC::initialize() #endif int chan = data()->info.channels; - configure(data()->info.sample_freq, chan, 16); + configure(data()->info.sample_freq, chan, Qmmp::PCM_S16LE); QMap rg_info; //replay gain information #ifdef MPC_OLD_API mpc_decoder_setup (&data()->decoder, &data()->reader); diff --git a/src/plugins/Input/sndfile/decoder_sndfile.cpp b/src/plugins/Input/sndfile/decoder_sndfile.cpp index 45ea15cbe..73a54ef0b 100644 --- a/src/plugins/Input/sndfile/decoder_sndfile.cpp +++ b/src/plugins/Input/sndfile/decoder_sndfile.cpp @@ -65,7 +65,7 @@ bool DecoderSndFile::initialize() m_totalTime = snd_info.frames * 1000 / m_freq; m_bitrate = QFileInfo(m_path).size () * 8.0 / m_totalTime + 0.5; - configure(m_freq, chan, 16); + configure(m_freq, chan, Qmmp::PCM_S16LE); qDebug("DecoderSndFile: detected format: %08X", snd_info.format); qDebug("DecoderSndFile: initialize succes"); return TRUE; diff --git a/src/plugins/Input/vorbis/decoder_vorbis.cpp b/src/plugins/Input/vorbis/decoder_vorbis.cpp index 7b8c1e480..c1d563963 100644 --- a/src/plugins/Input/vorbis/decoder_vorbis.cpp +++ b/src/plugins/Input/vorbis/decoder_vorbis.cpp @@ -134,7 +134,7 @@ bool DecoderVorbis::initialize() freq = ogginfo->rate; chan = ogginfo->channels; } - configure(freq, chan, 16); + configure(freq, chan, Qmmp::PCM_S16LE); inited = TRUE; return TRUE; } diff --git a/src/plugins/Input/wavpack/decoder_wavpack.cpp b/src/plugins/Input/wavpack/decoder_wavpack.cpp index 9c99c7992..d9ea2b62d 100644 --- a/src/plugins/Input/wavpack/decoder_wavpack.cpp +++ b/src/plugins/Input/wavpack/decoder_wavpack.cpp @@ -106,8 +106,21 @@ bool DecoderWavPack::initialize() m_freq = WavpackGetSampleRate (m_context); int bps = WavpackGetBitsPerSample (m_context); if (!m_output_buf) - m_output_buf = new int32_t[Qmmp::globalBufferSize()/4]; - configure(m_freq, m_chan, bps); + m_output_buf = new int32_t[QMMP_BUFFER_SIZE/4]; + switch(bps) + { + case 8: + configure(m_freq, m_chan, Qmmp::PCM_S8); + break; + case 16: + configure(m_freq, m_chan, Qmmp::PCM_S16LE); + break; + case 24: + configure(m_freq, m_chan, Qmmp::PCM_S24LE); + break; + case 32: + configure(m_freq, m_chan, Qmmp::PCM_S32LE); + } if(!m_parser) m_totalTime = (qint64) WavpackGetNumSamples(m_context) * 1000 / m_freq; else @@ -116,11 +129,11 @@ bool DecoderWavPack::initialize() m_offset = m_parser->offset(m_track); length_in_bytes = audioParameters().sampleRate() * audioParameters().channels() * - audioParameters().bits() * m_length/8000; + audioParameters().sampleSize() * m_length/1000; seek(0); } m_totalBytes = 0; - m_sz = audioParameters().bits() * audioParameters().channels()/8; + m_sz = audioParameters().sampleSize() * audioParameters().channels(); qDebug("DecoderWavPack: initialize succes"); return TRUE; } @@ -158,7 +171,7 @@ void DecoderWavPack::seek(qint64 time) { m_totalBytes = audioParameters().sampleRate() * audioParameters().channels() * - audioParameters().bits() * time/8000; + audioParameters().sampleSize() * time/1000; if(m_parser) time += m_offset; WavpackSeekSample (m_context, time * m_freq / 1000); @@ -229,7 +242,7 @@ void DecoderWavPack::next() m_length = m_parser->length(m_track); length_in_bytes = audioParameters().sampleRate() * audioParameters().channels() * - audioParameters().bits() * m_length/8000; + audioParameters().sampleSize() * m_length/1000; StateHandler::instance()->dispatch(m_parser->info(m_track)->metaData()); m_totalBytes = 0; } diff --git a/src/plugins/Output/alsa/outputalsa.cpp b/src/plugins/Output/alsa/outputalsa.cpp index 829641638..16cc7d0a8 100644 --- a/src/plugins/Output/alsa/outputalsa.cpp +++ b/src/plugins/Output/alsa/outputalsa.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2006-2008 by Ilya Kotov * + * Copyright (C) 2006-2010 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -57,7 +57,7 @@ OutputALSA::~OutputALSA() free (pcm_name); } -void OutputALSA::configure(quint32 freq, int chan, int prec) +void OutputALSA::configure(quint32 freq, int chan, Qmmp::AudioFormat format) { // we need to configure @@ -99,32 +99,32 @@ void OutputALSA::configure(quint32 freq, int chan, int prec) return; } } - snd_pcm_format_t format = SND_PCM_FORMAT_UNKNOWN; - switch (prec) + snd_pcm_format_t alsa_format = SND_PCM_FORMAT_UNKNOWN; + switch (format) { - case 8: - format = SND_PCM_FORMAT_S8; + case Qmmp::PCM_S8: + alsa_format = SND_PCM_FORMAT_S8; break; - case 16: - format = SND_PCM_FORMAT_S16_LE; + case Qmmp::PCM_S16LE: + alsa_format = SND_PCM_FORMAT_S16_LE; break; - case 24: - format = SND_PCM_FORMAT_S24_LE; + case Qmmp::PCM_S24LE: + alsa_format = SND_PCM_FORMAT_S24_LE; break; - case 32: - format = SND_PCM_FORMAT_S32_LE; + case Qmmp::PCM_S32LE: + alsa_format = SND_PCM_FORMAT_S32_LE; break; default: qWarning("OutputALSA: unsupported format detected"); return; } - if ((err = snd_pcm_hw_params_set_format(pcm_handle, hwparams, format)) < 0) + if ((err = snd_pcm_hw_params_set_format(pcm_handle, hwparams, alsa_format)) < 0) { qDebug("OutputALSA: Error setting format: %s", snd_strerror(err)); return; } exact_rate = rate;// = 11000; - qDebug("OutputALSA: frequency=%d, channels=%d, bits=%d", rate, chan,prec); + //qDebug("OutputALSA: frequency=%d, channels=%d, bits=%d", rate, chan,prec); if ((err = snd_pcm_hw_params_set_rate_near(pcm_handle, hwparams, &exact_rate, 0)) < 0) { @@ -181,13 +181,13 @@ void OutputALSA::configure(quint32 freq, int chan, int prec) return; } //setup needed values - m_bits_per_frame = snd_pcm_format_physical_width(format) * chan; + m_bits_per_frame = snd_pcm_format_physical_width(alsa_format) * chan; m_chunk_size = period_size; m_can_pause = snd_pcm_hw_params_can_pause(hwparams) && use_pause; qDebug("OutputALSA: can pause: %d", m_can_pause); - Output::configure(freq, chan, prec); //apply configuration + Output::configure(freq, chan, format); //apply configuration //create alsa prebuffer; - m_prebuf_size = Buffer::size() + m_bits_per_frame * m_chunk_size / 8; + m_prebuf_size = QMMP_BLOCK_SIZE + m_bits_per_frame * m_chunk_size / 8; m_prebuf = (uchar *)malloc(m_prebuf_size); } @@ -225,7 +225,7 @@ bool OutputALSA::initialize() qint64 OutputALSA::latency() { - return m_prebuf_fill * 8000 / sampleRate() / numChannels() / sampleSize(); + return m_prebuf_fill * 1000 / sampleRate() / numChannels() / sampleSize(); } void OutputALSA::pause() diff --git a/src/plugins/Output/alsa/outputalsa.h b/src/plugins/Output/alsa/outputalsa.h index b3dc92a68..b0afcebce 100644 --- a/src/plugins/Output/alsa/outputalsa.h +++ b/src/plugins/Output/alsa/outputalsa.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2006-2008 by Ilya Kotov * + * Copyright (C) 2006-2010 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -42,7 +42,7 @@ public: ~OutputALSA(); bool initialize(); - void configure(quint32, int, int); + void configure(quint32, int, Qmmp::AudioFormat format); qint64 latency(); void pause(); @@ -94,5 +94,4 @@ private: bool m_use_mmap; }; - #endif // OUTPUTALSA_H diff --git a/src/plugins/Output/alsa/settingsdialog.ui b/src/plugins/Output/alsa/settingsdialog.ui index c39d3937d..b578a1d52 100644 --- a/src/plugins/Output/alsa/settingsdialog.ui +++ b/src/plugins/Output/alsa/settingsdialog.ui @@ -14,6 +14,15 @@ ALSA Plugin Settings + + 6 + + + 6 + + + 6 + diff --git a/src/plugins/Output/alsa/translations/alsa_plugin_cs.ts b/src/plugins/Output/alsa/translations/alsa_plugin_cs.ts index a00c1a805..5b9f18c0a 100644 --- a/src/plugins/Output/alsa/translations/alsa_plugin_cs.ts +++ b/src/plugins/Output/alsa/translations/alsa_plugin_cs.ts @@ -32,57 +32,57 @@ Nastavení pluginu ALSA - + Device Settings Nastavení zařízení - + Audio device Zvukové zařízení - + Mixer Mixér - + Mixer card: Zvuková karta: - + Mixer device: Ovládání hlasitosti: - + Advanced Settings Pokročilá nastavení - + Soundcard Zvuková karta - + Buffer time (ms): Velikost bufferu (ms): - + Period time (ms): Délka periody (ms): - + Use mmap access Použít mmap - + Use snd_pcm_pause function diff --git a/src/plugins/Output/alsa/translations/alsa_plugin_de.ts b/src/plugins/Output/alsa/translations/alsa_plugin_de.ts index 7890c64ca..5e1cbee8c 100644 --- a/src/plugins/Output/alsa/translations/alsa_plugin_de.ts +++ b/src/plugins/Output/alsa/translations/alsa_plugin_de.ts @@ -32,57 +32,57 @@ Einstellungen ALSA-Modul - + Device Settings Geräte-Einstellungen - + Audio device Audiogerät - + Mixer Mixer - + Mixer card: Mixerkarte: - + Mixer device: Mixergerät: - + Advanced Settings Erweiterte Einstellungen - + Soundcard Soundkarte - + Buffer time (ms): Pufferzeit (ms): - + Period time (ms): Zeitraster (ms): - + Use mmap access Mmap-Unterstützung aktivieren - + Use snd_pcm_pause function „snd_pcm_pause“-Funktion verwenden diff --git a/src/plugins/Output/alsa/translations/alsa_plugin_it.ts b/src/plugins/Output/alsa/translations/alsa_plugin_it.ts index af23e7a7c..80c581637 100644 --- a/src/plugins/Output/alsa/translations/alsa_plugin_it.ts +++ b/src/plugins/Output/alsa/translations/alsa_plugin_it.ts @@ -32,57 +32,57 @@ Impostazioni modulo ALSA - + Device Settings Impostazione del device - + Audio device Dispositivo audio - + Mixer Mixer - + Mixer card: Scheda Mixer: - + Mixer device: Dispositivo Mixer: - + Advanced Settings Impostazoni avanzate - + Soundcard Scheda audio - + Buffer time (ms): Tempo di buffering (ms): - + Period time (ms): Periodo (ms): - + Use mmap access Usa accesso Mmap - + Use snd_pcm_pause function Usa la funzione snd_pcm_pause diff --git a/src/plugins/Output/alsa/translations/alsa_plugin_lt.ts b/src/plugins/Output/alsa/translations/alsa_plugin_lt.ts index 7c97d1c14..7bc83016a 100644 --- a/src/plugins/Output/alsa/translations/alsa_plugin_lt.ts +++ b/src/plugins/Output/alsa/translations/alsa_plugin_lt.ts @@ -27,52 +27,52 @@ SettingsDialog - + Device Settings Įrangos nustatymai - + Audio device Garso įranga - + Mixer Glotintuvas - + Mixer card: Glotintuvo plokštė : - + Mixer device: Glotintuvo įranga: - + Advanced Settings Papildomi nustatymai - + Soundcard Garso plokštė - + Buffer time (ms): Buferio laikas (ms): - + Period time (ms): Periodo laikas (ms): - + Use snd_pcm_pause function Naudoti snd_pcm_pause funciją @@ -82,7 +82,7 @@ ALSA įskiepio nustatymai - + Use mmap access Naudoti mmap prieigą diff --git a/src/plugins/Output/alsa/translations/alsa_plugin_pl.ts b/src/plugins/Output/alsa/translations/alsa_plugin_pl.ts index 1b9abdb69..cbf5e07b5 100644 --- a/src/plugins/Output/alsa/translations/alsa_plugin_pl.ts +++ b/src/plugins/Output/alsa/translations/alsa_plugin_pl.ts @@ -32,57 +32,57 @@ Ustawienia wtyczki ALSA - + Device Settings Ustawienia urządzenia - + Audio device Urządzenie dźwiękowe - + Mixer Mikser - + Mixer card: Karta miksująca: - + Mixer device: Urządzenie miksujące: - + Advanced Settings Zaawansowane ustawienia - + Soundcard Karta dźwiękowa - + Buffer time (ms): Wielkość buforu (ms): - + Period time (ms): Czas cyklu (ms): - + Use mmap access Użyj dostępu mmap - + Use snd_pcm_pause function Użyj funkcji snd_pcm_pause diff --git a/src/plugins/Output/alsa/translations/alsa_plugin_ru.ts b/src/plugins/Output/alsa/translations/alsa_plugin_ru.ts index 244715907..7b4557086 100644 --- a/src/plugins/Output/alsa/translations/alsa_plugin_ru.ts +++ b/src/plugins/Output/alsa/translations/alsa_plugin_ru.ts @@ -27,52 +27,52 @@ SettingsDialog - + Device Settings Параметры устройства - + Audio device Аудио устройство - + Mixer Микшер - + Mixer card: Карта микшера: - + Mixer device: Устройство микшера: - + Advanced Settings Дополнительные настройки - + Soundcard Звуковая карта - + Buffer time (ms): Время буферизации (мс): - + Period time (ms): Время периода (мс): - + Use snd_pcm_pause function Использовать функцию snd_pcm_pause @@ -82,7 +82,7 @@ Настройки модуля ALSA - + Use mmap access Использовать доступ mmap diff --git a/src/plugins/Output/alsa/translations/alsa_plugin_tr.ts b/src/plugins/Output/alsa/translations/alsa_plugin_tr.ts index 898446c40..7ee692993 100644 --- a/src/plugins/Output/alsa/translations/alsa_plugin_tr.ts +++ b/src/plugins/Output/alsa/translations/alsa_plugin_tr.ts @@ -32,57 +32,57 @@ ALSA Eklentisi Ayarları - + Device Settings Aygıt Ayarları - + Audio device Ses aygıtı - + Mixer Karıştırıcı - + Mixer card: Karıştırıcı kartı: - + Mixer device: Karıştırıcı aygıtı: - + Advanced Settings Gelişmiş Ayarlar - + Soundcard Ses kartı - + Buffer time (ms): Arabellek süresi (ms): - + Period time (ms): Periyot süresi (ms): - + Use mmap access mmap erişimi kullan - + Use snd_pcm_pause function diff --git a/src/plugins/Output/alsa/translations/alsa_plugin_uk_UA.ts b/src/plugins/Output/alsa/translations/alsa_plugin_uk_UA.ts index 9b415534e..716f7fa4d 100644 --- a/src/plugins/Output/alsa/translations/alsa_plugin_uk_UA.ts +++ b/src/plugins/Output/alsa/translations/alsa_plugin_uk_UA.ts @@ -27,52 +27,52 @@ SettingsDialog - + Device Settings Параметри пристроїв - + Audio device Аудіо пристрій - + Mixer Мікшер - + Mixer card: Карта мікшера: - + Mixer device: Пристрій мікшера: - + Advanced Settings Додаткові налаштування - + Soundcard Звукова карта - + Buffer time (ms): Час буферизації (мс): - + Period time (ms): Час періоду (мс): - + Use snd_pcm_pause function Використовувати функцію snd_pcm_pause @@ -82,7 +82,7 @@ Налаштування модуля ALSA - + Use mmap access Використовувати доступ mmap diff --git a/src/plugins/Output/alsa/translations/alsa_plugin_zh_CN.ts b/src/plugins/Output/alsa/translations/alsa_plugin_zh_CN.ts index 196cb3e87..c5368dbfa 100644 --- a/src/plugins/Output/alsa/translations/alsa_plugin_zh_CN.ts +++ b/src/plugins/Output/alsa/translations/alsa_plugin_zh_CN.ts @@ -27,52 +27,52 @@ SettingsDialog - + Device Settings 设备设置 - + Audio device 音频设备 - + Mixer 混频 - + Mixer card: 混频卡: - + Mixer device: 混频设备: - + Advanced Settings 高级设置 - + Soundcard 声卡 - + Buffer time (ms): 缓冲时间(ms): - + Period time (ms): 周期时间(ms): - + Use snd_pcm_pause function @@ -82,7 +82,7 @@ ALSA 插件设置 - + Use mmap access 使用内存映射 diff --git a/src/plugins/Output/alsa/translations/alsa_plugin_zh_TW.ts b/src/plugins/Output/alsa/translations/alsa_plugin_zh_TW.ts index 409330b4a..b509bcc07 100644 --- a/src/plugins/Output/alsa/translations/alsa_plugin_zh_TW.ts +++ b/src/plugins/Output/alsa/translations/alsa_plugin_zh_TW.ts @@ -27,52 +27,52 @@ SettingsDialog - + Device Settings 裝置設定 - + Audio device 聲訊裝置 - + Mixer 混頻 - + Mixer card: 混頻卡: - + Mixer device: 混頻裝置: - + Advanced Settings 進階設定 - + Soundcard 音效卡 - + Buffer time (ms): 緩衝時間(ms): - + Period time (ms): 周期時間(ms): - + Use snd_pcm_pause function @@ -82,7 +82,7 @@ ALSA 插件設定 - + Use mmap access 使用內存對映 diff --git a/src/plugins/Output/jack/outputjack.cpp b/src/plugins/Output/jack/outputjack.cpp index b064590f4..c60087711 100644 --- a/src/plugins/Output/jack/outputjack.cpp +++ b/src/plugins/Output/jack/outputjack.cpp @@ -23,8 +23,8 @@ #include #include #include - #include "outputjack.h" +#include #include #include @@ -42,10 +42,10 @@ OutputJACK::~OutputJACK() uninitialize(); } -void OutputJACK::configure(quint32 freq, int chan, int prec) +void OutputJACK::configure(quint32 freq, int chan, Qmmp::AudioFormat format) { qDebug("OutputJACK: configure"); - if(JACK_Open(&jack_device, prec, (unsigned long *)&freq, chan)) + if(JACK_Open(&jack_device, AudioParameters::sampleSize(format)*8, (unsigned long *)&freq, chan)) { m_configure = FALSE; m_inited = FALSE; @@ -54,7 +54,7 @@ void OutputJACK::configure(quint32 freq, int chan, int prec) else m_configure = TRUE; m_inited = TRUE; - Output::configure(freq, chan, prec); + Output::configure(freq, chan, format); qDebug("OutputJACK: configure end"); } @@ -72,7 +72,7 @@ bool OutputJACK::initialize() { qDebug("Unable to connect to JACK server."); } - return FALSE; + return FALSE; } jack_client_close (client); m_inited = TRUE; diff --git a/src/plugins/Output/jack/outputjack.h b/src/plugins/Output/jack/outputjack.h index 8a340002d..f2d6357b6 100644 --- a/src/plugins/Output/jack/outputjack.h +++ b/src/plugins/Output/jack/outputjack.h @@ -40,7 +40,7 @@ public: ~OutputJACK(); bool initialize(); - void configure(quint32, int, int); + void configure(quint32, int, Qmmp::AudioFormat format); qint64 latency(); private: diff --git a/src/plugins/Output/oss/outputoss.cpp b/src/plugins/Output/oss/outputoss.cpp index 9402d99bd..84d3d652e 100644 --- a/src/plugins/Output/oss/outputoss.cpp +++ b/src/plugins/Output/oss/outputoss.cpp @@ -65,7 +65,7 @@ OutputOSS* OutputOSS::instance() OutputOSS::OutputOSS(QObject * parent) : Output(parent), m_inited(FALSE), - m_frequency(-1), m_channels(-1), m_precision(-1), + m_frequency(-1), m_channels(-1), do_select(TRUE), m_audio_fd(-1) { @@ -89,12 +89,11 @@ OutputOSS::~OutputOSS() } } -void OutputOSS::configure(quint32 freq, int chan, int prec) +void OutputOSS::configure(quint32 freq, int chan, Qmmp::AudioFormat format) { // we need to configure - if (freq != m_frequency || chan != m_channels || prec != m_precision) + if (freq != m_frequency || chan != m_channels) { - qDebug("OutputOSS: frequency=%d, channels=%d, bits=%d", freq, chan, prec); // we have already configured, but are changing settings... // reset the device resetDSP(); @@ -111,15 +110,14 @@ void OutputOSS::configure(quint32 freq, int chan, int prec) #endif m_frequency = freq; m_channels = chan; - m_precision = prec; //m_bps = freq * chan * (prec / 8); int p; - switch (prec) + switch (format) { default: - case 16: + case Qmmp::PCM_S16LE: #if defined(AFMT_S16_NE) p = AFMT_S16_NE; #else @@ -127,7 +125,7 @@ void OutputOSS::configure(quint32 freq, int chan, int prec) #endif break; - case 8: + case Qmmp::PCM_S8: p = AFMT_S8; break; @@ -135,8 +133,8 @@ void OutputOSS::configure(quint32 freq, int chan, int prec) if (ioctl(m_audio_fd, SNDCTL_DSP_SETFMT, &p) == -1) qWarning("OutputOSS: can't set audio format"); - if(ioctl(m_audio_fd, SNDCTL_DSP_SAMPLESIZE, &prec) == -1) - qDebug("OutputOSS: can't set audio format"); + /*if(ioctl(m_audio_fd, SNDCTL_DSP_SAMPLESIZE, &prec) == -1) + qDebug("OutputOSS: can't set audio format");*/ int stereo = (chan > 1) ? 1 : 0; ioctl(m_audio_fd, SNDCTL_DSP_STEREO, &stereo); /*if (ioctl(m_audio_fd, SNDCTL_DSP_SPEED, &m_channels) == -1) @@ -146,7 +144,7 @@ void OutputOSS::configure(quint32 freq, int chan, int prec) if (ioctl(m_audio_fd, SNDCTL_DSP_SPEED, &freq) == -1) qWarning("OutputOSS: can't set audio format"); } - Output::configure(freq, chan, prec); + Output::configure(freq, chan, format); } void OutputOSS::reset() @@ -226,7 +224,6 @@ void OutputOSS::uninitialize() m_inited = FALSE; m_frequency = -1; m_channels = -1; - m_precision = -1; resetDSP(); if (m_audio_fd > 0) { diff --git a/src/plugins/Output/oss/outputoss.h b/src/plugins/Output/oss/outputoss.h index cd9d919aa..7fb0e4c94 100644 --- a/src/plugins/Output/oss/outputoss.h +++ b/src/plugins/Output/oss/outputoss.h @@ -36,7 +36,7 @@ public: virtual ~OutputOSS(); bool initialize(); - void configure(quint32, int, int); + void configure(quint32, int, Qmmp::AudioFormat format); qint64 latency(); int audio_fd(); static OutputOSS* instance(); @@ -62,7 +62,7 @@ private: bool m_inited; quint32 m_frequency; - int m_channels, m_precision; + int m_channels; bool do_select; int m_audio_fd; diff --git a/src/plugins/Output/pulseaudio/CMakeLists.txt b/src/plugins/Output/pulseaudio/CMakeLists.txt index c3072e4d5..c1501e08d 100644 --- a/src/plugins/Output/pulseaudio/CMakeLists.txt +++ b/src/plugins/Output/pulseaudio/CMakeLists.txt @@ -26,7 +26,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../) link_directories(${CMAKE_CURRENT_BINARY_DIR}/../../../qmmp) # pulseaudio -pkg_check_modules(PULSE libpulse-simple) +pkg_check_modules(PULSE libpulse-simple>=0.9.15) include_directories(${PULSE_INCLUDE_DIRS}) link_directories(${PULSE_LIBRARY_DIRS}) diff --git a/src/plugins/Output/pulseaudio/outputpulseaudio.cpp b/src/plugins/Output/pulseaudio/outputpulseaudio.cpp index e122e0c64..1765444fd 100644 --- a/src/plugins/Output/pulseaudio/outputpulseaudio.cpp +++ b/src/plugins/Output/pulseaudio/outputpulseaudio.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2006-2008 by Ilya Kotov * + * Copyright (C) 2006-2010 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -46,19 +46,24 @@ OutputPulseAudio::~OutputPulseAudio() uninitialize(); } -void OutputPulseAudio::configure(quint32 freq, int chan, int prec) +void OutputPulseAudio::configure(quint32 freq, int chan, Qmmp::AudioFormat format) { pa_sample_spec ss; - switch (prec) + switch (format) { - case 8: + case Qmmp::PCM_S8: ss.format = PA_SAMPLE_U8; break; - case 32: + case Qmmp::PCM_S16LE: + ss.format = PA_SAMPLE_S16LE; + break; + case Qmmp::PCM_S24LE: + ss.format = PA_SAMPLE_S24_32LE; + break; + case Qmmp::PCM_S32LE: ss.format = PA_SAMPLE_S32LE; break; - case 16: default: ss.format = PA_SAMPLE_S16LE; } @@ -81,8 +86,7 @@ void OutputPulseAudio::configure(quint32 freq, int chan, int prec) qWarning("OutputPulseAudio: pa_simple_new() failed: %s", pa_strerror(error)); return; } - qDebug("OutputPulseAudio: frequency=%d, channels=%d, bits=%d", uint(freq), chan, prec); - Output::configure(freq, chan, prec); + Output::configure(freq, chan, format); } bool OutputPulseAudio::initialize() diff --git a/src/plugins/Output/pulseaudio/outputpulseaudio.h b/src/plugins/Output/pulseaudio/outputpulseaudio.h index 5cc0bd93f..1a85e557a 100644 --- a/src/plugins/Output/pulseaudio/outputpulseaudio.h +++ b/src/plugins/Output/pulseaudio/outputpulseaudio.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2006-2008 by Ilya Kotov * + * Copyright (C) 2006-2010 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -40,7 +40,7 @@ public: ~OutputPulseAudio(); bool initialize(); - void configure(quint32, int, int); + void configure(quint32, int, Qmmp::AudioFormat format); qint64 latency(); private: diff --git a/src/plugins/Visual/analyzer/analyzer.cpp b/src/plugins/Visual/analyzer/analyzer.cpp index 215c70a8a..de17d214d 100644 --- a/src/plugins/Visual/analyzer/analyzer.cpp +++ b/src/plugins/Visual/analyzer/analyzer.cpp @@ -82,43 +82,35 @@ void Analyzer::clear() update(); } -void Analyzer::add (Buffer *b, unsigned long w, int c, int p) +void Analyzer::add (unsigned char *data, qint64 size, int chan) { if (!m_timer->isActive ()) return; - long len = b->nbytes, cnt; + long len = size, cnt; short *l = 0, *r = 0; - len /= c; - len /= (p / 8); + len /= chan; + len /= 2; if (len > 512) len = 512; cnt = len; - if (c == 2) + if (chan == 2) { l = new short[len]; r = new short[len]; - - if (p == 8) - stereo16_from_stereopcm8 (l, r, b->data, cnt); - else if (p == 16) - stereo16_from_stereopcm16 (l, r, (short *) b->data, cnt); + stereo16_from_stereopcm16 (l, r, (short *) data, cnt); } - else if (c == 1) + else if (chan == 1) { l = new short[len]; - - if (p == 8) - mono16_from_monopcm8 (l, b->data, cnt); - else if (p == 16) - mono16_from_monopcm16 (l, (short *) b->data, cnt); + mono16_from_monopcm16 (l, (short *) data, cnt); } else len = 0; if (len) - m_nodes.append (new VisualNode (l, r, len, w)); + m_nodes.append (new VisualNode (l, r, len)); } void Analyzer::timeout() diff --git a/src/plugins/Visual/analyzer/analyzer.h b/src/plugins/Visual/analyzer/analyzer.h index 9b0352dae..1c0e8974e 100644 --- a/src/plugins/Visual/analyzer/analyzer.h +++ b/src/plugins/Visual/analyzer/analyzer.h @@ -36,8 +36,8 @@ class Buffer; class VisualNode { public: - VisualNode(short *l, short *r, unsigned long n, unsigned long o) - : left(l), right(r), length(n), offset(o) + VisualNode(short *l, short *r, unsigned long n) + : left(l), right(r), length(n) { // left and right are allocated and then passed to this class // the code that allocated left and right should give up all ownership @@ -50,7 +50,7 @@ public: } short *left, *right; - long length, offset; + long length; }; class Analyzer : public Visual @@ -61,7 +61,7 @@ public: Analyzer( QWidget *parent = 0); virtual ~Analyzer(); - void add(Buffer *, unsigned long, int, int); + void add(unsigned char *data, qint64 size, int chan); void clear(); void paintEvent( QPaintEvent * ); diff --git a/src/plugins/Visual/projectm/projectmplugin.cpp b/src/plugins/Visual/projectm/projectmplugin.cpp index b29dfab1e..b7e1483a4 100644 --- a/src/plugins/Visual/projectm/projectmplugin.cpp +++ b/src/plugins/Visual/projectm/projectmplugin.cpp @@ -54,8 +54,10 @@ void ProjectMPlugin::clear() update(); } -void ProjectMPlugin::add ( Buffer *b, unsigned long, int, int) -{ //TODO 8 bit support +void ProjectMPlugin::add (unsigned char *data, qint64 size, int chan) +{ + Q_UNUSED(chan); + //TODO multichannel support if (m_projectMWidget->projectMInstance()) - m_projectMWidget->projectMInstance()->pcm()->addPCM16Data((short *)b->data, b->nbytes/4); + m_projectMWidget->projectMInstance()->pcm()->addPCM16Data((short *)data, size/4); } diff --git a/src/plugins/Visual/projectm/projectmplugin.h b/src/plugins/Visual/projectm/projectmplugin.h index db16ab110..5f201ef39 100644 --- a/src/plugins/Visual/projectm/projectmplugin.h +++ b/src/plugins/Visual/projectm/projectmplugin.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2009 by Ilya Kotov * + * Copyright (C) 2009-2010 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -35,7 +35,7 @@ public: ProjectMPlugin(QWidget *parent = 0); virtual ~ProjectMPlugin(); - void add(Buffer *, unsigned long, int, int); + void add(unsigned char *data, qint64 size, int chan); void clear(); private: diff --git a/src/qmmp/audioparameters.cpp b/src/qmmp/audioparameters.cpp index 9e513d586..658ae688f 100644 --- a/src/qmmp/audioparameters.cpp +++ b/src/qmmp/audioparameters.cpp @@ -24,33 +24,33 @@ AudioParameters::AudioParameters() { m_srate = 0; m_chan = 0; - m_bps = 0; + m_format = Qmmp::PCM_S16LE; } AudioParameters::AudioParameters(const AudioParameters &other) { m_srate = other.sampleRate(); m_chan = other.channels(); - m_bps = other.bits(); + m_format = other.format(); } -AudioParameters::AudioParameters(quint32 srate, int chan, int bps) +AudioParameters::AudioParameters(quint32 srate, int chan, Qmmp::AudioFormat format) { m_srate = srate; m_chan = chan; - m_bps = bps; + m_format = format; } void AudioParameters::operator=(const AudioParameters &p) { m_srate = p.sampleRate(); m_chan = p.channels(); - m_bps = p.bits(); + m_format = p.format(); } bool AudioParameters::operator==(const AudioParameters &p) const { - return m_srate == p.sampleRate() && m_chan == p.channels() && m_bps == p.bits(); + return m_srate == p.sampleRate() && m_chan == p.channels() && m_format == p.format(); } bool AudioParameters::operator!=(const AudioParameters &p) const @@ -68,7 +68,29 @@ int AudioParameters::channels() const return m_chan; } -int AudioParameters::bits() const +Qmmp::AudioFormat AudioParameters::format() const { - return m_bps; + return m_format; } + +int AudioParameters::sampleSize() const +{ + return sampleSize(m_format); +} + +int AudioParameters::sampleSize(Qmmp::AudioFormat format) +{ + switch(format) + { + case Qmmp::PCM_S8: + return 1; + case Qmmp::PCM_S16LE: + case Qmmp::PCM_UNKNOWM: + return 2; + case Qmmp::PCM_S24LE: + case Qmmp::PCM_S32LE: + return 4; + } + return 2; +} + diff --git a/src/qmmp/audioparameters.h b/src/qmmp/audioparameters.h index 4710375bc..2a99305eb 100644 --- a/src/qmmp/audioparameters.h +++ b/src/qmmp/audioparameters.h @@ -22,6 +22,7 @@ #define AUDIOPARAMETERS_H #include +#include "qmmp.h" /*! * @author Ilya Kotov @@ -30,7 +31,7 @@ class AudioParameters { public: AudioParameters(); - AudioParameters(quint32 srate, int chan, int bps); + AudioParameters(quint32 srate, int chan, Qmmp::AudioFormat format); AudioParameters(const AudioParameters &other); void operator=(const AudioParameters &p); @@ -39,12 +40,14 @@ public: quint32 sampleRate() const; int channels() const; - int bits() const; + Qmmp::AudioFormat format() const; + int sampleSize() const; + static int sampleSize(Qmmp::AudioFormat format); private: quint32 m_srate; int m_chan; - int m_bps; + Qmmp::AudioFormat m_format; }; #endif // AUDIOPARAMETERS_H diff --git a/src/qmmp/buffer.h b/src/qmmp/buffer.h index e0ab18a16..e8aac27a5 100644 --- a/src/qmmp/buffer.h +++ b/src/qmmp/buffer.h @@ -8,6 +8,7 @@ #define __buffer_h #define QMMP_BLOCK_SIZE 2048 +#define QMMP_BUFFER_SIZE (QMMP_BLOCK_SIZE*128) /*! @brief Audio buffer class. * @author Brad Hughes @@ -23,31 +24,24 @@ public: data = new unsigned char[QMMP_BLOCK_SIZE]; nbytes = 0; rate = 0; - exceeding = 0; + size = QMMP_BLOCK_SIZE; } /*! * Destructor. */ ~Buffer() { - delete data; + delete[] data; data = 0; nbytes = 0; rate = 0; - exceeding = 0; + size = 0; } unsigned char *data; /*!< Audio data */ unsigned long nbytes; /*!< Audio data size */ unsigned long rate; /*!< Buffer bitrate */ - unsigned long exceeding; /*!< The number of bytes on which the size of buffer exceeds the size of the block */ - /*! - * Returns block size. - */ - static unsigned int size() - { - return QMMP_BLOCK_SIZE; - } + unsigned long size; /*!< Buffer size */ }; diff --git a/src/qmmp/decoder.cpp b/src/qmmp/decoder.cpp index 369f1e769..d5046d6c0 100644 --- a/src/qmmp/decoder.cpp +++ b/src/qmmp/decoder.cpp @@ -37,9 +37,9 @@ void Decoder::setReplayGainInfo(const QMap &rg) m_rg = rg; } -void Decoder::configure(quint32 srate, int chan, int bps) +void Decoder::configure(quint32 srate, int chan, Qmmp::AudioFormat format) { - m_parameters = AudioParameters(srate, chan, bps); + m_parameters = AudioParameters(srate, chan, format); } void Decoder::next() diff --git a/src/qmmp/decoder.h b/src/qmmp/decoder.h index 44a917ff8..764491a36 100644 --- a/src/qmmp/decoder.h +++ b/src/qmmp/decoder.h @@ -110,9 +110,9 @@ protected: * Use this function inside initialize() reimplementation to tell other plugins about audio parameters. * @param srate Sample rate. * @param chan Number of channels. - * @param bps Bits per sample. + * @param f Audio format. */ - void configure(quint32 srate, int chan, int bps); + void configure(quint32 srate = 44100, int chan = 2, Qmmp::AudioFormat f = Qmmp::PCM_S16LE); private: static void checkFactories(); diff --git a/src/qmmp/effect.cpp b/src/qmmp/effect.cpp index eda224d84..27d6b98d1 100644 --- a/src/qmmp/effect.cpp +++ b/src/qmmp/effect.cpp @@ -30,18 +30,18 @@ Effect::Effect() { m_freq = 0; m_chan = 0; - m_res = 0; + m_format = Qmmp::PCM_UNKNOWM; m_factory = 0; } Effect::~Effect() {} -void Effect::configure(quint32 freq, int chan, int res) +void Effect::configure(quint32 freq, int chan, Qmmp::AudioFormat format) { m_freq = freq; m_chan = chan; - m_res = res; + m_format = format; } quint32 Effect::sampleRate() @@ -54,14 +54,14 @@ int Effect::channels() return m_chan; } -int Effect::bitsPerSample() +Qmmp::AudioFormat Effect::format() { - return m_res; + return m_format; } const AudioParameters Effect::audioParameters() const { - return AudioParameters(m_freq, m_chan, m_res); + return AudioParameters(m_freq, m_chan, m_format); } EffectFactory* Effect::factory() const diff --git a/src/qmmp/effect.h b/src/qmmp/effect.h index 325db8e25..05873cda4 100644 --- a/src/qmmp/effect.h +++ b/src/qmmp/effect.h @@ -23,6 +23,7 @@ #include #include #include "audioparameters.h" +#include "buffer.h" class EffectFactory; @@ -41,20 +42,18 @@ public: */ virtual ~Effect(); /*! - * Adds effect to the input data pointer \b in_data with the size \b size. - * Result is stored in the output data \b out_data. - * Return value is the size of the output data. + * Adds audio effect to the buffer \b b. * Subclass should implement this function. */ - virtual ulong process(char *in_data, const ulong size, char **out_data) = 0; + virtual void applyEffect(Buffer *b) = 0; /*! * Prepares object for usage. * Subclasses that reimplement this function must call the base implementation. * @param freq Sample rate. * @param chan Number of channels. - * @param res Bits per sample. + * @param f Audio format. */ - virtual void configure(quint32 freq, int chan, int res); + virtual void configure(quint32 srate = 44100, int chan = 2, Qmmp::AudioFormat f = Qmmp::PCM_S16LE); /*! * Returns samplerate. */ @@ -64,9 +63,9 @@ public: */ int channels(); /*! - * Returns bits per sample. + * Returns audio format. */ - int bitsPerSample(); + Qmmp::AudioFormat format(); const AudioParameters audioParameters() const; EffectFactory* factory() const; @@ -99,7 +98,7 @@ private: EffectFactory *m_factory; quint32 m_freq; int m_chan; - int m_res; + Qmmp::AudioFormat m_format; static void checkFactories(); static QList *m_factories; static QStringList m_files; diff --git a/src/qmmp/output.cpp b/src/qmmp/output.cpp index feff9e11f..6468d4165 100644 --- a/src/qmmp/output.cpp +++ b/src/qmmp/output.cpp @@ -9,7 +9,7 @@ #include #include #include - +#include "audioparameters.h" #include "buffer.h" #include "output.h" #include "volumecontrol.h" @@ -17,26 +17,74 @@ #include +//static functions +static inline void s8_to_s16(qint8 *in, qint16 *out, qint64 samples) +{ + for(qint64 i = 0; i < samples; ++i) + out[i] = in[i] << 8; + return; +} + +static inline void s24_to_s16(qint32 *in, qint16 *out, qint64 samples) +{ + for(qint64 i = 0; i < samples; ++i) + out[i] = in[i] >> 8; + return; +} + +static inline void s32_to_s16(qint32 *in, qint16 *out, qint64 samples) +{ + for(qint64 i = 0; i < samples; ++i) + out[i] = in[i] >> 16; + return; +} + Output::Output (QObject* parent) : QThread (parent), m_recycler (stackSize()) { m_handler = StateHandler::instance(); m_frequency = 0; m_channels = 0; - m_kbps = 0; + m_format = Qmmp::PCM_UNKNOWM; m_totalWritten = 0; m_currentMilliseconds = -1; m_bytesPerMillisecond = 0; m_userStop = FALSE; m_pause = FALSE; m_finish = FALSE; + m_visBuffer = 0; + m_visBufferSize = 0; + m_kbps = 0; } -void Output::configure(quint32 freq, int chan, int prec) +void Output::configure(quint32 freq, int chan, Qmmp::AudioFormat format) { m_frequency = freq; m_channels = chan; - m_precision = prec; - m_bytesPerMillisecond = freq * chan * (prec / 8) / 1000; + m_format = format; + QMap formatNames; + formatNames.insert(Qmmp::PCM_S8, "s8"); + formatNames.insert(Qmmp::PCM_S16LE, "s16le"); + formatNames.insert(Qmmp::PCM_S24LE, "s24le"); + formatNames.insert(Qmmp::PCM_S32LE, "s32le"); + qDebug("Output: %d Hz, %d ch, %s", freq, chan, qPrintable(formatNames.value(format))); + m_bytesPerMillisecond = freq * chan * AudioParameters::sampleSize(format) / 1000; + //visual buffer + if(m_visBuffer) + { + delete [] m_visBuffer; + m_visBuffer = 0; + m_visBufferSize = 0; + } + if(format == Qmmp::PCM_S8) + { + m_visBufferSize = QMMP_BLOCK_SIZE * 2; + m_visBuffer = new unsigned char [m_visBufferSize]; + } + else if(format == Qmmp::PCM_S24LE || format == Qmmp::PCM_S32LE) + { + m_visBufferSize = QMMP_BLOCK_SIZE / 2; + m_visBuffer = new unsigned char [m_visBufferSize]; + } } void Output::pause() @@ -92,25 +140,59 @@ int Output::numChannels() return m_channels; } -int Output::sampleSize() +Qmmp::AudioFormat Output::format() const +{ + return m_format; +} + +int Output::sampleSize() const { - return m_precision; + return AudioParameters::sampleSize(m_format); } Output::~Output() {} -void Output::dispatchVisual (Buffer *buffer, unsigned long written, - int chan, int prec) +void Output::dispatchVisual (Buffer *buffer) { if (!buffer) return; + + int sampleSize = AudioParameters::sampleSize(m_format); + int samples = buffer->nbytes/sampleSize; + int outSize = samples*2; + if((m_format != Qmmp::PCM_S16LE) && outSize > m_visBufferSize) //increase buffer size + { + delete[] m_visBuffer; + m_visBufferSize = outSize; + m_visBuffer = new unsigned char [m_visBufferSize]; + } + switch(m_format) + { + case Qmmp::PCM_S8: + s8_to_s16((qint8 *)buffer->data, (qint16 *) m_visBuffer, samples); + break; + case Qmmp::PCM_S16LE: + m_visBuffer = buffer->data; + outSize = buffer->nbytes; + break; + case Qmmp::PCM_S24LE: + s24_to_s16((qint32 *)buffer->data, (qint16 *) m_visBuffer, samples); + break; + case Qmmp::PCM_S32LE: + s32_to_s16((qint32 *)buffer->data, (qint16 *) m_visBuffer, samples); + break; + default: + return; + } foreach (Visual *visual, *Visual::visuals()) { visual->mutex()->lock (); - visual->add ( buffer, written, chan, prec ); + visual->add (m_visBuffer, outSize, m_channels); visual->mutex()->unlock(); } + if(m_format == Qmmp::PCM_S16LE) + m_visBuffer = 0; } @@ -186,9 +268,9 @@ void Output::run() mutex()->unlock(); if (b) { - dispatchVisual(b, m_totalWritten, m_channels, m_precision); - if (SoftwareVolume::instance()) - SoftwareVolume::instance()->changeVolume(b->data, b->nbytes, m_channels, m_precision); + dispatchVisual(b); + /*if (SoftwareVolume::instance()) + SoftwareVolume::instance()->changeVolume(b->data, b->nbytes, m_channels, m_precision);*/ l = 0; m = 0; while (l < b->nbytes) @@ -235,7 +317,7 @@ void Output::status() { m_currentMilliseconds = ct; dispatch(m_currentMilliseconds, m_kbps, - m_frequency, m_precision, m_channels); + m_frequency, AudioParameters::sampleSize(m_format)*8, m_channels); } } diff --git a/src/qmmp/output.h b/src/qmmp/output.h index 853ec1b8f..c5a4d704b 100644 --- a/src/qmmp/output.h +++ b/src/qmmp/output.h @@ -55,9 +55,9 @@ public: * Setups audio parameters of output interface. * @param freq Sample rate. * @param chan Number of channels. - * @param bits Bits per sample + * @param format Audio format */ - virtual void configure(quint32 freq, int chan, int bits); + virtual void configure(quint32 freq, int chan, Qmmp::AudioFormat format); /*! * Requests playback to pause. If it was paused already, playback should resume. * Subclasses that reimplement this function must call the base implementation. @@ -101,9 +101,11 @@ public: */ int numChannels(); /*! - * Returns bits per sample. + * Returns selected audio format. */ - int sampleSize(); + Qmmp::AudioFormat format() const; + + int sampleSize() const; /*! * Creates selected output. * @param parent Parent object. @@ -146,20 +148,24 @@ private: void dispatch(qint64 elapsed, int bitrate, int frequency, - int precision, + int bits, int channels); void dispatch(const Qmmp::State &state); - void dispatchVisual(Buffer *, unsigned long, int, int); + void dispatchVisual(Buffer *buffer); void clearVisuals(); QMutex m_mutex; Recycler m_recycler; StateHandler *m_handler; quint32 m_frequency; - int m_channels, m_precision, m_kbps; + int m_channels, m_kbps; + Qmmp::AudioFormat m_format; qint64 m_bytesPerMillisecond; bool m_userStop, m_pause; bool m_finish; qint64 m_totalWritten, m_currentMilliseconds; + unsigned char *m_visBuffer; + qint64 m_visBufferSize; + static void checkFactories(); static void registerFactory(OutputFactory *); diff --git a/src/qmmp/qmmp.cpp b/src/qmmp/qmmp.cpp index 4fe71cf9d..5be4dbe1e 100644 --- a/src/qmmp/qmmp.cpp +++ b/src/qmmp/qmmp.cpp @@ -32,7 +32,6 @@ #define LIB_DIR "/lib" #endif -#include "buffer.h" #include "qmmp.h" QString Qmmp::m_configFile; @@ -123,9 +122,3 @@ QString Qmmp::systemLanguageID() #endif return QLocale::system().name(); } - -unsigned int Qmmp::globalBufferSize() -{ - return Buffer::size() * 128; -} - diff --git a/src/qmmp/qmmp.h b/src/qmmp/qmmp.h index 360dd81b1..62cf446bf 100644 --- a/src/qmmp/qmmp.h +++ b/src/qmmp/qmmp.h @@ -63,6 +63,17 @@ public: REPLAYGAIN_ALBUM_GAIN, REPLAYGAIN_ALBUM_PEAK }; + /*! + * Audio formats + */ + enum AudioFormat + { + PCM_UNKNOWM = -1, /*!< Unknown format */ + PCM_S8 = 0, /*!< Signed 8 bit */ + PCM_S16LE, /*!< Signed 16 bit Little Endian */ + PCM_S24LE, /*!< Signed 24 bit Little Endian using low three bytes in 32-bit word */ + PCM_S32LE /*!< Signed 32 bit Little Endian */ + }; /*! * Returns configuration file path. */ @@ -109,11 +120,6 @@ public: * Returns system language */ static QString systemLanguageID(); - /*! - * Returns global buffer size in bytes - */ - static unsigned int globalBufferSize(); - private: static QString m_configFile; diff --git a/src/qmmp/qmmpaudioengine.cpp b/src/qmmp/qmmpaudioengine.cpp index aa99cea58..7f385897b 100644 --- a/src/qmmp/qmmpaudioengine.cpp +++ b/src/qmmp/qmmpaudioengine.cpp @@ -41,13 +41,12 @@ QmmpAudioEngine::QmmpAudioEngine(QObject *parent) : AbstractEngine(parent), m_factory(0), m_output(0), m_eqInited(FALSE), m_useEQ(FALSE) { - m_output_buf = new unsigned char[Qmmp::globalBufferSize()]; + m_output_buf = new unsigned char[QMMP_BUFFER_SIZE]; double b[] = {0,0,0,0,0,0,0,0,0,0}; setEQ(b, 0); qRegisterMetaType("Qmmp::State"); - _blksize = Buffer::size(); m_effects = Effect::create(); - m_bks = Buffer::size(); + m_bks = QMMP_BLOCK_SIZE; m_decoder = 0; m_output = 0; m_replayGain = new ReplayGain; @@ -174,7 +173,7 @@ void QmmpAudioEngine::addEffect(EffectFactory *factory) if(m_output && m_output->isRunning()) { Effect *effect = factory->create(); - effect->configure(m_ap.sampleRate(), m_ap.channels(), m_ap.bits()); + effect->configure(m_ap.sampleRate(), m_ap.channels(), m_ap.format()); if(effect->audioParameters() == m_ap) { mutex()->lock(); @@ -199,21 +198,11 @@ void QmmpAudioEngine::removeEffect(EffectFactory *factory) } if(!effect) return; - int index = m_effects.indexOf(effect); if(m_output && m_output->isRunning()) { - if(index == 0 && m_decoder->audioParameters() == effect->audioParameters()) - { - mutex()->lock(); - m_effects.removeAll(effect); - mutex()->unlock(); - } - else if(m_effects.at(index - 1)->audioParameters() == effect->audioParameters()) - { - mutex()->lock(); - m_effects.removeAll(effect); - mutex()->unlock(); - } + mutex()->lock(); + m_effects.removeAll(effect); + mutex()->unlock(); } } @@ -309,7 +298,7 @@ void QmmpAudioEngine::stop() qint64 QmmpAudioEngine::produceSound(char *data, qint64 size, quint32 brate, int chan) { - ulong sz = size < _blksize ? size : _blksize; + uint sz = size < m_bks ? size : m_bks; m_replayGain->applyReplayGain(data, sz); if (m_useEQ) { @@ -318,43 +307,19 @@ qint64 QmmpAudioEngine::produceSound(char *data, qint64 size, quint32 brate, int init_iir(); m_eqInited = TRUE; } - iir((void*) data, sz, chan > 2 ? 2 : chan); - } - char *out_data = data; - char *prev_data = data; - qint64 w = sz; - Effect* effect = 0; - foreach(effect, m_effects) - { - w = effect->process(prev_data, sz, &out_data); - - if (w <= 0) - { - // copy data if plugin can not process it - w = sz; - out_data = new char[w]; - memcpy(out_data, prev_data, w); - } - if (data != prev_data) - delete prev_data; - prev_data = out_data; + iir((void*) data, sz, chan); } - Buffer *b = m_output->recycler()->get(w); - - memcpy(b->data, out_data, w); - - if (data != out_data) - delete out_data; + Buffer *b = m_output->recycler()->get(); - if (w < _blksize + b->exceeding) - memset(b->data + w, 0, _blksize + b->exceeding - w); - - b->nbytes = w; + memcpy(b->data, data, sz); + b->nbytes = sz; b->rate = brate; - + foreach(Effect* effect, m_effects) + { + effect->applyEffect(b); + } m_output->recycler()->add(); - size -= sz; memmove(data, data + sz, size); return sz; @@ -406,7 +371,7 @@ void QmmpAudioEngine::run() } len = m_decoder->read((char *)(m_output_buf + m_output_at), - Qmmp::globalBufferSize() - m_output_at); + QMMP_BUFFER_SIZE - m_output_at); if (len > 0) { @@ -588,18 +553,18 @@ Output *QmmpAudioEngine::createOutput(Decoder *d) m_effects = Effect::create(); quint32 srate = m_ap.sampleRate(); int chan = m_ap.channels(); - int bps = m_ap.bits(); - m_replayGain->setSampleSize(bps); + Qmmp::AudioFormat format = m_ap.format(); + m_replayGain->setSampleSize(m_ap.sampleSize()); foreach(Effect *effect, m_effects) { - effect->configure(srate, chan, bps); + effect->configure(srate, chan, format); srate = effect->sampleRate(); chan = effect->channels(); - bps = effect->bitsPerSample(); + format = effect->format(); } m_chan = chan; - output->configure(srate, chan, bps); + output->configure(srate, chan, format); return output; } diff --git a/src/qmmp/qmmpaudioengine.h b/src/qmmp/qmmpaudioengine.h index 20372be8e..7d19e2917 100644 --- a/src/qmmp/qmmpaudioengine.h +++ b/src/qmmp/qmmpaudioengine.h @@ -73,11 +73,10 @@ private: QList m_effects; Output *m_output; - uint _blksize; bool m_eqInited; bool m_useEQ; bool m_done, m_finish, m_user_stop; - ulong m_bks; + uint m_bks; qint64 m_totalTime, m_seekTime; qint64 m_output_at; int m_bitrate, m_chan, m_bps; diff --git a/src/qmmp/recycler.cpp b/src/qmmp/recycler.cpp index fd8b03cff..a47b4f9c9 100644 --- a/src/qmmp/recycler.cpp +++ b/src/qmmp/recycler.cpp @@ -10,7 +10,7 @@ Recycler::Recycler ( unsigned int sz ) : add_index ( 0 ), done_index ( 0 ), current_count ( 0 ) { - buffer_count = sz / Buffer::size(); + buffer_count = sz / QMMP_BLOCK_SIZE; if (buffer_count < 4) { buffer_count = 4; @@ -60,18 +60,10 @@ int Recycler::used() const } -Buffer *Recycler::get(unsigned long size) +Buffer *Recycler::get() { if (full()) return 0; - if (size > Buffer::size() + buffers[add_index]->exceeding) - { - delete buffers[add_index]->data; - buffers[add_index]->data = new unsigned char[size]; - buffers[add_index]->exceeding = size - Buffer::size(); - //qDebug("new size = %d, index = %d", size, add_index); - } - return buffers[add_index]; } @@ -105,5 +97,5 @@ void Recycler::clear() unsigned int Recycler::size() const { - return buffer_count * Buffer::size(); + return buffer_count * QMMP_BLOCK_SIZE; } diff --git a/src/qmmp/recycler.h b/src/qmmp/recycler.h index 66ab6e147..82dcb30a9 100644 --- a/src/qmmp/recycler.h +++ b/src/qmmp/recycler.h @@ -49,9 +49,8 @@ public: Buffer *next(); /*! * Returns current buffer for writing. - * @param size Buffer size. */ - Buffer *get(unsigned long size); // get next in recycle + Buffer *get(); // get next in recycle /*! * Adds current buffer to queue. */ diff --git a/src/qmmp/replaygain.cpp b/src/qmmp/replaygain.cpp index 5d7db77ad..175dc24fd 100644 --- a/src/qmmp/replaygain.cpp +++ b/src/qmmp/replaygain.cpp @@ -23,13 +23,13 @@ ReplayGain::ReplayGain() { - m_bits = 0; + m_sampleSize = 2; m_scale = 1.0; } -void ReplayGain::setSampleSize(int bits) +void ReplayGain::setSampleSize(int size) { - m_bits = bits; + m_sampleSize = size; updateScale(); } @@ -60,19 +60,19 @@ void ReplayGain::applyReplayGain(char *data, qint64 size) { if(m_settings.mode() == ReplayGainSettings::DISABLED || m_scale == 1.0) return; - size = size*8/m_bits; - if(m_bits == 16) + size = size/m_sampleSize; + if(m_sampleSize == 2) { for (qint64 i = 0; i < size; i++) ((short*)data)[i]*= m_scale; } - else if(m_bits == 8) + else if(m_sampleSize == 1) { for (qint64 i = 0; i < size; i++) ((char*)data)[i]*= m_scale; } - else if(m_bits == 32) + else if(m_sampleSize == 4) { for (qint64 i = 0; i < size; i++) ((qint32*)data)[i]*= m_scale; diff --git a/src/qmmp/replaygain.h b/src/qmmp/replaygain.h index c11679243..ed6ca25c1 100644 --- a/src/qmmp/replaygain.h +++ b/src/qmmp/replaygain.h @@ -34,14 +34,14 @@ class ReplayGain public: ReplayGain(); - void setSampleSize(int bits); + void setSampleSize(int size); void setReplayGainSettings(const ReplayGainSettings &settings); void setReplayGainInfo(const QMap &info); void applyReplayGain(char *data, qint64 size); private: void updateScale(); - int m_bits; + int m_sampleSize; QMap m_info; ReplayGainSettings m_settings; double m_scale; diff --git a/src/qmmp/visual.h b/src/qmmp/visual.h index 7f3739384..e45eac657 100644 --- a/src/qmmp/visual.h +++ b/src/qmmp/visual.h @@ -49,12 +49,11 @@ public: /*! * Adds data for visualization. * Subclass should reimplement this function. - * @param b Buffer object pointer. - * @param freq Samplerate. - * @param chan Number of channels - * @param bits Bits per sample. + * @param data Audio data. + * @param size Size of audio data. + * @param chan Number of channels. */ - virtual void add(Buffer *b, unsigned long freq, int chan, int bits) = 0; + virtual void add(unsigned char *data, qint64 size, int chan) = 0; /*! * Resets visual plugin buffers and widgets. * Subclass should reimplement this function. diff --git a/src/ui/mainvisual.cpp b/src/ui/mainvisual.cpp index 77c1f3acc..ada7291df 100644 --- a/src/ui/mainvisual.cpp +++ b/src/ui/mainvisual.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2007-2009 by Ilya Kotov * + * Copyright (C) 2007-2010 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -52,6 +52,7 @@ MainVisual::MainVisual (QWidget *parent) m_nodes.clear(); createMenu(); readSettings(); + m_buf_at = 0; m_instance = this; } @@ -97,42 +98,40 @@ void MainVisual::clear() update(); } -void MainVisual::add (Buffer *b, unsigned long w, int c, int p) +void MainVisual::add (unsigned char *data, qint64 size, int chan) { if (!m_timer->isActive () || !m_vis) return; - long len = b->nbytes, cnt; + long len = size, cnt; short *l = 0, *r = 0; - len /= c; - len /= (p / 8); + + memcpy(m_buf + m_buf_at, data, qMin(qint64(2048 - m_buf_at), size)); + m_buf_at += qMin(qint64(2048 - m_buf_at), size); + if(m_buf_at < 2048) + return; + len = m_buf_at; + len /= chan; + len /= 2; if (len > 512) len = 512; cnt = len; - if (c >= 2) + if (chan >= 2) { l = new short[len]; r = new short[len]; - - if (p == 8) - stereo16_from_stereopcm8 (l, r, b->data, cnt); - else if (p == 16) - stereo16_from_stereopcm16 (l, r, (short *) b->data, cnt); + stereo16_from_stereopcm16 (l, r, (short *) m_buf, cnt); } - else if (c == 1) + else if (chan == 1) { l = new short[len]; - - if (p == 8) - mono16_from_monopcm8 (l, b->data, cnt); - else if (p == 16) - mono16_from_monopcm16 (l, (short *) b->data, cnt); + mono16_from_monopcm16 (l, (short *) m_buf, cnt); } else len = 0; - - m_nodes.append (new VisualNode (l, r, len, w)); + m_buf_at = 0; + m_nodes.append (new VisualNode (l, r, len)); } void MainVisual::timeout() diff --git a/src/ui/mainvisual.h b/src/ui/mainvisual.h index 02fbc7fba..30fcd67ab 100644 --- a/src/ui/mainvisual.h +++ b/src/ui/mainvisual.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2007-2009 by Ilya Kotov * + * Copyright (C) 2007-2010 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -34,8 +34,8 @@ class Buffer; class VisualNode { public: - VisualNode(short *l, short *r, unsigned long n, unsigned long o) - : left(l), right(r), length(n), offset(o) + VisualNode(short *l, short *r, unsigned long n) + : left(l), right(r), length(n) { // left and right are allocated and then passed to this class // the code that allocated left and right should give up all ownership @@ -48,7 +48,7 @@ public: } short *left, *right; - long length, offset; + long length; }; class VisualBase @@ -73,7 +73,7 @@ public: static MainVisual *instance(); void setVisual(VisualBase *newvis); - void add(Buffer *, unsigned long, int, int); + void add(unsigned char *data, qint64 size, int chan); void clear(); void paintEvent(QPaintEvent *); @@ -111,6 +111,8 @@ private: QActionGroup *m_analyzerTypeGroup; QAction *m_peaksAction; QAction *m_transparentAction; + unsigned char m_buf[2048]; + int m_buf_at; int m_ratio; }; diff --git a/src/ui/shadedvisual.cpp b/src/ui/shadedvisual.cpp index d58f96fa1..fdc487c7c 100644 --- a/src/ui/shadedvisual.cpp +++ b/src/ui/shadedvisual.cpp @@ -42,43 +42,35 @@ ShadedVisual::ShadedVisual(QWidget *parent) : Visual(parent) ShadedVisual::~ShadedVisual() {} -void ShadedVisual::add(Buffer *b, unsigned long w, int c, int p) +void ShadedVisual::add(unsigned char *data, qint64 size, int chan) { if (!m_timer->isActive ()) return; - long len = b->nbytes, cnt; + long len = size, cnt; short *l = 0, *r = 0; - len /= c; - len /= ( p / 8 ); + len /= chan; + len /= 2; if ( len > 512 ) len = 512; cnt = len; - if ( c == 2 ) + if (chan == 2) { l = new short[len]; r = new short[len]; - - if ( p == 8 ) - stereo16_from_stereopcm8 ( l, r, b->data, cnt ); - else if ( p == 16 ) - stereo16_from_stereopcm16 ( l, r, ( short * ) b->data, cnt ); + stereo16_from_stereopcm16 ( l, r, (short *) data, cnt); } - else if ( c == 1 ) + else if (chan == 1) { l = new short[len]; - - if ( p == 8 ) - mono16_from_monopcm8 ( l, b->data, cnt ); - else if ( p == 16 ) - mono16_from_monopcm16 ( l, ( short * ) b->data, cnt ); + mono16_from_monopcm16 (l, (short *) data, cnt); } else len = 0; if (len) - m_nodes.append (new VisualNode (l, r, len, w)); + m_nodes.append (new VisualNode (l, r, len)); } void ShadedVisual::clear() diff --git a/src/ui/shadedvisual.h b/src/ui/shadedvisual.h index 3c1cb30db..e276b8b24 100644 --- a/src/ui/shadedvisual.h +++ b/src/ui/shadedvisual.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2007-2009 by Ilya Kotov * + * Copyright (C) 2007-2010 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -40,7 +40,7 @@ public: ~ShadedVisual(); - void add(Buffer *, unsigned long, int, int); + void add(unsigned char *data, qint64 size, int chan); void clear(); void paintEvent (QPaintEvent *); diff --git a/src/ui/translations/qmmp_cs.ts b/src/ui/translations/qmmp_cs.ts index 696fbec6e..17466ae39 100644 --- a/src/ui/translations/qmmp_cs.ts +++ b/src/ui/translations/qmmp_cs.ts @@ -821,132 +821,132 @@ MainVisual - + Visualization Mode Režim vizualizace - + Analyzer Frekvenční analýza - + Scope Osciloskop - + Off Vypnuto - + Analyzer Mode Režim analýzy - + Normal Normální - + Fire Oheň - + Vertical Lines Sloupce - + Lines Úzké - + Bars Široké - + Peaks Špičky - + Refresh Rate Obnovovací frekvence - + 50 fps 50 Hz - + 25 fps 25 Hz - + 10 fps 10 Hz - + 5 fps 5 Hz - + Analyzer Falloff Pokles analyzátoru - - + + Slowest Nejpomalejší - - + + Slow Pomalý - - + + Medium Střední - - + + Fast Rychlý - - + + Fastest Nejrychlejší - + Peaks Falloff Pokles špiček - + Background Pozadí - + Transparent Průhledné diff --git a/src/ui/translations/qmmp_de.ts b/src/ui/translations/qmmp_de.ts index e48d2987f..419aa4b70 100644 --- a/src/ui/translations/qmmp_de.ts +++ b/src/ui/translations/qmmp_de.ts @@ -821,132 +821,132 @@ MainVisual - + Visualization Mode Visualisierungsmodus - + Analyzer Analyzer - + Scope Oszilloskop - + Off Aus - + Analyzer Mode Analyzer-Modus - + Normal Normal - + Fire Feuer - + Vertical Lines Vertikale Linien - + Lines Linien - + Bars Balken - + Peaks Spitzen - + Refresh Rate Wiederholfrequenz - + 50 fps 50 fps - + 25 fps 25 fps - + 10 fps 10 fps - + 5 fps 5 fps - + Analyzer Falloff Analyzer-Abfall - - + + Slowest Sehr langsam - - + + Slow Langsam - - + + Medium Mittel - - + + Fast Schnell - - + + Fastest Sehr schnell - + Peaks Falloff Peaks-Abfall - + Background Hintergrund - + Transparent Transparent diff --git a/src/ui/translations/qmmp_it.ts b/src/ui/translations/qmmp_it.ts index e68285d9e..d255464aa 100644 --- a/src/ui/translations/qmmp_it.ts +++ b/src/ui/translations/qmmp_it.ts @@ -821,132 +821,132 @@ MainVisual - + Visualization Mode Modo visualizzazione - + Analyzer Analizzatore - + Scope Oscilloscopio - + Off Chiudi - + Analyzer Mode Modo analizzatore - + Normal Normale - + Fire Fuoco - + Vertical Lines Linee verticali - + Lines Linee - + Bars Barre - + Peaks Picchi - + Refresh Rate Velocità di aggiornamento - + 50 fps 50 fps - + 25 fps 25 fps - + 10 fps 10 fps - + 5 fps 5 fps - + Analyzer Falloff Ricaduta analizzatore - - + + Slowest Molto lenta - - + + Slow Lenta - - + + Medium Media - - + + Fast Rapida - - + + Fastest Molto veloce - + Peaks Falloff Ricadua picchi - + Background Sfondo - + Transparent Transparente diff --git a/src/ui/translations/qmmp_lt.ts b/src/ui/translations/qmmp_lt.ts index 0af708ad1..424f99be7 100644 --- a/src/ui/translations/qmmp_lt.ts +++ b/src/ui/translations/qmmp_lt.ts @@ -822,132 +822,132 @@ MainVisual - + Visualization Mode Vizualizacijos metodas - + Analyzer Analizatorius - + Scope Scope - + Off Išjungta - + Analyzer Mode Analizatoriaus metodas - + Normal Įprastinis - + Fire Ugnis - + Vertical Lines Vertikalios linijos - + Lines Linijos - + Bars Bangos - + Peaks Pikai - + Refresh Rate Atnaujinimo dažnumas - + 50 fps 50 kps - + 25 fps 25 kps - + 10 fps 10 kps - + 5 fps 5 kps - + Analyzer Falloff Analyzer Falloff - - + + Slowest Lėčiausias - - + + Slow Lėtas - - + + Medium Vidutinis - - + + Fast Greitas - - + + Fastest Greičiausias - + Peaks Falloff Peaks Falloff - + Background Fonas - + Transparent Permatomumas diff --git a/src/ui/translations/qmmp_pl_PL.ts b/src/ui/translations/qmmp_pl_PL.ts index 24fdcaf8d..85c7b2cb4 100644 --- a/src/ui/translations/qmmp_pl_PL.ts +++ b/src/ui/translations/qmmp_pl_PL.ts @@ -821,132 +821,132 @@ MainVisual - + Visualization Mode Tryb wizualizacji - + Analyzer Analizator - + Scope - + Off Wyłączone - + Analyzer Mode Tryb Analizatora - + Normal Normalny - + Fire Ogień - + Vertical Lines Pionowe Linie - + Lines Linie - + Bars Słupki - + Peaks Piki - + Refresh Rate Odświeżanie - + 50 fps - + 25 fps - + 10 fps - + 5 fps - + Analyzer Falloff Prędkość Analizatora - - + + Slowest Najwolniej - - + + Slow Wolno - - + + Medium Średnio - - + + Fast Szybko - - + + Fastest Najszybciej - + Peaks Falloff Opadanie Pików - + Background Tło - + Transparent Przezroczystość diff --git a/src/ui/translations/qmmp_pt_BR.ts b/src/ui/translations/qmmp_pt_BR.ts index 90bb1ba03..c730dd312 100644 --- a/src/ui/translations/qmmp_pt_BR.ts +++ b/src/ui/translations/qmmp_pt_BR.ts @@ -821,132 +821,132 @@ MainVisual - + Visualization Mode - + Analyzer - + Scope - + Off - + Analyzer Mode - + Normal - + Fire - + Vertical Lines - + Lines - + Bars - + Peaks - + Refresh Rate - + 50 fps - + 25 fps - + 10 fps - + 5 fps - + Analyzer Falloff + + + + Slowest + + - Slowest + Slow - Slow + Medium - Medium + Fast - Fast - - - - - Fastest - + Peaks Falloff - + Background - + Transparent diff --git a/src/ui/translations/qmmp_ru.ts b/src/ui/translations/qmmp_ru.ts index d5e9fdb5f..67e7cc15c 100644 --- a/src/ui/translations/qmmp_ru.ts +++ b/src/ui/translations/qmmp_ru.ts @@ -821,132 +821,132 @@ MainVisual - + Visualization Mode Режим визуализации - + Analyzer Анализатор - + Scope Осциллограф - + Off Выключено - + Analyzer Mode Режим анализатора - + Normal Обычный - + Fire Огонь - + Vertical Lines Вертикальные линии - + Lines Линии - + Bars Полоски - + Peaks Пики - + Refresh Rate Частота обновления - + 50 fps - + 25 fps - + 10 fps - + 5 fps - + Analyzer Falloff Падение анализатора - - + + Slowest Самое медленное - - + + Slow Медленное - - + + Medium Среднее - - + + Fast Быстрое - - + + Fastest Самое быстрое - + Peaks Falloff Падение пиков - + Background Фон - + Transparent Прозрачность diff --git a/src/ui/translations/qmmp_tr.ts b/src/ui/translations/qmmp_tr.ts index 827ea76d4..d4758b244 100644 --- a/src/ui/translations/qmmp_tr.ts +++ b/src/ui/translations/qmmp_tr.ts @@ -821,132 +821,132 @@ MainVisual - + Visualization Mode Görselleştirme Modu - + Analyzer Çözümleyici - + Scope Kapsam - + Off Kapat - + Analyzer Mode Çözümleyici Modu - + Normal Normal - + Fire Ateş - + Vertical Lines Dikey Satırlar - + Lines Satırlar - + Bars Çubuklar - + Peaks Tepeler - + Refresh Rate Tazeleme Oranı - + 50 fps 50 fps - + 25 fps 25 fps - + 10 fps 10 fps - + 5 fps 5 fps - + Analyzer Falloff Çözümleyici Düşüşü - - + + Slowest En yavaş - - + + Slow Yavaş - - + + Medium Orta - - + + Fast Hızlı - - + + Fastest En hızlı - + Peaks Falloff Tepe Düşüşü - + Background Arkaplan - + Transparent Transparan diff --git a/src/ui/translations/qmmp_uk_UA.ts b/src/ui/translations/qmmp_uk_UA.ts index 5022c1f2c..d87cb079f 100644 --- a/src/ui/translations/qmmp_uk_UA.ts +++ b/src/ui/translations/qmmp_uk_UA.ts @@ -821,132 +821,132 @@ MainVisual - + Visualization Mode Режим візуалізації - + Analyzer Аналізатор - + Scope Осцилограф - + Off Вимкнено - + Analyzer Mode Режим аналізатора - + Normal Звичайний - + Fire Вогонь - + Vertical Lines Вертикальні лінії - + Lines Лінії - + Bars Смужки - + Peaks Піки - + Refresh Rate Частота оновлення - + 50 fps 50 ф/с - + 25 fps 25 ф/с - + 10 fps 10 ф/с - + 5 fps 5 ф/с - + Analyzer Falloff Падіння аналізатора - - + + Slowest Найповільніше - - + + Slow Повільне - - + + Medium Середнє - - + + Fast Швидке - - + + Fastest Найшвидше - + Peaks Falloff Падіння піків - + Background Тло - + Transparent Прозорість diff --git a/src/ui/translations/qmmp_zh_CN.ts b/src/ui/translations/qmmp_zh_CN.ts index 27d0f1f25..de6287ef7 100644 --- a/src/ui/translations/qmmp_zh_CN.ts +++ b/src/ui/translations/qmmp_zh_CN.ts @@ -821,132 +821,132 @@ MainVisual - + Visualization Mode 可视化模式 - + Analyzer 分析器 - + Scope 示波器 - + Off 关闭 - + Analyzer Mode 分析模式 - + Normal 标准 - + Fire 火花 - + Vertical Lines 垂直线 - + Lines 线形 - + Bars 条形 - + Peaks 峰值 - + Refresh Rate 刷新率 - + 50 fps 50 fps - + 25 fps 25 fps - + 10 fps 10 fps - + 5 fps 5 fps - + Analyzer Falloff 分析器下降速度 - - + + Slowest 最慢 - - + + Slow - - + + Medium - - + + Fast - - + + Fastest 最快 - + Peaks Falloff 峰值下降速度 - + Background 背景 - + Transparent 透明 diff --git a/src/ui/translations/qmmp_zh_TW.ts b/src/ui/translations/qmmp_zh_TW.ts index 753f474f4..39344f0c1 100644 --- a/src/ui/translations/qmmp_zh_TW.ts +++ b/src/ui/translations/qmmp_zh_TW.ts @@ -821,132 +821,132 @@ MainVisual - + Visualization Mode 可視化型態 - + Analyzer 解析器 - + Scope 示波器 - + Off 關閉 - + Analyzer Mode 解析型態 - + Normal 標準 - + Fire 火花 - + Vertical Lines 垂直線 - + Lines 線形 - + Bars 條形 - + Peaks 峰值 - + Refresh Rate 刷新率 - + 50 fps 50 fps - + 25 fps 25 fps - + 10 fps 10 fps - + 5 fps 5 fps - + Analyzer Falloff 解析器下降速度 - - + + Slowest 最慢 - - + + Slow - - + + Medium - - + + Fast - - + + Fastest 最快 - + Peaks Falloff 峰值下降速度 - + Background 背景 - + Transparent 透明 -- cgit v1.2.3-13-gbd6f