Bug 1135878 - Simply post-error cleanup logic in WASAPI cubeb backend. r=padenot

This commit is contained in:
Matthew Gregan 2015-02-24 13:42:33 +13:00
Родитель 302b3ccc09
Коммит bbfbfbf28c
2 изменённых файлов: 15 добавлений и 25 удалений

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

@ -5,4 +5,4 @@ Makefile.in build files for the Mozilla build system.
The cubeb git repository is: git://github.com/kinetiknz/cubeb.git
The git commit ID used was cacaae79dd8b7220202d0dfe3f889d55e23a77a5.
The git commit ID used was 6de5d3e488d808dd925ae0885a7552fc0a25b449.

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

@ -520,7 +520,14 @@ wasapi_stream_render_loop(LPVOID stream)
close_wasapi_stream(stm);
/* Reopen a stream and start it immediately. This will automatically pick the
* new default device for this role. */
setup_wasapi_stream(stm);
int r = setup_wasapi_stream(stm);
if (r != CUBEB_OK) {
/* Don't destroy the stream here, since we expect the caller to do
so after the error has propagated via the state callback. */
is_playing = false;
hr = -1;
continue;
}
}
stm->client->Start();
break;
@ -578,7 +585,7 @@ wasapi_stream_render_loop(LPVOID stream)
}
if (FAILED(hr)) {
stm->state_callback(stm, stm->user_ptr, CUBEB_STATE_STOPPED);
stm->state_callback(stm, stm->user_ptr, CUBEB_STATE_ERROR);
}
stm->context->revert_mm_thread_characteristics(mmcss_handle);
@ -967,8 +974,6 @@ int setup_wasapi_stream(cubeb_stream * stm)
hr = get_default_endpoint(&device);
if (FAILED(hr)) {
LOG("Could not get default endpoint, error: %x\n", hr);
stm->stream_reset_lock->leave();
wasapi_stream_destroy(stm);
return CUBEB_ERROR;
}
@ -980,8 +985,6 @@ int setup_wasapi_stream(cubeb_stream * stm)
SafeRelease(device);
if (FAILED(hr)) {
LOG("Could not activate the device to get an audio client: error: %x\n", hr);
stm->stream_reset_lock->leave();
wasapi_stream_destroy(stm);
return CUBEB_ERROR;
}
@ -990,8 +993,6 @@ int setup_wasapi_stream(cubeb_stream * stm)
hr = stm->client->GetMixFormat(&mix_format);
if (FAILED(hr)) {
LOG("Could not fetch current mix format from the audio client: error: %x\n", hr);
stm->stream_reset_lock->leave();
wasapi_stream_destroy(stm);
return CUBEB_ERROR;
}
@ -1015,16 +1016,12 @@ int setup_wasapi_stream(cubeb_stream * stm)
if (FAILED(hr)) {
LOG("Unable to initialize audio client: %x.\n", hr);
stm->stream_reset_lock->leave();
wasapi_stream_destroy(stm);
return CUBEB_ERROR;
}
hr = stm->client->GetBufferSize(&stm->buffer_frame_count);
if (FAILED(hr)) {
LOG("Could not get the buffer size from the client %x.\n", hr);
stm->stream_reset_lock->leave();
wasapi_stream_destroy(stm);
return CUBEB_ERROR;
}
@ -1035,8 +1032,6 @@ int setup_wasapi_stream(cubeb_stream * stm)
hr = stm->client->SetEventHandle(stm->refill_event);
if (FAILED(hr)) {
LOG("Could set the event handle for the client %x.\n", hr);
stm->stream_reset_lock->leave();
wasapi_stream_destroy(stm);
return CUBEB_ERROR;
}
@ -1044,8 +1039,6 @@ int setup_wasapi_stream(cubeb_stream * stm)
(void **)&stm->render_client);
if (FAILED(hr)) {
LOG("Could not get the render client %x.\n", hr);
stm->stream_reset_lock->leave();
wasapi_stream_destroy(stm);
return CUBEB_ERROR;
}
@ -1053,8 +1046,6 @@ int setup_wasapi_stream(cubeb_stream * stm)
(void **)&stm->audio_stream_volume);
if (FAILED(hr)) {
LOG("Could not get the IAudioStreamVolume %x.\n", hr);
stm->stream_reset_lock->leave();
wasapi_stream_destroy(stm);
return CUBEB_ERROR;
}
@ -1070,8 +1061,6 @@ int setup_wasapi_stream(cubeb_stream * stm)
CUBEB_RESAMPLER_QUALITY_DESKTOP);
if (!stm->resampler) {
LOG("Could not get a resampler\n");
stm->stream_reset_lock->leave();
wasapi_stream_destroy(stm);
return CUBEB_ERROR;
}
@ -1131,14 +1120,15 @@ wasapi_stream_init(cubeb * context, cubeb_stream ** stream,
}
{
/* Locking here is not stricly necessary, because we don't have a
/* Locking here is not strictly necessary, because we don't have a
notification client that can reset the stream yet, but it lets us
assert that the lock is held in the function. */
auto_lock lock(stm->stream_reset_lock);
rv = setup_wasapi_stream(stm);
if (rv != CUBEB_OK) {
return rv;
}
}
if (rv != CUBEB_OK) {
wasapi_stream_destroy(stm);
return rv;
}
hr = register_notification_client(stm);