From 7732d0e3e534586ee4d0f22c0677b3327201558d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Thu, 27 Jun 2024 01:43:44 +0200 Subject: [PATCH] pipewire: module-raop-sink: use `uint32_t` for sample rate 32 bits are enough, and additionally this also fixes an incorrect format string, which caused the default `audio.rate` to be incorrectly set on some platforms, such as 32-bit arm ones. Fixes #4080 --- src/modules/module-raop-sink.c | 14 +++++++------- src/modules/module-rtp/stream.c | 2 +- src/modules/module-rtp/stream.h | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/modules/module-raop-sink.c b/src/modules/module-raop-sink.c index 51918bd26..05e467d24 100644 --- a/src/modules/module-raop-sink.c +++ b/src/modules/module-raop-sink.c @@ -255,7 +255,7 @@ struct impl { struct spa_source *server_source; uint32_t psamples; - uint64_t rate; + uint32_t rate; uint32_t mtu; uint32_t stride; uint32_t latency; @@ -854,7 +854,7 @@ static void rtsp_do_post_feedback(void *data, uint64_t expirations) static uint32_t msec_to_samples(struct impl *impl, uint32_t msec) { - return msec * impl->rate / 1000; + return (uint64_t) msec * impl->rate / 1000; } static int rtsp_record_reply(void *data, int status, const struct spa_dict *headers, const struct pw_array *content) @@ -1244,7 +1244,7 @@ static int rtsp_do_announce(struct impl *impl) "a=rtpmap:96 AppleLossless\r\n" "a=fmtp:96 %d 0 16 40 10 14 2 255 0 0 %u\r\n", impl->session_id, ip_version, local_ip, - ip_version, host, impl->psamples, (uint32_t)impl->rate); + ip_version, host, impl->psamples, impl->rate); if (!sdp) return -errno; break; @@ -1259,7 +1259,7 @@ static int rtsp_do_announce(struct impl *impl) "a=fmtp:96 %d 0 16 40 10 14 2 255 0 0 %u\r\n" "a=min-latency:%d", impl->session_id, ip_version, local_ip, - ip_version, host, impl->psamples, (uint32_t)impl->rate, + ip_version, host, impl->psamples, impl->rate, rtp_latency); if (!sdp) return -errno; @@ -1296,7 +1296,7 @@ static int rtsp_do_announce(struct impl *impl) "a=rsaaeskey:%s\r\n" "a=aesiv:%s\r\n", impl->session_id, ip_version, local_ip, - ip_version, host, impl->psamples, (uint32_t)impl->rate, + ip_version, host, impl->psamples, impl->rate, key, iv); if (!sdp) return -errno; @@ -1881,7 +1881,7 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args) if (pw_properties_get(props, PW_KEY_AUDIO_FORMAT) == NULL) pw_properties_setf(props, PW_KEY_AUDIO_FORMAT, "%s", RAOP_FORMAT); if (pw_properties_get(props, PW_KEY_AUDIO_RATE) == NULL) - pw_properties_setf(props, PW_KEY_AUDIO_RATE, "%ld", impl->rate); + pw_properties_setf(props, PW_KEY_AUDIO_RATE, "%u", impl->rate); if (pw_properties_get(props, PW_KEY_DEVICE_ICON_NAME) == NULL) pw_properties_set(props, PW_KEY_DEVICE_ICON_NAME, "audio-speakers"); if (pw_properties_get(props, PW_KEY_NODE_NAME) == NULL) @@ -1892,7 +1892,7 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args) if (pw_properties_get(props, PW_KEY_NODE_DESCRIPTION) == NULL) pw_properties_setf(props, PW_KEY_NODE_DESCRIPTION, "%s", name); if (pw_properties_get(props, PW_KEY_NODE_LATENCY) == NULL) - pw_properties_setf(props, PW_KEY_NODE_LATENCY, "%d/%ld", + pw_properties_setf(props, PW_KEY_NODE_LATENCY, "%u/%u", impl->psamples, impl->rate); if (pw_properties_get(props, PW_KEY_NODE_VIRTUAL) == NULL) pw_properties_set(props, PW_KEY_NODE_VIRTUAL, "true"); diff --git a/src/modules/module-rtp/stream.c b/src/modules/module-rtp/stream.c index e4b094b54..4a87df035 100644 --- a/src/modules/module-rtp/stream.c +++ b/src/modules/module-rtp/stream.c @@ -633,7 +633,7 @@ int rtp_stream_receive_packet(struct rtp_stream *s, uint8_t *buffer, size_t len) return impl->receive_rtp(impl, buffer, len); } -uint64_t rtp_stream_get_time(struct rtp_stream *s, uint64_t *rate) +uint64_t rtp_stream_get_time(struct rtp_stream *s, uint32_t *rate) { struct impl *impl = (struct impl*)s; struct spa_io_position *pos = impl->io_position; diff --git a/src/modules/module-rtp/stream.h b/src/modules/module-rtp/stream.h index 28854fb3c..0221b5f1e 100644 --- a/src/modules/module-rtp/stream.h +++ b/src/modules/module-rtp/stream.h @@ -48,7 +48,7 @@ int rtp_stream_update_properties(struct rtp_stream *s, const struct spa_dict *di int rtp_stream_receive_packet(struct rtp_stream *s, uint8_t *buffer, size_t len); -uint64_t rtp_stream_get_time(struct rtp_stream *s, uint64_t *rate); +uint64_t rtp_stream_get_time(struct rtp_stream *s, uint32_t *rate); uint16_t rtp_stream_get_seq(struct rtp_stream *s);