summaryrefslogtreecommitdiffstats
path: root/src/multimedia
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2010-03-17 17:30:08 (GMT)
committerThiago Macieira <thiago.macieira@nokia.com>2010-03-17 17:30:08 (GMT)
commit0a5bcc8a0ab57becc36b140954b7034b3d11efbc (patch)
tree2310a77cf20d10609603c04f7d1bf29e9aec8042 /src/multimedia
parent4c1f54097a1fb1acff817ba8caa8af347ae56cd2 (diff)
parent83e321747920c31d6fa4c860de3683630fbedb5d (diff)
downloadQt-0a5bcc8a0ab57becc36b140954b7034b3d11efbc.zip
Qt-0a5bcc8a0ab57becc36b140954b7034b3d11efbc.tar.gz
Qt-0a5bcc8a0ab57becc36b140954b7034b3d11efbc.tar.bz2
Merge remote branch 'origin/4.6' into qt-4.7-from-4.6
Conflicts: src/s60installs/bwins/QtCoreu.def src/s60installs/eabi/QtCoreu.def
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()