From e543e04ca725ef1c240762529e7dafec31749683 Mon Sep 17 00:00:00 2001 From: Colin Guthrie Date: Thu, 3 Jul 2008 23:47:34 +0100 Subject: Implement a set volume function to expose this capability to higher layers --- src/modules/rtp/raop_client.c | 24 ++++++++++++++++++++++++ src/modules/rtp/raop_client.h | 1 + 2 files changed, 25 insertions(+) (limited to 'src') diff --git a/src/modules/rtp/raop_client.c b/src/modules/rtp/raop_client.c index 48deff0d..792eceec 100644 --- a/src/modules/rtp/raop_client.c +++ b/src/modules/rtp/raop_client.c @@ -342,6 +342,7 @@ static void rtsp_cb(pa_rtsp_client *rtsp, pa_rtsp_state state, pa_headerlist* he case STATE_TEARDOWN: case STATE_SET_PARAMETER: + pa_log_debug("RAOP: SET_PARAMETER"); break; case STATE_DISCONNECTED: pa_assert(c->closed_callback); @@ -439,6 +440,29 @@ int pa_raop_flush(pa_raop_client* c) } +int pa_raop_client_set_volume(pa_raop_client* c, pa_volume_t volume) +{ + int rv; + double db; + char *param; + + pa_assert(c); + + db = pa_sw_volume_to_dB(volume); + if (db < VOLUME_MIN) + db = VOLUME_MIN; + else if (db > VOLUME_MAX) + db = VOLUME_MAX; + + param = pa_sprintf_malloc("volume: %0.6f\r\n", db); + + /* We just hit and hope, cannot wait for the callback */ + rv = pa_rtsp_setparameter(c->rtsp, param); + pa_xfree(param); + return rv; +} + + int pa_raop_client_encode_sample(pa_raop_client* c, pa_memchunk* raw, pa_memchunk* encoded) { uint16_t len; diff --git a/src/modules/rtp/raop_client.h b/src/modules/rtp/raop_client.h index 882dae17..3d5ef167 100644 --- a/src/modules/rtp/raop_client.h +++ b/src/modules/rtp/raop_client.h @@ -36,6 +36,7 @@ void pa_raop_client_free(pa_raop_client* c); int pa_raop_connect(pa_raop_client* c); int pa_raop_flush(pa_raop_client* c); +int pa_raop_client_set_volume(pa_raop_client* c, pa_volume_t volume); int pa_raop_client_encode_sample(pa_raop_client* c, pa_memchunk* raw, pa_memchunk* encoded); typedef void (*pa_raop_client_cb_t)(int fd, void *userdata); -- cgit