summaryrefslogtreecommitdiff
path: root/src/multimedia/audio/qaudiooutput_symbian_p.cpp
diff options
context:
space:
mode:
authorGareth Stockwell <ext-gareth.stockwell@nokia.com>2010-09-14 15:02:03 +0100
committerGareth Stockwell <ext-gareth.stockwell@nokia.com>2010-09-17 13:43:15 +0100
commit82a0342fa076b4872c439079822bad61023af7da (patch)
treeea44d44db729f4059c0a3719a65c03884b9f47a6 /src/multimedia/audio/qaudiooutput_symbian_p.cpp
parent15f6338e3984e103728a66de2f25e09e19f9077e (diff)
downloadqt4-tools-82a0342fa076b4872c439079822bad61023af7da.tar.gz
Implement QAudioInput::suspend() using CMMFDevSound::Stop()
As with playback mode, lack of support for CMMFDevSound::Pause() in DevSound's recording mode causes problems on some devices. Specifically, while QAudioInput works fine on the Nokia 5800, this bug was observed on the Nokia N8. This fix means that suspending and resuming audio input will work correctly on all devices. Task-number: QTBUG-13506 Reviewed-by: Derick Hawcroft
Diffstat (limited to 'src/multimedia/audio/qaudiooutput_symbian_p.cpp')
-rw-r--r--src/multimedia/audio/qaudiooutput_symbian_p.cpp45
1 files changed, 19 insertions, 26 deletions
diff --git a/src/multimedia/audio/qaudiooutput_symbian_p.cpp b/src/multimedia/audio/qaudiooutput_symbian_p.cpp
index cc32f9ddcb..ea14e1946e 100644
--- a/src/multimedia/audio/qaudiooutput_symbian_p.cpp
+++ b/src/multimedia/audio/qaudiooutput_symbian_p.cpp
@@ -180,40 +180,33 @@ void QAudioOutputPrivate::suspend()
|| SymbianAudio::IdleState == m_internalState) {
m_notifyTimer->stop();
m_underflowTimer->stop();
-
const qint64 samplesWritten = SymbianAudio::Utils::bytesToSamples(
m_format, m_bytesWritten);
-
const qint64 samplesPlayed = getSamplesPlayed();
-
- m_bytesWritten = 0;
-
- // CMMFDevSound::Pause() is not guaranteed to work correctly in all
- // implementations, for play-mode DevSound sessions. We therefore
- // have to implement suspend() by calling CMMFDevSound::Stop().
- // Because this causes buffered data to be dropped, we replace the
- // lost data with silence following a call to resume(), in order to
- // ensure that processedUSecs() returns the correct value.
- m_devSound->stop();
- m_devSoundBuffer = 0;
m_totalSamplesPlayed += samplesPlayed;
-
- // Calculate the amount of data dropped
- const qint64 paddingSamples = samplesWritten - samplesPlayed;
- Q_ASSERT(paddingSamples >= 0);
- m_bytesPadding = SymbianAudio::Utils::samplesToBytes(m_format,
- paddingSamples);
-
- setState(SymbianAudio::SuspendedState);
+ m_bytesWritten = 0;
+ const bool paused = m_devSound->pause();
+ if (paused) {
+ setState(SymbianAudio::SuspendedPausedState);
+ } else {
+ m_devSoundBuffer = 0;
+ // Calculate the amount of data dropped
+ const qint64 paddingSamples = samplesWritten - samplesPlayed;
+ Q_ASSERT(paddingSamples >= 0);
+ m_bytesPadding = SymbianAudio::Utils::samplesToBytes(m_format,
+ paddingSamples);
+ setState(SymbianAudio::SuspendedStoppedState);
+ }
}
}
void QAudioOutputPrivate::resume()
{
- if (SymbianAudio::SuspendedState == m_internalState) {
- if (!m_pullMode && m_devSoundBuffer)
- bufferFilled();
- startPlayback();
+ if (QAudio::SuspendedState == m_externalState) {
+ if (SymbianAudio::SuspendedPausedState == m_internalState)
+ m_devSound->resume();
+ else
+ startPlayback();
}
}
@@ -271,7 +264,7 @@ int QAudioOutputPrivate::notifyInterval() const
qint64 QAudioOutputPrivate::processedUSecs() const
{
int samplesPlayed = 0;
- if (m_devSound && SymbianAudio::SuspendedState != m_internalState)
+ if (m_devSound && QAudio::SuspendedState != m_externalState)
samplesPlayed = getSamplesPlayed();
// Protect against division by zero