|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the QtMultimedia module of the Qt Toolkit. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
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 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
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 QAUDIOOUTPUT_MAC_P_H |
|
54 #define QAUDIOOUTPUT_MAC_P_H |
|
55 |
|
56 #include <CoreServices/CoreServices.h> |
|
57 #include <CoreAudio/CoreAudio.h> |
|
58 #include <AudioUnit/AudioUnit.h> |
|
59 #include <AudioToolbox/AudioToolbox.h> |
|
60 |
|
61 #include <QtCore/qobject.h> |
|
62 #include <QtCore/qmutex.h> |
|
63 #include <QtCore/qwaitcondition.h> |
|
64 #include <QtCore/qtimer.h> |
|
65 #include <QtCore/qatomic.h> |
|
66 |
|
67 #include <QtMultimedia/qaudio.h> |
|
68 #include <QtMultimedia/qaudioformat.h> |
|
69 #include <QtMultimedia/qaudioengine.h> |
|
70 |
|
71 QT_BEGIN_HEADER |
|
72 |
|
73 QT_BEGIN_NAMESPACE |
|
74 |
|
75 class QIODevice; |
|
76 |
|
77 namespace |
|
78 { |
|
79 class QAudioOutputBuffer; |
|
80 } |
|
81 |
|
82 class QAudioOutputPrivate : public QAbstractAudioOutput |
|
83 { |
|
84 Q_OBJECT |
|
85 |
|
86 public: |
|
87 bool isOpen; |
|
88 int internalBufferSize; |
|
89 int periodSizeBytes; |
|
90 qint64 totalFrames; |
|
91 QAudioFormat audioFormat; |
|
92 QIODevice* audioIO; |
|
93 AudioDeviceID audioDeviceId; |
|
94 AudioUnit audioUnit; |
|
95 Float64 clockFrequency; |
|
96 UInt64 startTime; |
|
97 AudioStreamBasicDescription deviceFormat; |
|
98 AudioStreamBasicDescription streamFormat; |
|
99 QAudioOutputBuffer* audioBuffer; |
|
100 QAtomicInt audioThreadState; |
|
101 QWaitCondition threadFinished; |
|
102 QMutex mutex; |
|
103 QTimer* intervalTimer; |
|
104 |
|
105 QAudio::Error errorCode; |
|
106 QAudio::State stateCode; |
|
107 |
|
108 QAudioOutputPrivate(const QByteArray& device, const QAudioFormat& format); |
|
109 ~QAudioOutputPrivate(); |
|
110 |
|
111 bool open(); |
|
112 void close(); |
|
113 |
|
114 QAudioFormat format() const; |
|
115 |
|
116 QIODevice* start(QIODevice* device); |
|
117 void stop(); |
|
118 void reset(); |
|
119 void suspend(); |
|
120 void resume(); |
|
121 |
|
122 int bytesFree() const; |
|
123 int periodSize() const; |
|
124 |
|
125 void setBufferSize(int value); |
|
126 int bufferSize() const; |
|
127 |
|
128 void setNotifyInterval(int milliSeconds); |
|
129 int notifyInterval() const; |
|
130 |
|
131 qint64 totalTime() const; |
|
132 qint64 clock() const; |
|
133 |
|
134 QAudio::Error error() const; |
|
135 QAudio::State state() const; |
|
136 |
|
137 void audioThreadStart(); |
|
138 void audioThreadStop(); |
|
139 void audioThreadDrain(); |
|
140 |
|
141 void audioDeviceStop(); |
|
142 void audioDeviceIdle(); |
|
143 void audioDeviceError(); |
|
144 |
|
145 void startTimers(); |
|
146 void stopTimers(); |
|
147 |
|
148 private slots: |
|
149 void deviceStopped(); |
|
150 void inputReady(); |
|
151 |
|
152 private: |
|
153 enum { Running, Draining, Stopped }; |
|
154 |
|
155 static OSStatus renderCallback(void* inRefCon, |
|
156 AudioUnitRenderActionFlags* ioActionFlags, |
|
157 const AudioTimeStamp* inTimeStamp, |
|
158 UInt32 inBusNumber, |
|
159 UInt32 inNumberFrames, |
|
160 AudioBufferList* ioData); |
|
161 }; |
|
162 |
|
163 QT_END_NAMESPACE |
|
164 |
|
165 QT_END_HEADER |
|
166 |
|
167 #endif |