56 #ifndef SPEAKER_FRONT_LEFT 57 #define SPEAKER_FRONT_LEFT 0x00000001 58 #define SPEAKER_FRONT_RIGHT 0x00000002 59 #define SPEAKER_FRONT_CENTER 0x00000004 60 #define SPEAKER_LOW_FREQUENCY 0x00000008 61 #define SPEAKER_BACK_LEFT 0x00000010 62 #define SPEAKER_BACK_RIGHT 0x00000020 63 #define SPEAKER_FRONT_LEFT_OF_CENTER 0x00000040 64 #define SPEAKER_FRONT_RIGHT_OF_CENTER 0x00000080 65 #define SPEAKER_BACK_CENTER 0x00000100 66 #define SPEAKER_SIDE_LEFT 0x00000200 67 #define SPEAKER_SIDE_RIGHT 0x00000400 68 #define SPEAKER_TOP_CENTER 0x00000800 69 #define SPEAKER_TOP_FRONT_LEFT 0x00001000 70 #define SPEAKER_TOP_FRONT_CENTER 0x00002000 71 #define SPEAKER_TOP_FRONT_RIGHT 0x00004000 72 #define SPEAKER_TOP_BACK_LEFT 0x00008000 73 #define SPEAKER_TOP_BACK_CENTER 0x00010000 74 #define SPEAKER_TOP_BACK_RIGHT 0x00020000 75 #define SPEAKER_RESERVED 0x7FFC0000 76 #define SPEAKER_ALL 0x80000000 79 #ifndef _WAVEFORMATEXTENSIBLE_ 81 #define _WAVEFORMATEXTENSIBLE_ 99 #if !defined(WAVE_FORMAT_EXTENSIBLE) 100 #define WAVE_FORMAT_EXTENSIBLE 0xFFFE 108 settings(audioFormat)
170 unsigned char* buffer;
172 DWORD totalBufferSize = (size +
sizeof(WAVEHDR))*count;
174 if((buffer=(
unsigned char*)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,
175 totalBufferSize)) == 0) {
176 qWarning(
"QAudioOutput: Memory allocation error");
179 blocks = (WAVEHDR*)buffer;
180 buffer +=
sizeof(WAVEHDR)*count;
181 for(i = 0; i < count; i++) {
182 blocks[i].dwBufferLength = size;
183 blocks[i].lpData = (LPSTR)buffer;
191 WAVEHDR* blocks = blockArray;
195 for(
int i = 0; i < count; i++) {
196 waveOutUnprepareHeader(
hWaveOut,blocks,
sizeof(WAVEHDR));
199 HeapFree(GetProcessHeap(), 0, blockArray);
259 qWarning(
"QAudioOutput: open error, invalid format.");
261 qWarning(
"QAudioOutput: open error, invalid number of channels (%d).",
264 qWarning(
"QAudioOutput: open error, invalid sample size (%d).",
307 wfx.nBlockAlign = (
wfx.wBitsPerSample >> 3) *
wfx.nChannels;
308 wfx.nAvgBytesPerSec =
wfx.nBlockAlign *
wfx.nSamplesPerSec;
310 UINT_PTR devId = WAVE_MAPPER;
313 unsigned long iNumDevs,ii;
314 iNumDevs = waveOutGetNumDevs();
315 for(ii=0;ii<iNumDevs;ii++) {
316 if(waveOutGetDevCaps(ii, &woc,
sizeof(WAVEOUTCAPS))
317 == MMSYSERR_NOERROR) {
331 CALLBACK_FUNCTION) != MMSYSERR_NOERROR) {
335 qWarning(
"QAudioOutput: open error");
347 static const GUID _KSDATAFORMAT_SUBTYPE_PCM = {
348 0x00000001, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
349 wfex.
SubFormat=_KSDATAFORMAT_SUBTYPE_PCM;
363 CALLBACK_FUNCTION) != MMSYSERR_NOERROR) {
367 qWarning(
"QAudioOutput: open error");
456 char* p = (
char*)
data;
469 for (
qint64 i = 0; i < (l >> 1); i++)
476 for (
qint64 i = 0; i < (l >> 2); i++)
494 if(current->dwFlags & WHDR_PREPARED)
495 waveOutUnprepareHeader(
hWaveOut, current,
sizeof(WAVEHDR));
501 memcpy(current->lpData, p, remain);
505 current->dwBufferLength = remain;
506 waveOutPrepareHeader(
hWaveOut, current,
sizeof(WAVEHDR));
507 waveOutWrite(
hWaveOut, current,
sizeof(WAVEHDR));
512 qDebug(
"write out l=%d, waveFreeBlockCount=%d",
577 qDebug()<<
"deviceReady() no. of chunks that can fit ="<<chunks<<
", chunks in bytes ="<<chunks*
period_size;
579 bool startup =
false;
591 qDebug() <<
"Skipping data as unable to write";
603 int input = period_size*chunks;
714 int chunk = audioDevice->write(
data+written,(l-written));
static void QT_WIN_CALLBACK waveOutProc(HWAVEOUT hWaveOut, UINT uMsg, DWORD_PTR dwInstance, DWORD_PTR dwParam1, DWORD_PTR dwParam2)
WAVEHDR * allocateBlocks(int size, int count)
#define SPEAKER_FRONT_RIGHT
qint64 write(const char *data, qint64 len)
#define QT_END_NAMESPACE
This macro expands to.
void notify()
This signal is emitted when x ms of audio data has been processed the interval set by setNotifyInterv...
void lock()
Locks the mutex.
void stateChanged(QAudio::State)
This signal is emitted when the device state has changed.
#define WAVE_FORMAT_EXTENSIBLE
char * data()
Returns a pointer to the data stored in the byte array.
OutputPrivate(QAudioOutputPrivate *audio)
const WAVEFORMATEXTENSIBLE * LPCWAVEFORMATEXTENSIBLE
QAudio::State state() const
Returns the state of audio processing.
The QByteArray class provides an array of bytes.
static C reverse(const C &l)
void resume()
Resumes processing audio data after a suspend()
virtual qint64 pos() const
For random-access devices, this function returns the position that data is written to or read from...
#define SPEAKER_BACK_RIGHT
T qFromBigEndian(const uchar *src)
QAudio::State deviceState
int msec() const
Returns the millisecond part (0 to 999) of the time.
#define SPEAKER_SIDE_LEFT
The QString class provides a Unicode character string.
T * qobject_cast(QObject *object)
friend class OutputPrivate
The QChar class provides a 16-bit Unicode character.
qint64 elapsed() const
Returns the number of milliseconds since this QElapsedTimer was last started.
QAudio::Error error() const
Returns the error state.
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
#define SPEAKER_LOW_FREQUENCY
int restart()
Sets this time to the current time and returns the number of milliseconds that have elapsed since the...
void reset()
Drops all audio data in the buffers, resets buffers to zero.
qint64 read(char *data, qint64 maxlen)
Reads at most maxSize bytes from the device into data, and returns the number of bytes read...
Q_CORE_EXPORT void qDebug(const char *,...)
void setBufferSize(int value)
Sets the audio buffer size to value in bytes.
#define SPEAKER_FRONT_CENTER
The QTime class provides clock time functions.
#define SPEAKER_SIDE_RIGHT
#define QT_BEGIN_NAMESPACE
This macro expands to.
QAudioOutputPrivate(const QByteArray &device, const QAudioFormat &audioFormat)
qint64 restart()
Restarts the timer and returns the time elapsed since the previous start.
qint64 readData(char *data, qint64 len)
Reads up to maxSize bytes from the device into data, and returns the number of bytes read or -1 if an...
int notifyInterval() const
Returns the notify interval in milliseconds.
struct WAVEFORMATEXTENSIBLE * LPPWAVEFORMATEXTENSIBLE
void freeBlocks(WAVEHDR *blockArray)
Q_CORE_EXPORT void qWarning(const char *,...)
int second() const
Returns the second part (0 to 59) of the time.
static const char * data(const QByteArray &arr)
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
qint64 elapsedUSecs() const
Returns the milliseconds since start() was called, including time in Idle and suspend states...
union WAVEFORMATEXTENSIBLE::@309 Samples
qint64 processedUSecs() const
Returns the amount of audio data processed since start() was called in milliseconds.
void suspend()
Stops processing audio data, preserving buffered audio data.
void unlock()
Unlocks the mutex.
#define SPEAKER_FRONT_LEFT
int periodSize() const
Returns the period size in bytes.
int elapsed() const
Returns the number of milliseconds that have elapsed since the last time start() or restart() was cal...
QAudioFormat format() const
Returns the QAudioFormat being used.
struct WAVEFORMATEXTENSIBLE * PWAVEFORMATEXTENSIBLE
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
int compare(const QString &s) const
static QTime currentTime()
Returns the current time as reported by the system clock.
int bytesFree() const
Returns the free space available in bytes in the audio buffer.
void setNotifyInterval(int milliSeconds)
Sets the interval for notify() signal to be emitted.
bool singleShot
This static function calls a slot after a given time interval.
void resize(int size)
Sets the size of the byte array to size bytes.
if(void) toggleToolbarShown
static const int buffer_size
int bufferSize() const
Returns the audio buffer size in bytes.
virtual bool open(OpenMode mode)
Opens the device and sets its OpenMode to mode.
#define SPEAKER_BACK_LEFT
QIODevice * start(QIODevice *device=0)
Uses the device as the QIODevice to transfer data.
void stop()
Stops the audio output.
volatile int waveFreeBlockCount
The QIODevice class is the base interface class of all I/O devices in Qt.
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
virtual bool seek(qint64 pos)
For random-access devices, this function sets the current position to pos, returning true on success...
qint64 writeData(const char *data, qint64 len)
Writes up to maxSize bytes from data to the device.