Bug 1604941 - Don't leave AudioContextOperation::Resume hanging. r=padenot

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Andreas Pehrson 2019-12-19 13:17:32 +00:00
Родитель fe6925d358
Коммит b5a333aa74
2 изменённых файлов: 10 добавлений и 21 удалений

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

@ -294,11 +294,7 @@ AsyncCubebTask::Run() {
case AsyncCubebOperation::INIT: { case AsyncCubebOperation::INIT: {
LOG(LogLevel::Debug, ("%p: AsyncCubebOperation::INIT driver=%p", LOG(LogLevel::Debug, ("%p: AsyncCubebOperation::INIT driver=%p",
mDriver->Graph(), mDriver.get())); mDriver->Graph(), mDriver.get()));
if (!mDriver->Init()) { mDriver->Init();
LOG(LogLevel::Warning,
("AsyncCubebOperation::INIT failed for driver=%p", mDriver.get()));
return NS_ERROR_FAILURE;
}
mDriver->CompleteAudioContextOperations(mOperation); mDriver->CompleteAudioContextOperations(mOperation);
break; break;
} }
@ -306,9 +302,7 @@ AsyncCubebTask::Run() {
LOG(LogLevel::Debug, ("%p: AsyncCubebOperation::SHUTDOWN driver=%p", LOG(LogLevel::Debug, ("%p: AsyncCubebOperation::SHUTDOWN driver=%p",
mDriver->Graph(), mDriver.get())); mDriver->Graph(), mDriver.get()));
mDriver->Stop(); mDriver->Stop();
mDriver->CompleteAudioContextOperations(mOperation); mDriver->CompleteAudioContextOperations(mOperation);
mDriver = nullptr; mDriver = nullptr;
mShutdownGrip = nullptr; mShutdownGrip = nullptr;
break; break;
@ -565,14 +559,13 @@ bool IsMacbookOrMacbookAir() {
return false; return false;
} }
bool AudioCallbackDriver::Init() { void AudioCallbackDriver::Init() {
MOZ_ASSERT(OnCubebOperationThread()); MOZ_ASSERT(OnCubebOperationThread());
MOZ_ASSERT(mAudioStreamState == AudioStreamState::Pending); MOZ_ASSERT(mAudioStreamState == AudioStreamState::Pending);
FallbackDriverState fallbackState = mFallbackDriverState; FallbackDriverState fallbackState = mFallbackDriverState;
if (fallbackState == FallbackDriverState::Stopped) { if (fallbackState == FallbackDriverState::Stopped) {
// The graph has already stopped us. We return true here because this was // The graph has already stopped us.
// not an actual failure. return;
return true;
} }
bool fromFallback = fallbackState == FallbackDriverState::Running; bool fromFallback = fallbackState == FallbackDriverState::Running;
cubeb* cubebContext = CubebUtils::GetCubebContext(); cubeb* cubebContext = CubebUtils::GetCubebContext();
@ -583,9 +576,8 @@ bool AudioCallbackDriver::Init() {
if (!fromFallback) { if (!fromFallback) {
CubebUtils::ReportCubebStreamInitFailure(true); CubebUtils::ReportCubebStreamInitFailure(true);
FallbackToSystemClockDriver(); FallbackToSystemClockDriver();
return true;
} }
return false; return;
} }
cubeb_stream_params output; cubeb_stream_params output;
@ -609,9 +601,8 @@ bool AudioCallbackDriver::Init() {
if (!fromFallback) { if (!fromFallback) {
CubebUtils::ReportCubebStreamInitFailure(firstStream); CubebUtils::ReportCubebStreamInitFailure(firstStream);
FallbackToSystemClockDriver(); FallbackToSystemClockDriver();
return true;
} }
return false; return;
} }
CubebUtils::AudioDeviceID forcedOutputDeviceId = nullptr; CubebUtils::AudioDeviceID forcedOutputDeviceId = nullptr;
@ -697,9 +688,8 @@ bool AudioCallbackDriver::Init() {
if (!fromFallback) { if (!fromFallback) {
CubebUtils::ReportCubebStreamInitFailure(firstStream); CubebUtils::ReportCubebStreamInitFailure(firstStream);
FallbackToSystemClockDriver(); FallbackToSystemClockDriver();
return true;
} }
return false; return;
} }
#ifdef XP_MACOSX #ifdef XP_MACOSX
@ -709,14 +699,13 @@ bool AudioCallbackDriver::Init() {
cubeb_stream_register_device_changed_callback( cubeb_stream_register_device_changed_callback(
mAudioStream, AudioCallbackDriver::DeviceChangedCallback_s); mAudioStream, AudioCallbackDriver::DeviceChangedCallback_s);
if (!StartStream()) { if (NS_WARN_IF(!StartStream())) {
LOG(LogLevel::Warning, LOG(LogLevel::Warning,
("%p: AudioCallbackDriver couldn't start a cubeb stream.", Graph())); ("%p: AudioCallbackDriver couldn't start a cubeb stream.", Graph()));
return false; return;
} }
LOG(LogLevel::Debug, ("%p: AudioCallbackDriver started.", Graph())); LOG(LogLevel::Debug, ("%p: AudioCallbackDriver started.", Graph()));
return true;
} }
void AudioCallbackDriver::Start() { void AudioCallbackDriver::Start() {

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

@ -658,7 +658,7 @@ class AudioCallbackDriver : public GraphDriver,
/* Start the cubeb stream */ /* Start the cubeb stream */
bool StartStream(); bool StartStream();
friend class AsyncCubebTask; friend class AsyncCubebTask;
bool Init(); void Init();
void Stop(); void Stop();
/** /**
* Fall back to a SystemClockDriver using a normal thread. If needed, * Fall back to a SystemClockDriver using a normal thread. If needed,