diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/qmmp/buffer.h | 2 | ||||
| -rw-r--r-- | src/qmmp/output.cpp | 6 | ||||
| -rw-r--r-- | src/qmmp/output.h | 4 | ||||
| -rw-r--r-- | src/qmmp/qmmpaudioengine.cpp | 5 | ||||
| -rw-r--r-- | src/qmmp/recycler.cpp | 9 | ||||
| -rw-r--r-- | src/qmmp/statehandler.cpp | 2 |
6 files changed, 15 insertions, 13 deletions
diff --git a/src/qmmp/buffer.h b/src/qmmp/buffer.h index 7104f8dff..910615f1f 100644 --- a/src/qmmp/buffer.h +++ b/src/qmmp/buffer.h @@ -8,7 +8,7 @@ #define __buffer_h #define QMMP_BLOCK_SIZE (2048*6) //512*4*6 -#define QMMP_BUFFER_SIZE (QMMP_BLOCK_SIZE*64) +#define QMMP_BUFFER_SIZE (QMMP_BLOCK_SIZE*32) /*! @brief Audio buffer class. * @author Brad Hughes <bhughes@trolltech.com> diff --git a/src/qmmp/output.cpp b/src/qmmp/output.cpp index c859a928a..b81f2d708 100644 --- a/src/qmmp/output.cpp +++ b/src/qmmp/output.cpp @@ -39,7 +39,7 @@ static inline void s32_to_s16(qint32 *in, qint16 *out, qint64 samples) return; } -Output::Output (QObject* parent) : QThread (parent), m_recycler (stackSize()) +Output::Output (QObject* parent) : QThread (parent), m_recycler (QMMP_BUFFER_SIZE) { m_handler = StateHandler::instance(); m_frequency = 0; @@ -113,11 +113,11 @@ qint64 Output::written() return m_totalWritten; } -void Output::seek(qint64 pos) +void Output::seek(qint64 pos, bool reset) { m_totalWritten = pos * m_bytesPerMillisecond; m_currentMilliseconds = -1; - m_skip = isRunning(); + m_skip = isRunning() && reset; } Recycler *Output::recycler() diff --git a/src/qmmp/output.h b/src/qmmp/output.h index c12aed0e4..088de8779 100644 --- a/src/qmmp/output.h +++ b/src/qmmp/output.h @@ -77,8 +77,10 @@ public: qint64 written(); /*! * Requests a seek to the time \b pos indicated, specified in milliseconds. + * If \b reset is \b true, this function also clears internal output buffers for faster seeking; + * otherwise does nothing with buffers. */ - void seek(qint64 pos); + void seek(qint64 pos, bool reset = false); /*! * Returns Recycler pointer. */ diff --git a/src/qmmp/qmmpaudioengine.cpp b/src/qmmp/qmmpaudioengine.cpp index 4f34dd79e..03baaed0c 100644 --- a/src/qmmp/qmmpaudioengine.cpp +++ b/src/qmmp/qmmpaudioengine.cpp @@ -205,7 +205,7 @@ void QmmpAudioEngine::seek(qint64 time) if (m_output && m_output->isRunning()) { m_output->mutex()->lock (); - m_output->seek(time); + m_output->seek(time, true); m_output->mutex()->unlock(); if (isRunning()) { @@ -299,12 +299,11 @@ qint64 QmmpAudioEngine::produceSound(char *data, qint64 size, quint32 brate, int { effect->applyEffect(b); } - m_output->recycler()->add(); - if (m_useEq) iir((void*) b->data, b->nbytes, chan); size -= sz; memmove(data, data + sz, size); + m_output->recycler()->add(); return sz; } diff --git a/src/qmmp/recycler.cpp b/src/qmmp/recycler.cpp index 299d30840..cfaf52fb0 100644 --- a/src/qmmp/recycler.cpp +++ b/src/qmmp/recycler.cpp @@ -12,9 +12,7 @@ Recycler::Recycler (unsigned int sz) { buffer_count = sz / QMMP_BLOCK_SIZE; if (buffer_count < 4) - { buffer_count = 4; - } buffers = new Buffer*[buffer_count]; @@ -76,8 +74,11 @@ Buffer *Recycler::get() void Recycler::add() { - add_index = ++add_index % buffer_count; - current_count++; + if(buffers[add_index]->nbytes) + { + add_index = ++add_index % buffer_count; + current_count++; + } } Buffer *Recycler::next() diff --git a/src/qmmp/statehandler.cpp b/src/qmmp/statehandler.cpp index 329d66461..ce7c1df32 100644 --- a/src/qmmp/statehandler.cpp +++ b/src/qmmp/statehandler.cpp @@ -24,7 +24,7 @@ #include "statehandler.h" #define TICK_INTERVAL 250 -#define PREFINISH_TIME 6000 +#define PREFINISH_TIME 11000 StateHandler* StateHandler::m_instance = 0; |
