Bug 1517252 - p1: don't lock HLSResourceCallbacksSupport mutex unnecessarily. r=jya

HLSResourceCallbacksSupport::mDecoder is cleared on main thread too, so
the nullness check already ensures decoder methods won't be called after
shut down. In fact, for OnError() the lock is harmful because the task calls
MediaDecoder::NetworkError(), which triggers decoder shutdown and eventually
HLSResourceCallbacksSupport::Detach(), which tries to lock the mutex again
while the mutex is still locked.

Differential Revision: https://phabricator.services.mozilla.com/D16709

--HG--
extra : moz-landing-system : lando
This commit is contained in:
John Lin 2019-01-22 22:55:58 +00:00
Родитель 5e38c8a5a5
Коммит e4a543d886
1 изменённых файлов: 2 добавлений и 3 удалений

Просмотреть файл

@ -52,6 +52,7 @@ HLSResourceCallbacksSupport::HLSResourceCallbacksSupport(HLSDecoder* aDecoder)
}
void HLSResourceCallbacksSupport::Detach() {
MOZ_ASSERT(NS_IsMainThread());
MutexAutoLock lock(mMutex);
mDecoder = nullptr;
}
@ -65,7 +66,6 @@ void HLSResourceCallbacksSupport::OnDataArrived() {
RefPtr<HLSResourceCallbacksSupport> self = this;
NS_DispatchToMainThread(NS_NewRunnableFunction(
"HLSResourceCallbacksSupport::OnDataArrived", [self]() -> void {
MutexAutoLock lock(self->mMutex);
if (self->mDecoder) {
self->mDecoder->NotifyDataArrived();
}
@ -80,8 +80,7 @@ void HLSResourceCallbacksSupport::OnError(int aErrorCode) {
}
RefPtr<HLSResourceCallbacksSupport> self = this;
NS_DispatchToMainThread(NS_NewRunnableFunction(
"HLSResourceCallbacksSupport::OnDataArrived", [self]() -> void {
MutexAutoLock lock(self->mMutex);
"HLSResourceCallbacksSupport::OnError", [self]() -> void {
if (self->mDecoder) {
// Since HLS source should be from the Internet, we treat all resource
// errors from GeckoHlsPlayer as network errors.