thestk / rtaudio

A set of C++ classes that provide a common API for realtime audio input/output across Linux (native ALSA, JACK, PulseAudio and OSS), Macintosh OS X (CoreAudio and JACK), and Windows (DirectSound, ASIO, and WASAPI) operating systems.
Other
1.5k stars 319 forks source link

Feedback on lost device #268

Closed gillesdegottex closed 2 years ago

gillesdegottex commented 4 years ago

Issues #194 and #195 already speak about disconnection of audio device while being use.

I couldn't find much feedback in an RtAudio stream about this situation and this is likely to happen more often in the future as many headset are now USB, with embedded audio cards.

I've found two ways to get feedback about a stream: through the RtAudioErrorCallback function (called at any point during the API-specific callback) and through the RtAudioStreamStatus (available on each RtAudioCallback calls, which is called once early in the API-specific callback).

Unfortunately:

Did I missed any other information somewhere ?

I've made a workaround that is more like a dirty fix in #267

garyscavone commented 4 years ago

Based on my work on #195, I started to develop the noexceptions branch but that was over a year ago. @radarsat more recently merged most of the changes from noexceptions into master but I think it may not have been complete, as I still see a “throw” in the RtApi::error() function. Take a look at the noexceptions branch and perhaps submit a PR to update the error function.

When I was working on the “unplugging” issue, I only remember making a fix for the OS-X API. It is possible I also did it for another 1 or 2 APIs. The desired behaviour if someone unplugs a device while a stream is running is to automatically stop the stream and issue an error message (but not throw an exception).

On Aug 7, 2020, at 11:17 AM, Gilles Degottex notifications@github.com wrote:

Issues #194 https://github.com/thestk/rtaudio/issues/194 and #195 https://github.com/thestk/rtaudio/issues/195 already speak about disconnection of audio device while being use.

I couldn't find much feedback in an RtAudio stream about this situation and this is likely to happen more often in the future as many headset are now USB, with embedded audio cards.

I've found two ways to get feedback about a stream: through the RtAudioErrorCallback function (called at any point during the API-specific callback) and through the RtAudioStreamStatus (available on each RtAudioCallback calls, which is called once early in the API-specific callback).

Unfortunately:

RtAudioErrorCallback always get a RtAudioError::WARNING (according to #195 https://github.com/thestk/rtaudio/issues/195 point 2.). A temporary XRUN cannot thus be distinguished from a permanent lost device (the error type is sort of confused with the mean to report the error, because a non-warning leads to exceptions and a warning leads to text output report) RtAudioStreamStatus gives information about XRUNs only. Did I missed any other information somewhere ?

I've made a workaround that is more like a dirty fix in #267 https://github.com/thestk/rtaudio/pull/267 — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/thestk/rtaudio/issues/268, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABJYDJNMP7SMJFQL67FOTB3R7QLHPANCNFSM4PXXI6SQ.

[ { "@context": "http://schema.org", "@type": "EmailMessage", "potentialAction": { "@type": "ViewAction", "target": "https://github.com/thestk/rtaudio/issues/268", "url": "https://github.com/thestk/rtaudio/issues/268", "name": "View Issue" }, "description": "View this Issue on GitHub", "publisher": { "@type": "Organization", "name": "GitHub", "url": "https://github.com" } } ]

gillesdegottex commented 4 years ago

That's great pointers, I'll definitely have a look at them. Thanks

garyscavone commented 2 years ago

I think this is somewhat addressed in the new device selection updates.