raop-sink: only set volume when connected

Only attempt to set the volume when connected. Apply the current
volume after connecting.

Based on patch by Tycho Haemers

Fixes #3175
This commit is contained in:
Wim Taymans 2023-04-22 11:16:55 +02:00
parent 68664adcd4
commit 12bc69a469

View file

@ -867,6 +867,7 @@ static int rtsp_record_reply(void *data, int status, const struct spa_dict *head
struct spa_pod_builder b; struct spa_pod_builder b;
struct spa_latency_info latency; struct spa_latency_info latency;
char progress[128]; char progress[128];
char header[128], volstr[64];
pw_log_info("reply %d", status); pw_log_info("reply %d", status);
@ -892,6 +893,10 @@ static int rtsp_record_reply(void *data, int status, const struct spa_dict *head
impl->sync_period = impl->info.rate / (impl->block_size / impl->frame_size); impl->sync_period = impl->info.rate / (impl->block_size / impl->frame_size);
impl->recording = true; impl->recording = true;
snprintf(header, sizeof(header), "volume: %s\r\n",
spa_dtoa(volstr, sizeof(volstr), impl->volume));
rtsp_send(impl, "SET_PARAMETER", "text/parameters", header, NULL);
snprintf(progress, sizeof(progress), "progress: %s/%s/%s\r\n", "0", "0", "0"); snprintf(progress, sizeof(progress), "progress: %s/%s/%s\r\n", "0", "0", "0");
return rtsp_send(impl, "SET_PARAMETER", "text/parameters", progress, NULL); return rtsp_send(impl, "SET_PARAMETER", "text/parameters", progress, NULL);
} }
@ -1597,8 +1602,10 @@ static void stream_props_changed(struct impl *impl, uint32_t id, const struct sp
snprintf(header, sizeof(header), "volume: %s\r\n", snprintf(header, sizeof(header), "volume: %s\r\n",
spa_dtoa(volstr, sizeof(volstr), volume)); spa_dtoa(volstr, sizeof(volstr), volume));
rtsp_send(impl, "SET_PARAMETER", "text/parameters", header, NULL); if (impl->connected)
rtsp_send(impl, "SET_PARAMETER", "text/parameters", header, NULL);
} }
spa_pod_builder_prop(&b, SPA_PROP_softVolumes, 0); spa_pod_builder_prop(&b, SPA_PROP_softVolumes, 0);
spa_pod_builder_array(&b, sizeof(float), SPA_TYPE_Float, spa_pod_builder_array(&b, sizeof(float), SPA_TYPE_Float,
n_vols, soft_vols); n_vols, soft_vols);