Use a helper method to clear winmm device lists

This commit is contained in:
Chris Robinson 2014-04-24 01:25:26 -07:00
parent 9af8e10c20
commit a4cf378af8

View File

@ -58,6 +58,17 @@ typedef struct {
static vector_al_string PlaybackDevices; static vector_al_string PlaybackDevices;
static vector_al_string CaptureDevices; 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) static void ProbePlaybackDevices(void)
{ {
@ -65,11 +76,7 @@ static void ProbePlaybackDevices(void)
ALuint numdevs; ALuint numdevs;
ALuint i; ALuint i;
iter = VECTOR_ITER_BEGIN(PlaybackDevices); clear_devlist(&PlaybackDevices);
end = VECTOR_ITER_END(PlaybackDevices);
for(;iter != end;iter++)
AL_STRING_DEINIT(*iter);
VECTOR_RESIZE(PlaybackDevices, 0);
numdevs = waveOutGetNumDevs(); numdevs = waveOutGetNumDevs();
VECTOR_RESERVE(PlaybackDevices, numdevs); VECTOR_RESERVE(PlaybackDevices, numdevs);
@ -113,11 +120,7 @@ static void ProbeCaptureDevices(void)
ALuint numdevs; ALuint numdevs;
ALuint i; ALuint i;
iter = VECTOR_ITER_BEGIN(CaptureDevices); clear_devlist(&CaptureDevices);
end = VECTOR_ITER_END(CaptureDevices);
for(;iter != end;iter++)
AL_STRING_DEINIT(*iter);
VECTOR_RESIZE(CaptureDevices, 0);
numdevs = waveInGetNumDevs(); numdevs = waveInGetNumDevs();
VECTOR_RESERVE(CaptureDevices, numdevs); VECTOR_RESERVE(CaptureDevices, numdevs);
@ -682,18 +685,10 @@ ALCboolean alcWinMMInit(BackendFuncs *FuncList)
void alcWinMMDeinit() void alcWinMMDeinit()
{ {
al_string *iter, *end; clear_devlist(&PlaybackDevices);
iter = VECTOR_ITER_BEGIN(PlaybackDevices);
end = VECTOR_ITER_END(PlaybackDevices);
for(;iter != end;iter++)
AL_STRING_DEINIT(*iter);
VECTOR_DEINIT(PlaybackDevices); VECTOR_DEINIT(PlaybackDevices);
iter = VECTOR_ITER_BEGIN(CaptureDevices); clear_devlist(&CaptureDevices);
end = VECTOR_ITER_END(CaptureDevices);
for(;iter != end;iter++)
AL_STRING_DEINIT(*iter);
VECTOR_DEINIT(CaptureDevices); VECTOR_DEINIT(CaptureDevices);
} }