summaryrefslogtreecommitdiffstats
path: root/src/multimedia
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-03-16 03:49:24 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-03-16 03:49:24 (GMT)
commit83e321747920c31d6fa4c860de3683630fbedb5d (patch)
tree25aaafcd3fe0e066b82760ee0969c80c3dabb0ee /src/multimedia
parent42a70e989ecaebaf5e044c611ae2e22bca1507e0 (diff)
parentabcbcece2988d36fe88116fae429685430452689 (diff)
downloadQt-83e321747920c31d6fa4c860de3683630fbedb5d.zip
Qt-83e321747920c31d6fa4c860de3683630fbedb5d.tar.gz
Qt-83e321747920c31d6fa4c860de3683630fbedb5d.tar.bz2
Merge branch '4.6' of scm.dev.nokia.troll.no:qt/qt-multimedia-staging into 4.6-integration
* '4.6' of scm.dev.nokia.troll.no:qt/qt-multimedia-staging: Use AudioConverter when not preferred format. Handle values passed to setNotifyInterval more robustly. Make sure to check for a valid audioformat before open.
Diffstat (limited to 'src/multimedia')
-rw-r--r--src/multimedia/audio/qaudioinput_mac_p.cpp69
-rw-r--r--src/multimedia/audio/qaudioinput_mac_p.h2
-rw-r--r--src/multimedia/audio/qaudiooutput_mac_p.cpp11
3 files changed, 52 insertions, 30 deletions
diff --git a/src/multimedia/audio/qaudioinput_mac_p.cpp b/src/multimedia/audio/qaudioinput_mac_p.cpp
index f394ca4..4b37b18 100644
--- a/src/multimedia/audio/qaudioinput_mac_p.cpp
+++ b/src/multimedia/audio/qaudioinput_mac_p.cpp
@@ -54,12 +54,11 @@
#include <QtCore/qtimer.h>
#include <QtCore/qdebug.h>
-#include <QtMultimedia/qaudiodeviceinfo.h>
#include <QtMultimedia/qaudioinput.h>
#include "qaudio_mac_p.h"
#include "qaudioinput_mac_p.h"
-
+#include "qaudiodeviceinfo_mac_p.h"
QT_BEGIN_NAMESPACE
@@ -241,7 +240,7 @@ public:
m_flushTimer = new QTimer(this);
connect(m_flushTimer, SIGNAL(timeout()), SLOT(flushBuffer()));
- if (inputFormat.mSampleRate != outputFormat.mSampleRate) {
+ if (toQAudioFormat(inputFormat) != toQAudioFormat(outputFormat)) {
if (AudioConverterNew(&m_inputFormat, &m_outputFormat, &m_audioConverter) != noErr) {
qWarning() << "QAudioInput: Unable to create an Audio Converter";
m_audioConverter = 0;
@@ -520,6 +519,7 @@ QAudioInputPrivate::QAudioInputPrivate(const QByteArray& device, QAudioFormat co
if (QAudio::Mode(mode) == QAudio::AudioOutput)
errorCode = QAudio::OpenError;
else {
+ audioDeviceInfo = new QAudioDeviceInfoInternal(device, QAudio::AudioInput);
isOpen = false;
audioDeviceId = AudioDeviceID(did);
audioUnit = 0;
@@ -540,6 +540,7 @@ QAudioInputPrivate::QAudioInputPrivate(const QByteArray& device, QAudioFormat co
QAudioInputPrivate::~QAudioInputPrivate()
{
close();
+ delete audioDeviceInfo;
}
bool QAudioInputPrivate::open()
@@ -577,7 +578,7 @@ bool QAudioInputPrivate::open()
1,
&enable,
sizeof(enable)) != noErr) {
- qWarning() << "QAudioInput: Unabled to switch to input mode (Enable Input)";
+ qWarning() << "QAudioInput: Unable to switch to input mode (Enable Input)";
return false;
}
@@ -588,7 +589,7 @@ bool QAudioInputPrivate::open()
0,
&enable,
sizeof(enable)) != noErr) {
- qWarning() << "QAudioInput: Unabled to switch to input mode (Disable output)";
+ qWarning() << "QAudioInput: Unable to switch to input mode (Disable output)";
return false;
}
@@ -619,35 +620,40 @@ bool QAudioInputPrivate::open()
}
// Set format
+ // Wanted
streamFormat = toAudioStreamBasicDescription(audioFormat);
- size = sizeof(deviceFormat);
- if (AudioUnitGetProperty(audioUnit,
- kAudioUnitProperty_StreamFormat,
- kAudioUnitScope_Input,
- 1,
- &deviceFormat,
- &size) != noErr) {
- qWarning() << "QAudioInput: Unable to retrieve device format";
- return false;
- }
-
- // If the device frequency is different to the requested use a converter
- if (deviceFormat.mSampleRate != streamFormat.mSampleRate) {
- AudioUnitSetProperty(audioUnit,
+ // Required on unit
+ if (audioFormat == audioDeviceInfo->preferredFormat()) {
+ deviceFormat = streamFormat;
+ AudioUnitSetProperty(audioUnit,
kAudioUnitProperty_StreamFormat,
kAudioUnitScope_Output,
1,
&deviceFormat,
- sizeof(streamFormat));
+ sizeof(deviceFormat));
}
else {
- AudioUnitSetProperty(audioUnit,
- kAudioUnitProperty_StreamFormat,
- kAudioUnitScope_Output,
- 1,
- &streamFormat,
- sizeof(streamFormat));
+ size = sizeof(deviceFormat);
+ if (AudioUnitGetProperty(audioUnit,
+ kAudioUnitProperty_StreamFormat,
+ kAudioUnitScope_Input,
+ 1,
+ &deviceFormat,
+ &size) != noErr) {
+ qWarning() << "QAudioInput: Unable to retrieve device format";
+ return false;
+ }
+
+ if (AudioUnitSetProperty(audioUnit,
+ kAudioUnitProperty_StreamFormat,
+ kAudioUnitScope_Output,
+ 1,
+ &deviceFormat,
+ sizeof(deviceFormat)) != noErr) {
+ qWarning() << "QAudioInput: Unable to set device format";
+ return false;
+ }
}
// Setup buffers
@@ -710,7 +716,7 @@ QIODevice* QAudioInputPrivate::start(QIODevice* device)
{
QIODevice* op = device;
- if (!open()) {
+ if (!audioFormat.isValid() || !open()) {
stateCode = QAudio::StoppedState;
errorCode = QAudio::OpenError;
return audioIO;
@@ -807,6 +813,12 @@ int QAudioInputPrivate::bufferSize() const
void QAudioInputPrivate::setNotifyInterval(int milliSeconds)
{
+ if (intervalTimer->interval() == milliSeconds)
+ return;
+
+ if (milliSeconds <= 0)
+ milliSeconds = 0;
+
intervalTimer->setInterval(milliSeconds);
}
@@ -886,7 +898,8 @@ void QAudioInputPrivate::audioDeviceError()
void QAudioInputPrivate::startTimers()
{
audioBuffer->startFlushTimer();
- intervalTimer->start();
+ if (intervalTimer->interval() > 0)
+ intervalTimer->start();
}
void QAudioInputPrivate::stopTimers()
diff --git a/src/multimedia/audio/qaudioinput_mac_p.h b/src/multimedia/audio/qaudioinput_mac_p.h
index 42f90e2..7aa4168 100644
--- a/src/multimedia/audio/qaudioinput_mac_p.h
+++ b/src/multimedia/audio/qaudioinput_mac_p.h
@@ -74,6 +74,7 @@ QT_BEGIN_NAMESPACE
class QTimer;
class QIODevice;
+class QAbstractAudioDeviceInfo;
namespace QtMultimediaInternal
{
@@ -104,6 +105,7 @@ public:
QTimer* intervalTimer;
AudioStreamBasicDescription streamFormat;
AudioStreamBasicDescription deviceFormat;
+ QAbstractAudioDeviceInfo *audioDeviceInfo;
QAudioInputPrivate(const QByteArray& device, QAudioFormat const& format);
~QAudioInputPrivate();
diff --git a/src/multimedia/audio/qaudiooutput_mac_p.cpp b/src/multimedia/audio/qaudiooutput_mac_p.cpp
index 6f32257..9689101 100644
--- a/src/multimedia/audio/qaudiooutput_mac_p.cpp
+++ b/src/multimedia/audio/qaudiooutput_mac_p.cpp
@@ -435,7 +435,7 @@ QIODevice* QAudioOutputPrivate::start(QIODevice* device)
{
QIODevice* op = device;
- if (!open()) {
+ if (!audioFormat.isValid() || !open()) {
stateCode = QAudio::StoppedState;
errorCode = QAudio::OpenError;
return audioIO;
@@ -536,6 +536,12 @@ int QAudioOutputPrivate::bufferSize() const
void QAudioOutputPrivate::setNotifyInterval(int milliSeconds)
{
+ if (intervalTimer->interval() == milliSeconds)
+ return;
+
+ if (milliSeconds <= 0)
+ milliSeconds = 0;
+
intervalTimer->setInterval(milliSeconds);
}
@@ -622,7 +628,8 @@ void QAudioOutputPrivate::audioDeviceError()
void QAudioOutputPrivate::startTimers()
{
audioBuffer->startFillTimer();
- intervalTimer->start();
+ if (intervalTimer->interval() > 0)
+ intervalTimer->start();
}
void QAudioOutputPrivate::stopTimers()