[pulseaudio-commits] Branch 'next' - 16 commits - src/pulse src/pulsecore

Tanu Kaskinen tanuk at kemper.freedesktop.org
Mon Jun 4 10:26:18 UTC 2018


 src/pulse/context.c       |    2 -
 src/pulse/context.h       |    2 -
 src/pulse/proplist.c      |   49 ++++++++++++++++++++++------------------------
 src/pulse/proplist.h      |   18 ++++++++--------
 src/pulse/scache.c        |    8 +++----
 src/pulse/scache.h        |    2 -
 src/pulsecore/hashmap.c   |   16 +++++++--------
 src/pulsecore/hashmap.h   |   14 ++++++-------
 src/pulsecore/tagstruct.c |    4 +--
 src/pulsecore/tagstruct.h |    4 +--
 10 files changed, 59 insertions(+), 60 deletions(-)

New commits:
commit 055e466a6b48703aa577e49a71c9221c5226fd08
Author: Lyndon Brown <jnqnfe at gmail.com>
Date:   Sun May 27 05:15:14 2018 +0100

    scache: pa_context_play_sample_with_proplist: constify proplist param
    
    If the given proplist is NULL, the function creates a new (empty)
    proplist. That caused a compiler warning after the constification, which
    is why the new proplist is now created using a separate variable.

diff --git a/src/pulse/scache.c b/src/pulse/scache.c
index de7b4112..d393229b 100644
--- a/src/pulse/scache.c
+++ b/src/pulse/scache.c
@@ -205,7 +205,7 @@ pa_operation *pa_context_play_sample(pa_context *c, const char *name, const char
     return o;
 }
 
-pa_operation *pa_context_play_sample_with_proplist(pa_context *c, const char *name, const char *dev, pa_volume_t volume, pa_proplist *p, pa_context_play_sample_cb_t cb, void *userdata) {
+pa_operation *pa_context_play_sample_with_proplist(pa_context *c, const char *name, const char *dev, pa_volume_t volume, const pa_proplist *p, pa_context_play_sample_cb_t cb, void *userdata) {
     pa_operation *o;
     pa_tagstruct *t;
     uint32_t tag;
@@ -237,9 +237,9 @@ pa_operation *pa_context_play_sample_with_proplist(pa_context *c, const char *na
     if (p)
         pa_tagstruct_put_proplist(t, p);
     else {
-        p = pa_proplist_new();
-        pa_tagstruct_put_proplist(t, p);
-        pa_proplist_free(p);
+        pa_proplist *empty_proplist = pa_proplist_new();
+        pa_tagstruct_put_proplist(t, empty_proplist);
+        pa_proplist_free(empty_proplist);
     }
 
     pa_pstream_send_tagstruct(c->pstream, t);
diff --git a/src/pulse/scache.h b/src/pulse/scache.h
index e4b82bc7..1be71983 100644
--- a/src/pulse/scache.h
+++ b/src/pulse/scache.h
@@ -116,7 +116,7 @@ pa_operation* pa_context_play_sample_with_proplist(
         const char *name                /**< Name of the sample to play */,
         const char *dev                 /**< Sink to play this sample on */,
         pa_volume_t volume              /**< Volume to play this sample with. Starting with 0.9.15 you may pass here PA_VOLUME_INVALID which will leave the decision about the volume to the server side, which is a good idea.  */ ,
-        pa_proplist *proplist           /**< Property list for this sound. The property list of the cached entry will have this merged into it. */,
+        const pa_proplist *proplist     /**< Property list for this sound. The property list of the cached entry will have this merged into it. */,
         pa_context_play_sample_cb_t cb  /**< Call this function after successfully starting playback, or NULL */,
         void *userdata                  /**< Userdata to pass to the callback */);
 

commit c0ea7d2c6138f09f7abd172a9e7f2a170e49c316
Author: Lyndon Brown <jnqnfe at gmail.com>
Date:   Sun May 27 05:14:04 2018 +0100

    scache: pa_context_play_sample_with_proplist: clarify proplist param
    
    Existing documentation was unclear about which property list would be the
    one changed (merged into), making it seem (along with the non-const
    proplist pointer param, which needs changing seperately), that the proplist
    object for which a pointer is given will be the one merged into, instead of
    the internal cached entry's proplist.

diff --git a/src/pulse/scache.h b/src/pulse/scache.h
index 2b85854e..e4b82bc7 100644
--- a/src/pulse/scache.h
+++ b/src/pulse/scache.h
@@ -116,7 +116,7 @@ pa_operation* pa_context_play_sample_with_proplist(
         const char *name                /**< Name of the sample to play */,
         const char *dev                 /**< Sink to play this sample on */,
         pa_volume_t volume              /**< Volume to play this sample with. Starting with 0.9.15 you may pass here PA_VOLUME_INVALID which will leave the decision about the volume to the server side, which is a good idea.  */ ,
-        pa_proplist *proplist           /**< Property list for this sound. The property list of the cached entry will be merged into this property list */,
+        pa_proplist *proplist           /**< Property list for this sound. The property list of the cached entry will have this merged into it. */,
         pa_context_play_sample_cb_t cb  /**< Call this function after successfully starting playback, or NULL */,
         void *userdata                  /**< Userdata to pass to the callback */);
 

commit 7340e7fff4dbfec2ebb527788968b65b10fc2758
Author: Lyndon Brown <jnqnfe at gmail.com>
Date:   Sun May 27 04:42:36 2018 +0100

    proplist: pa_proplist_equal: constify proplist pointers

diff --git a/src/pulse/proplist.c b/src/pulse/proplist.c
index a0913b10..91351159 100644
--- a/src/pulse/proplist.c
+++ b/src/pulse/proplist.c
@@ -674,7 +674,7 @@ int pa_proplist_isempty(const pa_proplist *p) {
     return pa_hashmap_isempty(MAKE_HASHMAP_CONST(p));
 }
 
-int pa_proplist_equal(pa_proplist *a, pa_proplist *b) {
+int pa_proplist_equal(const pa_proplist *a, const pa_proplist *b) {
     const void *key = NULL;
     struct property *a_prop = NULL;
     struct property *b_prop = NULL;
diff --git a/src/pulse/proplist.h b/src/pulse/proplist.h
index 2c99976f..e50518b3 100644
--- a/src/pulse/proplist.h
+++ b/src/pulse/proplist.h
@@ -404,7 +404,7 @@ int pa_proplist_isempty(const pa_proplist *p);
 
 /** Return non-zero when a and b have the same keys and values.
  * \since 0.9.16 */
-int pa_proplist_equal(pa_proplist *a, pa_proplist *b);
+int pa_proplist_equal(const pa_proplist *a, const pa_proplist *b);
 
 PA_C_DECL_END
 

commit b9b5b7e0570b5bd373228e5160bbb312dfc2ead7
Author: Lyndon Brown <jnqnfe at gmail.com>
Date:   Sun May 27 04:40:07 2018 +0100

    proplist: pa_proplist_[size|isempty]: constify proplist pointer

diff --git a/src/pulse/proplist.c b/src/pulse/proplist.c
index 4ad092d6..a0913b10 100644
--- a/src/pulse/proplist.c
+++ b/src/pulse/proplist.c
@@ -662,13 +662,13 @@ pa_proplist* pa_proplist_copy(const pa_proplist *p) {
     return copy;
 }
 
-unsigned pa_proplist_size(pa_proplist *p) {
+unsigned pa_proplist_size(const pa_proplist *p) {
     pa_assert(p);
 
     return pa_hashmap_size(MAKE_HASHMAP_CONST(p));
 }
 
-int pa_proplist_isempty(pa_proplist *p) {
+int pa_proplist_isempty(const pa_proplist *p) {
     pa_assert(p);
 
     return pa_hashmap_isempty(MAKE_HASHMAP_CONST(p));
diff --git a/src/pulse/proplist.h b/src/pulse/proplist.h
index c148c793..2c99976f 100644
--- a/src/pulse/proplist.h
+++ b/src/pulse/proplist.h
@@ -397,10 +397,10 @@ void pa_proplist_clear(pa_proplist *p);
 pa_proplist* pa_proplist_copy(const pa_proplist *p);
 
 /** Return the number of entries in the property list. \since 0.9.15 */
-unsigned pa_proplist_size(pa_proplist *p);
+unsigned pa_proplist_size(const pa_proplist *p);
 
 /** Returns 0 when the proplist is empty, positive otherwise \since 0.9.15 */
-int pa_proplist_isempty(pa_proplist *p);
+int pa_proplist_isempty(const pa_proplist *p);
 
 /** Return non-zero when a and b have the same keys and values.
  * \since 0.9.16 */

commit 9f9dfe8245dc0b46ecd5359a52fe5224c95aa103
Author: Lyndon Brown <jnqnfe at gmail.com>
Date:   Sun May 27 04:35:33 2018 +0100

    proplist: pa_proplist_contains: constify proplist pointer

diff --git a/src/pulse/proplist.c b/src/pulse/proplist.c
index 75500246..4ad092d6 100644
--- a/src/pulse/proplist.c
+++ b/src/pulse/proplist.c
@@ -632,7 +632,7 @@ fail:
     return NULL;
 }
 
-int pa_proplist_contains(pa_proplist *p, const char *key) {
+int pa_proplist_contains(const pa_proplist *p, const char *key) {
     pa_assert(p);
     pa_assert(key);
 
diff --git a/src/pulse/proplist.h b/src/pulse/proplist.h
index f7a42826..c148c793 100644
--- a/src/pulse/proplist.h
+++ b/src/pulse/proplist.h
@@ -387,7 +387,7 @@ pa_proplist *pa_proplist_from_string(const char *str);
 
 /** Returns 1 if an entry for the specified key exists in the
  * property list. Returns negative on error. \since 0.9.11 */
-int pa_proplist_contains(pa_proplist *p, const char *key);
+int pa_proplist_contains(const pa_proplist *p, const char *key);
 
 /** Remove all entries from the property list object. \since 0.9.11 */
 void pa_proplist_clear(pa_proplist *p);

commit 728abf50d9ee39be6e8e9bc5424084be6c9b0e95
Author: Lyndon Brown <jnqnfe at gmail.com>
Date:   Sun May 27 04:31:49 2018 +0100

    proplist: pa_proplist_to_string[_sep]: constify proplist pointer

diff --git a/src/pulse/proplist.c b/src/pulse/proplist.c
index f9aaea5b..75500246 100644
--- a/src/pulse/proplist.c
+++ b/src/pulse/proplist.c
@@ -379,7 +379,7 @@ const char *pa_proplist_iterate(const pa_proplist *p, void **state) {
     return prop->key;
 }
 
-char *pa_proplist_to_string_sep(pa_proplist *p, const char *sep) {
+char *pa_proplist_to_string_sep(const pa_proplist *p, const char *sep) {
     const char *key;
     void *state = NULL;
     pa_strbuf *buf;
@@ -437,7 +437,7 @@ char *pa_proplist_to_string_sep(pa_proplist *p, const char *sep) {
     return pa_strbuf_to_string_free(buf);
 }
 
-char *pa_proplist_to_string(pa_proplist *p) {
+char *pa_proplist_to_string(const pa_proplist *p) {
     char *s, *t;
 
     s = pa_proplist_to_string_sep(p, "\n");
diff --git a/src/pulse/proplist.h b/src/pulse/proplist.h
index 9e0f706e..f7a42826 100644
--- a/src/pulse/proplist.h
+++ b/src/pulse/proplist.h
@@ -374,12 +374,12 @@ const char *pa_proplist_iterate(const pa_proplist *p, void **state);
  * works very much like pa_proplist_to_string_sep() and uses a newline
  * as separator and appends one final one. Call pa_xfree() on the
  * result. \since 0.9.11 */
-char *pa_proplist_to_string(pa_proplist *p);
+char *pa_proplist_to_string(const pa_proplist *p);
 
 /** Format the property list nicely as a human readable string and
  * choose the separator. Call pa_xfree() on the result. \since
  * 0.9.15 */
-char *pa_proplist_to_string_sep(pa_proplist *p, const char *sep);
+char *pa_proplist_to_string_sep(const pa_proplist *p, const char *sep);
 
 /** Allocate a new property list and assign key/value from a human
  * readable string. \since 0.9.15 */

commit 0537c9f7df133c1625403165a7031e95527fa620
Author: Lyndon Brown <jnqnfe at gmail.com>
Date:   Sun May 27 03:04:43 2018 +0100

    context: pa_context_proplist_update: constify proplist pointer

diff --git a/src/pulse/context.c b/src/pulse/context.c
index 6adfc5a9..e7695009 100644
--- a/src/pulse/context.c
+++ b/src/pulse/context.c
@@ -1369,7 +1369,7 @@ uint32_t pa_context_get_index(pa_context *c) {
     return c->client_index;
 }
 
-pa_operation *pa_context_proplist_update(pa_context *c, pa_update_mode_t mode, pa_proplist *p, pa_context_success_cb_t cb, void *userdata) {
+pa_operation *pa_context_proplist_update(pa_context *c, pa_update_mode_t mode, const pa_proplist *p, pa_context_success_cb_t cb, void *userdata) {
     pa_operation *o;
     pa_tagstruct *t;
     uint32_t tag;
diff --git a/src/pulse/context.h b/src/pulse/context.h
index 9b96f8ce..2cb0776e 100644
--- a/src/pulse/context.h
+++ b/src/pulse/context.h
@@ -247,7 +247,7 @@ uint32_t pa_context_get_server_protocol_version(pa_context *c);
  * initially via pa_context_new_with_proplist() as possible instead a
  * posteriori with this function, since that information may then be
  * used to route streams of the client to the right device. \since 0.9.11 */
-pa_operation *pa_context_proplist_update(pa_context *c, pa_update_mode_t mode, pa_proplist *p, pa_context_success_cb_t cb, void *userdata);
+pa_operation *pa_context_proplist_update(pa_context *c, pa_update_mode_t mode, const pa_proplist *p, pa_context_success_cb_t cb, void *userdata);
 
 /** Update the property list of the client, remove entries. \since 0.9.11 */
 pa_operation *pa_context_proplist_remove(pa_context *c, const char *const keys[], pa_context_success_cb_t cb, void *userdata);

commit ae7ca2b04c981a27214bc81ebbb6e4c1d208afcf
Author: Lyndon Brown <jnqnfe at gmail.com>
Date:   Sun May 27 03:02:30 2018 +0100

    tagstruct: pa_tagstruct_put_format_info: constify format pointer

diff --git a/src/pulsecore/tagstruct.c b/src/pulsecore/tagstruct.c
index 50168717..6e9c7d15 100644
--- a/src/pulsecore/tagstruct.c
+++ b/src/pulsecore/tagstruct.c
@@ -334,7 +334,7 @@ void pa_tagstruct_put_proplist(pa_tagstruct *t, const pa_proplist *p) {
     pa_tagstruct_puts(t, NULL);
 }
 
-void pa_tagstruct_put_format_info(pa_tagstruct *t, pa_format_info *f) {
+void pa_tagstruct_put_format_info(pa_tagstruct *t, const pa_format_info *f) {
     pa_assert(t);
     pa_assert(f);
 
diff --git a/src/pulsecore/tagstruct.h b/src/pulsecore/tagstruct.h
index 9236490a..dcb51cbf 100644
--- a/src/pulsecore/tagstruct.h
+++ b/src/pulsecore/tagstruct.h
@@ -83,7 +83,7 @@ void pa_tagstruct_put_channel_map(pa_tagstruct *t, const pa_channel_map *map);
 void pa_tagstruct_put_cvolume(pa_tagstruct *t, const pa_cvolume *cvolume);
 void pa_tagstruct_put_proplist(pa_tagstruct *t, const pa_proplist *p);
 void pa_tagstruct_put_volume(pa_tagstruct *t, pa_volume_t volume);
-void pa_tagstruct_put_format_info(pa_tagstruct *t, pa_format_info *f);
+void pa_tagstruct_put_format_info(pa_tagstruct *t, const pa_format_info *f);
 
 int pa_tagstruct_get(pa_tagstruct *t, ...);
 

commit 49642a832889536d26ea001c832d7a4ffdd40c3e
Author: Lyndon Brown <jnqnfe at gmail.com>
Date:   Sun May 27 03:01:14 2018 +0100

    tagstruct: pa_tagstruct_put_proplist: constify proplist pointer

diff --git a/src/pulsecore/tagstruct.c b/src/pulsecore/tagstruct.c
index 8a29957b..50168717 100644
--- a/src/pulsecore/tagstruct.c
+++ b/src/pulsecore/tagstruct.c
@@ -310,7 +310,7 @@ void pa_tagstruct_put_volume(pa_tagstruct *t, pa_volume_t vol) {
     write_u32(t, vol);
 }
 
-void pa_tagstruct_put_proplist(pa_tagstruct *t, pa_proplist *p) {
+void pa_tagstruct_put_proplist(pa_tagstruct *t, const pa_proplist *p) {
     void *state = NULL;
     pa_assert(t);
     pa_assert(p);
diff --git a/src/pulsecore/tagstruct.h b/src/pulsecore/tagstruct.h
index 348c65d2..9236490a 100644
--- a/src/pulsecore/tagstruct.h
+++ b/src/pulsecore/tagstruct.h
@@ -81,7 +81,7 @@ void pa_tagstruct_put_timeval(pa_tagstruct*t, const struct timeval *tv);
 void pa_tagstruct_put_usec(pa_tagstruct*t, pa_usec_t u);
 void pa_tagstruct_put_channel_map(pa_tagstruct *t, const pa_channel_map *map);
 void pa_tagstruct_put_cvolume(pa_tagstruct *t, const pa_cvolume *cvolume);
-void pa_tagstruct_put_proplist(pa_tagstruct *t, pa_proplist *p);
+void pa_tagstruct_put_proplist(pa_tagstruct *t, const pa_proplist *p);
 void pa_tagstruct_put_volume(pa_tagstruct *t, pa_volume_t volume);
 void pa_tagstruct_put_format_info(pa_tagstruct *t, pa_format_info *f);
 

commit b2c5195200087b5b5514af47d636e00c7bb86e9e
Author: Lyndon Brown <jnqnfe at gmail.com>
Date:   Sun May 27 04:10:53 2018 +0100

    proplist: pa_proplist_gets: constify proplist pointer

diff --git a/src/pulse/proplist.c b/src/pulse/proplist.c
index 0da127ef..f9aaea5b 100644
--- a/src/pulse/proplist.c
+++ b/src/pulse/proplist.c
@@ -272,7 +272,7 @@ int pa_proplist_set(pa_proplist *p, const char *key, const void *data, size_t nb
     return 0;
 }
 
-const char *pa_proplist_gets(pa_proplist *p, const char *key) {
+const char *pa_proplist_gets(const pa_proplist *p, const char *key) {
     struct property *prop;
 
     pa_assert(p);
diff --git a/src/pulse/proplist.h b/src/pulse/proplist.h
index 68900183..9e0f706e 100644
--- a/src/pulse/proplist.h
+++ b/src/pulse/proplist.h
@@ -311,7 +311,7 @@ int pa_proplist_set(pa_proplist *p, const char *key, const void *data, size_t nb
  * the data is not valid UTF-8. Will return a NUL-terminated string in
  * an internally allocated buffer. The caller should make a copy of
  * the data before accessing the property list again. \since 0.9.11 */
-const char *pa_proplist_gets(pa_proplist *p, const char *key);
+const char *pa_proplist_gets(const pa_proplist *p, const char *key);
 
 /** Store the value for the specified key in \a data. Will store a
  * NUL-terminated string for string entries. The \a data pointer returned will

commit 2d3abbbdd27c86cfaf1dbc587f69011e76b20ebb
Author: Lyndon Brown <jnqnfe at gmail.com>
Date:   Sun May 27 02:59:12 2018 +0100

    proplist: pa_proplist_get: constify proplist pointer

diff --git a/src/pulse/proplist.c b/src/pulse/proplist.c
index 37877b4e..0da127ef 100644
--- a/src/pulse/proplist.c
+++ b/src/pulse/proplist.c
@@ -299,7 +299,7 @@ const char *pa_proplist_gets(pa_proplist *p, const char *key) {
     return (char*) prop->value;
 }
 
-int pa_proplist_get(pa_proplist *p, const char *key, const void **data, size_t *nbytes) {
+int pa_proplist_get(const pa_proplist *p, const char *key, const void **data, size_t *nbytes) {
     struct property *prop;
 
     pa_assert(p);
diff --git a/src/pulse/proplist.h b/src/pulse/proplist.h
index 14139a7e..68900183 100644
--- a/src/pulse/proplist.h
+++ b/src/pulse/proplist.h
@@ -318,7 +318,7 @@ const char *pa_proplist_gets(pa_proplist *p, const char *key);
  * point to an internally allocated buffer. The caller should make a
  * copy of the data before the property list is accessed again.
  * Returns zero on success, negative on error. \since 0.9.11 */
-int pa_proplist_get(pa_proplist *p, const char *key, const void **data, size_t *nbytes);
+int pa_proplist_get(const pa_proplist *p, const char *key, const void **data, size_t *nbytes);
 
 /** Update mode enum for pa_proplist_update(). \since 0.9.11 */
 typedef enum pa_update_mode {

commit c2185c5d8ca42bc53ac7741d7f79493116e1194e
Author: Lyndon Brown <jnqnfe at gmail.com>
Date:   Sun May 27 02:45:47 2018 +0100

    proplist: pa_proplist_iterate: constify proplist pointer

diff --git a/src/pulse/proplist.c b/src/pulse/proplist.c
index 328d3ad2..37877b4e 100644
--- a/src/pulse/proplist.c
+++ b/src/pulse/proplist.c
@@ -370,7 +370,7 @@ int pa_proplist_unset_many(pa_proplist *p, const char * const keys[]) {
     return n;
 }
 
-const char *pa_proplist_iterate(pa_proplist *p, void **state) {
+const char *pa_proplist_iterate(const pa_proplist *p, void **state) {
     struct property *prop;
 
     if (!(prop = pa_hashmap_iterate(MAKE_HASHMAP_CONST(p), state, NULL)))
diff --git a/src/pulse/proplist.h b/src/pulse/proplist.h
index cec3b357..14139a7e 100644
--- a/src/pulse/proplist.h
+++ b/src/pulse/proplist.h
@@ -368,7 +368,7 @@ int pa_proplist_unset_many(pa_proplist *p, const char * const keys[]);
  * current entry. On each invocation this function will return the
  * key string for the next entry. The keys in the property list do not
  * have any particular order. \since 0.9.11 */
-const char *pa_proplist_iterate(pa_proplist *p, void **state);
+const char *pa_proplist_iterate(const pa_proplist *p, void **state);
 
 /** Format the property list nicely as a human readable string. This
  * works very much like pa_proplist_to_string_sep() and uses a newline

commit 525e79b495b34cd9f8582a2dc5c3b6202db45096
Author: Lyndon Brown <jnqnfe at gmail.com>
Date:   Sun May 27 02:41:54 2018 +0100

    proplist: add and use const version of MAKE_HASHMAP macro

diff --git a/src/pulse/proplist.c b/src/pulse/proplist.c
index d8c64044..328d3ad2 100644
--- a/src/pulse/proplist.c
+++ b/src/pulse/proplist.c
@@ -40,6 +40,7 @@ struct property {
 };
 
 #define MAKE_HASHMAP(p) ((pa_hashmap*) (p))
+#define MAKE_HASHMAP_CONST(p) ((const pa_hashmap*) (p))
 #define MAKE_PROPLIST(p) ((pa_proplist*) (p))
 
 int pa_proplist_key_valid(const char *key) {
@@ -83,7 +84,7 @@ int pa_proplist_sets(pa_proplist *p, const char *key, const char *value) {
     if (!pa_proplist_key_valid(key) || !pa_utf8_valid(value))
         return -1;
 
-    if (!(prop = pa_hashmap_get(MAKE_HASHMAP(p), key))) {
+    if (!(prop = pa_hashmap_get(MAKE_HASHMAP_CONST(p), key))) {
         prop = pa_xnew(struct property, 1);
         prop->key = pa_xstrdup(key);
         add = true;
@@ -118,7 +119,7 @@ static int proplist_setn(pa_proplist *p, const char *key, size_t key_length, con
         return -1;
     }
 
-    if (!(prop = pa_hashmap_get(MAKE_HASHMAP(p), k))) {
+    if (!(prop = pa_hashmap_get(MAKE_HASHMAP_CONST(p), k))) {
         prop = pa_xnew(struct property, 1);
         prop->key = k;
         add = true;
@@ -181,7 +182,7 @@ static int proplist_sethex(pa_proplist *p, const char *key, size_t key_length, c
 
     pa_xfree(v);
 
-    if (!(prop = pa_hashmap_get(MAKE_HASHMAP(p), k))) {
+    if (!(prop = pa_hashmap_get(MAKE_HASHMAP_CONST(p), k))) {
         prop = pa_xnew(struct property, 1);
         prop->key = k;
         add = true;
@@ -221,7 +222,7 @@ int pa_proplist_setf(pa_proplist *p, const char *key, const char *format, ...) {
     if (!pa_utf8_valid(v))
         goto fail;
 
-    if (!(prop = pa_hashmap_get(MAKE_HASHMAP(p), key))) {
+    if (!(prop = pa_hashmap_get(MAKE_HASHMAP_CONST(p), key))) {
         prop = pa_xnew(struct property, 1);
         prop->key = pa_xstrdup(key);
         add = true;
@@ -252,7 +253,7 @@ int pa_proplist_set(pa_proplist *p, const char *key, const void *data, size_t nb
     if (!pa_proplist_key_valid(key))
         return -1;
 
-    if (!(prop = pa_hashmap_get(MAKE_HASHMAP(p), key))) {
+    if (!(prop = pa_hashmap_get(MAKE_HASHMAP_CONST(p), key))) {
         prop = pa_xnew(struct property, 1);
         prop->key = pa_xstrdup(key);
         add = true;
@@ -280,7 +281,7 @@ const char *pa_proplist_gets(pa_proplist *p, const char *key) {
     if (!pa_proplist_key_valid(key))
         return NULL;
 
-    if (!(prop = pa_hashmap_get(MAKE_HASHMAP(p), key)))
+    if (!(prop = pa_hashmap_get(MAKE_HASHMAP_CONST(p), key)))
         return NULL;
 
     if (prop->nbytes <= 0)
@@ -309,7 +310,7 @@ int pa_proplist_get(pa_proplist *p, const char *key, const void **data, size_t *
     if (!pa_proplist_key_valid(key))
         return -1;
 
-    if (!(prop = pa_hashmap_get(MAKE_HASHMAP(p), key)))
+    if (!(prop = pa_hashmap_get(MAKE_HASHMAP_CONST(p), key)))
         return -1;
 
     *data = prop->value;
@@ -329,9 +330,7 @@ void pa_proplist_update(pa_proplist *p, pa_update_mode_t mode, const pa_proplist
     if (mode == PA_UPDATE_SET)
         pa_proplist_clear(p);
 
-    /* MAKE_HASHMAP turns the const pointer into a non-const pointer, but
-     * that's ok, because we don't modify the hashmap contents. */
-    while ((prop = pa_hashmap_iterate(MAKE_HASHMAP(other), &state, NULL))) {
+    while ((prop = pa_hashmap_iterate(MAKE_HASHMAP_CONST(other), &state, NULL))) {
 
         if (mode == PA_UPDATE_MERGE && pa_proplist_contains(p, prop->key))
             continue;
@@ -374,7 +373,7 @@ int pa_proplist_unset_many(pa_proplist *p, const char * const keys[]) {
 const char *pa_proplist_iterate(pa_proplist *p, void **state) {
     struct property *prop;
 
-    if (!(prop = pa_hashmap_iterate(MAKE_HASHMAP(p), state, NULL)))
+    if (!(prop = pa_hashmap_iterate(MAKE_HASHMAP_CONST(p), state, NULL)))
         return NULL;
 
     return prop->key;
@@ -640,7 +639,7 @@ int pa_proplist_contains(pa_proplist *p, const char *key) {
     if (!pa_proplist_key_valid(key))
         return -1;
 
-    if (!(pa_hashmap_get(MAKE_HASHMAP(p), key)))
+    if (!(pa_hashmap_get(MAKE_HASHMAP_CONST(p), key)))
         return 0;
 
     return 1;
@@ -666,13 +665,13 @@ pa_proplist* pa_proplist_copy(const pa_proplist *p) {
 unsigned pa_proplist_size(pa_proplist *p) {
     pa_assert(p);
 
-    return pa_hashmap_size(MAKE_HASHMAP(p));
+    return pa_hashmap_size(MAKE_HASHMAP_CONST(p));
 }
 
 int pa_proplist_isempty(pa_proplist *p) {
     pa_assert(p);
 
-    return pa_hashmap_isempty(MAKE_HASHMAP(p));
+    return pa_hashmap_isempty(MAKE_HASHMAP_CONST(p));
 }
 
 int pa_proplist_equal(pa_proplist *a, pa_proplist *b) {
@@ -690,8 +689,8 @@ int pa_proplist_equal(pa_proplist *a, pa_proplist *b) {
     if (pa_proplist_size(a) != pa_proplist_size(b))
         return 0;
 
-    while ((a_prop = pa_hashmap_iterate(MAKE_HASHMAP(a), &state, &key))) {
-        if (!(b_prop = pa_hashmap_get(MAKE_HASHMAP(b), key)))
+    while ((a_prop = pa_hashmap_iterate(MAKE_HASHMAP_CONST(a), &state, &key))) {
+        if (!(b_prop = pa_hashmap_get(MAKE_HASHMAP_CONST(b), key)))
             return 0;
 
         if (a_prop->nbytes != b_prop->nbytes)

commit f8c161a9767943877297868ab331c030ac8b7023
Author: Lyndon Brown <jnqnfe at gmail.com>
Date:   Sun May 27 02:57:12 2018 +0100

    hashmap: constify pointer of pa_hashmap_get
    
    relies upon the same having just been done for the private hash_scan
    function

diff --git a/src/pulsecore/hashmap.c b/src/pulsecore/hashmap.c
index c03af3bc..c2fc3f5e 100644
--- a/src/pulsecore/hashmap.c
+++ b/src/pulsecore/hashmap.c
@@ -173,7 +173,7 @@ int pa_hashmap_put(pa_hashmap *h, void *key, void *value) {
     return 0;
 }
 
-void* pa_hashmap_get(pa_hashmap *h, const void *key) {
+void* pa_hashmap_get(const pa_hashmap *h, const void *key) {
     unsigned hash;
     struct hashmap_entry *e;
 
diff --git a/src/pulsecore/hashmap.h b/src/pulsecore/hashmap.h
index ea883765..c18a564f 100644
--- a/src/pulsecore/hashmap.h
+++ b/src/pulsecore/hashmap.h
@@ -45,7 +45,7 @@ void pa_hashmap_free(pa_hashmap*);
 int pa_hashmap_put(pa_hashmap *h, void *key, void *value);
 
 /* Return an entry from the hashmap */
-void* pa_hashmap_get(pa_hashmap *h, const void *key);
+void* pa_hashmap_get(const pa_hashmap *h, const void *key);
 
 /* Returns the data of the entry while removing */
 void* pa_hashmap_remove(pa_hashmap *h, const void *key);

commit 16625c351762dcefa89fa07078602e0cee072e72
Author: Lyndon Brown <jnqnfe at gmail.com>
Date:   Sun May 27 02:56:11 2018 +0100

    hashmap: constify pointer of private hash_scan function
    
    paves the way for doing the same for pa_hashmap_get and users of it

diff --git a/src/pulsecore/hashmap.c b/src/pulsecore/hashmap.c
index 6477783e..c03af3bc 100644
--- a/src/pulsecore/hashmap.c
+++ b/src/pulsecore/hashmap.c
@@ -119,7 +119,7 @@ void pa_hashmap_free(pa_hashmap *h) {
     pa_xfree(h);
 }
 
-static struct hashmap_entry *hash_scan(pa_hashmap *h, unsigned hash, const void *key) {
+static struct hashmap_entry *hash_scan(const pa_hashmap *h, unsigned hash, const void *key) {
     struct hashmap_entry *e;
     pa_assert(h);
     pa_assert(hash < NBUCKETS);

commit da02d409e07c1c108982148067df39bf8b0ad57b
Author: Lyndon Brown <jnqnfe at gmail.com>
Date:   Sun May 27 02:27:43 2018 +0100

    hashmap: constify hashmap ptr for various functions

diff --git a/src/pulsecore/hashmap.c b/src/pulsecore/hashmap.c
index 2385c55c..6477783e 100644
--- a/src/pulsecore/hashmap.c
+++ b/src/pulsecore/hashmap.c
@@ -231,7 +231,7 @@ void pa_hashmap_remove_all(pa_hashmap *h) {
     }
 }
 
-void *pa_hashmap_iterate(pa_hashmap *h, void **state, const void **key) {
+void *pa_hashmap_iterate(const pa_hashmap *h, void **state, const void **key) {
     struct hashmap_entry *e;
 
     pa_assert(h);
@@ -264,7 +264,7 @@ at_end:
     return NULL;
 }
 
-void *pa_hashmap_iterate_backwards(pa_hashmap *h, void **state, const void **key) {
+void *pa_hashmap_iterate_backwards(const pa_hashmap *h, void **state, const void **key) {
     struct hashmap_entry *e;
 
     pa_assert(h);
@@ -297,7 +297,7 @@ at_beginning:
     return NULL;
 }
 
-void* pa_hashmap_first(pa_hashmap *h) {
+void* pa_hashmap_first(const pa_hashmap *h) {
     pa_assert(h);
 
     if (!h->iterate_list_head)
@@ -306,7 +306,7 @@ void* pa_hashmap_first(pa_hashmap *h) {
     return h->iterate_list_head->value;
 }
 
-void* pa_hashmap_last(pa_hashmap *h) {
+void* pa_hashmap_last(const pa_hashmap *h) {
     pa_assert(h);
 
     if (!h->iterate_list_tail)
@@ -329,13 +329,13 @@ void* pa_hashmap_steal_first(pa_hashmap *h) {
     return data;
 }
 
-unsigned pa_hashmap_size(pa_hashmap *h) {
+unsigned pa_hashmap_size(const pa_hashmap *h) {
     pa_assert(h);
 
     return h->n_entries;
 }
 
-bool pa_hashmap_isempty(pa_hashmap *h) {
+bool pa_hashmap_isempty(const pa_hashmap *h) {
     pa_assert(h);
 
     return h->n_entries == 0;
diff --git a/src/pulsecore/hashmap.h b/src/pulsecore/hashmap.h
index b1027e75..ea883765 100644
--- a/src/pulsecore/hashmap.h
+++ b/src/pulsecore/hashmap.h
@@ -61,10 +61,10 @@ int pa_hashmap_remove_and_free(pa_hashmap *h, const void *key);
 void pa_hashmap_remove_all(pa_hashmap *h);
 
 /* Return the current number of entries of the hashmap */
-unsigned pa_hashmap_size(pa_hashmap *h);
+unsigned pa_hashmap_size(const pa_hashmap *h);
 
 /* Return true if the hashmap is empty */
-bool pa_hashmap_isempty(pa_hashmap *h);
+bool pa_hashmap_isempty(const pa_hashmap *h);
 
 /* May be used to iterate through the hashmap. Initially the opaque
    pointer *state has to be set to NULL. The hashmap may not be
@@ -72,19 +72,19 @@ bool pa_hashmap_isempty(pa_hashmap *h);
    via pa_hashmap_remove(). The key of the entry is returned in *key,
    if key is non-NULL. After the last entry in the hashmap NULL is
    returned. */
-void *pa_hashmap_iterate(pa_hashmap *h, void **state, const void**key);
+void *pa_hashmap_iterate(const pa_hashmap *h, void **state, const void**key);
 
 /* Same as pa_hashmap_iterate() but goes backwards */
-void *pa_hashmap_iterate_backwards(pa_hashmap *h, void **state, const void**key);
+void *pa_hashmap_iterate_backwards(const pa_hashmap *h, void **state, const void**key);
 
 /* Remove the oldest entry in the hashmap and return it */
 void *pa_hashmap_steal_first(pa_hashmap *h);
 
 /* Return the oldest entry in the hashmap */
-void* pa_hashmap_first(pa_hashmap *h);
+void* pa_hashmap_first(const pa_hashmap *h);
 
 /* Return the newest entry in the hashmap */
-void* pa_hashmap_last(pa_hashmap *h);
+void* pa_hashmap_last(const pa_hashmap *h);
 
 /* A macro to ease iteration through all entries */
 #define PA_HASHMAP_FOREACH(e, h, state) \



More information about the pulseaudio-commits mailing list