summaryrefslogtreecommitdiffstats
path: root/src/multimedia
diff options
context:
space:
mode:
Diffstat (limited to 'src/multimedia')
-rw-r--r--src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp74
-rw-r--r--src/multimedia/audio/qaudioinput_alsa_p.cpp1
-rw-r--r--src/multimedia/audio/qaudioinput_win32_p.cpp14
-rw-r--r--src/multimedia/audio/qaudioinput_win32_p.h1
-rw-r--r--src/multimedia/audio/qaudiooutput_alsa_p.cpp2
-rw-r--r--src/multimedia/audio/qaudiooutput_win32_p.cpp8
-rw-r--r--src/multimedia/audio/qaudiooutput_win32_p.h2
7 files changed, 76 insertions, 26 deletions
diff --git a/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp
index 67dc90c..aee0807 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_alsa_p.cpp b/src/multimedia/audio/qaudioinput_alsa_p.cpp
index ead9995..6b15008 100644
--- a/src/multimedia/audio/qaudioinput_alsa_p.cpp
+++ b/src/multimedia/audio/qaudioinput_alsa_p.cpp
@@ -428,7 +428,6 @@ bool QAudioInputPrivate::open()
void QAudioInputPrivate::close()
{
- deviceState = QAudio::StoppedState;
timer->stop();
if ( handle ) {
diff --git a/src/multimedia/audio/qaudioinput_win32_p.cpp b/src/multimedia/audio/qaudioinput_win32_p.cpp
index 180cbda..b5d673e 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 QT_WIN_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 a2cf2ea..66c2535 100644
--- a/src/multimedia/audio/qaudioinput_win32_p.h
+++ b/src/multimedia/audio/qaudioinput_win32_p.h
@@ -122,6 +122,7 @@ private:
volatile int waveFreeBlockCount;
int waveCurrentBlock;
+ CRITICAL_SECTION waveInCriticalSection;
static void QT_WIN_CALLBACK waveInProc( HWAVEIN hWaveIn, UINT uMsg,
DWORD dwInstance, DWORD dwParam1, DWORD dwParam2 );
diff --git a/src/multimedia/audio/qaudiooutput_alsa_p.cpp b/src/multimedia/audio/qaudiooutput_alsa_p.cpp
index 1cef335..cf3726b 100644
--- a/src/multimedia/audio/qaudiooutput_alsa_p.cpp
+++ b/src/multimedia/audio/qaudiooutput_alsa_p.cpp
@@ -485,7 +485,6 @@ bool QAudioOutputPrivate::open()
void QAudioOutputPrivate::close()
{
- deviceState = QAudio::StoppedState;
timer->stop();
if ( handle ) {
@@ -701,6 +700,7 @@ bool QAudioOutputPrivate::deviceReady()
} else if(l < 0) {
close();
+ deviceState = QAudio::StoppedState;
errorState = QAudio::IOError;
emit stateChanged(deviceState);
}
diff --git a/src/multimedia/audio/qaudiooutput_win32_p.cpp b/src/multimedia/audio/qaudiooutput_win32_p.cpp
index 4bcbd09..13bce58 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 bb176a0..68a40f7 100644
--- a/src/multimedia/audio/qaudiooutput_win32_p.h
+++ b/src/multimedia/audio/qaudiooutput_win32_p.h
@@ -119,6 +119,8 @@ private:
static void QT_WIN_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();