Repository navigation
Install error callback before probing devices in RtAudio constructor - #489
Merged
Merged
Conversation
The RtAudio(Api, ErrorCallback) constructor created each API object with openRtApi() and only installed the user's error callback afterwards, but the constructor then enumerates devices itself (getDeviceNames() in the compiled-API fallback loop), so warnings and errors emitted during that probing (e.g. RtApiCore::probeDeviceInfo / RtApiJack::probeDevices messages) fell back to being printed on stderr even though a callback was supplied. Forward the callback into openRtApi() and install it on the API object as soon as the object exists, so all subsequent errors and warnings, including the constructor's own device probing, are routed to the user's callback. Errors raised inside the API constructors themselves (before the object is returned) are still not capturable; that would require API constructor changes. Fixes thestk#473
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
RtAudio(Api, ErrorCallback)constructor only installed the error callback afteropenRtApi()returned, but in theUNSPECIFIEDfallback path it probes devices(
getDeviceNames()) before the callback exists on the API object, so probing warningsand errors (e.g.
RtApiCore::probeDeviceInfomessages) were printed to stderr evenwhen a callback was supplied - with no way for the application to intercept them
(#473).
Forward the callback into
openRtApi()(a private helper; default argument, so nopublic API change) and install it as soon as the API object is created. Errors emitted
by the constructor's own device enumeration are now routed to the user's callback.
Errors raised inside the API constructors themselves are still not capturable; that
would need API constructor signature changes and is out of scope here.
Fixes #473
Testing
Not run: no RtAudio build available here, the change was verified by reading the
sources. Suggested checks:
RtAudio(RtAudio::UNSPECIFIED, myCallback)on a machine where a probedAPI emits a warning (no JACK server running, or a CoreAudio device that fails
probeDeviceInfo): the message must arrive via the callback, not stderr...." message still goes through the callback.
showWarnings(false)behavior unchanged.