-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
synchronization for libmpv #1542
Comments
Currently, asynchronous commands are executed synchronously within the core (just that the API function returns immediately, instead of blocking for the result), so they're not much different from synchronous commands. |
Ah, then, may I think any sync version function call will flush all queued commands? |
Yep, currently. Currently, synchronous vs. asynchronous is a bit of a mess. The core always runs commands synchronous or asynchronously, depending what it is. For example, We still can introduce something like |
If you think this behavior might be changed, i think mpv_flush() for alias of "ignore" command will be helpful in order to ensure synchronization at mpv_flush() regardless of internal behavior of mpv. Thank you! |
This does what it's documented to do. The implementation reuses the code in mpv_detach_destroy(). Due to the way async requests currently work, just sending a synchronous dummy request (like a "ignore" command) would be enough to ensure synchronization, but this code will continue to work even if this changes. The line "ctx->event_mask = 0;" is removed, but it shouldn't be needed. (If a client is somehow very slow to terminate, this could silence an annoying queue overflow message, but all in all it does nothing.) Calling mpv_wait_async_requests() and mpv_wait_event() concurrently is in theory allowed, so change pthread_cond_signal() to pthread_cond_broadcast() to avoid missed wakeups. As requested in issue #1542.
Added something... I hope it's what you expected. |
Thank you! |
This does what it's documented to do. The implementation reuses the code in mpv_detach_destroy(). Due to the way async requests currently work, just sending a synchronous dummy request (like a "ignore" command) would be enough to ensure synchronization, but this code will continue to work even if this changes. The line "ctx->event_mask = 0;" is removed, but it shouldn't be needed. (If a client is somehow very slow to terminate, this could silence an annoying queue overflow message, but all in all it does nothing.) Calling mpv_wait_async_requests() and mpv_wait_event() concurrently is in theory allowed, so change pthread_cond_signal() to pthread_cond_broadcast() to avoid missed wakeups. As requested in issue mpv-player#1542.
libmpv provides each set of sync and async version for command/property.
async version set is very useful for not-blocking operations, but sometimes, its utilization is restricted by absence of synchronization functionality like glFinish() in OpenGL.
Suppose 'A' is an operation which can be executed asynchronously when they're executed independently and 'B' is another operation which depends on the execution state of 'A'.
Lack of synchronization enforces me to write two set of functions sync/async for 'A' or just let me give up async version.
I think something like mpv_synchronize() or mpv_flush() will make it easier to use async set of APIs.
The text was updated successfully, but these errors were encountered: