diff options
| -rw-r--r-- | src/plugins/Output/alsa/outputalsa.cpp | 10 | ||||
| -rw-r--r-- | src/qmmp/output.cpp | 17 | ||||
| -rw-r--r-- | src/qmmp/output.h | 3 |
3 files changed, 20 insertions, 10 deletions
diff --git a/src/plugins/Output/alsa/outputalsa.cpp b/src/plugins/Output/alsa/outputalsa.cpp index 5974efa06..63922ead1 100644 --- a/src/plugins/Output/alsa/outputalsa.cpp +++ b/src/plugins/Output/alsa/outputalsa.cpp @@ -222,15 +222,7 @@ bool OutputALSA::initialize() qint64 OutputALSA::latency() { - long used = 0; - - /*if (! m_pause) - { - if (ioctl(audio_fd, SNDCTL_DSP_GETODELAY, &used) == -1) - used = 0; - }*/ - - return used; + return m_prebuf_fill * 8000 / sampleRate() / numChannels() / sampleSize(); } qint64 OutputALSA::writeAudio(unsigned char *data, qint64 maxSize) diff --git a/src/qmmp/output.cpp b/src/qmmp/output.cpp index c5ad809f7..90591baf7 100644 --- a/src/qmmp/output.cpp +++ b/src/qmmp/output.cpp @@ -76,6 +76,21 @@ void Output::setStateHandler(StateHandler *handler) m_handler = handler; } +quint32 Output::sampleRate() +{ + return m_frequency; +} + +int Output::numChannels() +{ + return m_channels; +} + +int Output::sampleSize() +{ + return m_precision; +} + Output::~Output() {} @@ -190,7 +205,7 @@ void Output::run() void Output::status() { - qint64 ct = (m_totalWritten - latency()) / m_bytesPerMillisecond; + qint64 ct = m_totalWritten / m_bytesPerMillisecond - latency(); if (ct < 0) ct = 0; diff --git a/src/qmmp/output.h b/src/qmmp/output.h index d50be846d..24056adbd 100644 --- a/src/qmmp/output.h +++ b/src/qmmp/output.h @@ -45,6 +45,9 @@ public: Recycler *recycler(); QMutex *mutex(); void setStateHandler(StateHandler *handler); + quint32 sampleRate(); + int numChannels(); + int sampleSize(); static void registerFactory(OutputFactory *); static Output *create(QObject *); |
