aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/backends/alsa.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2014-08-09 06:15:11 -0700
committerChris Robinson <[email protected]>2014-08-09 06:15:11 -0700
commitf173a6787082e577a6bb8de08577980118bcd029 (patch)
tree6f5ecb9fc8be131980274bf400a5f6ab1d8753bb /Alc/backends/alsa.c
parent1692dda4b9908d97c80ec5e446f642b24374667b (diff)
Use VECTOR_FIND_IF and VECTOR_FOR_EACH instead of manual loops
Diffstat (limited to 'Alc/backends/alsa.c')
-rw-r--r--Alc/backends/alsa.c36
1 files changed, 12 insertions, 24 deletions
diff --git a/Alc/backends/alsa.c b/Alc/backends/alsa.c
index 2d3a8425..d5174da8 100644
--- a/Alc/backends/alsa.c
+++ b/Alc/backends/alsa.c
@@ -625,23 +625,17 @@ static ALCenum ALCplaybackAlsa_open(ALCplaybackAlsa *self, const ALCchar *name)
if(name)
{
- const DevMap *iter, *end;
+ const DevMap *iter;
if(VECTOR_SIZE(PlaybackDevices) == 0)
probe_devices(SND_PCM_STREAM_PLAYBACK, &PlaybackDevices);
- iter = VECTOR_ITER_BEGIN(PlaybackDevices);
- end = VECTOR_ITER_END(PlaybackDevices);
- for(;iter != end;iter++)
- {
- if(al_string_cmp_cstr(iter->name, name) == 0)
- {
- driver = al_string_get_cstr(iter->device_name);
- break;
- }
- }
- if(iter == end)
+#define MATCH_NAME(i) (al_string_cmp_cstr((i)->name, name) == 0)
+ VECTOR_FIND_IF(iter, const DevMap, PlaybackDevices, MATCH_NAME);
+#undef MATCH_NAME
+ if(iter == VECTOR_ITER_END(PlaybackDevices))
return ALC_INVALID_VALUE;
+ driver = al_string_get_cstr(iter->device_name);
}
else
{
@@ -956,23 +950,17 @@ static ALCenum ALCcaptureAlsa_open(ALCcaptureAlsa *self, const ALCchar *name)
if(name)
{
- const DevMap *iter, *end;
+ const DevMap *iter;
if(VECTOR_SIZE(CaptureDevices) == 0)
probe_devices(SND_PCM_STREAM_CAPTURE, &CaptureDevices);
- iter = VECTOR_ITER_BEGIN(CaptureDevices);
- end = VECTOR_ITER_END(CaptureDevices);
- for(;iter != end;iter++)
- {
- if(al_string_cmp_cstr(iter->name, name) == 0)
- {
- driver = al_string_get_cstr(iter->device_name);
- break;
- }
- }
- if(iter == end)
+#define MATCH_NAME(i) (al_string_cmp_cstr((i)->name, name) == 0)
+ VECTOR_FIND_IF(iter, const DevMap, CaptureDevices, MATCH_NAME);
+#undef MATCH_NAME
+ if(iter == VECTOR_ITER_END(CaptureDevices))
return ALC_INVALID_VALUE;
+ driver = al_string_get_cstr(iter->device_name);
}
else
{