Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update sample code and documentation to use new data and error callback interfaces #1091

Merged
merged 5 commits into from
Nov 24, 2020

Conversation

dturner
Copy link
Collaborator

@dturner dturner commented Nov 20, 2020

This PR refactors the sample code away from using a single callback (AudioStreamCallback) for both data and error events to using the new AudioStreamDataCallback and AudioStreamErrorCallback classes.

The only issue I faced was that the original DefaultAudioStreamCallback (used by hello-oboe and megadrone) would attempt to set thread affinity inside the data callback and would reset it inside the error callback through a single field: mIsThreadAffinitySet.

By separating the two callbacks the error callback no longer has access to this field. To solve this I added a reset method to DefaultDataCallback which can be called to reset the data callback to its initial configuration (in this case, only the thread affinity).

The responsibility for calling reset moves away from the error callback, which just calls restart on its IRestartable parent. It's up to the parent to call reset on the data callback. Example here: https://github.com/google/oboe/compare/master...dturner:split_callbacks?expand=1#diff-300176f2b98467e0664a62ca6d40aa3f5c2401121741bcdea15a787557a6071bR133.

@dturner dturner requested a review from philburk November 20, 2020 12:09
@dturner dturner changed the title Update sample code to use new data and error callback interfaces Update sample code and documentation to use new data and error callback interfaces Nov 20, 2020
Copy link
Collaborator

@philburk philburk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will coerce the ErrorTimeout to ErrorDisconnect in Oboe.

@dturner dturner merged commit 736c08a into google:master Nov 24, 2020
@dturner dturner deleted the split_callbacks branch November 24, 2020 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants