mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 00:05:36 +00:00
Bug 1571513 - Setup PrincipalHandle and Playing listener of a DecodedStream in the start. r=alwu
`mPrincipalHandle` and `mPlaying` listeners were being connected in the ctor of a DecodedStream. However, this is not necessary because their attributes will only be modified after the sink start. In addition to that, it was causing problems if a sink was replaced before being started or stopped (and shutdown). This is a valid scenario, though, that we need to support. Differential Revision: https://phabricator.services.mozilla.com/D63830 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
f67e7d443b
commit
1d184960b3
@ -381,16 +381,13 @@ DecodedStream::DecodedStream(
|
||||
mPlaying(false, "DecodedStream::mPlaying"),
|
||||
mPrincipalHandle(aStateMachine->OwnerThread(), PRINCIPAL_HANDLE_NONE,
|
||||
"DecodedStream::mPrincipalHandle (Mirror)"),
|
||||
mCanonicalOutputPrincipal(aStateMachine->CanonicalOutputPrincipal()),
|
||||
mOutputTracks(std::move(aOutputTracks)),
|
||||
mVolume(aVolume),
|
||||
mPlaybackRate(aPlaybackRate),
|
||||
mPreservesPitch(aPreservesPitch),
|
||||
mAudioQueue(aAudioQueue),
|
||||
mVideoQueue(aVideoQueue) {
|
||||
mPrincipalHandle.Connect(aStateMachine->CanonicalOutputPrincipal());
|
||||
|
||||
mWatchManager.Watch(mPlaying, &DecodedStream::PlayingChanged);
|
||||
}
|
||||
mVideoQueue(aVideoQueue) {}
|
||||
|
||||
DecodedStream::~DecodedStream() {
|
||||
MOZ_ASSERT(mStartTime.isNothing(), "playback should've ended.");
|
||||
@ -421,6 +418,8 @@ nsresult DecodedStream::Start(const TimeUnit& aStartTime,
|
||||
mLastOutputTime = TimeUnit::Zero();
|
||||
mInfo = aInfo;
|
||||
mPlaying = true;
|
||||
mPrincipalHandle.Connect(mCanonicalOutputPrincipal);
|
||||
mWatchManager.Watch(mPlaying, &DecodedStream::PlayingChanged);
|
||||
ConnectListener();
|
||||
|
||||
class R : public Runnable {
|
||||
@ -516,6 +515,9 @@ void DecodedStream::Stop() {
|
||||
// Clear mData immediately when this playback session ends so we won't
|
||||
// send data to the wrong track in SendData() in next playback session.
|
||||
DestroyData(std::move(mData));
|
||||
|
||||
mPrincipalHandle.DisconnectIfConnected();
|
||||
mWatchManager.Unwatch(mPlaying, &DecodedStream::PlayingChanged);
|
||||
}
|
||||
|
||||
bool DecodedStream::IsStarted() const {
|
||||
|
@ -96,6 +96,7 @@ class DecodedStream : public MediaSink {
|
||||
|
||||
Watchable<bool> mPlaying;
|
||||
Mirror<PrincipalHandle> mPrincipalHandle;
|
||||
AbstractCanonical<PrincipalHandle>* mCanonicalOutputPrincipal;
|
||||
const nsTArray<RefPtr<ProcessedMediaTrack>> mOutputTracks;
|
||||
|
||||
double mVolume;
|
||||
|
Loading…
Reference in New Issue
Block a user