-
Notifications
You must be signed in to change notification settings - Fork 111
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
media_codec: Add support for asynchronous notification callbacks #410
Conversation
6e1607e
to
e51eac8
Compare
It is not only questionable, this should break on Perhaps you can work something out to give a In the past I've been wanting to have some |
@zarik5 you might want to see this! |
Let's not have the PR link in the commit title (as if this was a final merge-commit) please :) |
Looking at the Android source code, when an Maybe we can pass a reference to the callback, but.. why? Even something as simple as
I was just copying the convention from previous commits. Is the PR number added to the commit automatically or something? |
@spencercw oh I may have skimmed your question too quickly then and assumed the deadlocks were caused by wrapping things in a (The only use I can think of then is typically using the same callback function for multiple objects, and being able to distinguish which of the codec objects just called the callback... But you can also use the userdata pointer for that, as already done by storing extra data in
It'll be added automatically on squash merge by GitHub indeed 🙂 (and I think we'd have it twice otherwise, if I'm careless while clicking merge). |
e51eac8
to
dec9182
Compare
@spencercw thanks for #412, it's merged now. Can you rebase this and perhaps look at / mark-as-resolved the above discussion items? |
dec9182
to
a628917
Compare
Rebased on master. I think that's all comments addressed now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good already, thanks for doing so many drive-by cleanups and improvements to the media_codec.rs
API too!
Probably my main concern is not having doc-comments on any of these, but (for functions that were already here before your PR) that should be tackled in a separate PR.
Let me know if you're up for that or if I should tackle this, as I am quite pedantic towards tailoring the upstream docs to Rust 😉
28e78c8
to
d1dbf4a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good! The only remaining comments are to update the line-ranges in the links, then this is good to merge (and I know I've been asking a lot, thanks for bearing with me...).
1a66810
to
2bb5833
Compare
No worries. It's good to get it all polished up before merging :) |
2bb5833
to
afc4bcc
Compare
/// and what are specified. | ||
/// | ||
/// Once the callback is unregistered or the codec is reset / released, the previously | ||
/// registered callback will not be called. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really nitty, but want to make the same remark that previous callbacks are also unregistered when this returns an error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how I feel about documenting implementation behaviour that is not mentioned in the upstream documentation. I guess it's not the worst thing since we rely on that behaviour within this function anyway, just feels a bit icky..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then let's not, and let's have our Rust docs as incomplete as the NDK ones 👌
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a bit sad to be honest but 🤷♂️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zarik5 what's sad? The fact that AOSP unregisters previously-successfully-registered callbacks on error, or the fact that we're not going to document it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation bit.
afc4bcc
to
f72eba2
Compare
Note that unlike the audio data callback, I do not provide a reference to the codec as a callback parameter. Happy to be overruled on this, but I find the notion of constructing a new
MediaCodec
which wraps anffi::AMediaCodec
already owned by anotherMediaCodec
somewhere else to be a bit questionable. If you really need access to theMediaCodec
within the callback than you can use aMutex
or something, but the reality is that you can't actually do very much within the callback. For example, if you try to release the output buffer in the 'output available' callback then the whole thing just deadlocks.Typical usage might look something like this (sans proper error handling):
Elsewhere...