Implement a set volume function to expose this capability to higher layers

This commit is contained in:
Colin Guthrie 2008-07-03 23:47:34 +01:00
parent 36f2aad5f0
commit e543e04ca7
2 changed files with 25 additions and 0 deletions

View file

@ -342,6 +342,7 @@ static void rtsp_cb(pa_rtsp_client *rtsp, pa_rtsp_state state, pa_headerlist* he
case STATE_TEARDOWN: case STATE_TEARDOWN:
case STATE_SET_PARAMETER: case STATE_SET_PARAMETER:
pa_log_debug("RAOP: SET_PARAMETER");
break; break;
case STATE_DISCONNECTED: case STATE_DISCONNECTED:
pa_assert(c->closed_callback); 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) int pa_raop_client_encode_sample(pa_raop_client* c, pa_memchunk* raw, pa_memchunk* encoded)
{ {
uint16_t len; uint16_t len;

View file

@ -36,6 +36,7 @@ void pa_raop_client_free(pa_raop_client* c);
int pa_raop_connect(pa_raop_client* c); int pa_raop_connect(pa_raop_client* c);
int pa_raop_flush(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); 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); typedef void (*pa_raop_client_cb_t)(int fd, void *userdata);