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
This commit is contained in:
Barnabás Pőcze 2024-06-27 01:43:44 +02:00 committed by Wim Taymans
parent 4067b3a985
commit 7732d0e3e5
3 changed files with 9 additions and 9 deletions

View file

@ -255,7 +255,7 @@ struct impl {
struct spa_source *server_source; struct spa_source *server_source;
uint32_t psamples; uint32_t psamples;
uint64_t rate; uint32_t rate;
uint32_t mtu; uint32_t mtu;
uint32_t stride; uint32_t stride;
uint32_t latency; 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) 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) 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=rtpmap:96 AppleLossless\r\n"
"a=fmtp:96 %d 0 16 40 10 14 2 255 0 0 %u\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, 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) if (!sdp)
return -errno; return -errno;
break; 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=fmtp:96 %d 0 16 40 10 14 2 255 0 0 %u\r\n"
"a=min-latency:%d", "a=min-latency:%d",
impl->session_id, ip_version, local_ip, 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); rtp_latency);
if (!sdp) if (!sdp)
return -errno; return -errno;
@ -1296,7 +1296,7 @@ static int rtsp_do_announce(struct impl *impl)
"a=rsaaeskey:%s\r\n" "a=rsaaeskey:%s\r\n"
"a=aesiv:%s\r\n", "a=aesiv:%s\r\n",
impl->session_id, ip_version, local_ip, 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); key, iv);
if (!sdp) if (!sdp)
return -errno; 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) if (pw_properties_get(props, PW_KEY_AUDIO_FORMAT) == NULL)
pw_properties_setf(props, PW_KEY_AUDIO_FORMAT, "%s", RAOP_FORMAT); pw_properties_setf(props, PW_KEY_AUDIO_FORMAT, "%s", RAOP_FORMAT);
if (pw_properties_get(props, PW_KEY_AUDIO_RATE) == NULL) 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) if (pw_properties_get(props, PW_KEY_DEVICE_ICON_NAME) == NULL)
pw_properties_set(props, PW_KEY_DEVICE_ICON_NAME, "audio-speakers"); pw_properties_set(props, PW_KEY_DEVICE_ICON_NAME, "audio-speakers");
if (pw_properties_get(props, PW_KEY_NODE_NAME) == NULL) 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) if (pw_properties_get(props, PW_KEY_NODE_DESCRIPTION) == NULL)
pw_properties_setf(props, PW_KEY_NODE_DESCRIPTION, "%s", name); pw_properties_setf(props, PW_KEY_NODE_DESCRIPTION, "%s", name);
if (pw_properties_get(props, PW_KEY_NODE_LATENCY) == NULL) 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); impl->psamples, impl->rate);
if (pw_properties_get(props, PW_KEY_NODE_VIRTUAL) == NULL) if (pw_properties_get(props, PW_KEY_NODE_VIRTUAL) == NULL)
pw_properties_set(props, PW_KEY_NODE_VIRTUAL, "true"); pw_properties_set(props, PW_KEY_NODE_VIRTUAL, "true");

View file

@ -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); 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 impl *impl = (struct impl*)s;
struct spa_io_position *pos = impl->io_position; struct spa_io_position *pos = impl->io_position;

View file

@ -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); 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); uint16_t rtp_stream_get_seq(struct rtp_stream *s);