source: trunk/src/multimedia/audio/qaudio_symbian_p.h@ 769

Last change on this file since 769 was 769, checked in by Dmitry A. Kuminov, 15 years ago

trunk: Merged in qt 4.6.3 sources from branches/vendor/nokia/qt.

File size: 5.7 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
6**
7** This file is part of the QtMultimedia module of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
15**
16** GNU Lesser General Public License Usage
17** Alternatively, this file may be used under the terms of the GNU Lesser
18** General Public License version 2.1 as published by the Free Software
19** Foundation and appearing in the file LICENSE.LGPL included in the
20** packaging of this file. Please review the following information to
21** ensure the GNU Lesser General Public License version 2.1 requirements
22** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23**
24** In addition, as a special exception, Nokia gives you certain additional
25** rights. These rights are described in the Nokia Qt LGPL Exception
26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42//
43// W A R N I N G
44// -------------
45//
46// This file is not part of the Qt API. It exists for the convenience
47// of other Qt classes. This header file may change from version to
48// version without notice, or even be removed.
49//
50// We mean it.
51//
52
53#ifndef QAUDIO_SYMBIAN_P_H
54#define QAUDIO_SYMBIAN_P_H
55
56#include <QtCore/QList>
57#include <QtCore/QString>
58#include <QtMultimedia/qaudioformat.h>
59#include <QtMultimedia/qaudio.h>
60#include <sounddevice.h>
61
62QT_BEGIN_NAMESPACE
63
64namespace SymbianAudio {
65
66/**
67 * Default values used by audio input and output classes, when underlying
68 * DevSound instance has not yet been created.
69 */
70
71const int DefaultBufferSize = 4096; // bytes
72const int DefaultNotifyInterval = 1000; // ms
73
74/**
75 * Enumeration used to track state of internal DevSound instances.
76 * Values are translated to the corresponding QAudio::State values by
77 * SymbianAudio::Utils::stateNativeToQt.
78 */
79enum State {
80 ClosedState
81 , InitializingState
82 , ActiveState
83 , IdleState
84 , SuspendedState
85};
86
87/**
88 * Wrapper around DevSound instance
89 */
90class DevSoundWrapper
91 : public QObject
92 , public MDevSoundObserver
93{
94 Q_OBJECT
95
96public:
97 DevSoundWrapper(QAudio::Mode mode, QObject *parent = 0);
98 ~DevSoundWrapper();
99
100public:
101 // List of supported codecs; can be called once object is constructed
102 const QList<QString>& supportedCodecs() const;
103
104 // Asynchronous initialization function; emits devsoundInitializeComplete
105 void initialize(const QString& codec);
106
107 // Capabilities, for selected codec. Can be called once initialize has returned
108 // successfully.
109 const QList<int>& supportedFrequencies() const;
110 const QList<int>& supportedChannels() const;
111 const QList<int>& supportedSampleSizes() const;
112 const QList<QAudioFormat::Endian>& supportedByteOrders() const;
113 const QList<QAudioFormat::SampleType>& supportedSampleTypes() const;
114
115 bool isFormatSupported(const QAudioFormat &format) const;
116
117 int samplesProcessed() const;
118 bool setFormat(const QAudioFormat &format);
119 bool start();
120 void pause();
121 void stop();
122 void bufferProcessed();
123
124public:
125 // MDevSoundObserver
126 void InitializeComplete(TInt aError);
127 void ToneFinished(TInt aError);
128 void BufferToBeFilled(CMMFBuffer *aBuffer);
129 void PlayError(TInt aError);
130 void BufferToBeEmptied(CMMFBuffer *aBuffer);
131 void RecordError(TInt aError);
132 void ConvertError(TInt aError);
133 void DeviceMessage(TUid aMessageType, const TDesC8 &aMsg);
134
135signals:
136 void initializeComplete(int error);
137 void bufferToBeProcessed(CMMFBuffer *buffer);
138 void processingError(int error);
139
140private:
141 void getSupportedCodecs();
142 void populateCapabilities();
143
144private:
145 const QAudio::Mode m_mode;
146 TMMFState m_nativeMode;
147
148 enum State {
149 StateIdle,
150 StateInitializing,
151 StateInitialized
152 } m_state;
153
154 CMMFDevSound* m_devsound;
155 TFourCC m_fourcc;
156
157 QList<QString> m_supportedCodecs;
158 QList<int> m_supportedFrequencies;
159 QList<int> m_supportedChannels;
160 QList<int> m_supportedSampleSizes;
161 QList<QAudioFormat::Endian> m_supportedByteOrders;
162 QList<QAudioFormat::SampleType> m_supportedSampleTypes;
163
164};
165
166
167namespace Utils {
168
169/**
170 * Convert internal states to QAudio states.
171 */
172QAudio::State stateNativeToQt(State nativeState);
173
174/**
175 * Convert data length to number of samples.
176 */
177qint64 bytesToSamples(const QAudioFormat &format, qint64 length);
178
179/**
180 * Convert number of samples to data length.
181 */
182qint64 samplesToBytes(const QAudioFormat &format, qint64 samples);
183
184} // namespace Utils
185} // namespace SymbianAudio
186
187QT_END_NAMESPACE
188
189#endif
Note: See TracBrowser for help on using the repository browser.