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.49k
stars
317
forks
source link
Add support to CoreAudio for changing sample rates on a stream #429
We've started using rtAudio in the runtime for our programming language (Cmajor), and we came across issues where the sample rate could be updated on the audio device after our application using rtaudio was up and running. This is a specific problem with MacOS, so using the CoreAudio implementation, and i've put together a fix which works for us, and so have created this pull request to see if you want to integrate this solution.
I've added an additional callback to the RtAudio class, alongside the error callback, which is called when stream properties are updated. I've kept this vague on the basis that there are multiple properties which the client may care about, so this could be extended in future.
Within the RtApiCore implementation, i've generalised an existing property change listener, which was previously used to handle device disconnect events, so that it can also handle sample rate changes. Sample rate changes are bubbled up to the class instance, and the callback is called if the sample rate has been updated.
I did consider using the error callback, either a specific error case, or a warning level, but that felt ugly and likely error prone for existing applications. This implementation will I believe have no changes of behaviour unless a callback is added to the class.
I have tried to stick to your coding standards, apologies if this is not quite right, my editor kept being helpful and doing the wrong thing :)
We've started using rtAudio in the runtime for our programming language (Cmajor), and we came across issues where the sample rate could be updated on the audio device after our application using rtaudio was up and running. This is a specific problem with MacOS, so using the CoreAudio implementation, and i've put together a fix which works for us, and so have created this pull request to see if you want to integrate this solution.
I've added an additional callback to the RtAudio class, alongside the error callback, which is called when stream properties are updated. I've kept this vague on the basis that there are multiple properties which the client may care about, so this could be extended in future.
Within the RtApiCore implementation, i've generalised an existing property change listener, which was previously used to handle device disconnect events, so that it can also handle sample rate changes. Sample rate changes are bubbled up to the class instance, and the callback is called if the sample rate has been updated.
I did consider using the error callback, either a specific error case, or a warning level, but that felt ugly and likely error prone for existing applications. This implementation will I believe have no changes of behaviour unless a callback is added to the class.
I have tried to stick to your coding standards, apologies if this is not quite right, my editor kept being helpful and doing the wrong thing :)