53 #include <QtCore/qcoreapplication.h> 67 access = SND_PCM_ACCESS_RW_INTERLEAVED;
119 err = snd_pcm_prepare(
handle);
128 }
else if((err == -ESTRPIPE)||(err == -EIO)) {
130 while((err = snd_pcm_resume(
handle)) == -EAGAIN){
139 err = snd_pcm_prepare(
handle);
155 snd_pcm_format_t
format = SND_PCM_FORMAT_UNKNOWN;
158 format = SND_PCM_FORMAT_U8;
162 format = SND_PCM_FORMAT_S16_LE;
164 format = SND_PCM_FORMAT_S16_BE;
167 format = SND_PCM_FORMAT_U16_LE;
169 format = SND_PCM_FORMAT_U16_BE;
174 format = SND_PCM_FORMAT_S24_LE;
176 format = SND_PCM_FORMAT_S24_BE;
179 format = SND_PCM_FORMAT_U24_LE;
181 format = SND_PCM_FORMAT_U24_BE;
186 format = SND_PCM_FORMAT_S32_LE;
188 format = SND_PCM_FORMAT_S32_BE;
191 format = SND_PCM_FORMAT_U32_LE;
193 format = SND_PCM_FORMAT_U32_BE;
196 format = SND_PCM_FORMAT_FLOAT_LE;
198 format = SND_PCM_FORMAT_FLOAT_BE;
202 format = SND_PCM_FORMAT_FLOAT64_LE;
204 format = SND_PCM_FORMAT_FLOAT64_BE;
207 return format != SND_PCM_FORMAT_UNKNOWN
269 qWarning(
"QAudioOutput: open error, invalid format.");
271 qWarning(
"QAudioOutput: open error, invalid sample rate (%d).",
287 #if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) 293 #if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) 301 while(snd_card_get_name(idx,&name) == 0) {
311 while((count < 5) && (err < 0)) {
316 if (( err < 0)||(
handle == 0)) {
322 snd_pcm_nonblock(
handle, 0 );
325 snd_pcm_hw_params_alloca( &
hwparams );
329 unsigned int chunks = 8;
365 err = snd_pcm_hw_params_set_rate_near(
handle,
hwparams, &freakuency, 0 );
375 errMessage =
QString::fromLatin1(
"QAudioInput: snd_pcm_hw_params_set_buffer_time_near: err = %1").
arg(err);
382 errMessage =
QString::fromLatin1(
"QAudioInput: snd_pcm_hw_params_set_period_time_near: err = %1").
arg(err);
386 err = snd_pcm_hw_params_set_periods_near(
handle,
hwparams, &chunks, &dir);
414 snd_pcm_sw_params_t *swparams;
415 snd_pcm_sw_params_alloca(&swparams);
416 snd_pcm_sw_params_current(
handle, swparams);
420 snd_pcm_sw_params(
handle, swparams);
425 snd_pcm_prepare(
handle );
466 int frames = snd_pcm_avail_update(
handle);
492 if (bytesToRead < 0) {
496 if (bytesToRead < 0) {
506 bytesToRead = qMin<qint64>(len, bytesToRead);
508 int count=0, err = 0;
515 if (readFrames >= 0) {
516 err = snd_pcm_frames_to_bytes(
handle, readFrames);
521 }
else if((readFrames == -EAGAIN) || (readFrames == -EINTR)) {
526 if(readFrames == -EPIPE) {
528 err = snd_pcm_prepare(
handle);
529 }
else if(readFrames == -ESTRPIPE) {
530 err = snd_pcm_prepare(
handle);
539 qDebug()<<
"frames to write to QIODevice = "<<
540 snd_pcm_bytes_to_frames(
handle, (
int)err )<<
" ("<<err<<
") bytes";
591 err = snd_pcm_prepare(
handle );
595 err = snd_pcm_start(
handle);
731 return audioDevice->read(data,len);
#define QT_END_NAMESPACE
This macro expands to.
The QByteArray class provides an array of bytes.
int length() const
Returns the number of characters in this string.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
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)
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)
static void processEvents(QEventLoop::ProcessEventsFlags flags=QEventLoop::AllEvents)
Processes all pending events for the calling thread according to the specified flags until there are ...
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.
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
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...
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
QByteArray mid(int index, int len=-1) const
Returns a byte array containing len bytes from this byte array, starting at position pos...
int indexOf(char c, int from=0) const
Returns the index position of the first occurrence of the character ch in the byte array...
QByteArray toLocal8Bit() const Q_REQUIRED_RESULT
Returns the local 8-bit representation of the string as a QByteArray.
T & first()
Returns a reference to the first item in the list.
const char * constData() const
Returns a pointer to the data stored in the byte array.
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
Disconnects signal in object sender from method in object receiver.
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
int compare(const QString &s) const
static QTime currentTime()
Returns the current time as reported by the system clock.
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
int qstrncmp(const char *str1, const char *str2, uint len)
virtual bool open(OpenMode mode)
Opens the device and sets its OpenMode to mode.
The QTimer class provides repetitive and single-shot timers.
qint64 write(const char *data, qint64 len)
Writes at most maxSize bytes of data from data to the device.
static QList< QByteArray > availableDevices(QAudio::Mode)
The QIODevice class is the base interface class of all I/O devices in Qt.
void stop()
Stops the timer.
void start(int msec)
Starts or restarts the timer with a timeout interval of msec milliseconds.
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...