QAbstractAudioOutput* QAudioDeviceFactory::createOutputDevice(QAudioDeviceInfo const& deviceInfo, QAudioFormat const &format) { if (deviceInfo.isNull()) return new QNullOutputDevice(); #ifndef QT_NO_AUDIO_BACKEND #if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA) || defined(Q_OS_SYMBIAN)) if (deviceInfo.realm() == QLatin1String("builtin")) { QAbstractAudioOutput* p = new QAudioOutputPrivate(deviceInfo.handle()); if (p) p->setFormat(format); return p; } #endif #endif #if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) QAudioSystemFactoryInterface* plugin = qobject_cast<QAudioSystemFactoryInterface*>(audioLoader()->instance(deviceInfo.realm())); if (plugin) { QAbstractAudioOutput* p = plugin->createOutput(deviceInfo.handle()); if (p) p->setFormat(format); return p; } #endif return new QNullOutputDevice(); }
QList<QAudioDeviceInfo> QAudioDeviceFactory::availableDevices(QAudio::Mode mode) { QList<QAudioDeviceInfo> devices; #ifndef QT_NO_AUDIO_BACKEND #if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA) || defined(Q_OS_SYMBIAN)) foreach (const QByteArray &handle, QAudioDeviceInfoInternal::availableDevices(mode)) devices << QAudioDeviceInfo(QLatin1String("builtin"), handle, mode); #endif #endif #if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) QAudioPluginLoader* l = audioLoader(); foreach (const QString& key, l->keys()) { QAudioSystemFactoryInterface* plugin = qobject_cast<QAudioSystemFactoryInterface*>(l->instance(key)); if (plugin) { foreach (QByteArray const& handle, plugin->availableDevices(mode)) devices << QAudioDeviceInfo(key, handle, mode); } delete plugin; } #endif return devices; }
QAbstractAudioDeviceInfo* QAudioDeviceFactory::audioDeviceInfo(const QString &realm, const QByteArray &handle, QAudio::Mode mode) { QAbstractAudioDeviceInfo *rc = 0; #if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) QAudioSystemFactoryInterface* plugin = qobject_cast<QAudioSystemFactoryInterface*>(audioLoader()->instance(realm)); if (plugin) rc = plugin->createDeviceInfo(handle, mode); #endif return rc == 0 ? new QNullDeviceInfo() : rc; }
QList<QAudioDeviceInfo> QAudioDeviceFactory::availableDevices(QAudio::Mode mode) { QList<QAudioDeviceInfo> devices; #if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) QMediaPluginLoader* l = audioLoader(); foreach (const QString& key, l->keys()) { QAudioSystemFactoryInterface* plugin = qobject_cast<QAudioSystemFactoryInterface*>(l->instance(key)); if (plugin) { foreach (QByteArray const& handle, plugin->availableDevices(mode)) devices << QAudioDeviceInfo(key, handle, mode); } } #endif return devices; }
QAbstractAudioOutput* QAudioDeviceFactory::createOutputDevice(QAudioDeviceInfo const& deviceInfo, QAudioFormat const &format) { if (deviceInfo.isNull()) return new QNullOutputDevice(); #if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) QAudioSystemFactoryInterface* plugin = qobject_cast<QAudioSystemFactoryInterface*>(audioLoader()->instance(deviceInfo.realm())); if (plugin) { QAbstractAudioOutput* p = plugin->createOutput(deviceInfo.handle()); if (p) p->setFormat(format); return p; } #endif return new QNullOutputDevice(); }
QAbstractAudioDeviceInfo* QAudioDeviceFactory::audioDeviceInfo(const QString &realm, const QByteArray &handle, QAudio::Mode mode) { QAbstractAudioDeviceInfo *rc = 0; #ifndef QT_NO_AUDIO_BACKEND #if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA) || defined(Q_OS_SYMBIAN)) if (realm == QLatin1String("builtin")) return new QAudioDeviceInfoInternal(handle, mode); #endif #endif #if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) QAudioSystemFactoryInterface* plugin = qobject_cast<QAudioSystemFactoryInterface*>(audioLoader()->instance(realm)); if (plugin) rc = plugin->createDeviceInfo(handle, mode); #endif return rc == 0 ? new QNullDeviceInfo() : rc; }
QAudioDeviceInfo QAudioDeviceFactory::defaultOutputDevice() { #if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) QAudioSystemFactoryInterface* plugin = qobject_cast<QAudioSystemFactoryInterface*>(audioLoader()->instance(QLatin1String("default"))); if (plugin) { QList<QByteArray> list = plugin->availableDevices(QAudio::AudioOutput); if (list.size() > 0) return QAudioDeviceInfo(QLatin1String("default"), list.at(0), QAudio::AudioOutput); } #endif QAudioDeviceInfo result; #ifndef QT_NO_AUDIO_BACKEND #if (defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(HAS_ALSA) || defined(Q_OS_SYMBIAN)) result = QAudioDeviceInfo(QLatin1String("builtin"), QAudioDeviceInfoInternal::defaultOutputDevice(), QAudio::AudioOutput); #endif #endif return result; }
QAudioDeviceInfo QAudioDeviceFactory::defaultOutputDevice() { #if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) QAudioSystemFactoryInterface* plugin = qobject_cast<QAudioSystemFactoryInterface*>(audioLoader()->instance(defaultKey())); if (plugin) { QList<QByteArray> list = plugin->availableDevices(QAudio::AudioOutput); if (list.size() > 0) return QAudioDeviceInfo(defaultKey(), list.at(0), QAudio::AudioOutput); } // if no plugin is marked as default or if the default plugin doesn't have any output device, // return the first output available from other plugins. QList<QAudioDeviceInfo> outputDevices = availableDevices(QAudio::AudioOutput); if (!outputDevices.isEmpty()) return outputDevices.first(); #endif return QAudioDeviceInfo(); }