From 5a02f926e3629e9d8fb9b25cb1d90b25d9f89057 Mon Sep 17 00:00:00 2001 From: ejurgensen Date: Thu, 8 Jan 2015 22:03:53 +0100 Subject: [PATCH] Fix bug in float to string conversion of raop volume (credit @andreas-p, issue #84) --- src/raop.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/raop.c b/src/raop.c index adbf7065..7b098707 100644 --- a/src/raop.c +++ b/src/raop.c @@ -2290,7 +2290,8 @@ raop_set_volume_internal(struct raop_session *rs, int volume, evrtsp_req_cb cb) raop_volume = raop_volume_convert(volume, rs->devname); /* Don't let locales get in the way here */ - ret = evbuffer_add_printf(evbuf, "volume: %d.%06d\r\n", (int)raop_volume, -(int)(1000000.0 * (raop_volume - (int)raop_volume))); + /* We use -%d and -(int)raop_volume so -0.3 won't become 0.3 */ + ret = evbuffer_add_printf(evbuf, "volume: -%d.%06d\r\n", -(int)raop_volume, -(int)(1000000.0 * (raop_volume - (int)raop_volume))); if (ret < 0) { DPRINTF(E_LOG, L_RAOP, "Out of memory for SET_PARAMETER payload (volume)\n");