Qt 4.8
qaudioinput_mac_p.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtMultimedia module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
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 
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 
72 
74 
75 class QTimer;
76 class QIODevice;
78 
79 namespace QtMultimediaInternal
80 {
81 class QAudioInputBuffer;
82 }
83 
85 {
86  Q_OBJECT
87 
88 public:
89  bool isOpen;
95  AudioUnit audioUnit;
96  AudioDeviceID audioDeviceId;
97  Float64 clockFrequency;
98  UInt64 startTime;
106  AudioStreamBasicDescription streamFormat;
107  AudioStreamBasicDescription deviceFormat;
109 
110  QAudioInputPrivate(const QByteArray& device, QAudioFormat const& format);
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 
150 private slots:
151  void deviceStopped();
152 
153 private:
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 
166 
168 
169 #endif // QAUDIOINPUT_MAC_P_H
Error
Definition: qaudio.h:58
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
The QMutex class provides access serialization between threads.
Definition: qmutex.h:60
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
The QAtomicInt class provides platform-independent atomic operations on integers. ...
Definition: qatomic.h:55
QWaitCondition threadFinished
#define error(msg)
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
Q_CORE_EXPORT QTextStream & reset(QTextStream &s)
QAudioFormat audioFormat
QAudio::State stateCode
AudioStreamBasicDescription deviceFormat
AudioStreamBasicDescription streamFormat
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
QAudio::Error errorCode
__int64 qint64
Definition: qglobal.h:942
The QAbstractAudioInput class provides access for QAudioInput to access the audio device provided by ...
Definition: qaudioengine.h:100
signed long OSStatus
AudioDeviceID audioDeviceId
#define Q_OBJECT
Definition: qobjectdefs.h:157
QtMultimediaInternal::QAudioInputBuffer * audioBuffer
State
Definition: qaudio.h:59
The QAbstractAudioDeviceInfo class provides access for QAudioDeviceInfo to access the audio device pr...
Definition: qaudioengine.h:56
QAbstractAudioDeviceInfo * audioDeviceInfo
The QAudioFormat class stores audio parameter information.
Definition: qaudioformat.h:60
The QTimer class provides repetitive and single-shot timers.
Definition: qtimer.h:56
#define slots
Definition: qobjectdefs.h:68
The QIODevice class is the base interface class of all I/O devices in Qt.
Definition: qiodevice.h:66
#define QT_END_HEADER
Definition: qglobal.h:137
int open(const char *, int,...)