diff options
author | Chris Robinson <[email protected]> | 2009-12-26 10:46:29 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2009-12-26 10:46:29 -0800 |
commit | c1fd977e799b6037f91688ad6aaddfd1e627fd10 (patch) | |
tree | 098617a82ec83ffa69d26950bc85029650e84d12 /Alc/pulseaudio.c | |
parent | cbbda9329297c6e2feedbf03b6ad853501ae4e96 (diff) |
Consolidate pulse capture failure path
Diffstat (limited to 'Alc/pulseaudio.c')
-rw-r--r-- | Alc/pulseaudio.c | 38 |
1 files changed, 14 insertions, 24 deletions
diff --git a/Alc/pulseaudio.c b/Alc/pulseaudio.c index e8c21b2b..00be70fd 100644 --- a/Alc/pulseaudio.c +++ b/Alc/pulseaudio.c @@ -681,9 +681,7 @@ static ALCboolean pulse_open_capture(ALCdevice *device, const ALCchar *device_na if(!(data->ring = CreateRingBuffer(data->frame_size, data->samples))) { ppa_threaded_mainloop_unlock(data->loop); - pulse_close(device); - pulse_unload(); - return ALC_FALSE; + goto fail; } data->attr.minreq = -1; @@ -711,27 +709,21 @@ static ALCboolean pulse_open_capture(ALCdevice *device, const ALCchar *device_na default: AL_PRINT("Unknown format: 0x%x\n", device->Format); ppa_threaded_mainloop_unlock(data->loop); - pulse_close(device); - pulse_unload(); - return ALC_FALSE; + goto fail; } if(ppa_sample_spec_valid(&data->spec) == 0) { AL_PRINT("Invalid sample format\n"); ppa_threaded_mainloop_unlock(data->loop); - pulse_close(device); - pulse_unload(); - return ALC_FALSE; + goto fail; } if(!ppa_channel_map_init_auto(&chanmap, data->spec.channels, PA_CHANNEL_MAP_WAVEEX)) { AL_PRINT("Couldn't build map for channel count (%d)!\n", data->spec.channels); ppa_threaded_mainloop_unlock(data->loop); - pulse_close(device); - pulse_unload(); - return ALC_FALSE; + goto fail; } data->stream = ppa_stream_new(data->context, data->stream_name, &data->spec, &chanmap); @@ -741,9 +733,7 @@ static ALCboolean pulse_open_capture(ALCdevice *device, const ALCchar *device_na ppa_strerror(ppa_context_errno(data->context))); ppa_threaded_mainloop_unlock(data->loop); - pulse_close(device); - pulse_unload(); - return ALC_FALSE; + goto fail; } ppa_stream_set_state_callback(data->stream, stream_state_callback, device); @@ -754,12 +744,10 @@ static ALCboolean pulse_open_capture(ALCdevice *device, const ALCchar *device_na ppa_strerror(ppa_context_errno(data->context))); ppa_stream_unref(data->stream); - ppa_threaded_mainloop_unlock(data->loop); - data->stream = NULL; - pulse_close(device); - pulse_unload(); - return ALC_FALSE; + + ppa_threaded_mainloop_unlock(data->loop); + goto fail; } while((state=ppa_stream_get_state(data->stream)) != PA_STREAM_READY) @@ -773,10 +761,7 @@ static ALCboolean pulse_open_capture(ALCdevice *device, const ALCchar *device_na data->stream = NULL; ppa_threaded_mainloop_unlock(data->loop); - - pulse_close(device); - pulse_unload(); - return ALC_FALSE; + goto fail; } ppa_threaded_mainloop_wait(data->loop); @@ -785,6 +770,11 @@ static ALCboolean pulse_open_capture(ALCdevice *device, const ALCchar *device_na ppa_threaded_mainloop_unlock(data->loop); return ALC_TRUE; + +fail: + pulse_close(device); + pulse_unload(); + return ALC_FALSE; } //}}} static void pulse_close_capture(ALCdevice *device) //{{{ |