summaryrefslogtreecommitdiffstats
path: root/src/multimedia
diff options
context:
space:
mode:
authorDavid Boddie <dboddie@trolltech.com>2010-01-06 12:45:29 (GMT)
committerDavid Boddie <dboddie@trolltech.com>2010-01-06 12:45:29 (GMT)
commita628b5579a977594cf125110589c8bd5096db380 (patch)
tree104988aaef8d19f7a24610eef50ebb9633eaa376 /src/multimedia
parent982cffb529f65c7d0c401844ef9af1925e550ffb (diff)
parente8b3defc466fff9110ee00b6e730d405cde52abc (diff)
downloadQt-a628b5579a977594cf125110589c8bd5096db380.zip
Qt-a628b5579a977594cf125110589c8bd5096db380.tar.gz
Qt-a628b5579a977594cf125110589c8bd5096db380.tar.bz2
Merge branch '4.6' of git@scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.6
Diffstat (limited to 'src/multimedia')
-rw-r--r--src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp5
-rw-r--r--src/multimedia/audio/qaudioinput_win32_p.cpp38
-rw-r--r--src/multimedia/audio/qaudiooutput_win32_p.cpp8
3 files changed, 38 insertions, 13 deletions
diff --git a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp
index 9645fa8..f58f5be 100644
--- a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp
+++ b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp
@@ -403,6 +403,7 @@ void QAudioDeviceInfoInternal::updateLists()
QList<QByteArray> QAudioDeviceInfoInternal::availableDevices(QAudio::Mode mode)
{
+ QList<QByteArray> allDevices;
QList<QByteArray> devices;
QByteArray filter;
@@ -430,6 +431,7 @@ QList<QByteArray> QAudioDeviceInfoInternal::availableDevices(QAudio::Mode mode)
if((name != NULL) && (descr != NULL) && ((io == NULL) || (io == filter))) {
QString deviceName = QLatin1String(name);
QString deviceDescription = QLatin1String(descr);
+ allDevices.append(deviceName.toLocal8Bit().constData());
if(deviceDescription.contains(QLatin1String("Default Audio Device")))
devices.append(deviceName.toLocal8Bit().constData());
}
@@ -457,6 +459,9 @@ QList<QByteArray> QAudioDeviceInfoInternal::availableDevices(QAudio::Mode mode)
if (idx > 0)
devices.append("default");
#endif
+ if (devices.size() == 0 && allDevices.size() > 0)
+ return allDevices;
+
return devices;
}
diff --git a/src/multimedia/audio/qaudioinput_win32_p.cpp b/src/multimedia/audio/qaudioinput_win32_p.cpp
index b7f9ffd..f50a547 100644
--- a/src/multimedia/audio/qaudioinput_win32_p.cpp
+++ b/src/multimedia/audio/qaudioinput_win32_p.cpp
@@ -153,6 +153,14 @@ WAVEHDR* QAudioInputPrivate::allocateBlocks(int size, int count)
void QAudioInputPrivate::freeBlocks(WAVEHDR* blockArray)
{
+ WAVEHDR* blocks = blockArray;
+
+ int count = buffer_size/period_size;
+
+ for(int i = 0; i < count; i++) {
+ waveInUnprepareHeader(hWaveIn,&blocks[i], sizeof(WAVEHDR));
+ blocks+=sizeof(WAVEHDR);
+ }
HeapFree(GetProcessHeap(), 0, blockArray);
}
@@ -222,11 +230,6 @@ bool QAudioInputPrivate::open()
} else {
period_size = buffer_size/5;
}
-#ifdef Q_OS_WINCE
- // For wince reduce size to 40ms for buffer size and 20ms period
- buffer_size = settings.frequency()*settings.channels()*(settings.sampleSize()/8)*0.04;
- period_size = buffer_size/2;
-#endif
timeStamp.restart();
elapsedTimeOffset = 0;
wfx.nSamplesPerSec = settings.frequency();
@@ -317,7 +320,7 @@ void QAudioInputPrivate::close()
deviceState = QAudio::StoppedState;
int count = 0;
- while(!finished && count < 100) {
+ while(!finished && count < 500) {
count++;
Sleep(10);
}
@@ -349,9 +352,10 @@ 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) {
+ if(waveBlocks[header].dwBytesRecorded > 0 && waveBlocks[header].dwFlags & WHDR_DONE) {
if(pullMode) {
l = audioSource->write(waveBlocks[header].lpData,
waveBlocks[header].dwBytesRecorded);
@@ -394,6 +398,9 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len)
//no data, not ready yet, next time
return 0;
}
+
+ waveInUnprepareHeader(hWaveIn,&waveBlocks[header], sizeof(WAVEHDR));
+
EnterCriticalSection(&waveInCriticalSection);
waveFreeBlockCount++;
LeaveCriticalSection(&waveInCriticalSection);
@@ -401,17 +408,22 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len)
waveBlocks[header].dwFlags = 0L;
result = waveInPrepareHeader(hWaveIn,&waveBlocks[header], sizeof(WAVEHDR));
if(result != MMSYSERR_NOERROR) {
+ result = waveInPrepareHeader(hWaveIn,&waveBlocks[header], sizeof(WAVEHDR));
qWarning("QAudioInput: failed to prepare block %d,err=%d",header,result);
- errorState = QAudio::OpenError;
- deviceState = QAudio::StoppedState;
- emit stateChanged(deviceState);
+ errorState = QAudio::IOError;
+ EnterCriticalSection(&waveInCriticalSection);
+ waveFreeBlockCount--;
+ LeaveCriticalSection(&waveInCriticalSection);
+ return 0;
}
result = waveInAddBuffer(hWaveIn, &waveBlocks[header], sizeof(WAVEHDR));
if(result != MMSYSERR_NOERROR) {
qWarning("QAudioInput: failed to setup block %d,err=%d",header,result);
- errorState = QAudio::OpenError;
- deviceState = QAudio::StoppedState;
- emit stateChanged(deviceState);
+ errorState = QAudio::IOError;
+ EnterCriticalSection(&waveInCriticalSection);
+ waveFreeBlockCount--;
+ LeaveCriticalSection(&waveInCriticalSection);
+ return 0;
}
header++;
if(header >= buffer_size/period_size)
diff --git a/src/multimedia/audio/qaudiooutput_win32_p.cpp b/src/multimedia/audio/qaudiooutput_win32_p.cpp
index 2cfc472..02c8cfe 100644
--- a/src/multimedia/audio/qaudiooutput_win32_p.cpp
+++ b/src/multimedia/audio/qaudiooutput_win32_p.cpp
@@ -147,6 +147,14 @@ WAVEHDR* QAudioOutputPrivate::allocateBlocks(int size, int count)
void QAudioOutputPrivate::freeBlocks(WAVEHDR* blockArray)
{
+ WAVEHDR* blocks = blockArray;
+
+ int count = buffer_size/period_size;
+
+ for(int i = 0; i < count; i++) {
+ waveOutUnprepareHeader(hWaveOut,&blocks[i], sizeof(WAVEHDR));
+ blocks+=sizeof(WAVEHDR);
+ }
HeapFree(GetProcessHeap(), 0, blockArray);
}