diff options
author | Chris Robinson <[email protected]> | 2014-04-24 01:25:26 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2014-04-24 01:25:26 -0700 |
commit | a4cf378af8692e5653a1582baeca2d487ac14adb (patch) | |
tree | bb6b5d9d0a6f44eb2175d7e239c46cd720e0e221 /Alc/backends/winmm.c | |
parent | 9af8e10c2087a5d2714d8f461e2dbe80ddd4f3eb (diff) |
Use a helper method to clear winmm device lists
Diffstat (limited to 'Alc/backends/winmm.c')
-rw-r--r-- | Alc/backends/winmm.c | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/Alc/backends/winmm.c b/Alc/backends/winmm.c index 9c7d0d98..d274a81c 100644 --- a/Alc/backends/winmm.c +++ b/Alc/backends/winmm.c @@ -58,6 +58,17 @@ typedef struct { static vector_al_string PlaybackDevices; static vector_al_string CaptureDevices; +static void clear_devlist(vector_al_string *list) +{ + al_string *iter, *end; + + iter = VECTOR_ITER_BEGIN(*list); + end = VECTOR_ITER_END(*list); + for(;iter != end;iter++) + AL_STRING_DEINIT(*iter); + VECTOR_RESIZE(*list, 0); +} + static void ProbePlaybackDevices(void) { @@ -65,11 +76,7 @@ static void ProbePlaybackDevices(void) ALuint numdevs; ALuint i; - iter = VECTOR_ITER_BEGIN(PlaybackDevices); - end = VECTOR_ITER_END(PlaybackDevices); - for(;iter != end;iter++) - AL_STRING_DEINIT(*iter); - VECTOR_RESIZE(PlaybackDevices, 0); + clear_devlist(&PlaybackDevices); numdevs = waveOutGetNumDevs(); VECTOR_RESERVE(PlaybackDevices, numdevs); @@ -113,11 +120,7 @@ static void ProbeCaptureDevices(void) ALuint numdevs; ALuint i; - iter = VECTOR_ITER_BEGIN(CaptureDevices); - end = VECTOR_ITER_END(CaptureDevices); - for(;iter != end;iter++) - AL_STRING_DEINIT(*iter); - VECTOR_RESIZE(CaptureDevices, 0); + clear_devlist(&CaptureDevices); numdevs = waveInGetNumDevs(); VECTOR_RESERVE(CaptureDevices, numdevs); @@ -682,18 +685,10 @@ ALCboolean alcWinMMInit(BackendFuncs *FuncList) void alcWinMMDeinit() { - al_string *iter, *end; - - iter = VECTOR_ITER_BEGIN(PlaybackDevices); - end = VECTOR_ITER_END(PlaybackDevices); - for(;iter != end;iter++) - AL_STRING_DEINIT(*iter); + clear_devlist(&PlaybackDevices); VECTOR_DEINIT(PlaybackDevices); - iter = VECTOR_ITER_BEGIN(CaptureDevices); - end = VECTOR_ITER_END(CaptureDevices); - for(;iter != end;iter++) - AL_STRING_DEINIT(*iter); + clear_devlist(&CaptureDevices); VECTOR_DEINIT(CaptureDevices); } |