diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2009-12-18 13:09:02 +0100 |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2009-12-18 13:09:02 +0100 |
commit | 99e1dc904eab4b38c90803f13d73f90b9c048920 (patch) | |
tree | 84967abb98484d1e0de51ebe58b821d220aac5ac | |
parent | b3e3e9c917786288858eb8b33aa8fe7fa390091c (diff) | |
parent | a4550c49e982aa0218ab7097b814678505f8482c (diff) | |
download | qt4-tools-99e1dc904eab4b38c90803f13d73f90b9c048920.tar.gz |
Merge branch '4.6' of scm.dev.nokia.troll.no:qt/qt-multimedia-team into 4.6-integration
* '4.6' of scm.dev.nokia.troll.no:qt/qt-multimedia-team:
Check if the scene exists before attempting to set its focus item.
The "audioinput" multimedia example locks up the audio input/output
no audiodevices found using QAudioDeviceInfo::availableDevices on Ubuntu
-rw-r--r-- | src/gui/graphicsview/qgraphicsitem.cpp | 2 | ||||
-rw-r--r-- | src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp | 5 | ||||
-rw-r--r-- | src/multimedia/audio/qaudioinput_win32_p.cpp | 38 | ||||
-rw-r--r-- | src/multimedia/audio/qaudiooutput_win32_p.cpp | 8 |
4 files changed, 39 insertions, 14 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index fbfd8e6c10..726d57197c 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -2181,7 +2181,7 @@ void QGraphicsItemPrivate::setVisibleHelper(bool newVisible, bool explicitly, bo } // Enable subfocus - if (newVisible) { + if (scene && newVisible) { QGraphicsItem *p = parent; bool done = false; while (p) { diff --git a/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_alsa_p.cpp index 9645fa8e61..f58f5be66c 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 b7f9ffd823..f50a5473e1 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 2cfc472d65..02c8cfe046 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); } |