summaryrefslogtreecommitdiffstats
path: root/src/multimedia/audio/qaudiooutput_symbian_p.cpp
diff options
context:
space:
mode:
authorGareth Stockwell <ext-gareth.stockwell@nokia.com>2010-09-14 14:02:03 (GMT)
committerGareth Stockwell <ext-gareth.stockwell@nokia.com>2010-09-17 13:21:06 (GMT)
commit737b75e19b7206cb9888e87930cb37b1906a6345 (patch)
tree3cb777f81837eb1f59a90e8e27fe961533463d74 /src/multimedia/audio/qaudiooutput_symbian_p.cpp
parent9fd8589c9d4574c04a989a6c5e1d335779d2b244 (diff)
downloadQt-737b75e19b7206cb9888e87930cb37b1906a6345.zip
Qt-737b75e19b7206cb9888e87930cb37b1906a6345.tar.gz
Qt-737b75e19b7206cb9888e87930cb37b1906a6345.tar.bz2
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 cc32f9d..ea14e19 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