55 #include <alsa/version.h> 66 #if (SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) 162 #if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) 168 #if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) 176 while(snd_card_get_name(idx,&name) == 0) {
209 snd_pcm_hw_params_t *
params;
215 #if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) 221 #if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) 229 while(snd_card_get_name(idx,&name) == 0) {
247 bool testChannel =
false;
248 bool testCodec =
false;
249 bool testFreq =
false;
250 bool testType =
false;
251 bool testSize =
false;
255 snd_pcm_nonblock( handle, 0 );
256 snd_pcm_hw_params_alloca( ¶ms );
257 snd_pcm_hw_params_any( handle, params );
260 snd_pcm_hw_params_set_channels(handle,params,format.
channels());
261 snd_pcm_hw_params_set_rate(handle,params,format.
frequency(),dir);
268 err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S8);
270 err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U8);
275 err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S16_LE);
277 err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S16_BE);
280 err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U16_LE);
282 err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U16_BE);
288 err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S32_LE);
290 err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S32_BE);
293 err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U32_LE);
295 err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U32_BE);
305 if(err>=0 && format.
channels() != -1) {
306 err = snd_pcm_hw_params_test_channels(handle,params,format.
channels());
308 err = snd_pcm_hw_params_set_channels(handle,params,format.
channels());
314 err = snd_pcm_hw_params_test_rate(handle,params,format.
frequency(),0);
316 err = snd_pcm_hw_params_set_rate(handle,params,format.
frequency(),dir);
326 err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S8);
328 err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U8);
333 err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S16_LE);
335 err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S16_BE);
338 err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U16_LE);
340 err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U16_BE);
346 err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S32_LE);
348 err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_S32_BE);
351 err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U32_LE);
353 err = snd_pcm_hw_params_set_format(handle,params,SND_PCM_FORMAT_U32_BE);
362 err = snd_pcm_hw_params(handle, params);
368 snd_pcm_close(handle);
372 snd_pcm_close(handle);
399 #if (SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) 422 #if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) 425 char *
name, *descr, *io;
427 if(snd_device_name_hint(-1,
"pcm", &hints) < 0) {
428 qWarning() <<
"no alsa devices available";
440 name = snd_device_name_get_hint(*n,
"NAME");
441 if (name != 0 &&
qstrcmp(name,
"null") != 0) {
442 descr = snd_device_name_get_hint(*n,
"DESC");
443 io = snd_device_name_get_hint(*n,
"IOID");
445 if ((descr != NULL) && ((io == NULL) || (io == filter))) {
461 snd_device_name_free_hint(hints);
463 if(devices.
size() > 0) {
464 devices.
append(
"default");
470 while(snd_card_get_name(idx,&name) == 0) {
475 devices.
append(
"default");
477 if (devices.
size() == 0 && allDevices.
size() > 0)
486 if(devices.
size() == 0)
489 return devices.
first();
495 if(devices.
size() == 0)
498 return devices.
first();
501 #if (SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) 502 void QAudioDeviceInfoInternal::checkSurround()
510 char *
name, *descr, *io;
512 if(snd_device_name_hint(-1,
"pcm", &hints) < 0)
518 name = snd_device_name_get_hint(*n,
"NAME");
519 descr = snd_device_name_get_hint(*n,
"DESC");
520 io = snd_device_name_get_hint(*n,
"IOID");
521 if((name != NULL) && (descr != NULL)) {
540 snd_device_name_free_hint(hints);
QBool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
static QByteArray defaultOutputDevice()
const unsigned int MAX_SAMPLE_RATES
#define QT_END_NAMESPACE
This macro expands to.
const unsigned int SAMPLE_RATES[]
The QByteArray class provides an array of bytes.
QString deviceName() const
Returns the audio device name.
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
QList< QAudioFormat::SampleType > typez
~QAudioDeviceInfoInternal()
static QByteArray defaultInputDevice()
void append(const T &t)
Inserts value at the end of the list.
QAudioFormat preferredFormat() const
Returns the nearest settings.
#define QT_BEGIN_NAMESPACE
This macro expands to.
The QStringList class provides a list of strings.
snd_pcm_hw_params_t * params
QList< int > channelsList()
Returns the list of currently available channels.
bool isFormatSupported(const QAudioFormat &format) const
Returns true if format is available from audio device.
Q_CORE_EXPORT void qWarning(const char *,...)
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
void clear()
Removes all items from the list.
QByteArray toLocal8Bit() const Q_REQUIRED_RESULT
Returns the local 8-bit representation of the string as a QByteArray.
QAudioDeviceInfoInternal(QByteArray dev, QAudio::Mode mode)
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.
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
QStringList codecList()
Returns the list of currently available codecs.
QList< QAudioFormat::SampleType > sampleTypeList()
Returns the list of currently available sample types.
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
int compare(const QString &s) const
QAudioFormat nearestFormat(const QAudioFormat &format) const
Returns the nearest settings format.
QList< QAudioFormat::Endian > byteOrderz
QList< QAudioFormat::Endian > byteOrderList()
Returns the list of currently available byte orders.
QList< int > sampleSizeList()
Returns the list of currently available sample sizes.
int size() const
Returns the number of items in the list.
QFuture< void > filter(Sequence &sequence, FilterFunction filterFunction)
QList< int > frequencyList()
Returns the list of currently available frequencies.
int qstrcmp(const QByteArray &str1, const char *str2)
static QList< QByteArray > availableDevices(QAudio::Mode)
bool testSettings(const QAudioFormat &format) const