summaryrefslogtreecommitdiffstats
path: root/src/multimedia/audio/qaudiooutput_win32_p.cpp
diff options
context:
space:
mode:
authorKurt Korbatits <kurt.korbatits@nokia.com>2009-09-30 04:53:37 (GMT)
committerKurt Korbatits <kurt.korbatits@nokia.com>2009-09-30 04:53:37 (GMT)
commitf4bcf5c9fd51ed1923239ea1ad0d78bcd3d56f62 (patch)
treee149c3d355882cec80031b7bc0927ee1a9375809 /src/multimedia/audio/qaudiooutput_win32_p.cpp
parent8c3bf71e6fcbcfb21b9574e25cfdb00614a0c68d (diff)
downloadQt-f4bcf5c9fd51ed1923239ea1ad0d78bcd3d56f62.zip
Qt-f4bcf5c9fd51ed1923239ea1ad0d78bcd3d56f62.tar.gz
Qt-f4bcf5c9fd51ed1923239ea1ad0d78bcd3d56f62.tar.bz2
Fixed error in notify() signal and totalTime() in QAudioInput and
QAudioOutput. -The notify() signal was not firing the correct number of times. -The totalTime() on wince was incorrect (unit test). Reviewed-by:Justin McPherson
Diffstat (limited to 'src/multimedia/audio/qaudiooutput_win32_p.cpp')
-rw-r--r--src/multimedia/audio/qaudiooutput_win32_p.cpp33
1 files changed, 28 insertions, 5 deletions
diff --git a/src/multimedia/audio/qaudiooutput_win32_p.cpp b/src/multimedia/audio/qaudiooutput_win32_p.cpp
index aea3a3f..bb61f41 100644
--- a/src/multimedia/audio/qaudiooutput_win32_p.cpp
+++ b/src/multimedia/audio/qaudiooutput_win32_p.cpp
@@ -58,6 +58,8 @@ QT_BEGIN_NAMESPACE
static CRITICAL_SECTION waveOutCriticalSection;
+static const int minimumIntervalTime = 50;
+
QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray &device, const QAudioFormat& audioFormat):
settings(audioFormat)
{
@@ -221,6 +223,7 @@ bool QAudioOutputPrivate::open()
audioBuffer = new char[buffer_size];
timeStamp.restart();
+ elapsedTimeOffset = 0;
wfx.nSamplesPerSec = settings.frequency();
wfx.wBitsPerSample = settings.sampleSize();
@@ -261,6 +264,7 @@ bool QAudioOutputPrivate::open()
totalTimeValue = 0;
timeStampOpened.restart();
+ elapsedTimeOffset = 0;
errorState = QAudio::NoError;
if(pullMode) {
@@ -316,7 +320,10 @@ int QAudioOutputPrivate::bufferSize() const
void QAudioOutputPrivate::setNotifyInterval(int ms)
{
- intervalTime = ms;
+ if(ms >= minimumIntervalTime)
+ intervalTime = ms;
+ else
+ intervalTime = minimumIntervalTime;
}
int QAudioOutputPrivate::notifyInterval() const
@@ -420,7 +427,6 @@ void QAudioOutputPrivate::feedback()
bool QAudioOutputPrivate::deviceReady()
{
if(pullMode) {
- int i = 0;
int chunks = bytesAvailable/period_size;
#ifdef DEBUG_AUDIO
qDebug()<<"deviceReady() avail="<<bytesAvailable<<" bytes, period size="<<period_size<<" bytes";
@@ -430,6 +436,22 @@ bool QAudioOutputPrivate::deviceReady()
if(totalTimeValue == 0)
startup = true;
+ bool full=false;
+ EnterCriticalSection(&waveOutCriticalSection);
+ if(waveFreeBlockCount==0) full = true;
+ LeaveCriticalSection(&waveOutCriticalSection);
+ if (full){
+#ifdef DEBUG_AUDIO
+ qDebug() << "Skipping data as unable to write";
+#endif
+ if((timeStamp.elapsed() + elapsedTimeOffset) > intervalTime ) {
+ emit notify();
+ elapsedTimeOffset = timeStamp.elapsed() + elapsedTimeOffset - intervalTime;
+ timeStamp.restart();
+ }
+ return true;
+ }
+
if(startup)
waveOutPause(hWaveOut);
int input = period_size*chunks;
@@ -451,7 +473,7 @@ bool QAudioOutputPrivate::deviceReady()
}
LeaveCriticalSection(&waveOutCriticalSection);
- } else if(i < 0) {
+ } else if(l < 0) {
bytesAvailable = bytesFree();
errorState = QAudio::IOError;
}
@@ -459,8 +481,9 @@ bool QAudioOutputPrivate::deviceReady()
if(deviceState != QAudio::ActiveState)
return true;
- if(timeStamp.elapsed() > intervalTime && intervalTime > 50) {
+ if((timeStamp.elapsed() + elapsedTimeOffset) > intervalTime) {
emit notify();
+ elapsedTimeOffset = timeStamp.elapsed() + elapsedTimeOffset - intervalTime;
timeStamp.restart();
}
@@ -468,7 +491,7 @@ bool QAudioOutputPrivate::deviceReady()
}
qint64 QAudioOutputPrivate::clock() const
-{
+{
if(deviceState != QAudio::ActiveState)
return 0;