diff options
author | Arun Raghavan <arun.raghavan@collabora.co.uk> | 2011-03-02 11:31:51 +0530 |
---|---|---|
committer | Arun Raghavan <arun.raghavan@collabora.co.uk> | 2011-05-02 11:54:48 +0530 |
commit | e418e49ecbd643f3cac87438d00baaf86275927c (patch) | |
tree | 53a5290e3bf85fb4201f470b3e84a4267399cb8c | |
parent | 13229fb39e7b8cff3f114c98f8236d9123442243 (diff) |
format: Avoid some code duplication
We frequently need to free an idxset containing pa_format_infos, so
define an internal free function that can be used directly with this
(instead of defining it once-per-file).
-rw-r--r-- | src/pulse/format.c | 4 | ||||
-rw-r--r-- | src/pulse/internal.h | 1 | ||||
-rw-r--r-- | src/pulsecore/protocol-native.c | 7 | ||||
-rw-r--r-- | src/pulsecore/sink-input.c | 14 |
4 files changed, 12 insertions, 14 deletions
diff --git a/src/pulse/format.c b/src/pulse/format.c index af24eb2e..9bb76732 100644 --- a/src/pulse/format.c +++ b/src/pulse/format.c @@ -66,6 +66,10 @@ void pa_format_info_free(pa_format_info *f) { pa_xfree(f); } +void pa_format_info_free2(pa_format_info *f, void *userdata) { + pa_format_info_free(f); +} + int pa_format_info_valid(pa_format_info *f) { return (f->encoding >= 0 && f->encoding < PA_ENCODING_MAX && f->plist != NULL); } diff --git a/src/pulse/internal.h b/src/pulse/internal.h index 228e8dc4..351aeec9 100644 --- a/src/pulse/internal.h +++ b/src/pulse/internal.h @@ -296,6 +296,7 @@ pa_tagstruct *pa_tagstruct_command(pa_context *c, uint32_t command, uint32_t *ta void pa_ext_device_manager_command(pa_context *c, uint32_t tag, pa_tagstruct *t); void pa_ext_stream_restore_command(pa_context *c, uint32_t tag, pa_tagstruct *t); +void pa_format_info_free2(pa_format_info *f, void *userdata); pa_bool_t pa_format_info_is_compatible(pa_format_info *first, pa_format_info *second); pa_format_info* pa_format_info_from_sample_spec(pa_sample_spec *ss, pa_channel_map *map); pa_bool_t pa_format_info_to_sample_spec(pa_format_info *f, pa_sample_spec *ss, pa_channel_map *map); diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c index 83321790..ee2bc4f5 100644 --- a/src/pulsecore/protocol-native.c +++ b/src/pulsecore/protocol-native.c @@ -35,6 +35,7 @@ #include <pulse/utf8.h> #include <pulse/util.h> #include <pulse/xmalloc.h> +#include <pulse/internal.h> #include <pulsecore/native-common.h> #include <pulsecore/packet.h> @@ -1849,10 +1850,6 @@ static pa_tagstruct *reply_new(uint32_t tag) { return reply; } -static void free_format_info(pa_format_info *f, void *userdata) { - pa_format_info_free(f); -} - static void command_create_playback_stream(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) { pa_native_connection *c = PA_NATIVE_CONNECTION(userdata); playback_stream *s; @@ -2110,7 +2107,7 @@ error: if (p) pa_proplist_free(p); if (formats) - pa_idxset_free(formats, (pa_free2_cb_t) free_format_info, NULL); + pa_idxset_free(formats, (pa_free2_cb_t) pa_format_info_free2, NULL); return; } diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c index a4659558..0f34e650 100644 --- a/src/pulsecore/sink-input.c +++ b/src/pulsecore/sink-input.c @@ -130,10 +130,6 @@ void pa_sink_input_new_data_set_muted(pa_sink_input_new_data *data, pa_bool_t mu data->muted = !!mute; } -static void free_format_info(pa_format_info *f, void *userdata) { - pa_format_info_free(f); -} - pa_bool_t pa_sink_input_new_data_set_sink(pa_sink_input_new_data *data, pa_sink *s, pa_bool_t save) { pa_bool_t ret = TRUE; pa_idxset *formats = NULL; @@ -154,12 +150,12 @@ pa_bool_t pa_sink_input_new_data_set_sink(pa_sink_input_new_data *data, pa_sink data->sink = s; data->save_sink = save; if (data->nego_formats) - pa_idxset_free(data->nego_formats, (pa_free2_cb_t) free_format_info, NULL); + pa_idxset_free(data->nego_formats, (pa_free2_cb_t) pa_format_info_free2, NULL); data->nego_formats = formats; } else { /* Sink doesn't support any of the formats requested by the client */ if (formats) - pa_idxset_free(formats, (pa_free2_cb_t) free_format_info, NULL); + pa_idxset_free(formats, (pa_free2_cb_t) pa_format_info_free2, NULL); ret = FALSE; } } @@ -172,7 +168,7 @@ pa_bool_t pa_sink_input_new_data_set_formats(pa_sink_input_new_data *data, pa_id pa_assert(formats); if (data->req_formats) - pa_idxset_free(formats, (pa_free2_cb_t) free_format_info, NULL); + pa_idxset_free(formats, (pa_free2_cb_t) pa_format_info_free2, NULL); data->req_formats = formats; @@ -188,10 +184,10 @@ void pa_sink_input_new_data_done(pa_sink_input_new_data *data) { pa_assert(data); if (data->req_formats) - pa_idxset_free(data->req_formats, (pa_free2_cb_t) free_format_info, NULL); + pa_idxset_free(data->req_formats, (pa_free2_cb_t) pa_format_info_free2, NULL); if (data->nego_formats) - pa_idxset_free(data->nego_formats, (pa_free2_cb_t) free_format_info, NULL); + pa_idxset_free(data->nego_formats, (pa_free2_cb_t) pa_format_info_free2, NULL); if (data->format) pa_format_info_free(data->format); |