mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Move active media session logic to constellation
This commit is contained in:
parent
08f9f17ed3
commit
85ec66b43e
7 changed files with 46 additions and 51 deletions
|
@ -83,7 +83,6 @@ use constellation::{Constellation, InitialConstellationState, UnprivilegedPipeli
|
|||
use constellation::{FromCompositorLogger, FromScriptLogger};
|
||||
use crossbeam_channel::{unbounded, Sender};
|
||||
use embedder_traits::{EmbedderMsg, EmbedderProxy, EmbedderReceiver, EventLoopWaker};
|
||||
use embedder_traits::{MediaSessionEvent, MediaSessionPlaybackState};
|
||||
use env_logger::Builder as EnvLoggerBuilder;
|
||||
use euclid::{Scale, Size2D};
|
||||
#[cfg(all(
|
||||
|
@ -272,8 +271,6 @@ pub struct Servo<Window: WindowMethods + 'static + ?Sized> {
|
|||
embedder_events: Vec<(Option<BrowserId>, EmbedderMsg)>,
|
||||
profiler_enabled: bool,
|
||||
webgl_thread_data: Option<Rc<WebGLMainThread>>,
|
||||
/// Browser ID of the active media session, if any.
|
||||
active_media_session: Option<BrowserId>,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
|
@ -560,7 +557,6 @@ where
|
|||
embedder_events: Vec::new(),
|
||||
profiler_enabled: false,
|
||||
webgl_thread_data,
|
||||
active_media_session: None,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -750,31 +746,6 @@ where
|
|||
self.embedder_events.push(event);
|
||||
},
|
||||
|
||||
(EmbedderMsg::MediaSessionEvent(event), ShutdownState::NotShuttingDown) => {
|
||||
// Unlikely at this point, but we may receive events coming from
|
||||
// different media sessions, so we set the active media session based
|
||||
// on Playing events.
|
||||
// The last media session claiming to be in playing state is set to
|
||||
// the active media session.
|
||||
// Events coming from inactive media sessions are discarded.
|
||||
if self.active_media_session.is_some() {
|
||||
match event {
|
||||
MediaSessionEvent::PlaybackStateChange(ref state) => {
|
||||
match state {
|
||||
MediaSessionPlaybackState::Playing => (),
|
||||
_ => return,
|
||||
};
|
||||
},
|
||||
_ => (),
|
||||
};
|
||||
}
|
||||
self.active_media_session = top_level_browsing_context;
|
||||
self.embedder_events.push((
|
||||
top_level_browsing_context,
|
||||
EmbedderMsg::MediaSessionEvent(event),
|
||||
));
|
||||
},
|
||||
|
||||
(msg, ShutdownState::NotShuttingDown) => {
|
||||
self.embedder_events.push((top_level_browsing_context, msg));
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue