[pulseaudio-discuss] [PATCH] context: constify pa_context_set_error()
Tanu Kaskinen
tanuk at iki.fi
Mon Jun 18 08:13:40 UTC 2018
This allows constifying public API functions that report their errors
via the context error but don't modify the context in any other way.
Philosophical arguments could be made why this is wrong, but I believe
in practice this is a net positive change.
---
src/pulse/context.c | 2 +-
src/pulse/internal.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/pulse/context.c b/src/pulse/context.c
index dc59ed2d8..37f81e9a9 100644
--- a/src/pulse/context.c
+++ b/src/pulse/context.c
@@ -313,7 +313,7 @@ void pa_context_set_state(pa_context *c, pa_context_state_t st) {
pa_context_unref(c);
}
-int pa_context_set_error(pa_context *c, int error) {
+int pa_context_set_error(const pa_context *c, int error) {
pa_assert(error >= 0);
pa_assert(error < PA_ERR_MAX);
diff --git a/src/pulse/internal.h b/src/pulse/internal.h
index 04f35e9a3..ec74f41b2 100644
--- a/src/pulse/internal.h
+++ b/src/pulse/internal.h
@@ -274,7 +274,7 @@ void pa_context_simple_ack_callback(pa_pdispatch *pd, uint32_t command, uint32_t
void pa_stream_simple_ack_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata);
void pa_context_fail(pa_context *c, int error);
-int pa_context_set_error(pa_context *c, int error);
+int pa_context_set_error(const pa_context *c, int error);
void pa_context_set_state(pa_context *c, pa_context_state_t st);
int pa_context_handle_error(pa_context *c, uint32_t command, pa_tagstruct *t, bool fail);
pa_operation* pa_context_send_simple_command(pa_context *c, uint32_t command, void (*internal_callback)(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata), void (*cb)(void), void *userdata);
--
2.17.0
More information about the pulseaudio-discuss
mailing list