Skip to content

Commit

Permalink
Bug 1604941 - Don't leave AudioContextOperation::Resume hanging. r=pa…
Browse files Browse the repository at this point in the history
…denot

Differential Revision: https://phabricator.services.mozilla.com/D57696
  • Loading branch information
Pehrsons committed Dec 19, 2019
1 parent 5d89c6e commit 9896e12
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 21 deletions.
29 changes: 9 additions & 20 deletions dom/media/GraphDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,21 +294,15 @@ AsyncCubebTask::Run() {
case AsyncCubebOperation::INIT: {
LOG(LogLevel::Debug, ("%p: AsyncCubebOperation::INIT driver=%p",
mDriver->Graph(), mDriver.get()));
if (!mDriver->Init()) {
LOG(LogLevel::Warning,
("AsyncCubebOperation::INIT failed for driver=%p", mDriver.get()));
return NS_ERROR_FAILURE;
}
mDriver->Init();
mDriver->CompleteAudioContextOperations(mOperation);
break;
}
case AsyncCubebOperation::SHUTDOWN: {
LOG(LogLevel::Debug, ("%p: AsyncCubebOperation::SHUTDOWN driver=%p",
mDriver->Graph(), mDriver.get()));
mDriver->Stop();

mDriver->CompleteAudioContextOperations(mOperation);

mDriver = nullptr;
mShutdownGrip = nullptr;
break;
Expand Down Expand Up @@ -565,14 +559,13 @@ bool IsMacbookOrMacbookAir() {
return false;
}

bool AudioCallbackDriver::Init() {
void AudioCallbackDriver::Init() {
MOZ_ASSERT(OnCubebOperationThread());
MOZ_ASSERT(mAudioStreamState == AudioStreamState::Pending);
FallbackDriverState fallbackState = mFallbackDriverState;
if (fallbackState == FallbackDriverState::Stopped) {
// The graph has already stopped us. We return true here because this was
// not an actual failure.
return true;
// The graph has already stopped us.
return;
}
bool fromFallback = fallbackState == FallbackDriverState::Running;
cubeb* cubebContext = CubebUtils::GetCubebContext();
Expand All @@ -583,9 +576,8 @@ bool AudioCallbackDriver::Init() {
if (!fromFallback) {
CubebUtils::ReportCubebStreamInitFailure(true);
FallbackToSystemClockDriver();
return true;
}
return false;
return;
}

cubeb_stream_params output;
Expand All @@ -609,9 +601,8 @@ bool AudioCallbackDriver::Init() {
if (!fromFallback) {
CubebUtils::ReportCubebStreamInitFailure(firstStream);
FallbackToSystemClockDriver();
return true;
}
return false;
return;
}

CubebUtils::AudioDeviceID forcedOutputDeviceId = nullptr;
Expand Down Expand Up @@ -697,9 +688,8 @@ bool AudioCallbackDriver::Init() {
if (!fromFallback) {
CubebUtils::ReportCubebStreamInitFailure(firstStream);
FallbackToSystemClockDriver();
return true;
}
return false;
return;
}

#ifdef XP_MACOSX
Expand All @@ -709,14 +699,13 @@ bool AudioCallbackDriver::Init() {
cubeb_stream_register_device_changed_callback(
mAudioStream, AudioCallbackDriver::DeviceChangedCallback_s);

if (!StartStream()) {
if (NS_WARN_IF(!StartStream())) {
LOG(LogLevel::Warning,
("%p: AudioCallbackDriver couldn't start a cubeb stream.", Graph()));
return false;
return;
}

LOG(LogLevel::Debug, ("%p: AudioCallbackDriver started.", Graph()));
return true;
}

void AudioCallbackDriver::Start() {
Expand Down
2 changes: 1 addition & 1 deletion dom/media/GraphDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ class AudioCallbackDriver : public GraphDriver,
/* Start the cubeb stream */
bool StartStream();
friend class AsyncCubebTask;
bool Init();
void Init();
void Stop();
/**
* Fall back to a SystemClockDriver using a normal thread. If needed,
Expand Down

0 comments on commit 9896e12

Please sign in to comment.