source: trunk/src/multimedia/audio/qaudioinput_mac_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.

  • Property svn:eol-style set to native
File size: 4.9 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
54#ifndef QAUDIOINPUT_MAC_P_H
55#define QAUDIOINPUT_MAC_P_H
56
57#include <CoreServices/CoreServices.h>
58#include <CoreAudio/CoreAudio.h>
59#include <AudioUnit/AudioUnit.h>
60#include <AudioToolbox/AudioToolbox.h>
61
62#include <QtCore/qobject.h>
63#include <QtCore/qmutex.h>
64#include <QtCore/qwaitcondition.h>
65#include <QtCore/qatomic.h>
66
67#include <QtMultimedia/qaudio.h>
68#include <QtMultimedia/qaudioformat.h>
69#include <QtMultimedia/qaudioengine.h>
70
71QT_BEGIN_HEADER
72
73QT_BEGIN_NAMESPACE
74
75class QTimer;
76class QIODevice;
77class QAbstractAudioDeviceInfo;
78
79namespace QtMultimediaInternal
80{
81class QAudioInputBuffer;
82}
83
84class QAudioInputPrivate : public QAbstractAudioInput
85{
86 Q_OBJECT
87
88public:
89 bool isOpen;
90 int periodSizeBytes;
91 int internalBufferSize;
92 qint64 totalFrames;
93 QAudioFormat audioFormat;
94 QIODevice* audioIO;
95 AudioUnit audioUnit;
96 AudioDeviceID audioDeviceId;
97 Float64 clockFrequency;
98 UInt64 startTime;
99 QAudio::Error errorCode;
100 QAudio::State stateCode;
101 QtMultimediaInternal::QAudioInputBuffer* audioBuffer;
102 QMutex mutex;
103 QWaitCondition threadFinished;
104 QAtomicInt audioThreadState;
105 QTimer* intervalTimer;
106 AudioStreamBasicDescription streamFormat;
107 AudioStreamBasicDescription deviceFormat;
108 QAbstractAudioDeviceInfo *audioDeviceInfo;
109
110 QAudioInputPrivate(const QByteArray& device, QAudioFormat const& format);
111 ~QAudioInputPrivate();
112
113 bool open();
114 void close();
115
116 QAudioFormat format() const;
117
118 QIODevice* start(QIODevice* device);
119 void stop();
120 void reset();
121 void suspend();
122 void resume();
123 void idle();
124
125 int bytesReady() const;
126 int periodSize() const;
127
128 void setBufferSize(int value);
129 int bufferSize() const;
130
131 void setNotifyInterval(int milliSeconds);
132 int notifyInterval() const;
133
134 qint64 processedUSecs() const;
135 qint64 elapsedUSecs() const;
136
137 QAudio::Error error() const;
138 QAudio::State state() const;
139
140 void audioThreadStart();
141 void audioThreadStop();
142
143 void audioDeviceStop();
144 void audioDeviceFull();
145 void audioDeviceError();
146
147 void startTimers();
148 void stopTimers();
149
150private slots:
151 void deviceStopped();
152
153private:
154 enum { Running, Stopped };
155
156 // Input callback
157 static OSStatus inputCallback(void* inRefCon,
158 AudioUnitRenderActionFlags* ioActionFlags,
159 const AudioTimeStamp* inTimeStamp,
160 UInt32 inBusNumber,
161 UInt32 inNumberFrames,
162 AudioBufferList* ioData);
163};
164
165QT_END_NAMESPACE
166
167QT_END_HEADER
168
169#endif // QAUDIOINPUT_MAC_P_H
Note: See TracBrowser for help on using the repository browser.