Bug 1530715 - P32: Close the stream if failing in stream reinitialization. r=padenot

Before reporting the error by the state callback, closing the stream to
make sure the data callback and device-changed callback are
unregistered.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Chun-Min Chang 2019-07-10 08:06:39 +00:00
Родитель f06595279a
Коммит 56e7631637
2 изменённых файлов: 13 добавлений и 2 удалений

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

@ -3,4 +3,4 @@ git repository using the update.sh script.
The cubeb-coreaudio-rs git repository is: https://github.com/ChunMinChang/cubeb-coreaudio-rs
The git commit ID used was d7d9b40a6c9385a34412c111d537737f9d09bc37 (2019-06-25 11:32:22 -0700)
The git commit ID used was 87e92cb0760cb7be490dd1588748dc8f1e5ed961 (2019-06-25 11:32:22 -0700)

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

@ -2705,6 +2705,7 @@ impl<'ctx> AudioUnitStream<'ctx> {
"({:p}) Create input device info failed. This can happen when last media device is unplugged",
self as *const AudioUnitStream
);
self.close();
e
})?;
}
@ -2717,6 +2718,7 @@ impl<'ctx> AudioUnitStream<'ctx> {
"({:p}) Create output device info failed. This can happen when last media device is unplugged",
self as *const AudioUnitStream
);
self.close();
e
})?;
@ -2735,6 +2737,7 @@ impl<'ctx> AudioUnitStream<'ctx> {
"({:p}) Create input device info failed. This can happen when last media device is unplugged",
self as *const AudioUnitStream
);
self.close();
e
})?;
self.setup().map_err(|e| {
@ -2742,6 +2745,7 @@ impl<'ctx> AudioUnitStream<'ctx> {
"({:p}) Second stream reinit failed.",
self as *const AudioUnitStream
);
self.close();
e
})?;
}
@ -2753,7 +2757,14 @@ impl<'ctx> AudioUnitStream<'ctx> {
// If the stream was running, start it again.
if !self.shutdown.load(Ordering::SeqCst) {
self.start_internal()?;
self.start_internal().map_err(|e| {
cubeb_log!(
"({:p}) Start audiounit failed.",
self as *const AudioUnitStream
);
self.close();
e
})?;
}
}