-
Notifications
You must be signed in to change notification settings - Fork 571
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
Add API to set sleep time before close. #1593
Conversation
Add: AudioStream::setDelayBeforeCloseMillis(delay) This can be used to avoid use-after-free bugs cause by callbacks running when close is called. Fixes #1500
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.
Can run some tests before/after the changes and verify that the timeout increased a lot if you call setDelayBeforeCloseMillis() on a stream? This might be messy to add as a unit test but a quick sanity check before submitting would be good.
"timeout"? Are you suggesting that we measure the time it takes to close a stream and assert that the time increases when we call setDelayBeforeCloseMillis() with a higher value? |
This test works if we set setDelayBeforeCloseMillis() to a ridiculous number like 1000ms. Otherwise, the test may be too noisy. Alternatively, you can simply change testReturnStop.cpp locally to call setDelayBeforeCloseMillis() as a sanity check. |
Bump version to 1.6.3
I added a test that detects the increase in time required to close the stream. |
Great! Are you planning to push your test? |
|
// Two milliseconds may be enough but 10 msec is even safer. | ||
static constexpr int kDelayBeforeCloseMillis = 10; | ||
public: | ||
int32_t getMDelayBeforeCloseMillis() const; |
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.
Should we make this uint32_t?
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 Google C++ style guide says:
You should not use the unsigned integer types such as uint32_t, unless there is a valid reason
such as representing a bit pattern rather than a number, or you need defined overflow
modulo 2^N. In particular, do not use unsigned types to say a number will never be negative.
Instead, use assertions for this.
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.
Left some minor comments. Feel free to submit either without addressing my comments or after addressing my comments.
Add: AudioStream::setDelayBeforeCloseMillis(delay)
This can be used to avoid use-after-free bugs
cause by callbacks running when close is called.
Fixes #1500