зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1339259 - Hold Windows AudioSession object while recycling registration. r=jimm
When we UnregisterAudioSessionNotification in response to an OnSessionDisconnected message, we unintentionally decrement the refcount before restoring it. This KungFu grips us for the duration of that operation. --HG-- extra : rebase_source : 7c7e786064811d040d23741c143d9eef04edb5e0
This commit is contained in:
Родитель
f2f143f706
Коммит
0601f5b64f
|
@ -281,6 +281,7 @@ AudioSession::Start()
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// Increments refcount of 'this'.
|
||||
hr = mAudioSessionControl->RegisterAudioSessionNotification(this);
|
||||
if (FAILED(hr)) {
|
||||
StopInternal();
|
||||
|
@ -297,6 +298,7 @@ AudioSession::StopInternal()
|
|||
{
|
||||
if (mAudioSessionControl &&
|
||||
(mState == STARTED || mState == STOPPED)) {
|
||||
// Decrement refcount of 'this'
|
||||
mAudioSessionControl->UnregisterAudioSessionNotification(this);
|
||||
}
|
||||
mAudioSessionControl = nullptr;
|
||||
|
@ -420,6 +422,10 @@ AudioSession::OnSessionDisconnectedInternal()
|
|||
if (!mAudioSessionControl)
|
||||
return NS_OK;
|
||||
|
||||
// When successful, UnregisterAudioSessionNotification will decrement the
|
||||
// refcount of 'this'. Start will re-increment it. In the interim,
|
||||
// we'll need to reference ourselves.
|
||||
RefPtr<AudioSession> kungFuDeathGrip(this);
|
||||
mAudioSessionControl->UnregisterAudioSessionNotification(this);
|
||||
mAudioSessionControl = nullptr;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче