diff options
author | Rohan McGovern <rohan@mcgovern.id.au> | 2010-03-06 23:44:26 (GMT) |
---|---|---|
committer | Rohan McGovern <rohan@mcgovern.id.au> | 2010-03-06 23:44:26 (GMT) |
commit | ad341d612129287793620bc84d3077afd64f97a4 (patch) | |
tree | 3d62b038c34985046ad1f3ff56c1c4e85a194ed2 /src/multimedia/audio | |
parent | b20ef0ade0aec89b969bd0ae7f754c680e390c67 (diff) | |
parent | 2458cb45665b0fe3144266122f876bd541de9c42 (diff) | |
download | Qt-ad341d612129287793620bc84d3077afd64f97a4.zip Qt-ad341d612129287793620bc84d3077afd64f97a4.tar.gz Qt-ad341d612129287793620bc84d3077afd64f97a4.tar.bz2 |
Merge remote branch 'origin/4.6' into qt-4.7-from-4.6
Conflicts:
configure.exe
examples/multimedia/audioinput/audioinput.cpp
src/corelib/io/qfsfileengine.cpp
src/gui/egl/qegl_wince.cpp
src/gui/egl/qeglproperties.cpp
src/gui/egl/qeglproperties_p.h
src/gui/embedded/directfb.pri
src/gui/kernel/qapplication_win.cpp
src/gui/painting/qdrawutil.cpp
src/opengl/qgl_p.h
src/sql/drivers/odbc/qsql_odbc.cpp
src/sql/drivers/odbc/qsql_odbc.h
tests/auto/auto.pro
tests/auto/qgl/tst_qgl.cpp
translations/assistant_adp_ru.ts
Diffstat (limited to 'src/multimedia/audio')
-rw-r--r-- | src/multimedia/audio/qaudioinput_mac_p.cpp | 12 | ||||
-rw-r--r-- | src/multimedia/audio/qaudioinput_mac_p.h | 4 | ||||
-rw-r--r-- | src/multimedia/audio/qaudiooutput_alsa_p.cpp | 44 | ||||
-rw-r--r-- | src/multimedia/audio/qaudiooutput_mac_p.cpp | 10 | ||||
-rw-r--r-- | src/multimedia/audio/qaudiooutput_mac_p.h | 4 |
5 files changed, 59 insertions, 15 deletions
diff --git a/src/multimedia/audio/qaudioinput_mac_p.cpp b/src/multimedia/audio/qaudioinput_mac_p.cpp index 7251513..bd2de52 100644 --- a/src/multimedia/audio/qaudioinput_mac_p.cpp +++ b/src/multimedia/audio/qaudioinput_mac_p.cpp @@ -64,7 +64,7 @@ QT_BEGIN_NAMESPACE -namespace +namespace QtMultimediaInternal { static const int default_buffer_size = 4 * 1024; @@ -169,8 +169,10 @@ public: void reset() { - for (UInt32 i = 0; i < bfs->mNumberBuffers; ++i) + for (UInt32 i = 0; i < bfs->mNumberBuffers; ++i) { bfs->mBuffers[i].mDataByteSize = dataSize; + bfs->mBuffers[i].mData = 0; + } } private: @@ -523,7 +525,7 @@ QAudioInputPrivate::QAudioInputPrivate(const QByteArray& device, QAudioFormat co startTime = 0; totalFrames = 0; audioBuffer = 0; - internalBufferSize = default_buffer_size; + internalBufferSize = QtMultimediaInternal::default_buffer_size; clockFrequency = AudioGetHostClockFrequency() / 1000; errorCode = QAudio::NoError; stateCode = QAudio::StoppedState; @@ -668,13 +670,13 @@ bool QAudioInputPrivate::open() else internalBufferSize -= internalBufferSize % streamFormat.mBytesPerFrame; - audioBuffer = new QAudioInputBuffer(internalBufferSize, + audioBuffer = new QtMultimediaInternal::QAudioInputBuffer(internalBufferSize, periodSizeBytes, deviceFormat, streamFormat, this); - audioIO = new MacInputDevice(audioBuffer, this); + audioIO = new QtMultimediaInternal::MacInputDevice(audioBuffer, this); // Init if (AudioUnitInitialize(audioUnit) != noErr) { diff --git a/src/multimedia/audio/qaudioinput_mac_p.h b/src/multimedia/audio/qaudioinput_mac_p.h index e1b8e4a..42f90e2 100644 --- a/src/multimedia/audio/qaudioinput_mac_p.h +++ b/src/multimedia/audio/qaudioinput_mac_p.h @@ -75,7 +75,7 @@ QT_BEGIN_NAMESPACE class QTimer; class QIODevice; -namespace +namespace QtMultimediaInternal { class QAudioInputBuffer; } @@ -97,7 +97,7 @@ public: UInt64 startTime; QAudio::Error errorCode; QAudio::State stateCode; - QAudioInputBuffer* audioBuffer; + QtMultimediaInternal::QAudioInputBuffer* audioBuffer; QMutex mutex; QWaitCondition threadFinished; QAtomicInt audioThreadState; diff --git a/src/multimedia/audio/qaudiooutput_alsa_p.cpp b/src/multimedia/audio/qaudiooutput_alsa_p.cpp index b127103..e49c75a 100644 --- a/src/multimedia/audio/qaudiooutput_alsa_p.cpp +++ b/src/multimedia/audio/qaudiooutput_alsa_p.cpp @@ -369,10 +369,52 @@ bool QAudioOutputPrivate::open() } } if ( !fatal ) { + unsigned int maxBufferTime = 0; + unsigned int minBufferTime = 0; + unsigned int maxPeriodTime = 0; + unsigned int minPeriodTime = 0; + + err = snd_pcm_hw_params_get_buffer_time_max(hwparams, &maxBufferTime, &dir); + if ( err >= 0) + err = snd_pcm_hw_params_get_buffer_time_min(hwparams, &minBufferTime, &dir); + if ( err >= 0) + err = snd_pcm_hw_params_get_period_time_max(hwparams, &maxPeriodTime, &dir); + if ( err >= 0) + err = snd_pcm_hw_params_get_period_time_min(hwparams, &minPeriodTime, &dir); + + if ( err < 0 ) { + fatal = true; + errMessage = QString::fromLatin1("QAudioOutput: buffer/period min and max: err = %1").arg(err); + } else { + if (maxBufferTime < buffer_time || buffer_time < minBufferTime || maxPeriodTime < period_time || minPeriodTime > period_time) { +#ifdef DEBUG_AUDIO + qDebug()<<"defaults out of range"; + qDebug()<<"pmin="<<minPeriodTime<<", pmax="<<maxPeriodTime<<", bmin="<<minBufferTime<<", bmax="<<maxBufferTime; +#endif + period_time = minPeriodTime; + if (period_time*4 <= maxBufferTime) { + // Use 4 periods if possible + buffer_time = period_time*4; + chunks = 4; + } else if (period_time*2 <= maxBufferTime) { + // Use 2 periods if possible + buffer_time = period_time*2; + chunks = 2; + } else { + qWarning()<<"QAudioOutput: alsa only supports single period!"; + fatal = true; + } +#ifdef DEBUG_AUDIO + qDebug()<<"used: buffer_time="<<buffer_time<<", period_time="<<period_time; +#endif + } + } + } + if ( !fatal ) { err = snd_pcm_hw_params_set_buffer_time_near(handle, hwparams, &buffer_time, &dir); if ( err < 0 ) { fatal = true; - errMessage = QString::fromLatin1("QAudioOutput: snd_pcm_hw_params_set_buffer_time_near: err = %1").arg(err); + errMessage = QString::fromLatin1("QAudioOutput: snd_pcm_hw_params_set_buffer_time_near: err = %1").arg(err); } } if ( !fatal ) { diff --git a/src/multimedia/audio/qaudiooutput_mac_p.cpp b/src/multimedia/audio/qaudiooutput_mac_p.cpp index 518f78f..6f32257 100644 --- a/src/multimedia/audio/qaudiooutput_mac_p.cpp +++ b/src/multimedia/audio/qaudiooutput_mac_p.cpp @@ -70,7 +70,7 @@ QT_BEGIN_NAMESPACE -namespace +namespace QtMultimediaInternal { static const int default_buffer_size = 8 * 1024; @@ -237,7 +237,7 @@ class MacOutputDevice : public QIODevice Q_OBJECT public: - MacOutputDevice(QAudioOutputBuffer* audioBuffer, QObject* parent): + MacOutputDevice(QtMultimediaInternal::QAudioOutputBuffer* audioBuffer, QObject* parent): QIODevice(parent), m_audioBuffer(audioBuffer) { @@ -263,7 +263,7 @@ public: } private: - QAudioOutputBuffer* m_audioBuffer; + QtMultimediaInternal::QAudioOutputBuffer* m_audioBuffer; }; @@ -285,7 +285,7 @@ QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray& device, const QAudioF startTime = 0; totalFrames = 0; audioBuffer = 0; - internalBufferSize = default_buffer_size; + internalBufferSize = QtMultimediaInternal::default_buffer_size; clockFrequency = AudioGetHostClockFrequency() / 1000; errorCode = QAudio::NoError; stateCode = QAudio::StoppedState; @@ -399,7 +399,7 @@ bool QAudioOutputPrivate::open() else internalBufferSize -= internalBufferSize % streamFormat.mBytesPerFrame; - audioBuffer = new QAudioOutputBuffer(internalBufferSize, periodSizeBytes, audioFormat); + audioBuffer = new QtMultimediaInternal::QAudioOutputBuffer(internalBufferSize, periodSizeBytes, audioFormat); connect(audioBuffer, SIGNAL(readyRead()), SLOT(inputReady())); // Pull audioIO = new MacOutputDevice(audioBuffer, this); diff --git a/src/multimedia/audio/qaudiooutput_mac_p.h b/src/multimedia/audio/qaudiooutput_mac_p.h index 1aacc67..752905c 100644 --- a/src/multimedia/audio/qaudiooutput_mac_p.h +++ b/src/multimedia/audio/qaudiooutput_mac_p.h @@ -74,7 +74,7 @@ QT_BEGIN_NAMESPACE class QIODevice; -namespace +namespace QtMultimediaInternal { class QAudioOutputBuffer; } @@ -96,7 +96,7 @@ public: UInt64 startTime; AudioStreamBasicDescription deviceFormat; AudioStreamBasicDescription streamFormat; - QAudioOutputBuffer* audioBuffer; + QtMultimediaInternal::QAudioOutputBuffer* audioBuffer; QAtomicInt audioThreadState; QWaitCondition threadFinished; QMutex mutex; |