115 unsigned char* buffer;
117 DWORD totalBufferSize = (size +
sizeof(WAVEHDR))*count;
119 if((buffer=(
unsigned char*)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,
120 totalBufferSize)) == 0) {
121 qWarning(
"QAudioInput: Memory allocation error");
124 blocks = (WAVEHDR*)buffer;
125 buffer +=
sizeof(WAVEHDR)*count;
126 for(i = 0; i < count; i++) {
127 blocks[i].dwBufferLength = size;
128 blocks[i].lpData = (LPSTR)buffer;
129 blocks[i].dwBytesRecorded=0;
130 blocks[i].dwUser = 0L;
131 blocks[i].dwFlags = 0L;
132 blocks[i].dwLoops = 0L;
133 result = waveInPrepareHeader(
hWaveIn,&blocks[i],
sizeof(WAVEHDR));
134 if(
result != MMSYSERR_NOERROR) {
135 qWarning(
"QAudioInput: Can't prepare block %d",i);
145 WAVEHDR* blocks = blockArray;
149 for(
int i = 0; i < count; i++) {
150 waveInUnprepareHeader(
hWaveIn,blocks,
sizeof(WAVEHDR));
153 HeapFree(GetProcessHeap(), 0, blockArray);
220 qWarning(
"QAudioInput: open error, invalid format.");
222 qWarning(
"QAudioInput: open error, invalid number of channels (%d).",
225 qWarning(
"QAudioInput: open error, invalid sample size (%d).",
235 #ifndef Q_OS_WINCE // Default buffer size, 200ms, default period size is 40ms 240 #else // For wince reduce size to 40ms for buffer size and 20ms period 263 wfx.nBlockAlign = (
wfx.wBitsPerSample >> 3) *
wfx.nChannels;
264 wfx.nAvgBytesPerSec =
wfx.nBlockAlign *
wfx.nSamplesPerSec;
266 UINT_PTR devId = WAVE_MAPPER;
269 unsigned long iNumDevs,ii;
270 iNumDevs = waveInGetNumDevs();
271 for(ii=0;ii<iNumDevs;ii++) {
272 if(waveInGetDevCaps(ii, &wic,
sizeof(WAVEINCAPS))
273 == MMSYSERR_NOERROR) {
286 CALLBACK_FUNCTION) != MMSYSERR_NOERROR) {
290 qWarning(
"QAudioInput: failed to open audio device");
299 qWarning(
"QAudioInput: failed to allocate blocks. open failed");
311 if(
result != MMSYSERR_NOERROR) {
312 qWarning(
"QAudioInput: failed to setup block %d,err=%d",i,
result);
321 qWarning(
"QAudioInput: failed to start audio input");
391 qWarning(
"QAudioInput: IOError, can't write to QIODevice");
435 if(
result != MMSYSERR_NOERROR) {
437 qWarning(
"QAudioInput: failed to prepare block %d,err=%d",header,
result);
447 if(
result != MMSYSERR_NOERROR) {
448 qWarning(
"QAudioInput: failed to setup block %d,err=%d",header,
result);
475 qDebug()<<
"read in len="<<written;
486 if(
result != MMSYSERR_NOERROR) {
487 qWarning(
"QAudioInput: failed to setup block %d,err=%d",i,
result);
617 return audioDevice->read(
data,len);
#define QT_END_NAMESPACE
This macro expands to.
void lock()
Locks the mutex.
The QByteArray class provides an array of bytes.
int msec() const
Returns the millisecond part (0 to 999) of the time.
long ASN1_INTEGER_get ASN1_INTEGER * a
The QString class provides a Unicode character string.
T * qobject_cast(QObject *object)
The QChar class provides a 16-bit Unicode character.
qint64 elapsed() const
Returns the number of milliseconds since this QElapsedTimer was last started.
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
int restart()
Sets this time to the current time and returns the number of milliseconds that have elapsed since the...
Q_CORE_EXPORT void qDebug(const char *,...)
The QTime class provides clock time functions.
#define QT_BEGIN_NAMESPACE
This macro expands to.
qint64 restart()
Restarts the timer and returns the time elapsed since the previous start.
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...
void unlock()
Unlocks the mutex.
int elapsed() const
Returns the number of milliseconds that have elapsed since the last time start() or restart() was cal...
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.
bool singleShot
This static function calls a slot after a given time interval.
virtual bool open(OpenMode mode)
Opens the device and sets its OpenMode to mode.
qint64 write(const char *data, qint64 len)
Writes at most maxSize bytes of data from data to the device.
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...