aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/plugins/Output/directsound/outputdirectsound.cpp10
-rw-r--r--src/plugins/Output/directsound/outputdirectsound.h4
-rw-r--r--src/plugins/Output/directsound/outputdirectsoundfactory.cpp2
-rw-r--r--src/plugins/Output/directsound/outputdirectsoundfactory.h2
-rw-r--r--src/plugins/Output/waveout/outputwaveout.cpp20
-rw-r--r--src/plugins/Output/waveout/outputwaveout.h4
-rw-r--r--src/plugins/Output/waveout/outputwaveoutfactory.cpp2
-rw-r--r--src/plugins/Output/waveout/outputwaveoutfactory.h2
8 files changed, 33 insertions, 13 deletions
diff --git a/src/plugins/Output/directsound/outputdirectsound.cpp b/src/plugins/Output/directsound/outputdirectsound.cpp
index bd9281ca3..2d84ad5ba 100644
--- a/src/plugins/Output/directsound/outputdirectsound.cpp
+++ b/src/plugins/Output/directsound/outputdirectsound.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2014-2016 by Ilya Kotov *
+ * Copyright (C) 2014-2017 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -50,6 +50,8 @@ OutputDirectSound::OutputDirectSound() : Output()
m_primaryBuffer = 0;
m_dsBuffer = 0;
m_dsBufferAt = 0;
+ m_latency = 0;
+ m_bytesPerSecond = 0;
instance = this;
}
@@ -61,8 +63,10 @@ OutputDirectSound::~OutputDirectSound()
bool OutputDirectSound::initialize(quint32 freq, ChannelMap map, Qmmp::AudioFormat format)
{
+ m_latency = 0;
DSBUFFERDESC bufferDesc;
+
HRESULT result = DirectSoundCreate8(0, &m_ds, 0);
if(result != DS_OK)
{
@@ -178,13 +182,14 @@ bool OutputDirectSound::initialize(quint32 freq, ChannelMap map, Qmmp::AudioForm
configure(freq, out_map, format);
if(volumeControl)
volumeControl->restore();
+ m_bytesPerSecond = (sampleRate() * sampleSize() * channels());
return true;
}
qint64 OutputDirectSound::latency()
{
- return 0;
+ return m_latency;
}
qint64 OutputDirectSound::writeAudio(unsigned char *data, qint64 len)
@@ -193,6 +198,7 @@ qint64 OutputDirectSound::writeAudio(unsigned char *data, qint64 len)
DWORD size = 0, size2 = 0;
DWORD available = bytesToWrite(); //available bytes
+ m_latency = (DS_BUFSIZE - available) * 1000 / m_bytesPerSecond;
if(available < 128)
{
usleep(5000);
diff --git a/src/plugins/Output/directsound/outputdirectsound.h b/src/plugins/Output/directsound/outputdirectsound.h
index 46d2a0b21..295073a18 100644
--- a/src/plugins/Output/directsound/outputdirectsound.h
+++ b/src/plugins/Output/directsound/outputdirectsound.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2014-2016 by Ilya Kotov *
+ * Copyright (C) 2014-2017 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -74,6 +74,8 @@ private:
} DSoundChannels;
static DSoundChannels m_dsound_pos[10];
+ qint64 m_latency;
+ qint32 m_bytesPerSecond;
};
/**
diff --git a/src/plugins/Output/directsound/outputdirectsoundfactory.cpp b/src/plugins/Output/directsound/outputdirectsoundfactory.cpp
index d0287ad40..d62b45543 100644
--- a/src/plugins/Output/directsound/outputdirectsoundfactory.cpp
+++ b/src/plugins/Output/directsound/outputdirectsoundfactory.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2014-2016 by Ilya Kotov *
+ * Copyright (C) 2014-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/directsound/outputdirectsoundfactory.h b/src/plugins/Output/directsound/outputdirectsoundfactory.h
index c2e23b697..f244789ec 100644
--- a/src/plugins/Output/directsound/outputdirectsoundfactory.h
+++ b/src/plugins/Output/directsound/outputdirectsoundfactory.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2014 by Ilya Kotov *
+ * Copyright (C) 2014-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/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 *