aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/Effect/srconverter/srconverter.cpp
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2010-01-16 15:33:17 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2010-01-16 15:33:17 +0000
commit435f1da1de18bafe57e43e47fd8a6fc69fd8bab7 (patch)
treee332293971b3b3883685b79c62bcd50bf2f49c12 /src/plugins/Effect/srconverter/srconverter.cpp
parent2fa169a585994ceb40db55405f46783d06820947 (diff)
downloadqmmp-435f1da1de18bafe57e43e47fd8a6fc69fd8bab7.tar.gz
qmmp-435f1da1de18bafe57e43e47fd8a6fc69fd8bab7.tar.bz2
qmmp-435f1da1de18bafe57e43e47fd8a6fc69fd8bab7.zip
updated audio engine
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@1503 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/Effect/srconverter/srconverter.cpp')
-rw-r--r--src/plugins/Effect/srconverter/srconverter.cpp39
1 files changed, 20 insertions, 19 deletions
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()