diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2015-12-24 19:35:07 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2015-12-24 19:35:07 +0000 |
| commit | bd33abb2785feba43cf9a950fbaec37a5daa1f0b (patch) | |
| tree | 278cf073730e165b4d70766fc1e8ddfb1edc04df | |
| parent | 0da14774695aabfb6842ca5dd0a7303bafa0e34d (diff) | |
| download | qmmp-bd33abb2785feba43cf9a950fbaec37a5daa1f0b.tar.gz qmmp-bd33abb2785feba43cf9a950fbaec37a5daa1f0b.tar.bz2 qmmp-bd33abb2785feba43cf9a950fbaec37a5daa1f0b.zip | |
refactoring
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@5880 90c681e8-e032-0410-971d-27865f9a5e38
| -rw-r--r-- | src/qmmp/qmmpaudioengine.cpp | 18 | ||||
| -rw-r--r-- | src/qmmp/recycler.cpp | 16 | ||||
| -rw-r--r-- | src/qmmp/recycler_p.h | 6 |
3 files changed, 20 insertions, 20 deletions
diff --git a/src/qmmp/qmmpaudioengine.cpp b/src/qmmp/qmmpaudioengine.cpp index f490958fb..089a64891 100644 --- a/src/qmmp/qmmpaudioengine.cpp +++ b/src/qmmp/qmmpaudioengine.cpp @@ -297,12 +297,13 @@ void QmmpAudioEngine::stop() qint64 QmmpAudioEngine::produceSound(unsigned char *data, qint64 size, quint32 brate) { Buffer *b = m_output->recycler()->get(); - //uint sz = size < m_bks ? size : m_bks; - size_t samples = qMin(m_bks / sizeof(float), (uint)size / m_ap.sampleSize()); - size_t in_size = samples * m_ap.sampleSize(); + size_t sz = size < m_bks ? size : m_bks; + size_t samples = sz / m_ap.sampleSize(); - m_converter->toFloat(data, b->data, samples); + //size_t samples = qMin(m_bks / sizeof(float), (uint)size / m_ap.sampleSize()); + //size_t in_size = samples * m_ap.sampleSize(); + m_converter->toFloat(data, b->data, samples); //m_replayGain->applyReplayGain(data, sz); //memcpy(b->data, data, sz); @@ -312,10 +313,9 @@ qint64 QmmpAudioEngine::produceSound(unsigned char *data, qint64 size, quint32 b { effect->applyEffect(b); }*/ - size -= in_size; - memmove(data, data + in_size, size); + memmove(data, data + sz, size - sz); m_output->recycler()->add(); - return in_size; + return sz; } void QmmpAudioEngine::finish() @@ -603,8 +603,8 @@ OutputWriter *QmmpAudioEngine::createOutput() if(m_output_buf) delete [] m_output_buf; - m_bks = output->recycler()->blockSize(); - m_output_size = m_bks * 4 * m_ap.sampleSize(); + m_bks = output->recycler()->blockSamples() * m_ap.sampleSize(); + m_output_size = m_bks * 4; m_output_buf = new unsigned char[m_output_size]; return output; } diff --git a/src/qmmp/recycler.cpp b/src/qmmp/recycler.cpp index ef92253b8..a5aaf835c 100644 --- a/src/qmmp/recycler.cpp +++ b/src/qmmp/recycler.cpp @@ -16,7 +16,7 @@ Recycler::Recycler () m_current_count = 0; m_buffer_count = 0; m_blocked = 0; - m_block_size = 0; + m_block_samples = 0; m_buffers = 0; } @@ -36,7 +36,7 @@ void Recycler::configure(quint32 freq, int chan) { size_t block_size = chan * QMMP_BLOCK_FRAMES; unsigned int buffer_count = freq * QmmpSettings::instance()->bufferSize() / 1000 / QMMP_BLOCK_FRAMES; - if(block_size == m_block_size && buffer_count == m_buffer_count) + if(block_size == m_block_samples && buffer_count == m_buffer_count) return; for (unsigned int i = 0; i < m_buffer_count; i++) @@ -50,7 +50,7 @@ void Recycler::configure(quint32 freq, int chan) m_done_index = 0; m_current_count = 0; m_blocked = 0; - m_block_size = block_size; + m_block_samples = block_size; m_buffer_count = buffer_count; @@ -61,7 +61,7 @@ void Recycler::configure(quint32 freq, int chan) for (unsigned int i = 0; i < m_buffer_count; i++) { - m_buffers[i] = new Buffer(m_block_size); + m_buffers[i] = new Buffer(m_block_samples); } } @@ -134,12 +134,12 @@ void Recycler::clear() m_done_index = 0; } -size_t Recycler::size() const +size_t Recycler::samples() const { - return m_buffer_count * m_block_size; + return m_buffer_count * m_block_samples; } -size_t Recycler::blockSize() const +size_t Recycler::blockSamples() const { - return m_block_size; + return m_block_samples; } diff --git a/src/qmmp/recycler_p.h b/src/qmmp/recycler_p.h index 6cf75bad4..5ed56a327 100644 --- a/src/qmmp/recycler_p.h +++ b/src/qmmp/recycler_p.h @@ -72,11 +72,11 @@ public: /*! * Returns size of all buffers in samples. */ - size_t size() const; // size in samples + size_t samples() const; // size in samples /*! * Returns block size in samples. */ - size_t blockSize() const; // size in samples + size_t blockSamples() const; // size in samples /*! * Returns mutex pointer. @@ -99,7 +99,7 @@ public: private: unsigned int m_buffer_count, m_add_index, m_done_index, m_current_count; - size_t m_block_size; + size_t m_block_samples; Buffer **m_buffers; QMutex m_mtx; QWaitCondition m_cnd; |
