Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'jb51747-rationalised' into 'master'
Ensure audio continues when screen is locked See merge request mer-core/gecko-dev!177
- Loading branch information
Showing
3 changed files
with
129 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
125 changes: 125 additions & 0 deletions
125
rpm/0045-sailfishos-media-Ensure-audio-continues-when-screen-.patch
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
From 234f3bce084b90dc233afd8bdc3e003135ed06ea Mon Sep 17 00:00:00 2001 | ||
From: David Llewellyn-Jones <david.llewellyn-jones@jolla.com> | ||
Date: Thu, 29 Oct 2020 15:20:18 +0200 | ||
Subject: [PATCH] [sailfishos][media] Ensure audio continues when screen is | ||
locked. Contributes to JB#51747 | ||
|
||
This rationalises two previous commits from sailfishos-esr52, | ||
integrating the functionality of the NemoResourceHandler class into | ||
MediaDecoder. | ||
|
||
This is needed so that the "media-decoder-info" notifications are sent | ||
out when certain types of media are started/stopped and to signal | ||
whether the media contains audio and/or video. | ||
|
||
An additional change ensures media is started/stopped with the | ||
Thaw/Freeze of docuemnts (switching the check from visible status to | ||
hidden status). | ||
|
||
The previous relevant commits:- | ||
|
||
commit 9e2dc6c89b83a623ad27ac14edc501585ef8ecd9 | ||
Author: Oleg <romaxa@gmail.com> | ||
Date: Thu Oct 30 23:54:05 2014 -0700 | ||
|
||
[sailfishos][media] Add NemoResourceHandler | ||
|
||
Original SHA1: b318b3c9f723544c32895a8a4c49d7f44b6752be | ||
|
||
Signed-off-by: Raine Makelainen <raine.makelainen@jolla.com> | ||
|
||
commit 50fc4fac5ed1433acb0dff6e23dc3055f76c3226 | ||
Author: Andrew den Exter <andrew.den.exter@qinetic.com.au> | ||
Date: Thu Nov 29 17:20:06 2018 +1000 | ||
|
||
[sailfishos][media] Update media resource state when the playing | ||
state changes for any reason. Fixes JB#42900 | ||
--- | ||
dom/html/HTMLMediaElement.cpp | 4 ++-- | ||
dom/media/MediaDecoder.cpp | 27 +++++++++++++++++++++++++++ | ||
2 files changed, 29 insertions(+), 2 deletions(-) | ||
|
||
diff --git a/dom/html/HTMLMediaElement.cpp b/dom/html/HTMLMediaElement.cpp | ||
index ce5decf5c073..a6dfb1eca5ac 100644 | ||
--- a/dom/html/HTMLMediaElement.cpp | ||
+++ b/dom/html/HTMLMediaElement.cpp | ||
@@ -6046,7 +6046,7 @@ void HTMLMediaElement::NotifyOwnerDocumentActivityChanged() { | ||
} | ||
|
||
bool pauseElement = ShouldElementBePaused(); | ||
- SuspendOrResumeElement(pauseElement, !IsActive()); | ||
+ SuspendOrResumeElement(pauseElement, IsHidden()); | ||
|
||
// If the owning document has become inactive we should shutdown the CDM. | ||
if (!OwnerDoc()->IsCurrentActiveDocument() && mMediaKeys) { | ||
@@ -6869,7 +6869,7 @@ void HTMLMediaElement::NotifyAudioPlaybackChanged( | ||
|
||
bool HTMLMediaElement::ShouldElementBePaused() { | ||
// Bfcached page or inactive document. | ||
- if (!IsActive()) { | ||
+ if (IsHidden()) { | ||
return true; | ||
} | ||
|
||
diff --git a/dom/media/MediaDecoder.cpp b/dom/media/MediaDecoder.cpp | ||
index 9cc84e1e371b..8b1c9603c1d8 100644 | ||
--- a/dom/media/MediaDecoder.cpp | ||
+++ b/dom/media/MediaDecoder.cpp | ||
@@ -29,6 +29,10 @@ | ||
#include "nsIObserver.h" | ||
#include "nsPrintfCString.h" | ||
#include "nsTArray.h" | ||
+#include "nsThreadUtils.h" | ||
+#include "mozilla/Services.h" | ||
+#include "nsIObserverService.h" | ||
+#include "nsString.h" | ||
#include <algorithm> | ||
#include <limits> | ||
|
||
@@ -77,6 +81,14 @@ static const char* ToPlayStateStr(MediaDecoder::PlayState aState) { | ||
return "UNKNOWN"; | ||
} | ||
|
||
+static void SendMediaDecoderInfo(const nsString& aData) { | ||
+ MOZ_ASSERT(NS_IsMainThread()); | ||
+ nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService(); | ||
+ if (obs) { | ||
+ obs->NotifyObservers(nullptr, "media-decoder-info", aData.get()); | ||
+ } | ||
+} | ||
+ | ||
class MediaMemoryTracker : public nsIMemoryReporter { | ||
virtual ~MediaMemoryTracker(); | ||
|
||
@@ -564,6 +576,11 @@ void MediaDecoder::MetadataLoaded( | ||
aInfo->mAudio.mChannels, aInfo->mAudio.mRate, aInfo->HasAudio(), | ||
aInfo->HasVideo()); | ||
|
||
+ nsString data; | ||
+ data.AppendPrintf("{ \"owner\" : \"%p\", \"state\": \"meta\", \"a\" : %i, \"v\" : %i }", | ||
+ this, aInfo->HasAudio(), aInfo->HasVideo()); | ||
+ SendMediaDecoderInfo(data); | ||
+ | ||
mMediaSeekable = aInfo->mMediaSeekable; | ||
mMediaSeekableOnlyInBufferedRanges = | ||
aInfo->mMediaSeekableOnlyInBufferedRanges; | ||
@@ -754,6 +771,16 @@ void MediaDecoder::ChangeState(PlayState aState) { | ||
MOZ_ASSERT(!IsShutdown(), "SHUTDOWN is the final state."); | ||
AbstractThread::AutoEnter context(AbstractMainThread()); | ||
|
||
+ if (mPlayState != aState) { | ||
+ nsString data; | ||
+ if (aState == PLAY_STATE_PLAYING) { | ||
+ data.AppendPrintf("{ \"owner\" : \"%p\", \"state\": \"play\" }", this); | ||
+ } else { | ||
+ data.AppendPrintf("{ \"owner\" : \"%p\", \"state\": \"pause\" }", this); | ||
+ } | ||
+ SendMediaDecoderInfo(data); | ||
+ } | ||
+ | ||
if (mNextState == aState) { | ||
mNextState = PLAY_STATE_PAUSED; | ||
} | ||
-- | ||
2.26.2 | ||
|
This file contains 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