0

On a PC w/ Ubuntu 14.04, Qt 5.5.0 & Bluez 4.101-0ubuntu13.1, I'm trying to play audio to BT sink devices over A2DP.

To do so, I'm connecting to those devices using Bluez and then play to it using QAudioOutput with a device detected using search on QAudioDeviceInfo::availableDevices(QAudio::AudioOutput) output. However, the QAudioDeviceInfo::availableDevices(QAudio::AudioOutput) output does not change after calling it for the second, and requires restart of the application for the list to refresh. Since I can't create QAudioDeviceInfo (to input to the QAudioOutput) with my custom parameters of the ALSA hw device, I can't stream audio to new A2DP sink devices.

Has anyone encountered this issue? Is there a solution or a workaround? I'll appreciate the help.

G. Ko
  • 403
  • 6
  • 15
  • Someone has recently asked the same question about detecting runtime disconnections and connections of the cameras. – Velkan Feb 09 '16 at 07:35
  • can you share a link? I can't find it – G. Ko Feb 09 '16 at 07:38
  • There was no solution for that ([stackoverflow](http://stackoverflow.com/questions/35033999/qml-detect-disconnect-webcam), [qtcentre](http://www.qtcentre.org/threads/65038-qml-detect-turn-off-or-disconnect-webcam), [forum.qt.io](https://forum.qt.io/topic/63352/detect-disconnect-webcam)). The fastest way to know what's going on is to look into Qt with a debugger. – Velkan Feb 09 '16 at 07:49
  • You mean trace Qt's calls to ALSA? – G. Ko Feb 09 '16 at 07:58
  • I think you have to connect the device before launching the application. I work with audio professionally, and even pro audio interfaces on windows are not detected when connected during the daw is running. – dtech Feb 09 '16 at 08:02
  • The application must be able to connect to various BT devices and switch between them at runtime – G. Ko Feb 09 '16 at 08:05
  • BT device is one thing, audio device is a whole other thing, BT or USB or whatever. – dtech Feb 09 '16 at 08:05
  • I mean that it's not an option to restart the application for every new device connection – G. Ko Feb 09 '16 at 08:07
  • In much the same way, inserting a USB drive during an application is running will have it visible to the app, inserting a USB audio device will not. – dtech Feb 09 '16 at 08:07
  • Well, I might be wrong, but that's my personal experience. Try to see if any other audio application recognizes it without restarting. – dtech Feb 09 '16 at 08:09
  • 1
    Audio devices on Linux are detected fine (with whatever contemporary sound system you use). If something doesn't work, it can be fixed in the Qt plugin that interacts with the audio subsystem of the OS. – Velkan Feb 09 '16 at 08:17

1 Answers1

0

One possible and easy workaround comes to mind, although it is somewhat hacky. You can use a separate process and use IPC to transfer data between your main application process and the audio output process. This way you can relaunch the process and detect newly connected audio devices without having to quit the main application.

Or you can use the main application as merely a controller to the other process, avoiding the need for extensive IPC, not that audio will be a problem but still.

dtech
  • 47,916
  • 17
  • 112
  • 190
  • I thought about creating a wrapper process for ALSA's `aplay`, which may be even better, but that'll happen if there's no builtin solution w/ Qt. – G. Ko Feb 09 '16 at 08:49