From: Jeongho Mok Date: Thu, 8 Dec 2016 08:53:19 +0000 (+0900) Subject: Use PA_HASHMAP_FOREACH_KV, and set state NULL for FOREACH X-Git-Tag: accepted/tizen/3.0/common/20161215.162935~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a6009ddf3a54907f0fef2d2f58271b81c2ca2793;p=platform%2Fcore%2Fmultimedia%2Fpulseaudio-modules-tizen.git Use PA_HASHMAP_FOREACH_KV, and set state NULL for FOREACH [Version] 5.0.103 [Profile] Common [Issue Type] Enhancement Change-Id: I026f50af0c760ca151bdcb19e877e50ea77bae24 --- diff --git a/packaging/pulseaudio-modules-tizen.spec b/packaging/pulseaudio-modules-tizen.spec index f141b46..bf45b4b 100644 --- a/packaging/pulseaudio-modules-tizen.spec +++ b/packaging/pulseaudio-modules-tizen.spec @@ -1,6 +1,6 @@ Name: pulseaudio-modules-tizen Summary: Pulseaudio modules for Tizen -Version: 5.0.102 +Version: 5.0.103 Release: 0 Group: Multimedia/Audio License: LGPL-2.1+ diff --git a/src/device-manager.c b/src/device-manager.c index 89cdbfa..daba72e 100644 --- a/src/device-manager.c +++ b/src/device-manager.c @@ -205,10 +205,6 @@ static const char* const valid_alsa_device_modargs[] = { NULL }; -/* A macro to ease iteration through all entries */ -#define PA_HASHMAP_FOREACH_KEY(e, h, state, key) \ - for ((state) = NULL, (e) = pa_hashmap_iterate((h), &(state), (const void**)&(key)); (e); (e) = pa_hashmap_iterate((h), &(state), (const void**)&(key))) - #define BT_CVSD_CODEC_ID 1 // narrow-band #define BT_MSBC_CODEC_ID 2 // wide-band /* @@ -1085,7 +1081,7 @@ static const char* device_type_info_get_role(struct device_type_info *type_info, return NULL; } - PA_HASHMAP_FOREACH_KEY(_device_string, pcm_devices, state, role) { + PA_HASHMAP_FOREACH_KV(role, _device_string, pcm_devices, state) { if (pa_streq(_device_string, device_string)) { return role; } @@ -1244,7 +1240,7 @@ static int _fill_new_data_sinks(pa_tz_device_new_data *data, struct device_type_ return -1; } - PA_HASHMAP_FOREACH_KEY(device_string, type_info->playback_devices, state, role) { + PA_HASHMAP_FOREACH_KV(role, device_string, type_info->playback_devices, state) { sink = _core_get_sink(dm->core, device_string, NULL); if (sink) pa_tz_device_new_data_add_sink(data, role, sink); @@ -1268,7 +1264,7 @@ static int _fill_new_data_sources(pa_tz_device_new_data *data, struct device_typ return -1; } - PA_HASHMAP_FOREACH_KEY(device_string, type_info->capture_devices, state, role) { + PA_HASHMAP_FOREACH_KV(role, device_string, type_info->capture_devices, state) { source = _core_get_source(dm->core, device_string, NULL); if (source) pa_tz_device_new_data_add_source(data, role, source); @@ -1675,7 +1671,7 @@ static void* load_device(pa_core *c, bool is_sink, const char *device_string, co static int _load_type_devices(struct device_type_info *type_info, bool is_playback, pa_device_manager *dm) { pa_hashmap *pcm_devices; pa_idxset *file_infos; - void *state = NULL; + void *state; char *role; const char *device_string, *params; @@ -1697,7 +1693,7 @@ static int _load_type_devices(struct device_type_info *type_info, bool is_playba return -1; } - PA_HASHMAP_FOREACH_KEY(device_string, pcm_devices, state, role) { + PA_HASHMAP_FOREACH_KV(role, device_string, pcm_devices, state) { params = _file_infos_get_param(file_infos, device_string, role); if (params == NULL) { pa_log_error("Failed to get param for %s", device_string); diff --git a/src/tizen-device-def.h b/src/tizen-device-def.h index 251d4cd..4688cec 100644 --- a/src/tizen-device-def.h +++ b/src/tizen-device-def.h @@ -40,10 +40,6 @@ typedef enum dm_device_bt_sco_status_type { DM_DEVICE_BT_SCO_STATUS_OPENED } dm_device_bt_sco_status_t; -/* A macro to ease iteration through all entries */ -#define PA_HASHMAP_FOREACH_KEY(e, h, state, key) \ - for ((state) = NULL, (e) = pa_hashmap_iterate((h), &(state), (const void**)&(key)); (e); (e) = pa_hashmap_iterate((h), &(state), (const void**)&(key))) - bool device_type_is_builtin(const char *device_type); bool device_type_is_use_external_card(const char *device_type); bool device_type_is_valid(const char *device_type); diff --git a/src/tizen-device.c b/src/tizen-device.c index 25cdd39..67eae6d 100644 --- a/src/tizen-device.c +++ b/src/tizen-device.c @@ -30,7 +30,7 @@ static uint32_t _new_event_id() { static char* get_playback_list_str(pa_hashmap *playback_devices) { pa_sink *sink = NULL; - void *state = NULL; + void *state; const char *role; pa_strbuf *buf; @@ -39,7 +39,7 @@ static char* get_playback_list_str(pa_hashmap *playback_devices) { buf = pa_strbuf_new(); pa_strbuf_printf(buf, " Playback device list\n"); - PA_HASHMAP_FOREACH_KEY(sink, playback_devices, state, role) + PA_HASHMAP_FOREACH_KV(role, sink, playback_devices, state) pa_strbuf_printf(buf, " %-13s -> %s\n", role, sink->name); return pa_strbuf_tostring_free(buf); @@ -47,7 +47,7 @@ static char* get_playback_list_str(pa_hashmap *playback_devices) { static char* get_capture_list_str(pa_hashmap *capture_devices) { pa_source *source = NULL; - void *state = NULL; + void *state; const char *role; pa_strbuf *buf; @@ -56,7 +56,7 @@ static char* get_capture_list_str(pa_hashmap *capture_devices) { buf = pa_strbuf_new(); pa_strbuf_printf(buf, " Capture device list\n"); - PA_HASHMAP_FOREACH_KEY(source, capture_devices, state, role) + PA_HASHMAP_FOREACH_KV(role, source, capture_devices, state) pa_strbuf_printf(buf, " %-13s -> %s\n", role, source->name); return pa_strbuf_tostring_free(buf); @@ -319,7 +319,7 @@ static int device_remove_sink(pa_tz_device *device, pa_sink *sink) { pa_assert(device); - PA_HASHMAP_FOREACH_KEY(_sink, device->playback_devices, state, role) { + PA_HASHMAP_FOREACH_KV(role, _sink, device->playback_devices, state) { if (sink == _sink) return device_remove_sink_with_role(device, role); } @@ -334,7 +334,7 @@ static int device_remove_source(pa_tz_device *device, pa_source *source) { pa_assert(device); - PA_HASHMAP_FOREACH_KEY(_source, device->capture_devices, state, role) { + PA_HASHMAP_FOREACH_KV(role, _source, device->capture_devices, state) { if (source == _source) return device_remove_source_with_role(device, role); } @@ -578,14 +578,14 @@ bool pa_tz_device_is_use_internal_codec(pa_tz_device *device) { bool pa_tz_device_is_all_suspended(pa_tz_device *device) { pa_sink *sink; pa_source *source; - void *state1 = NULL, *state2 = NULL; + void *state; - PA_HASHMAP_FOREACH(sink, device->playback_devices, state1) { + PA_HASHMAP_FOREACH(sink, device->playback_devices, state) { if (pa_sink_get_state(sink) != PA_SINK_SUSPENDED) return false; } - PA_HASHMAP_FOREACH(source, device->capture_devices, state2) { + PA_HASHMAP_FOREACH(source, device->capture_devices, state) { if (pa_source_get_state(source) != PA_SOURCE_SUSPENDED) return false; }