summaryrefslogtreecommitdiffstats
path: root/src/multimedia/audio/qaudio_symbian_p.h
diff options
context:
space:
mode:
authorGareth Stockwell <ext-gareth.stockwell@nokia.com>2010-05-10 07:40:05 (GMT)
committerGareth Stockwell <ext-gareth.stockwell@nokia.com>2010-05-10 07:43:32 (GMT)
commita4bd18a3640fcad545fbd5a85374eb0056687dee (patch)
tree9376302c6027ebfdaabc069a4a488bc6a616e4fc /src/multimedia/audio/qaudio_symbian_p.h
parent23f3c92081a8afd6ff4be352fee407817950e72f (diff)
downloadQt-a4bd18a3640fcad545fbd5a85374eb0056687dee.zip
Qt-a4bd18a3640fcad545fbd5a85374eb0056687dee.tar.gz
Qt-a4bd18a3640fcad545fbd5a85374eb0056687dee.tar.bz2
Return correct formats supported lists from Symbian audio backend
* QAudioDeviceInfoInternal functions now call CMMFDevSound::InitializeL() The root cause of QTBUG-10205 was that CMMFDevSound::IntitializeL() was not called before CMMFDevSound::Capabilities(), resulting in incorrect values being returned by QAudioDeviceInfo 'supported format' functions. Resolving this was not straightforward because, while QAudioDeviceInfo is an entirely synchronous API, CMMFDevSound::InitializeL() is an asynchronous function. The changes therefore include a while(QApplication::instance()->processEvents(...)) loop, which is not a particularly elegant solution. * Encapsulated all interaction with CMMFDevSound API in DevSoundWrapper class Because the original bug fix required QAudioDeviceInfoInternal to call CMMFDevSound::InitializeL(), MDevSoundObserver callback functions had to be implemented in QAudioDeviceInfoInternal. Rather than pollute QAudioDeviceInfoInternal, a new class, DevSoundWrapper, was created which encapsulates all interaction with CMMFDevSound, and therefore implements MDevSoundObserver. QAudioInputPrivate and QAudioOutputPrivate now call CMMFDevSound via DevSoundWrapper, with only the required MDevSoundObserver callbacks forwarded on via signals. After fixing this bug, running the auto test suites exposed a number of regressions which had been introduced by the necessary refactoring described above; this commit therefore also includes fixes for the following: * No stateChanged() signal emitted during DevSound initialization Previously, QAudioInput / QAudioOutput would emit a state change from StoppedState to IdleState or ActiveState, as soon as start() was called. In the case where the requested format is subsequently found to be unsupported, in addition to the error() value being set to OpenError, a second state change would be emitted, back to StoppedState. This is not the behaviour exhibited by the other platforms' backends, and therefore caused an auto test failure. Now, the backend only transitions to IdleState / ActiveState on successful initialization. * Stop emitting notify() signal when notifyInterval is set to zero * Call CMMFDevSound::RecordInitL() from QAudioInput::resume() if no buffer is currently held This is necessary in order to restart the data flow. * Call CMMFDevSound::BufferFilled() from QAudioOutput::resume() in push mode The auto test does not resume pushing data to QAudioOutput until 'bytesFree() >= periodSize()' becomes true. Because, for the Symbian backend, periodSize() == bufferSize(), this condition is only met when a new buffer is provided by DevSound via BufferToBeFilled(). Task-number: QTBUG-10205
Diffstat (limited to 'src/multimedia/audio/qaudio_symbian_p.h')
-rw-r--r--src/multimedia/audio/qaudio_symbian_p.h113
1 files changed, 73 insertions, 40 deletions
diff --git a/src/multimedia/audio/qaudio_symbian_p.h b/src/multimedia/audio/qaudio_symbian_p.h
index d5238b4..58ef192 100644
--- a/src/multimedia/audio/qaudio_symbian_p.h
+++ b/src/multimedia/audio/qaudio_symbian_p.h
@@ -53,7 +53,8 @@
#ifndef QAUDIO_SYMBIAN_P_H
#define QAUDIO_SYMBIAN_P_H
-#include <QtCore/qnamespace.h>
+#include <QtCore/QList>
+#include <QtCore/QString>
#include <QtMultimedia/qaudioformat.h>
#include <QtMultimedia/qaudio.h>
#include <sounddevice.h>
@@ -83,60 +84,92 @@ enum State {
, SuspendedState
};
-/*
- * Helper class for querying DevSound codec / format support
+/**
+ * Wrapper around DevSound instance
*/
-class DevSoundCapabilities {
+class DevSoundWrapper
+ : public QObject
+ , public MDevSoundObserver
+{
+ Q_OBJECT
+
+public:
+ DevSoundWrapper(QAudio::Mode mode, QObject *parent = 0);
+ ~DevSoundWrapper();
+
public:
- DevSoundCapabilities(CMMFDevSound &devsound, QAudio::Mode mode);
- ~DevSoundCapabilities();
+ // List of supported codecs; can be called once object is constructed
+ const QList<QString>& supportedCodecs() const;
+
+ // Asynchronous initialization function; emits devsoundInitializeComplete
+ void initialize(const QString& codec);
+
+ // Capabilities, for selected codec. Can be called once initialize has returned
+ // successfully.
+ const QList<int>& supportedFrequencies() const;
+ const QList<int>& supportedChannels() const;
+ const QList<int>& supportedSampleSizes() const;
+ const QList<QAudioFormat::Endian>& supportedByteOrders() const;
+ const QList<QAudioFormat::SampleType>& supportedSampleTypes() const;
- const RArray<TFourCC>& fourCC() const { return m_fourCC; }
- const TMMFCapabilities& caps() const { return m_caps; }
+ bool isFormatSupported(const QAudioFormat &format) const;
+
+ int samplesProcessed() const;
+ bool setFormat(const QAudioFormat &format);
+ bool start();
+ void pause();
+ void stop();
+ void bufferProcessed();
+
+public:
+ // MDevSoundObserver
+ void InitializeComplete(TInt aError);
+ void ToneFinished(TInt aError);
+ void BufferToBeFilled(CMMFBuffer *aBuffer);
+ void PlayError(TInt aError);
+ void BufferToBeEmptied(CMMFBuffer *aBuffer);
+ void RecordError(TInt aError);
+ void ConvertError(TInt aError);
+ void DeviceMessage(TUid aMessageType, const TDesC8 &aMsg);
+
+signals:
+ void initializeComplete(int error);
+ void bufferToBeProcessed(CMMFBuffer *buffer);
+ void processingError(int error);
private:
- void constructL(CMMFDevSound &devsound, QAudio::Mode mode);
+ void getSupportedCodecs();
+ void populateCapabilities();
private:
- RArray<TFourCC> m_fourCC;
- TMMFCapabilities m_caps;
-};
+ const QAudio::Mode m_mode;
+ TMMFState m_nativeMode;
-namespace Utils {
+ enum State {
+ StateIdle,
+ StateInitializing,
+ StateInitialized
+ } m_state;
-/**
- * Convert native audio capabilities to QAudio lists.
- */
-void capabilitiesNativeToQt(const DevSoundCapabilities &caps,
- QList<int> &frequencies,
- QList<int> &channels,
- QList<int> &sampleSizes,
- QList<QAudioFormat::Endian> &byteOrders,
- QList<QAudioFormat::SampleType> &sampleTypes);
+ CMMFDevSound* m_devsound;
+ TFourCC m_fourcc;
-/**
- * Check whether format is supported.
- */
-bool isFormatSupported(const QAudioFormat &format,
- const DevSoundCapabilities &caps);
+ QList<QString> m_supportedCodecs;
+ QList<int> m_supportedFrequencies;
+ QList<int> m_supportedChannels;
+ QList<int> m_supportedSampleSizes;
+ QList<QAudioFormat::Endian> m_supportedByteOrders;
+ QList<QAudioFormat::SampleType> m_supportedSampleTypes;
-/**
- * Convert QAudioFormat to native format types.
- *
- * Note that, despite the name, DevSound uses TMMFCapabilities to specify
- * single formats as well as capabilities.
- *
- * Note that this function does not modify outputFormat.iBufferSize.
- */
-bool formatQtToNative(const QAudioFormat &inputFormat,
- TUint32 &outputFourCC,
- TMMFCapabilities &outputFormat);
+};
+
+
+namespace Utils {
/**
* Convert internal states to QAudio states.
*/
-QAudio::State stateNativeToQt(State nativeState,
- QAudio::State initializingState);
+QAudio::State stateNativeToQt(State nativeState);
/**
* Convert data length to number of samples.