summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp74
-rw-r--r--src/multimedia/audio/qaudioinput_win32_p.cpp14
-rw-r--r--src/multimedia/audio/qaudioinput_win32_p.h2
-rw-r--r--src/multimedia/audio/qaudiooutput_win32_p.cpp8
-rw-r--r--src/multimedia/audio/qaudiooutput_win32_p.h2
5 files changed, 76 insertions, 24 deletions
diff --git a/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp
index f6b8154..465bc98 100644
--- a/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp
+++ b/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp
@@ -78,6 +78,8 @@ QAudioDeviceInfoInternal::QAudioDeviceInfoInternal(QByteArray dev, QAudio::Mode
{
device = QLatin1String(dev);
this->mode = mode;
+
+ updateLists();
}
QAudioDeviceInfoInternal::~QAudioDeviceInfoInternal()
@@ -176,22 +178,70 @@ bool QAudioDeviceInfoInternal::testSettings(const QAudioFormat& format) const
// See if what is in settings will work (return value).
bool failed = false;
+ bool match = false;
- // For now, just accept only audio/pcm codec
- if(!format.codec().startsWith(QLatin1String("audio/pcm")))
- failed = true;
+ // check codec
+ for( int i = 0; i < codecz.count(); i++) {
+ if (format.codec() == codecz.at(i))
+ match = true;
+ }
+ if (!match) failed = true;
+
+ // check channel
+ match = false;
+ if (!failed) {
+ for( int i = 0; i < channelz.count(); i++) {
+ if (format.channels() == channelz.at(i)) {
+ match = true;
+ break;
+ }
+ }
+ }
+ if (!match) failed = true;
+
+ // check frequency
+ match = false;
+ if (!failed) {
+ for( int i = 0; i < freqz.count(); i++) {
+ if (format.frequency() == freqz.at(i)) {
+ match = true;
+ break;
+ }
+ }
+ }
- if(!failed && !(format.channels() == 1 || format.channels() == 2))
- failed = true;
+ // check sample size
+ match = false;
+ if (!failed) {
+ for( int i = 0; i < sizez.count(); i++) {
+ if (format.sampleSize() == sizez.at(i)) {
+ match = true;
+ break;
+ }
+ }
+ }
- if(!failed) {
- if(!(format.frequency() == 8000 || format.frequency() == 11025 || format.frequency() == 22050 ||
- format.frequency() == 44100 || format.frequency() == 48000 || format.frequency() == 96000))
- failed = true;
+ // check byte order
+ match = false;
+ if (!failed) {
+ for( int i = 0; i < byteOrderz.count(); i++) {
+ if (format.byteOrder() == byteOrderz.at(i)) {
+ match = true;
+ break;
+ }
+ }
}
- if(!failed && !(format.sampleSize() == 8 || format.sampleSize() == 16))
- failed = true;
+ // check sample type
+ match = false;
+ if (!failed) {
+ for( int i = 0; i < typez.count(); i++) {
+ if (format.sampleType() == typez.at(i)) {
+ match = true;
+ break;
+ }
+ }
+ }
if(!failed) {
// settings work
@@ -332,6 +382,8 @@ void QAudioDeviceInfoInternal::updateLists()
codecz.append(QLatin1String("audio/pcm"));
}
+ if (freqz.count() > 0)
+ freqz.prepend(8000);
}
QList<QByteArray> QAudioDeviceInfoInternal::availableDevices(QAudio::Mode mode)
diff --git a/src/multimedia/audio/qaudioinput_win32_p.cpp b/src/multimedia/audio/qaudioinput_win32_p.cpp
index ec0359a..df469d7 100644
--- a/src/multimedia/audio/qaudioinput_win32_p.cpp
+++ b/src/multimedia/audio/qaudioinput_win32_p.cpp
@@ -57,8 +57,6 @@ QT_BEGIN_NAMESPACE
//#define DEBUG_AUDIO 1
-static CRITICAL_SECTION waveInCriticalSection;
-
static const int minimumIntervalTime = 50;
QAudioInputPrivate::QAudioInputPrivate(const QByteArray &device, const QAudioFormat& audioFormat):
@@ -104,16 +102,16 @@ void CALLBACK QAudioInputPrivate::waveInProc( HWAVEIN hWaveIn, UINT uMsg,
case WIM_OPEN:
break;
case WIM_DATA:
- EnterCriticalSection(&waveInCriticalSection);
+ EnterCriticalSection(&qAudio->waveInCriticalSection);
if(qAudio->waveFreeBlockCount > 0)
qAudio->waveFreeBlockCount--;
qAudio->feedback();
- LeaveCriticalSection(&waveInCriticalSection);
+ LeaveCriticalSection(&qAudio->waveInCriticalSection);
break;
case WIM_CLOSE:
- EnterCriticalSection(&waveInCriticalSection);
+ EnterCriticalSection(&qAudio->waveInCriticalSection);
qAudio->finished = true;
- LeaveCriticalSection(&waveInCriticalSection);
+ LeaveCriticalSection(&qAudio->waveInCriticalSection);
break;
default:
return;
@@ -226,8 +224,8 @@ bool QAudioInputPrivate::open()
#endif
header = 0;
if(buffer_size == 0) {
- // Default buffer size, 100ms, default period size is 20ms
- buffer_size = settings.frequency()*settings.channels()*(settings.sampleSize()/8)*0.1;
+ // Default buffer size, 200ms, default period size is 40ms
+ buffer_size = settings.frequency()*settings.channels()*(settings.sampleSize()/8)*0.2;
period_size = buffer_size/5;
} else {
period_size = buffer_size/5;
diff --git a/src/multimedia/audio/qaudioinput_win32_p.h b/src/multimedia/audio/qaudioinput_win32_p.h
index d555eff..a12c75e 100644
--- a/src/multimedia/audio/qaudioinput_win32_p.h
+++ b/src/multimedia/audio/qaudioinput_win32_p.h
@@ -122,6 +122,8 @@ private:
volatile int waveFreeBlockCount;
int waveCurrentBlock;
+ CRITICAL_SECTION waveInCriticalSection;
+
static void CALLBACK waveInProc( HWAVEIN hWaveIn, UINT uMsg,
DWORD dwInstance, DWORD dwParam1, DWORD dwParam2 );
diff --git a/src/multimedia/audio/qaudiooutput_win32_p.cpp b/src/multimedia/audio/qaudiooutput_win32_p.cpp
index f3ba079..e818723 100644
--- a/src/multimedia/audio/qaudiooutput_win32_p.cpp
+++ b/src/multimedia/audio/qaudiooutput_win32_p.cpp
@@ -56,8 +56,6 @@
QT_BEGIN_NAMESPACE
-static CRITICAL_SECTION waveOutCriticalSection;
-
static const int minimumIntervalTime = 50;
QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray &device, const QAudioFormat& audioFormat):
@@ -107,16 +105,16 @@ void CALLBACK QAudioOutputPrivate::waveOutProc( HWAVEOUT hWaveOut, UINT uMsg,
case WOM_CLOSE:
return;
case WOM_DONE:
- EnterCriticalSection(&waveOutCriticalSection);
+ EnterCriticalSection(&qAudio->waveOutCriticalSection);
if(qAudio->finished || qAudio->buffer_size == 0 || qAudio->period_size == 0) {
- LeaveCriticalSection(&waveOutCriticalSection);
+ LeaveCriticalSection(&qAudio->waveOutCriticalSection);
return;
}
qAudio->waveFreeBlockCount++;
if(qAudio->waveFreeBlockCount >= qAudio->buffer_size/qAudio->period_size)
qAudio->waveFreeBlockCount = qAudio->buffer_size/qAudio->period_size;
qAudio->feedback();
- LeaveCriticalSection(&waveOutCriticalSection);
+ LeaveCriticalSection(&qAudio->waveOutCriticalSection);
break;
default:
return;
diff --git a/src/multimedia/audio/qaudiooutput_win32_p.h b/src/multimedia/audio/qaudiooutput_win32_p.h
index 6e0899f..a7a0b07 100644
--- a/src/multimedia/audio/qaudiooutput_win32_p.h
+++ b/src/multimedia/audio/qaudiooutput_win32_p.h
@@ -119,6 +119,8 @@ private:
static void CALLBACK waveOutProc( HWAVEOUT hWaveOut, UINT uMsg,
DWORD dwInstance, DWORD dwParam1, DWORD dwParam2 );
+ CRITICAL_SECTION waveOutCriticalSection;
+
WAVEHDR* allocateBlocks(int size, int count);
void freeBlocks(WAVEHDR* blockArray);
bool open();