summaryrefslogtreecommitdiffstats
path: root/src/multimedia/audio/qaudioinput_win32_p.cpp
diff options
context:
space:
mode:
authoraxis <qt-info@nokia.com>2010-02-26 09:05:39 (GMT)
committeraxis <qt-info@nokia.com>2010-02-26 09:05:39 (GMT)
commit5e9382c018e231c5e2ef49dd8a38eaff535b9837 (patch)
tree89f13d31d5804c38999fdefd0e2aca39d305f91c /src/multimedia/audio/qaudioinput_win32_p.cpp
parent11e54877f87ff97039452f117d40ec17eefbcbff (diff)
parent53e7dda038e9251ca7380d3717709764c580192e (diff)
downloadQt-5e9382c018e231c5e2ef49dd8a38eaff535b9837.zip
Qt-5e9382c018e231c5e2ef49dd8a38eaff535b9837.tar.gz
Qt-5e9382c018e231c5e2ef49dd8a38eaff535b9837.tar.bz2
Merge branch '4.6' of scm.dev.nokia.troll.no:qt/qt-s60-public into master-s60
Conflicts: qmake/generators/symbian/initprojectdeploy_symbian.cpp qmake/generators/symbian/symmake_abld.h
Diffstat (limited to 'src/multimedia/audio/qaudioinput_win32_p.cpp')
-rw-r--r--src/multimedia/audio/qaudioinput_win32_p.cpp42
1 files changed, 26 insertions, 16 deletions
diff --git a/src/multimedia/audio/qaudioinput_win32_p.cpp b/src/multimedia/audio/qaudioinput_win32_p.cpp
index cc4fdee..594f6ca 100644
--- a/src/multimedia/audio/qaudioinput_win32_p.cpp
+++ b/src/multimedia/audio/qaudioinput_win32_p.cpp
@@ -192,9 +192,11 @@ QIODevice* QAudioInputPrivate::start(QIODevice* device)
//set to pull mode
pullMode = true;
audioSource = device;
+ deviceState = QAudio::ActiveState;
} else {
//set to push mode
pullMode = false;
+ deviceState = QAudio::IdleState;
audioSource = new InputPrivate(this);
audioSource->open(QIODevice::ReadOnly | QIODevice::Unbuffered);
}
@@ -311,7 +313,6 @@ bool QAudioInputPrivate::open()
elapsedTimeOffset = 0;
totalTimeValue = 0;
errorState = QAudio::NoError;
- deviceState = QAudio::ActiveState;
return true;
}
@@ -320,9 +321,9 @@ void QAudioInputPrivate::close()
if(deviceState == QAudio::StoppedState)
return;
+ deviceState = QAudio::StoppedState;
waveInReset(hWaveIn);
waveInClose(hWaveIn);
- deviceState = QAudio::StoppedState;
int count = 0;
while(!finished && count < 500) {
@@ -357,7 +358,6 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len)
char* p = data;
qint64 l = 0;
qint64 written = 0;
-
while(!done) {
// Read in some audio data
if(waveBlocks[header].dwBytesRecorded > 0 && waveBlocks[header].dwFlags & WHDR_DONE) {
@@ -378,11 +378,12 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len)
errorState = QAudio::IOError;
} else {
- totalTimeValue += waveBlocks[header].dwBytesRecorded
- /((settings.channels()*settings.sampleSize()/8))
- *10000/settings.frequency()*100;
+ totalTimeValue += waveBlocks[header].dwBytesRecorded;
errorState = QAudio::NoError;
- deviceState = QAudio::ActiveState;
+ if (deviceState != QAudio::ActiveState) {
+ deviceState = QAudio::ActiveState;
+ emit stateChanged(deviceState);
+ }
resuming = false;
}
} else {
@@ -392,16 +393,17 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len)
#ifdef DEBUG_AUDIO
qDebug()<<"IN: "<<waveBlocks[header].dwBytesRecorded<<", OUT: "<<l;
#endif
- totalTimeValue += waveBlocks[header].dwBytesRecorded
- /((settings.channels()*settings.sampleSize()/8))
- *10000/settings.frequency()*100;
+ totalTimeValue += waveBlocks[header].dwBytesRecorded;
errorState = QAudio::NoError;
- deviceState = QAudio::ActiveState;
+ if (deviceState != QAudio::ActiveState) {
+ deviceState = QAudio::ActiveState;
+ emit stateChanged(deviceState);
+ }
resuming = false;
}
} else {
//no data, not ready yet, next time
- return 0;
+ break;
}
waveInUnprepareHeader(hWaveIn,&waveBlocks[header], sizeof(WAVEHDR));
@@ -510,7 +512,13 @@ int QAudioInputPrivate::notifyInterval() const
qint64 QAudioInputPrivate::processedUSecs() const
{
- return totalTimeValue;
+ if (deviceState == QAudio::StoppedState)
+ return 0;
+ qint64 result = qint64(1000000) * totalTimeValue /
+ (settings.channels()*(settings.sampleSize()/8)) /
+ settings.frequency();
+
+ return result;
}
void QAudioInputPrivate::suspend()
@@ -540,6 +548,9 @@ bool QAudioInputPrivate::deviceReady()
QTime now(QTime::currentTime());
qDebug()<<now.second()<<"s "<<now.msec()<<"ms :deviceReady() INPUT";
#endif
+ if(deviceState != QAudio::ActiveState && deviceState != QAudio::IdleState)
+ return true;
+
if(pullMode) {
// reads some audio data and writes it to QIODevice
read(0,0);
@@ -548,8 +559,6 @@ bool QAudioInputPrivate::deviceReady()
InputPrivate* a = qobject_cast<InputPrivate*>(audioSource);
a->trigger();
}
- if(deviceState != QAudio::ActiveState)
- return true;
if((timeStamp.elapsed() + elapsedTimeOffset) > intervalTime) {
emit notify();
@@ -582,7 +591,8 @@ InputPrivate::~InputPrivate() {}
qint64 InputPrivate::readData( char* data, qint64 len)
{
// push mode, user read() called
- if(audioDevice->deviceState != QAudio::ActiveState)
+ if(audioDevice->deviceState != QAudio::ActiveState &&
+ audioDevice->deviceState != QAudio::IdleState)
return 0;
// Read in some audio data
return audioDevice->read(data,len);