Bug 1300446 - Check return value from GetCubebContext - r=kinetik

MozReview-Commit-ID: Y9b5Aq2RZE

--HG--
extra : rebase_source : 11422dc401d95cd91329b33b082b29bd193b16da
This commit is contained in:
Gerald Squelart 2016-08-30 17:20:10 -07:00
Родитель f1e3f0e4e8
Коммит 6e6bb23cf3
3 изменённых файлов: 22 добавлений и 8 удалений

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

@ -313,12 +313,15 @@ cubeb_stream_type ConvertChannelToCubebType(dom::AudioChannel aChannel)
void GetCurrentBackend(nsAString& aBackend)
{
const char* backend = cubeb_get_backend_id(GetCubebContext());
if (!backend) {
aBackend.AssignLiteral("unknown");
return;
cubeb* cubebContext = GetCubebContext();
if (cubebContext) {
const char* backend = cubeb_get_backend_id(cubebContext);
if (backend) {
aBackend.AssignASCII(backend);
return;
}
}
aBackend.AssignASCII(backend);
aBackend.AssignLiteral("unknown");
}
} // namespace CubebUtils

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

@ -588,6 +588,12 @@ AudioCallbackDriver::~AudioCallbackDriver()
void
AudioCallbackDriver::Init()
{
cubeb* cubebContext = CubebUtils::GetCubebContext();
if (!cubebContext) {
NS_WARNING("Could not get cubeb context.");
return;
}
cubeb_stream_params output;
cubeb_stream_params input;
uint32_t latency_frames;
@ -619,7 +625,7 @@ AudioCallbackDriver::Init()
output.format = CUBEB_SAMPLE_FLOAT32NE;
}
if (cubeb_get_min_latency(CubebUtils::GetCubebContext(), output, &latency_frames) != CUBEB_OK) {
if (cubeb_get_min_latency(cubebContext, output, &latency_frames) != CUBEB_OK) {
NS_WARNING("Could not get minimal latency from cubeb.");
return;
}
@ -650,7 +656,7 @@ AudioCallbackDriver::Init()
// XXX Only pass input input if we have an input listener. Always
// set up output because it's easier, and it will just get silence.
// XXX Add support for adding/removing an input listener later.
cubeb_stream_init(CubebUtils::GetCubebContext(), &stream,
cubeb_stream_init(cubebContext, &stream,
"AudioCallbackDriver",
input_id,
mGraphImpl->mInputWanted ? &input : nullptr,

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

@ -54,9 +54,14 @@ StaticMutex AudioInputCubeb::sMutex;
void AudioInputCubeb::UpdateDeviceList()
{
cubeb* cubebContext = CubebUtils::GetCubebContext();
if (!cubebContext) {
return;
}
cubeb_device_collection *devices = nullptr;
if (CUBEB_OK != cubeb_enumerate_devices(CubebUtils::GetCubebContext(),
if (CUBEB_OK != cubeb_enumerate_devices(cubebContext,
CUBEB_DEVICE_TYPE_INPUT,
&devices)) {
return;