From 6b48eaf5918e54b4f6cc7e9366da72ee6fe416b6 Mon Sep 17 00:00:00 2001 From: trialuser02 Date: Wed, 25 Sep 2013 12:05:06 +0000 Subject: rgscan: added album gain calculation git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@3723 90c681e8-e032-0410-971d-27865f9a5e38 --- src/plugins/General/rgscan/rgscaner.cpp | 51 +++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 18 deletions(-) (limited to 'src/plugins/General/rgscan/rgscaner.cpp') diff --git a/src/plugins/General/rgscan/rgscaner.cpp b/src/plugins/General/rgscan/rgscaner.cpp index 1fda543e0..fc46142e9 100644 --- a/src/plugins/General/rgscan/rgscaner.cpp +++ b/src/plugins/General/rgscan/rgscaner.cpp @@ -19,34 +19,41 @@ ***************************************************************************/ #include +#include #include -#include +#include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "gain_analysis.h" #include "rgscaner.h" -#define QStringToTString_qt4(s) TagLib::String(s.toUtf8().constData(), TagLib::String::UTF8) - RGScaner::RGScaner() { m_gain = 0.; m_user_stop = false; m_is_running = false; + m_handle = 0; + m_decoder = 0; + m_source = 0; } RGScaner::~RGScaner() { stop(); + if(m_handle) + { + DeinitGainAbalysis(m_handle); + m_handle = 0; + } + if(m_decoder) + { + delete m_decoder; + m_decoder = 0; + } + if(m_source) + { + delete m_source; + m_source = 0; + } } bool RGScaner::prepare(const QString &url) @@ -116,6 +123,11 @@ double RGScaner::gain() return m_gain; } +GainHandle_t *RGScaner::handle() +{ + return m_handle; +} + void RGScaner::run() { m_is_running = true; @@ -134,10 +146,13 @@ void RGScaner::run() double out_right[buf_size/4]; - GainHandle_t *handle = 0; - - InitGainAnalysis(&handle, 44100); + if(m_handle) + { + DeinitGainAbalysis(m_handle); + m_handle = 0; + } + InitGainAnalysis(&m_handle, 44100); forever { @@ -155,7 +170,7 @@ void RGScaner::run() out_left[i] = ((short *) output_buf)[i*2]; out_right[i] = ((short *) output_buf)[i*2+1]; } - AnalyzeSamples(handle, out_left, out_right, len/4, 2); + AnalyzeSamples(m_handle, out_left, out_right, len/4, 2); output_at = 0; } @@ -171,7 +186,7 @@ void RGScaner::run() m_mutex.unlock(); } - m_gain = GetTitleGain(handle); + m_gain = GetTitleGain(m_handle); qDebug("RGScaner: thread %ld finished", QThread::currentThreadId()); m_is_running = false; emit progress(100); -- cgit v1.2.3-13-gbd6f