зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1541290 - Restart driver properly on revive method. r=padenot
Revive method of AudioCallbackDriver was wrong because it was re-initializing an already initialized driver. That was hitting an assert. Instead of that it should stop the drained stream and start it again. Also, mStarted member should be reset properly on the stop method. Differential Revision: https://phabricator.services.mozilla.com/D26678 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
3e45f049fa
Коммит
5fc615519b
|
@ -419,7 +419,8 @@ AsyncCubebTask::AsyncCubebTask(AudioCallbackDriver* aDriver,
|
|||
mDriver(aDriver),
|
||||
mOperation(aOperation),
|
||||
mShutdownGrip(aDriver->GraphImpl()) {
|
||||
NS_WARNING_ASSERTION(mDriver->mAudioStream || aOperation == INIT,
|
||||
NS_WARNING_ASSERTION(
|
||||
mDriver->mAudioStream || aOperation == AsyncCubebOperation::INIT,
|
||||
"No audio stream!");
|
||||
}
|
||||
|
||||
|
@ -441,6 +442,22 @@ AsyncCubebTask::Run() {
|
|||
mDriver->CompleteAudioContextOperations(mOperation);
|
||||
break;
|
||||
}
|
||||
case AsyncCubebOperation::START: {
|
||||
LOG(LogLevel::Debug, ("%p: AsyncCubebOperation::START driver=%p",
|
||||
mDriver->GraphImpl(), mDriver.get()));
|
||||
if (!mDriver->StartStream()) {
|
||||
LOG(LogLevel::Warning,
|
||||
("%p: AsyncCubebOperation couldn't start the driver=%p.",
|
||||
mDriver->GraphImpl(), mDriver.get()));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case AsyncCubebOperation::STOP: {
|
||||
LOG(LogLevel::Debug, ("%p: AsyncCubebOperation::STOP driver=%p",
|
||||
mDriver->GraphImpl(), mDriver.get()));
|
||||
mDriver->Stop();
|
||||
break;
|
||||
}
|
||||
case AsyncCubebOperation::SHUTDOWN: {
|
||||
LOG(LogLevel::Debug, ("%p: AsyncCubebOperation::SHUTDOWN driver=%p",
|
||||
mDriver->GraphImpl(), mDriver.get()));
|
||||
|
@ -713,6 +730,7 @@ void AudioCallbackDriver::Stop() {
|
|||
if (cubeb_stream_stop(mAudioStream) != CUBEB_OK) {
|
||||
NS_WARNING("Could not stop cubeb stream for MSG.");
|
||||
}
|
||||
mStarted = false;
|
||||
}
|
||||
|
||||
void AudioCallbackDriver::Revive() {
|
||||
|
@ -728,9 +746,16 @@ void AudioCallbackDriver::Revive() {
|
|||
LOG(LogLevel::Debug,
|
||||
("Starting audio threads for MediaStreamGraph %p from a new thread.",
|
||||
mGraphImpl.get()));
|
||||
RefPtr<AsyncCubebTask> initEvent =
|
||||
new AsyncCubebTask(this, AsyncCubebOperation::INIT);
|
||||
initEvent->Dispatch();
|
||||
if (IsStarted()) {
|
||||
RefPtr<AsyncCubebTask> stopEvent =
|
||||
new AsyncCubebTask(this, AsyncCubebOperation::STOP);
|
||||
// This dispatches to a thread pool with a maximum of one thread thus it
|
||||
// is guaranteed to be executed before the start event, right below.
|
||||
stopEvent->Dispatch();
|
||||
}
|
||||
RefPtr<AsyncCubebTask> startEvent =
|
||||
new AsyncCubebTask(this, AsyncCubebOperation::START);
|
||||
startEvent->Dispatch();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -322,7 +322,7 @@ struct StreamAndPromiseForOperation {
|
|||
dom::AudioContextOperationFlags mFlags;
|
||||
};
|
||||
|
||||
enum AsyncCubebOperation { INIT, SHUTDOWN };
|
||||
enum class AsyncCubebOperation { INIT, START, STOP, SHUTDOWN };
|
||||
enum class AudioInputType { Unknown, Voice };
|
||||
|
||||
/**
|
||||
|
|
Загрузка…
Ссылка в новой задаче