diff options
-rw-r--r-- | Alc/backends/alsa.c | 17 | ||||
-rw-r--r-- | Alc/backends/dsound.c | 16 | ||||
-rw-r--r-- | Alc/backends/mmdevapi.c | 18 | ||||
-rw-r--r-- | Alc/backends/pulseaudio.c | 17 | ||||
-rw-r--r-- | Alc/backends/winmm.c | 29 | ||||
-rw-r--r-- | Alc/vector.h | 7 |
6 files changed, 49 insertions, 55 deletions
diff --git a/Alc/backends/alsa.c b/Alc/backends/alsa.c index 4cade858..749db892 100644 --- a/Alc/backends/alsa.c +++ b/Alc/backends/alsa.c @@ -1302,6 +1302,11 @@ static ALint64 ALCcaptureAlsa_getLatency(ALCcaptureAlsa *self) } +static inline void AppendAllDevicesList2(const DevMap *entry) +{ AppendAllDevicesList(al_string_get_cstr(entry->name)); } +static inline void AppendCaptureDeviceList2(const DevMap *entry) +{ AppendCaptureDeviceList(al_string_get_cstr(entry->name)); } + typedef struct ALCalsaBackendFactory { DERIVE_FROM_TYPE(ALCbackendFactory); } ALCalsaBackendFactory; @@ -1341,24 +1346,16 @@ static ALCboolean ALCalsaBackendFactory_querySupport(ALCalsaBackendFactory* UNUS static void ALCalsaBackendFactory_probe(ALCalsaBackendFactory* UNUSED(self), enum DevProbe type) { - DevMap *iter, *end; - switch(type) { case ALL_DEVICE_PROBE: probe_devices(SND_PCM_STREAM_PLAYBACK, &PlaybackDevices); - iter = VECTOR_ITER_BEGIN(PlaybackDevices); - end = VECTOR_ITER_END(PlaybackDevices); - for(;iter != end;iter++) - AppendAllDevicesList(al_string_get_cstr(iter->name)); + VECTOR_FOR_EACH(const DevMap, PlaybackDevices, AppendAllDevicesList2); break; case CAPTURE_DEVICE_PROBE: probe_devices(SND_PCM_STREAM_CAPTURE, &CaptureDevices); - iter = VECTOR_ITER_BEGIN(CaptureDevices); - end = VECTOR_ITER_END(CaptureDevices); - for(;iter != end;iter++) - AppendCaptureDeviceList(al_string_get_cstr(iter->name)); + VECTOR_FOR_EACH(const DevMap, CaptureDevices, AppendCaptureDeviceList2); break; } } diff --git a/Alc/backends/dsound.c b/Alc/backends/dsound.c index 12ea8103..3ca398ed 100644 --- a/Alc/backends/dsound.c +++ b/Alc/backends/dsound.c @@ -950,6 +950,11 @@ done: } +static inline void AppendAllDevicesList2(const DevMap *entry) +{ AppendAllDevicesList(al_string_get_cstr(entry->name)); } +static inline void AppendCaptureDeviceList2(const DevMap *entry) +{ AppendCaptureDeviceList(al_string_get_cstr(entry->name)); } + typedef struct ALCdsoundBackendFactory { DERIVE_FROM_TYPE(ALCbackendFactory); } ALCdsoundBackendFactory; @@ -1006,7 +1011,6 @@ static ALCboolean ALCdsoundBackendFactory_querySupport(ALCdsoundBackendFactory* static void ALCdsoundBackendFactory_probe(ALCdsoundBackendFactory* UNUSED(self), enum DevProbe type) { - DevMap *iter, *end; HRESULT hr, hrcom; /* Initialize COM to prevent name truncation */ @@ -1018,10 +1022,7 @@ static void ALCdsoundBackendFactory_probe(ALCdsoundBackendFactory* UNUSED(self), hr = DirectSoundEnumerateW(DSoundEnumDevices, &PlaybackDevices); if(FAILED(hr)) ERR("Error enumerating DirectSound playback devices (0x%lx)!\n", hr); - iter = VECTOR_ITER_BEGIN(PlaybackDevices); - end = VECTOR_ITER_END(PlaybackDevices); - for(;iter != end;++iter) - AppendAllDevicesList(al_string_get_cstr(iter->name)); + VECTOR_FOR_EACH(const DevMap, PlaybackDevices, AppendAllDevicesList2); break; case CAPTURE_DEVICE_PROBE: @@ -1029,10 +1030,7 @@ static void ALCdsoundBackendFactory_probe(ALCdsoundBackendFactory* UNUSED(self), hr = DirectSoundCaptureEnumerateW(DSoundEnumDevices, &CaptureDevices); if(FAILED(hr)) ERR("Error enumerating DirectSound capture devices (0x%lx)!\n", hr); - iter = VECTOR_ITER_BEGIN(CaptureDevices); - end = VECTOR_ITER_END(CaptureDevices); - for(;iter != end;++iter) - AppendCaptureDeviceList(al_string_get_cstr(iter->name)); + VECTOR_FOR_EACH(const DevMap, CaptureDevices, AppendCaptureDeviceList2); break; } if(SUCCEEDED(hrcom)) diff --git a/Alc/backends/mmdevapi.c b/Alc/backends/mmdevapi.c index 968b73ff..4061105c 100644 --- a/Alc/backends/mmdevapi.c +++ b/Alc/backends/mmdevapi.c @@ -1032,6 +1032,11 @@ static ALint64 ALCmmdevPlayback_getLatency(ALCmmdevPlayback *self) } +static inline void AppendAllDevicesList2(const DevMap *entry) +{ AppendAllDevicesList(al_string_get_cstr(entry->name)); } +static inline void AppendCaptureDeviceList2(const DevMap *entry) +{ AppendCaptureDeviceList(al_string_get_cstr(entry->name)); } + typedef struct ALCmmdevBackendFactory { DERIVE_FROM_TYPE(ALCbackendFactory); } ALCmmdevBackendFactory; @@ -1105,30 +1110,23 @@ static ALCboolean ALCmmdevBackendFactory_querySupport(ALCmmdevBackendFactory* UN static void ALCmmdevBackendFactory_probe(ALCmmdevBackendFactory* UNUSED(self), enum DevProbe type) { ThreadRequest req = { NULL, 0 }; - const DevMap *iter, *end; - HRESULT hr = E_FAIL; req.FinishedEvt = CreateEvent(NULL, FALSE, FALSE, NULL); if(req.FinishedEvt == NULL) ERR("Failed to create event: %lu\n", GetLastError()); else { + HRESULT hr = E_FAIL; if(PostThreadMessage(ThreadID, WM_USER_Enumerate, (WPARAM)&req, type)) hr = WaitForResponse(&req); if(SUCCEEDED(hr)) switch(type) { case ALL_DEVICE_PROBE: - iter = VECTOR_ITER_BEGIN(PlaybackDevices); - end = VECTOR_ITER_END(PlaybackDevices); - for(;iter != end;iter++) - AppendAllDevicesList(al_string_get_cstr(iter->name)); + VECTOR_FOR_EACH(const DevMap, PlaybackDevices, AppendAllDevicesList2); break; case CAPTURE_DEVICE_PROBE: - iter = VECTOR_ITER_BEGIN(CaptureDevices); - end = VECTOR_ITER_END(CaptureDevices); - for(;iter != end;iter++) - AppendCaptureDeviceList(al_string_get_cstr(iter->name)); + VECTOR_FOR_EACH(const DevMap, CaptureDevices, AppendCaptureDeviceList2); break; } CloseHandle(req.FinishedEvt); diff --git a/Alc/backends/pulseaudio.c b/Alc/backends/pulseaudio.c index d1472c7d..f71f9ec9 100644 --- a/Alc/backends/pulseaudio.c +++ b/Alc/backends/pulseaudio.c @@ -1617,6 +1617,11 @@ static void ALCpulseCapture_unlock(ALCpulseCapture *self) } +static inline void AppendAllDevicesList2(const DevMap *entry) +{ AppendAllDevicesList(al_string_get_cstr(entry->name)); } +static inline void AppendCaptureDeviceList2(const DevMap *entry) +{ AppendCaptureDeviceList(al_string_get_cstr(entry->name)); } + typedef struct ALCpulseBackendFactory { DERIVE_FROM_TYPE(ALCbackendFactory); } ALCpulseBackendFactory; @@ -1702,24 +1707,16 @@ static ALCboolean ALCpulseBackendFactory_querySupport(ALCpulseBackendFactory* UN static void ALCpulseBackendFactory_probe(ALCpulseBackendFactory* UNUSED(self), enum DevProbe type) { - DevMap *iter, *end; - switch(type) { case ALL_DEVICE_PROBE: ALCpulsePlayback_probeDevices(); - iter = VECTOR_ITER_BEGIN(PlaybackDevices); - end = VECTOR_ITER_END(PlaybackDevices); - for(;iter != end;iter++) - AppendAllDevicesList(al_string_get_cstr(iter->name)); + VECTOR_FOR_EACH(const DevMap, PlaybackDevices, AppendAllDevicesList2); break; case CAPTURE_DEVICE_PROBE: ALCpulseCapture_probeDevices(); - iter = VECTOR_ITER_BEGIN(CaptureDevices); - end = VECTOR_ITER_END(CaptureDevices); - for(;iter != end;iter++) - AppendCaptureDeviceList(al_string_get_cstr(iter->name)); + VECTOR_FOR_EACH(const DevMap, CaptureDevices, AppendCaptureDeviceList2); break; } } diff --git a/Alc/backends/winmm.c b/Alc/backends/winmm.c index d274a81c..2f01ffdf 100644 --- a/Alc/backends/winmm.c +++ b/Alc/backends/winmm.c @@ -659,6 +659,17 @@ static ALCuint WinMMAvailableSamples(ALCdevice *Device) } +static inline void AppendAllDevicesList2(const al_string *name) +{ + if(!al_string_empty(*name)) + AppendAllDevicesList(al_string_get_cstr(*name)); +} +static inline void AppendCaptureDeviceList2(const al_string *name) +{ + if(!al_string_empty(*name)) + AppendCaptureDeviceList(al_string_get_cstr(*name)); +} + static const BackendFuncs WinMMFuncs = { WinMMOpenPlayback, WinMMClosePlayback, @@ -694,30 +705,16 @@ void alcWinMMDeinit() void alcWinMMProbe(enum DevProbe type) { - const al_string *iter, *end; - switch(type) { case ALL_DEVICE_PROBE: ProbePlaybackDevices(); - iter = VECTOR_ITER_BEGIN(PlaybackDevices); - end = VECTOR_ITER_END(PlaybackDevices); - for(;iter != end;iter++) - { - if(!al_string_empty(*iter)) - AppendAllDevicesList(al_string_get_cstr(*iter)); - } + VECTOR_FOR_EACH(const al_string, PlaybackDevices, AppendAllDevicesList2); break; case CAPTURE_DEVICE_PROBE: ProbeCaptureDevices(); - iter = VECTOR_ITER_BEGIN(CaptureDevices); - end = VECTOR_ITER_END(CaptureDevices); - for(;iter != end;iter++) - { - if(!al_string_empty(*iter)) - AppendCaptureDeviceList(al_string_get_cstr(*iter)); - } + VECTOR_FOR_EACH(const al_string, CaptureDevices, AppendCaptureDeviceList2); break; } } diff --git a/Alc/vector.h b/Alc/vector.h index 242c5fa5..b4a843d5 100644 --- a/Alc/vector.h +++ b/Alc/vector.h @@ -59,4 +59,11 @@ ALboolean vector_insert(void *ptr, size_t base_size, size_t obj_size, void *ins_ #define VECTOR_ELEM(_x, _o) ((_x)->Data[(_o)]) +#define VECTOR_FOR_EACH(_t, _x, _f) do { \ + _t *_iter = VECTOR_ITER_BEGIN((_x)); \ + _t *_end = VECTOR_ITER_END((_x)); \ + for(;_iter != _end;++_iter) \ + (_f)(_iter); \ +} while(0) + #endif /* AL_VECTOR_H */ |