зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1053186 - AudioOffloadPlayer: Avoid glitch during start of playback. r=roc
This commit is contained in:
Родитель
d59255b1c1
Коммит
3898f15d2e
|
@ -119,8 +119,11 @@ public:
|
|||
// required to begin playback have been acquired. Can be called on any thread.
|
||||
virtual void NotifyWaitingForResourcesStatusChanged() = 0;
|
||||
|
||||
// Called by Reader if the current audio track can be offloaded
|
||||
virtual void SetCanOffloadAudio(bool aCanOffloadAudio) {}
|
||||
// Set by Reader if the current audio track can be offloaded
|
||||
virtual void SetPlatformCanOffloadAudio(bool aCanOffloadAudio) {}
|
||||
|
||||
// Called by Decoder/State machine to check audio offload condtions are met
|
||||
virtual bool CheckDecoderCanOffloadAudio() { return false; }
|
||||
|
||||
// Called from HTMLMediaElement when owner document activity changes
|
||||
virtual void SetElementVisibility(bool aIsVisible) {}
|
||||
|
|
|
@ -1135,6 +1135,11 @@ void MediaDecoderStateMachine::StartPlayback()
|
|||
NS_ASSERTION(!IsPlaying(), "Shouldn't be playing when StartPlayback() is called");
|
||||
AssertCurrentThreadInMonitor();
|
||||
|
||||
if (mDecoder->CheckDecoderCanOffloadAudio()) {
|
||||
DECODER_LOG(PR_LOG_DEBUG, "Offloading playback");
|
||||
return;
|
||||
}
|
||||
|
||||
mDecoder->NotifyPlaybackStarted();
|
||||
SetPlayStartTime(TimeStamp::Now());
|
||||
|
||||
|
|
|
@ -41,12 +41,19 @@ MediaOmxCommonDecoder::MediaOmxCommonDecoder()
|
|||
}
|
||||
|
||||
void
|
||||
MediaOmxCommonDecoder::SetCanOffloadAudio(bool aCanOffloadAudio)
|
||||
MediaOmxCommonDecoder::SetPlatformCanOffloadAudio(bool aCanOffloadAudio)
|
||||
{
|
||||
ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
|
||||
mCanOffloadAudio = aCanOffloadAudio;
|
||||
}
|
||||
|
||||
bool
|
||||
MediaOmxCommonDecoder::CheckDecoderCanOffloadAudio()
|
||||
{
|
||||
return (mCanOffloadAudio && !mFallbackToStateMachine && !mOutputStreams.Length() &&
|
||||
mInitialPlaybackRate == 1.0);
|
||||
}
|
||||
|
||||
void
|
||||
MediaOmxCommonDecoder::MetadataLoaded(MediaInfo* aInfo,
|
||||
MetadataTags* aTags)
|
||||
|
@ -55,8 +62,7 @@ MediaOmxCommonDecoder::MetadataLoaded(MediaInfo* aInfo,
|
|||
MediaDecoder::MetadataLoaded(aInfo, aTags);
|
||||
|
||||
ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
|
||||
if (!mCanOffloadAudio || mFallbackToStateMachine || mOutputStreams.Length() ||
|
||||
mInitialPlaybackRate != 1.0) {
|
||||
if (!CheckDecoderCanOffloadAudio()) {
|
||||
DECODER_LOG(PR_LOG_DEBUG, ("In %s Offload Audio check failed",
|
||||
__PRETTY_FUNCTION__));
|
||||
return;
|
||||
|
@ -79,6 +85,7 @@ MediaOmxCommonDecoder::MetadataLoaded(MediaInfo* aInfo,
|
|||
}
|
||||
|
||||
mAudioOffloadPlayer = nullptr;
|
||||
mFallbackToStateMachine = true;
|
||||
DECODER_LOG(PR_LOG_DEBUG, ("In %s Unable to start offload audio %d."
|
||||
"Switching to normal mode", __PRETTY_FUNCTION__, err));
|
||||
}
|
||||
|
|
|
@ -31,7 +31,8 @@ public:
|
|||
virtual void PlaybackPositionChanged();
|
||||
virtual void UpdateReadyStateForData();
|
||||
virtual void SetElementVisibility(bool aIsVisible);
|
||||
virtual void SetCanOffloadAudio(bool aCanOffloadAudio);
|
||||
virtual void SetPlatformCanOffloadAudio(bool aCanOffloadAudio);
|
||||
virtual bool CheckDecoderCanOffloadAudio();
|
||||
virtual void AddOutputStream(ProcessedMediaStream* aStream,
|
||||
bool aFinishWhenEnded);
|
||||
virtual void SetPlaybackRate(double aPlaybackRate);
|
||||
|
|
|
@ -73,7 +73,7 @@ void MediaOmxCommonReader::CheckAudioOffload()
|
|||
if ((meta.get()) && hasNoVideo && isNotStreaming && isTypeMusic &&
|
||||
canOffloadStream(meta, false, false, AUDIO_STREAM_MUSIC)) {
|
||||
DECODER_LOG(PR_LOG_DEBUG, ("Can offload this audio stream"));
|
||||
mDecoder->SetCanOffloadAudio(true);
|
||||
mDecoder->SetPlatformCanOffloadAudio(true);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
Загрузка…
Ссылка в новой задаче