diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2017-04-18 19:56:55 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2017-04-18 19:56:55 +0000 |
| commit | e7b06c4b734a9978243751e3f44afa8b2faa21ff (patch) | |
| tree | a8407988e15eead05101bd0112f62bb4073f89cc /src/plugins/Output/waveout | |
| parent | fcd41290acbb1582f4e463ecaca868e52ec00bfb (diff) | |
| download | qmmp-e7b06c4b734a9978243751e3f44afa8b2faa21ff.tar.gz qmmp-e7b06c4b734a9978243751e3f44afa8b2faa21ff.tar.bz2 qmmp-e7b06c4b734a9978243751e3f44afa8b2faa21ff.zip | |
implemented latency() function for DirectSound and WavOut output plugins
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@7123 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/Output/waveout')
| -rw-r--r-- | src/plugins/Output/waveout/outputwaveout.cpp | 20 | ||||
| -rw-r--r-- | src/plugins/Output/waveout/outputwaveout.h | 4 | ||||
| -rw-r--r-- | src/plugins/Output/waveout/outputwaveoutfactory.cpp | 2 | ||||
| -rw-r--r-- | src/plugins/Output/waveout/outputwaveoutfactory.h | 2 |
4 files changed, 20 insertions, 8 deletions
diff --git a/src/plugins/Output/waveout/outputwaveout.cpp b/src/plugins/Output/waveout/outputwaveout.cpp index 6b26608b1..7a8b24d4b 100644 --- a/src/plugins/Output/waveout/outputwaveout.cpp +++ b/src/plugins/Output/waveout/outputwaveout.cpp @@ -1,5 +1,5 @@ /***************************************************************************
- * Copyright (C) 2009-2013 by Ilya Kotov *
+ * Copyright (C) 2009-2017 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -75,8 +75,8 @@ free_memory (void) OutputWaveOut::OutputWaveOut() : Output()
{
- //m_connection = 0;
- //m_dev = 0;
+ m_totalWritten = 0;
+ m_frameSize = 0;
}
OutputWaveOut::~OutputWaveOut()
@@ -87,6 +87,7 @@ OutputWaveOut::~OutputWaveOut() bool OutputWaveOut::initialize(quint32 freq, ChannelMap map, Qmmp::AudioFormat format)
{
Q_UNUSED(format);
+ m_totalWritten = 0;
if (!waveOutGetNumDevs ())
{
qWarning("OutputWaveOut: no audio device found");
@@ -132,14 +133,20 @@ bool OutputWaveOut::initialize(quint32 freq, ChannelMap map, Qmmp::AudioFormat f waveOutReset (dev);
InitializeCriticalSection (&cs);
configure(freq, map, Qmmp::PCM_S16LE);
-
+ m_frameSize = channels() * sampleSize();
return true;
}
qint64 OutputWaveOut::latency()
{
- return 0;
+ MMTIME mmtime;
+ mmtime.wType = TIME_SAMPLES;
+
+ if(waveOutGetPosition(dev, &mmtime, sizeof(MMTIME)) != MMSYSERR_NOERROR)
+ return 0;
+
+ return (m_totalWritten / m_frameSize - mmtime.u.sample) * 1000 / sampleRate();
}
qint64 OutputWaveOut::writeAudio(unsigned char *data, qint64 len)
@@ -194,6 +201,7 @@ qint64 OutputWaveOut::writeAudio(unsigned char *data, qint64 len) ScheduledBlocks++;
LeaveCriticalSection (&cs);
+ m_totalWritten += len;
return len;
}
@@ -220,6 +228,7 @@ void OutputWaveOut::reset() while (PlayedWaveHeadersCount > 0) // free used blocks ...
free_memory ();
waveOutReset (dev);
+ m_totalWritten = 0;
}
void OutputWaveOut::uninitialize()
@@ -239,6 +248,7 @@ void OutputWaveOut::uninitialize() }
DeleteCriticalSection (&cs);
+ m_totalWritten = 0;
return;
}
diff --git a/src/plugins/Output/waveout/outputwaveout.h b/src/plugins/Output/waveout/outputwaveout.h index 688d4ed45..18dbc7126 100644 --- a/src/plugins/Output/waveout/outputwaveout.h +++ b/src/plugins/Output/waveout/outputwaveout.h @@ -1,5 +1,5 @@ /***************************************************************************
- * Copyright (C) 2009-2014 by Ilya Kotov *
+ * Copyright (C) 2009-2017 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -49,6 +49,8 @@ private: // helper functions
void status();
void uninitialize();
+ qint64 m_totalWritten;
+ qint32 m_frameSize;
};
class VolumeWaveOut : public Volume
diff --git a/src/plugins/Output/waveout/outputwaveoutfactory.cpp b/src/plugins/Output/waveout/outputwaveoutfactory.cpp index 102d9cc21..d3861a077 100644 --- a/src/plugins/Output/waveout/outputwaveoutfactory.cpp +++ b/src/plugins/Output/waveout/outputwaveoutfactory.cpp @@ -1,5 +1,5 @@ /***************************************************************************
- * Copyright (C) 2009-2016 by Ilya Kotov *
+ * Copyright (C) 2009-2017 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
diff --git a/src/plugins/Output/waveout/outputwaveoutfactory.h b/src/plugins/Output/waveout/outputwaveoutfactory.h index f7654dbe1..82d8529a6 100644 --- a/src/plugins/Output/waveout/outputwaveoutfactory.h +++ b/src/plugins/Output/waveout/outputwaveoutfactory.h @@ -1,5 +1,5 @@ /***************************************************************************
- * Copyright (C) 2009-2014 by Ilya Kotov *
+ * Copyright (C) 2009-2017 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
|
