[pulseaudio-discuss] [PATCH v2 10/18] format, core-format: Constify some function parameters
Tanu Kaskinen
tanu.kaskinen at linux.intel.com
Wed Dec 18 09:28:15 PST 2013
---
src/pulse/format.c | 18 +++++++++---------
src/pulse/format.h | 18 +++++++++---------
src/pulsecore/core-format.c | 14 +++++++-------
src/pulsecore/core-format.h | 14 +++++++-------
4 files changed, 32 insertions(+), 32 deletions(-)
diff --git a/src/pulse/format.c b/src/pulse/format.c
index 9b42cdb..6c34594 100644
--- a/src/pulse/format.c
+++ b/src/pulse/format.c
@@ -171,7 +171,7 @@ error:
goto out;
}
-int pa_format_info_is_compatible(pa_format_info *first, pa_format_info *second) {
+int pa_format_info_is_compatible(const pa_format_info *first, const pa_format_info *second) {
const char *key;
void *state = NULL;
@@ -194,7 +194,7 @@ int pa_format_info_is_compatible(pa_format_info *first, pa_format_info *second)
return true;
}
-pa_format_info* pa_format_info_from_sample_spec(pa_sample_spec *ss, pa_channel_map *map) {
+pa_format_info* pa_format_info_from_sample_spec(const pa_sample_spec *ss, const pa_channel_map *map) {
char cm[PA_CHANNEL_MAP_SNPRINT_MAX];
pa_format_info *f;
@@ -217,7 +217,7 @@ pa_format_info* pa_format_info_from_sample_spec(pa_sample_spec *ss, pa_channel_m
}
/* For PCM streams */
-int pa_format_info_to_sample_spec(pa_format_info *f, pa_sample_spec *ss, pa_channel_map *map) {
+int pa_format_info_to_sample_spec(const pa_format_info *f, pa_sample_spec *ss, pa_channel_map *map) {
pa_assert(f);
pa_assert(ss);
@@ -236,7 +236,7 @@ int pa_format_info_to_sample_spec(pa_format_info *f, pa_sample_spec *ss, pa_chan
return 0;
}
-pa_prop_type_t pa_format_info_get_prop_type(pa_format_info *f, const char *key) {
+pa_prop_type_t pa_format_info_get_prop_type(const pa_format_info *f, const char *key) {
const char *str;
json_object *o, *o1;
pa_prop_type_t type;
@@ -310,7 +310,7 @@ pa_prop_type_t pa_format_info_get_prop_type(pa_format_info *f, const char *key)
return type;
}
-int pa_format_info_get_prop_int(pa_format_info *f, const char *key, int *v) {
+int pa_format_info_get_prop_int(const pa_format_info *f, const char *key, int *v) {
const char *str;
json_object *o;
@@ -337,7 +337,7 @@ int pa_format_info_get_prop_int(pa_format_info *f, const char *key, int *v) {
return 0;
}
-int pa_format_info_get_prop_int_range(pa_format_info *f, const char *key, int *min, int *max) {
+int pa_format_info_get_prop_int_range(const pa_format_info *f, const char *key, int *min, int *max) {
const char *str;
json_object *o, *o1;
int ret = -PA_ERR_INVALID;
@@ -377,7 +377,7 @@ out:
return ret;
}
-int pa_format_info_get_prop_int_array(pa_format_info *f, const char *key, int **values, int *n_values) {
+int pa_format_info_get_prop_int_array(const pa_format_info *f, const char *key, int **values, int *n_values) {
const char *str;
json_object *o, *o1;
int i, ret = -PA_ERR_INVALID;
@@ -420,7 +420,7 @@ out:
return ret;
}
-int pa_format_info_get_prop_string(pa_format_info *f, const char *key, char **v) {
+int pa_format_info_get_prop_string(const pa_format_info *f, const char *key, char **v) {
const char *str = NULL;
json_object *o;
@@ -447,7 +447,7 @@ int pa_format_info_get_prop_string(pa_format_info *f, const char *key, char **v)
return 0;
}
-int pa_format_info_get_prop_string_array(pa_format_info *f, const char *key, char ***values, int *n_values) {
+int pa_format_info_get_prop_string_array(const pa_format_info *f, const char *key, char ***values, int *n_values) {
const char *str;
json_object *o, *o1;
int i, ret = -PA_ERR_INVALID;
diff --git a/src/pulse/format.h b/src/pulse/format.h
index 4184bee..e3c8f36 100644
--- a/src/pulse/format.h
+++ b/src/pulse/format.h
@@ -114,7 +114,7 @@ int pa_format_info_is_pcm(const pa_format_info *f);
* stream's format is compatible with a given sink. In such a case,
* \a first would be the sink's format and \a second would be the
* stream's. \since 1.0 */
-int pa_format_info_is_compatible(pa_format_info *first, pa_format_info *second);
+int pa_format_info_is_compatible(const pa_format_info *first, const pa_format_info *second);
/** Maximum required string length for
* pa_format_info_snprint(). Please note that this value can change
@@ -131,14 +131,14 @@ char *pa_format_info_snprint(char *s, size_t l, const pa_format_info *f);
pa_format_info* pa_format_info_from_string(const char *str);
/** Utility function to take a \a pa_sample_spec and generate the corresponding \a pa_format_info. \since 2.0 */
-pa_format_info* pa_format_info_from_sample_spec(pa_sample_spec *ss, pa_channel_map *map);
+pa_format_info* pa_format_info_from_sample_spec(const pa_sample_spec *ss, const pa_channel_map *map);
/** Utility function to generate a \a pa_sample_spec and \a pa_channel_map corresponding to a given \a pa_format_info. The
* conversion for PCM formats is straight-forward. For non-PCM formats, if there is a fixed size-time conversion (i.e. all
* IEC61937-encapsulated formats), a "fake" sample spec whose size-time conversion corresponds to this format is provided and
* the channel map argument is ignored. For formats with variable size-time conversion, this function will fail. Returns a
* negative integer if conversion failed and 0 on success. \since 2.0 */
-int pa_format_info_to_sample_spec(pa_format_info *f, pa_sample_spec *ss, pa_channel_map *map);
+int pa_format_info_to_sample_spec(const pa_format_info *f, pa_sample_spec *ss, pa_channel_map *map);
/** Represents the type of value type of a property on a \ref pa_format_info. \since 2.0 */
typedef enum pa_prop_type_t {
@@ -171,24 +171,24 @@ typedef enum pa_prop_type_t {
/** \endcond */
/** Gets the type of property \a key in a given \ref pa_format_info. \since 2.0 */
-pa_prop_type_t pa_format_info_get_prop_type(pa_format_info *f, const char *key);
+pa_prop_type_t pa_format_info_get_prop_type(const pa_format_info *f, const char *key);
/** Gets an integer property from the given format info. Returns 0 on success and a negative integer on failure. \since 2.0 */
-int pa_format_info_get_prop_int(pa_format_info *f, const char *key, int *v);
+int pa_format_info_get_prop_int(const pa_format_info *f, const char *key, int *v);
/** Gets an integer range property from the given format info. Returns 0 on success and a negative integer on failure.
* \since 2.0 */
-int pa_format_info_get_prop_int_range(pa_format_info *f, const char *key, int *min, int *max);
+int pa_format_info_get_prop_int_range(const pa_format_info *f, const char *key, int *min, int *max);
/** Gets an integer array property from the given format info. \a values contains the values and \a n_values contains the
* number of elements. The caller must free \a values using \ref pa_xfree. Returns 0 on success and a negative integer on
* failure. \since 2.0 */
-int pa_format_info_get_prop_int_array(pa_format_info *f, const char *key, int **values, int *n_values);
+int pa_format_info_get_prop_int_array(const pa_format_info *f, const char *key, int **values, int *n_values);
/** Gets a string property from the given format info. The caller must free the returned string using \ref pa_xfree. Returns
* 0 on success and a negative integer on failure. \since 2.0 */
-int pa_format_info_get_prop_string(pa_format_info *f, const char *key, char **v);
+int pa_format_info_get_prop_string(const pa_format_info *f, const char *key, char **v);
/** Gets a string array property from the given format info. \a values contains the values and \a n_values contains
* the number of elements. The caller must free \a values using \ref pa_format_info_free_string_array. Returns 0 on success and
* a negative integer on failure. \since 2.0 */
-int pa_format_info_get_prop_string_array(pa_format_info *f, const char *key, char ***values, int *n_values);
+int pa_format_info_get_prop_string_array(const pa_format_info *f, const char *key, char ***values, int *n_values);
/** Frees a string array returned by \ref pa_format_info_get_prop_string_array. \since 2.0 */
void pa_format_info_free_string_array(char **values, int n_values);
diff --git a/src/pulsecore/core-format.c b/src/pulsecore/core-format.c
index f3fe4b1..f74dc79 100644
--- a/src/pulsecore/core-format.c
+++ b/src/pulsecore/core-format.c
@@ -28,7 +28,7 @@
#include <pulsecore/macro.h>
-int pa_format_info_get_sample_format(pa_format_info *f, pa_sample_format_t *sf) {
+int pa_format_info_get_sample_format(const pa_format_info *f, pa_sample_format_t *sf) {
int r;
char *sf_str;
pa_sample_format_t sf_local;
@@ -54,7 +54,7 @@ int pa_format_info_get_sample_format(pa_format_info *f, pa_sample_format_t *sf)
return 0;
}
-int pa_format_info_get_rate(pa_format_info *f, uint32_t *rate) {
+int pa_format_info_get_rate(const pa_format_info *f, uint32_t *rate) {
int r;
int rate_local;
@@ -76,7 +76,7 @@ int pa_format_info_get_rate(pa_format_info *f, uint32_t *rate) {
return 0;
}
-int pa_format_info_get_channels(pa_format_info *f, uint8_t *channels) {
+int pa_format_info_get_channels(const pa_format_info *f, uint8_t *channels) {
int r;
int channels_local;
@@ -98,7 +98,7 @@ int pa_format_info_get_channels(pa_format_info *f, uint8_t *channels) {
return 0;
}
-int pa_format_info_get_channel_map(pa_format_info *f, pa_channel_map *map) {
+int pa_format_info_get_channel_map(const pa_format_info *f, pa_channel_map *map) {
int r;
char *map_str;
@@ -158,8 +158,8 @@ fail:
return NULL;
}
-int pa_format_info_to_sample_spec2(pa_format_info *f, pa_sample_spec *ss, pa_channel_map *map, pa_sample_spec *fallback_ss,
- pa_channel_map *fallback_map) {
+int pa_format_info_to_sample_spec2(const pa_format_info *f, pa_sample_spec *ss, pa_channel_map *map,
+ const pa_sample_spec *fallback_ss, const pa_channel_map *fallback_map) {
int r, r2;
pa_sample_spec ss_local;
pa_channel_map map_local;
@@ -225,7 +225,7 @@ int pa_format_info_to_sample_spec2(pa_format_info *f, pa_sample_spec *ss, pa_cha
return 0;
}
-int pa_format_info_to_sample_spec_fake(pa_format_info *f, pa_sample_spec *ss, pa_channel_map *map) {
+int pa_format_info_to_sample_spec_fake(const pa_format_info *f, pa_sample_spec *ss, pa_channel_map *map) {
int rate;
pa_assert(f);
diff --git a/src/pulsecore/core-format.h b/src/pulsecore/core-format.h
index ce3923e..f2fa12e 100644
--- a/src/pulsecore/core-format.h
+++ b/src/pulsecore/core-format.h
@@ -27,22 +27,22 @@
/* Gets the sample format stored in the format info. Returns a negative error
* code on failure. If the sample format property is not set at all, returns
* -PA_ERR_NOENTITY. */
-int pa_format_info_get_sample_format(pa_format_info *f, pa_sample_format_t *sf);
+int pa_format_info_get_sample_format(const pa_format_info *f, pa_sample_format_t *sf);
/* Gets the sample rate stored in the format info. Returns a negative error
* code on failure. If the sample rate property is not set at all, returns
* -PA_ERR_NOENTITY. */
-int pa_format_info_get_rate(pa_format_info *f, uint32_t *rate);
+int pa_format_info_get_rate(const pa_format_info *f, uint32_t *rate);
/* Gets the channel count stored in the format info. Returns a negative error
* code on failure. If the channels property is not set at all, returns
* -PA_ERR_NOENTITY. */
-int pa_format_info_get_channels(pa_format_info *f, uint8_t *channels);
+int pa_format_info_get_channels(const pa_format_info *f, uint8_t *channels);
/* Gets the channel map stored in the format info. Returns a negative error
* code on failure. If the channel map property is not set at all, returns
* -PA_ERR_NOENTITY. */
-int pa_format_info_get_channel_map(pa_format_info *f, pa_channel_map *map);
+int pa_format_info_get_channel_map(const pa_format_info *f, pa_channel_map *map);
/* Convert a sample spec and an optional channel map to a new PCM format info
* object (remember to free it). If map is NULL, then the channel map will be
@@ -69,13 +69,13 @@ pa_format_info *pa_format_info_from_sample_spec2(const pa_sample_spec *ss, const
* a fallback sample spec and channel map. That functionality can't be added to
* the original function, because the function is part of the public API and
* adding parameters to it would break the API. */
-int pa_format_info_to_sample_spec2(pa_format_info *f, pa_sample_spec *ss, pa_channel_map *map, pa_sample_spec *fallback_ss,
- pa_channel_map *fallback_map);
+int pa_format_info_to_sample_spec2(const pa_format_info *f, pa_sample_spec *ss, pa_channel_map *map,
+ const pa_sample_spec *fallback_ss, const pa_channel_map *fallback_map);
/* For compressed formats. Converts the format info into a sample spec and a
* channel map that an ALSA device can use as its configuration parameters when
* playing back the compressed data. That is, the returned sample spec doesn't
* describe the audio content, but the device parameters. */
-int pa_format_info_to_sample_spec_fake(pa_format_info *f, pa_sample_spec *ss, pa_channel_map *map);
+int pa_format_info_to_sample_spec_fake(const pa_format_info *f, pa_sample_spec *ss, pa_channel_map *map);
#endif
--
1.8.3.1
More information about the pulseaudio-discuss
mailing list