Make the media player API more statefull#467
Merged
jdm merged 1 commit intoservo:mainfrom Dec 4, 2025
Merged
Conversation
989137e to
647fefa
Compare
Contributor
Author
jdm
approved these changes
Nov 20, 2025
New media player APIs (`paused`, `playback_rate`, `volume`) were added to track the current associated state to reduce overhead of the media backend state changes. The `setter` methods will return `Result<T, PlayerError>` while the `getter` methods - T (default value on media error). Note that handling the playback rate change it quite tricky for gsteamer backend (need to wait until GST_STATE_PAUSED). The `gst_play_set_rate` function not only sets the playback rate property in GstPlay but also creates a new `seek` request with the current position, then fires `seek done` event afterwards and changes the state to `PlayState::Paused`. There are client application requrement to send `PlayerEvent::Paused` event after receiving the initial metadata, so the `send_paused_event` workaround has been added to the gstreamer backend for other cases. servo/servo#40740 Signed-off-by: Andrei Volykhin <[email protected]>
647fefa to
9964323
Compare
Contributor
Author
|
Applied more global changes for the media player instead of just for the |
tharkum
added a commit
to tharkum/servo
that referenced
this pull request
Dec 3, 2025
It's important to check the media player's `paused` state to avoid unnecessary changes to its internal state (via `play`, `pause`), including configuration the `playback rate` and `volume` properties. Depends on servo/media#467 Testing: The expected test results are unchanged because it is the implicit performance improvements of the media stack, with the exception of the following test, which is affected by the `playback rate` state caching mechanism (the `seek` position is not overridden for default playback rate (1.0)). - html/semantics/embedded-content/media-elements/preserves-pitch.html See https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/4762 Signed-off-by: Andrei Volykhin <[email protected]>
tharkum
added a commit
to tharkum/servo
that referenced
this pull request
Dec 3, 2025
It's important to check the media player's `paused` state to avoid unnecessary changes to its internal state (via `play`, `pause`), including configuration the `playback rate` and `volume` properties. Depends on servo/media#467 Testing: The expected test results are unchanged because it is the implicit performance improvements of the media stack, with the exception of the following test, which is affected by the `playback rate` state caching mechanism (the `seek` position is not overridden for default playback rate (1.0)). - html/semantics/embedded-content/media-elements/preserves-pitch.html See https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/4762 Signed-off-by: Andrei Volykhin <[email protected]>
jdm
approved these changes
Dec 4, 2025
tharkum
added a commit
to tharkum/servo
that referenced
this pull request
Dec 4, 2025
It's important to check the media player's `paused` state to avoid unnecessary changes to its internal state (via `play`, `pause`), including configuration the `playback rate` and `volume` properties. Depends on servo/media#467 Testing: The expected test results are unchanged because it is the implicit performance improvements of the media stack, with the exception of the following test, which is affected by the `playback rate` state caching mechanism (the `seek` position is not overridden for default playback rate (1.0)). - html/semantics/embedded-content/media-elements/preserves-pitch.html See https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/4762 Signed-off-by: Andrei Volykhin <[email protected]>
tharkum
added a commit
to tharkum/servo
that referenced
this pull request
Dec 4, 2025
It's important to check the media player's `paused` state to avoid unnecessary changes to its internal state (via `play`, `pause`), including configuration the `playback rate` and `volume` properties. Depends on servo/media#467 Testing: The expected test results are unchanged because it is the implicit performance improvements of the media stack, with the exception of the following test, which is affected by the `playback rate` state caching mechanism (the `seek` position is not overridden for default playback rate (1.0)). - html/semantics/embedded-content/media-elements/preserves-pitch.html See https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/4762 Signed-off-by: Andrei Volykhin <[email protected]>
github-merge-queue bot
pushed a commit
to servo/servo
that referenced
this pull request
Dec 4, 2025
…ite (#41027) It's important to check the media player's `paused` state to avoid unnecessary changes to its internal state (via `play`, `pause`), including configuration the `playback rate` and `volume` properties. Depends on servo/media#467 Testing: The expected test results are unchanged because it is the implicit performance improvements of the media stack, with the exception of the following test, which is affected by the `playback rate` state caching mechanism (the `seek` position is not overridden for default playback rate (1.0)). - html/semantics/embedded-content/media-elements/preserves-pitch.html See https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/4762 Signed-off-by: Andrei Volykhin <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
New media player APIs (
paused,playback_rate,volume) were added to track the current associated state toreduce overhead of the media backend state changes.
The
settermethods will returnResult<T, PlayerError>while thegettermethods - T (default value on media error).Note that handling the playback rate change it quite tricky for gsteamer backend (need to wait until GST_STATE_PAUSED).
The
gst_play_set_ratefunction not only sets the playback rate property in GstPlay but also creates a newseekrequest with the current position, then firesseek doneevent afterwards and changes the state toPlayState::Paused.There are client application requirement to send
PlayerEvent::Pausedevent after receiving the initial metadata, so thesend_paused_eventworkaround has been added to the gstreamer backend for other cases.servo/servo#40740