tvservice: Enhance callback mechanism #162
Merged
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.
While working on our VLC mmal plugins, which use tvservice to get notified about display mode changes we ran into a small problem:
VLC might create multiple vout instances in parallel of which each one needs to register a callback to get notified about mode changes. The first problem is the limit of 2 callbacks, which may be triggered in this case. The second, even more critical one, is the unregister function which only checks the function pointer for removal of the callback list.
In our case we register the same function pointer multiple times but with different context data each. So when a vout is destroyed we need to ensure that the correct callback is unregistered, which can be done with vc_tv_unregister_callback_full as proposed in this pull requests. It simply takes the data pointer as second argument and requires a match of function and data pointer for removal.