diff options
author | Chris Robinson <[email protected]> | 2014-04-24 01:38:24 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2014-04-24 01:38:24 -0700 |
commit | 7dd4a2348ff330339e9ea09a80e3bdaeb7640062 (patch) | |
tree | 67a15d40d90d4c888963b419c718734e83733c35 /Alc/backends/pulseaudio.c | |
parent | a4cf378af8692e5653a1582baeca2d487ac14adb (diff) |
Use a helper function to clear PulseAudio device lists
Diffstat (limited to 'Alc/backends/pulseaudio.c')
-rw-r--r-- | Alc/backends/pulseaudio.c | 56 |
1 files changed, 20 insertions, 36 deletions
diff --git a/Alc/backends/pulseaudio.c b/Alc/backends/pulseaudio.c index 01c229f9..d1472c7d 100644 --- a/Alc/backends/pulseaudio.c +++ b/Alc/backends/pulseaudio.c @@ -463,6 +463,20 @@ DECL_VECTOR(DevMap) static vector_DevMap PlaybackDevices; static vector_DevMap CaptureDevices; +static void clear_devlist(vector_DevMap *list) +{ + DevMap *iter, *end; + + iter = VECTOR_ITER_BEGIN(*list); + end = VECTOR_ITER_END(*list); + for(;iter != end;iter++) + { + AL_STRING_DEINIT(iter->name); + AL_STRING_DEINIT(iter->device_name); + } + VECTOR_RESIZE(*list, 0); +} + typedef struct ALCpulsePlayback { DERIVE_FROM_TYPE(ALCbackend); @@ -563,6 +577,8 @@ static void ALCpulsePlayback_probeDevices(void) { pa_threaded_mainloop *loop; + clear_devlist(&PlaybackDevices); + if((loop=pa_threaded_mainloop_new()) && pa_threaded_mainloop_start(loop) >= 0) { @@ -1215,6 +1231,8 @@ static void ALCpulseCapture_probeDevices(void) { pa_threaded_mainloop *loop; + clear_devlist(&CaptureDevices); + if((loop=pa_threaded_mainloop_new()) && pa_threaded_mainloop_start(loop) >= 0) { @@ -1662,24 +1680,10 @@ static ALCboolean ALCpulseBackendFactory_init(ALCpulseBackendFactory* UNUSED(sel static void ALCpulseBackendFactory_deinit(ALCpulseBackendFactory* UNUSED(self)) { - DevMap *iter, *end; - - iter = VECTOR_ITER_BEGIN(PlaybackDevices); - end = VECTOR_ITER_END(PlaybackDevices); - for(;iter != end;iter++) - { - AL_STRING_DEINIT(iter->name); - AL_STRING_DEINIT(iter->device_name); - } + clear_devlist(&PlaybackDevices); VECTOR_DEINIT(PlaybackDevices); - iter = VECTOR_ITER_BEGIN(CaptureDevices); - end = VECTOR_ITER_END(CaptureDevices); - for(;iter != end;iter++) - { - AL_STRING_DEINIT(iter->name); - AL_STRING_DEINIT(iter->device_name); - } + clear_devlist(&CaptureDevices); VECTOR_DEINIT(CaptureDevices); if(prop_filter) @@ -1703,17 +1707,7 @@ static void ALCpulseBackendFactory_probe(ALCpulseBackendFactory* UNUSED(self), e switch(type) { case ALL_DEVICE_PROBE: - iter = VECTOR_ITER_BEGIN(PlaybackDevices); - end = VECTOR_ITER_END(PlaybackDevices); - for(;iter != end;iter++) - { - AL_STRING_DEINIT(iter->name); - AL_STRING_DEINIT(iter->device_name); - } - VECTOR_RESIZE(PlaybackDevices, 0); - ALCpulsePlayback_probeDevices(); - iter = VECTOR_ITER_BEGIN(PlaybackDevices); end = VECTOR_ITER_END(PlaybackDevices); for(;iter != end;iter++) @@ -1721,17 +1715,7 @@ static void ALCpulseBackendFactory_probe(ALCpulseBackendFactory* UNUSED(self), e break; case CAPTURE_DEVICE_PROBE: - iter = VECTOR_ITER_BEGIN(CaptureDevices); - end = VECTOR_ITER_END(CaptureDevices); - for(;iter != end;iter++) - { - AL_STRING_DEINIT(iter->name); - AL_STRING_DEINIT(iter->device_name); - } - VECTOR_RESIZE(CaptureDevices, 0); - ALCpulseCapture_probeDevices(); - iter = VECTOR_ITER_BEGIN(CaptureDevices); end = VECTOR_ITER_END(CaptureDevices); for(;iter != end;iter++) |