summaryrefslogtreecommitdiffstats
path: root/src/modules
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/alsa-util.c31
-rw-r--r--src/modules/dbus-util.c6
-rw-r--r--src/modules/gconf/module-gconf.c8
-rw-r--r--src/modules/module-alsa-sink.c75
-rw-r--r--src/modules/module-alsa-source.c55
-rw-r--r--src/modules/module-combine.c6
-rw-r--r--src/modules/module-detect.c6
-rw-r--r--src/modules/module-device-restore.c4
-rw-r--r--src/modules/module-esound-compat-spawnpid.c2
-rw-r--r--src/modules/module-esound-sink.c16
-rw-r--r--src/modules/module-hal-detect.c10
-rw-r--r--src/modules/module-jack-sink.c10
-rw-r--r--src/modules/module-jack-source.c4
-rw-r--r--src/modules/module-ladspa-sink.c28
-rw-r--r--src/modules/module-oss.c66
-rw-r--r--src/modules/module-pipe-sink.c6
-rw-r--r--src/modules/module-pipe-source.c6
-rw-r--r--src/modules/module-protocol-stub.c10
-rw-r--r--src/modules/module-sine.c6
-rw-r--r--src/modules/module-stream-restore.c10
-rw-r--r--src/modules/module-tunnel.c36
-rw-r--r--src/modules/module-volume-restore.c2
-rw-r--r--src/modules/module-x11-bell.c2
-rw-r--r--src/modules/module-x11-xsmp.c4
-rw-r--r--src/modules/module-zeroconf-discover.c4
-rw-r--r--src/modules/oss-util.c6
-rw-r--r--src/modules/rtp/module-rtp-recv.c18
-rw-r--r--src/modules/rtp/module-rtp-send.c17
-rw-r--r--src/modules/rtp/rtp.c21
-rw-r--r--src/modules/rtp/sap.c28
-rw-r--r--src/modules/rtp/sdp.c8
31 files changed, 259 insertions, 252 deletions
diff --git a/src/modules/alsa-util.c b/src/modules/alsa-util.c
index e3e8c85c..e8c7e146 100644
--- a/src/modules/alsa-util.c
+++ b/src/modules/alsa-util.c
@@ -39,7 +39,7 @@
#include "alsa-util.h"
struct pa_alsa_fdlist {
- int num_fds;
+ unsigned num_fds;
struct pollfd *fds;
/* This is a temporary buffer used to avoid lots of mallocs */
struct pollfd *work_fds;
@@ -50,7 +50,7 @@ struct pa_alsa_fdlist {
pa_defer_event *defer;
pa_io_event **ios;
- int polled;
+ pa_bool_t polled;
void (*cb)(void *userdata);
void *userdata;
@@ -59,7 +59,8 @@ struct pa_alsa_fdlist {
static void io_cb(pa_mainloop_api*a, pa_io_event* e, int fd, pa_io_event_flags_t events, void *userdata) {
struct pa_alsa_fdlist *fdl = userdata;
- int err, i;
+ int err;
+ unsigned i;
unsigned short revents;
pa_assert(a);
@@ -71,11 +72,11 @@ static void io_cb(pa_mainloop_api*a, pa_io_event* e, int fd, pa_io_event_flags_t
if (fdl->polled)
return;
- fdl->polled = 1;
+ fdl->polled = TRUE;
memcpy(fdl->work_fds, fdl->fds, sizeof(struct pollfd) * fdl->num_fds);
- for (i = 0;i < fdl->num_fds; i++) {
+ for (i = 0; i < fdl->num_fds; i++) {
if (e == fdl->ios[i]) {
if (events & PA_IO_EVENT_INPUT)
fdl->work_fds[i].revents |= POLLIN;
@@ -104,7 +105,8 @@ static void io_cb(pa_mainloop_api*a, pa_io_event* e, int fd, pa_io_event_flags_t
static void defer_cb(pa_mainloop_api*a, pa_defer_event* e, void *userdata) {
struct pa_alsa_fdlist *fdl = userdata;
- int num_fds, i, err;
+ unsigned num_fds, i;
+ int err;
struct pollfd *temp;
pa_assert(a);
@@ -113,8 +115,7 @@ static void defer_cb(pa_mainloop_api*a, pa_defer_event* e, void *userdata) {
a->defer_enable(fdl->defer, 0);
- num_fds = snd_mixer_poll_descriptors_count(fdl->mixer);
- pa_assert(num_fds > 0);
+ num_fds = (unsigned) snd_mixer_poll_descriptors_count(fdl->mixer);
if (num_fds != fdl->num_fds) {
if (fdl->fds)
@@ -132,7 +133,7 @@ static void defer_cb(pa_mainloop_api*a, pa_defer_event* e, void *userdata) {
return;
}
- fdl->polled = 0;
+ fdl->polled = FALSE;
if (memcmp(fdl->fds, fdl->work_fds, sizeof(struct pollfd) * num_fds) == 0)
return;
@@ -176,7 +177,7 @@ struct pa_alsa_fdlist *pa_alsa_fdlist_new(void) {
fdl->m = NULL;
fdl->defer = NULL;
fdl->ios = NULL;
- fdl->polled = 0;
+ fdl->polled = FALSE;
return fdl;
}
@@ -190,9 +191,9 @@ void pa_alsa_fdlist_free(struct pa_alsa_fdlist *fdl) {
}
if (fdl->ios) {
- int i;
+ unsigned i;
pa_assert(fdl->m);
- for (i = 0;i < fdl->num_fds;i++)
+ for (i = 0; i < fdl->num_fds; i++)
fdl->m->io_free(fdl->ios[i]);
pa_xfree(fdl->ios);
}
@@ -403,7 +404,7 @@ int pa_alsa_set_hw_params(
/* If the sample rate deviates too much, we need to resample */
if (r < ss->rate*.95 || r > ss->rate*1.05)
ss->rate = r;
- ss->channels = c;
+ ss->channels = (uint8_t) c;
ss->format = f;
pa_assert(_periods > 0);
@@ -1056,10 +1057,10 @@ pa_rtpoll_item* pa_alsa_build_pollfd(snd_pcm_t *pcm, pa_rtpoll *rtpoll) {
return NULL;
}
- item = pa_rtpoll_item_new(rtpoll, PA_RTPOLL_NEVER, n);
+ item = pa_rtpoll_item_new(rtpoll, PA_RTPOLL_NEVER, (unsigned) n);
pollfd = pa_rtpoll_item_get_pollfd(item, NULL);
- if ((err = snd_pcm_poll_descriptors(pcm, pollfd, n)) < 0) {
+ if ((err = snd_pcm_poll_descriptors(pcm, pollfd, (unsigned) n)) < 0) {
pa_log("snd_pcm_poll_descriptors() failed: %s", snd_strerror(err));
pa_rtpoll_item_free(item);
return NULL;
diff --git a/src/modules/dbus-util.c b/src/modules/dbus-util.c
index c9c32a15..d2abf087 100644
--- a/src/modules/dbus-util.c
+++ b/src/modules/dbus-util.c
@@ -126,7 +126,7 @@ static void handle_time_event(pa_mainloop_api *ea, pa_time_event* e, const struc
dbus_timeout_handle(timeout);
/* restart it for the next scheduled time */
- pa_timeval_add(&next, dbus_timeout_get_interval(timeout) * 1000);
+ pa_timeval_add(&next, (pa_usec_t) dbus_timeout_get_interval(timeout) * 1000);
ea->time_restart(e, &next);
}
}
@@ -192,7 +192,7 @@ static dbus_bool_t add_timeout(DBusTimeout *timeout, void *data) {
return FALSE;
pa_gettimeofday(&tv);
- pa_timeval_add(&tv, dbus_timeout_get_interval(timeout) * 1000);
+ pa_timeval_add(&tv, (pa_usec_t) dbus_timeout_get_interval(timeout) * 1000);
ev = c->mainloop->time_new(c->mainloop, &tv, handle_time_event, timeout);
@@ -227,7 +227,7 @@ static void toggle_timeout(DBusTimeout *timeout, void *data) {
struct timeval tv;
pa_gettimeofday(&tv);
- pa_timeval_add(&tv, dbus_timeout_get_interval(timeout) * 1000);
+ pa_timeval_add(&tv, (pa_usec_t) dbus_timeout_get_interval(timeout) * 1000);
c->mainloop->time_restart(ev, &tv);
} else
diff --git a/src/modules/gconf/module-gconf.c b/src/modules/gconf/module-gconf.c
index e2b0f7c0..6e8ab6ea 100644
--- a/src/modules/gconf/module-gconf.c
+++ b/src/modules/gconf/module-gconf.c
@@ -96,7 +96,7 @@ static int fill_buf(struct userdata *u) {
if ((r = pa_read(u->fd, u->buf + u->buf_fill, BUF_MAX - u->buf_fill, &u->fd_type)) <= 0)
return -1;
- u->buf_fill += r;
+ u->buf_fill += (size_t) r;
return 0;
}
@@ -123,7 +123,7 @@ static char *read_string(struct userdata *u) {
if ((e = memchr(u->buf, 0, u->buf_fill))) {
char *ret = pa_xstrdup(u->buf);
- u->buf_fill -= e - u->buf +1;
+ u->buf_fill -= (size_t) (e - u->buf +1);
memmove(u->buf, e+1, u->buf_fill);
return ret;
}
@@ -164,10 +164,10 @@ static void unload_all_modules(struct userdata *u, struct module_info*m) {
static void load_module(
struct userdata *u,
struct module_info *m,
- int i,
+ unsigned i,
const char *name,
const char *args,
- int is_new) {
+ pa_bool_t is_new) {
pa_module *mod;
diff --git a/src/modules/module-alsa-sink.c b/src/modules/module-alsa-sink.c
index 8980ba24..e3f9a5ff 100644
--- a/src/modules/module-alsa-sink.c
+++ b/src/modules/module-alsa-sink.c
@@ -143,7 +143,7 @@ static void fix_tsched_watermark(struct userdata *u) {
size_t min_sleep, min_wakeup;
pa_assert(u);
- max_use = u->hwbuf_size - u->hwbuf_unused_frames * u->frame_size;
+ max_use = u->hwbuf_size - (size_t) u->hwbuf_unused_frames * u->frame_size;
min_sleep = pa_usec_to_bytes(TSCHED_MIN_SLEEP_USEC, &u->sink->sample_spec);
min_wakeup = pa_usec_to_bytes(TSCHED_MIN_WAKEUP_USEC, &u->sink->sample_spec);
@@ -216,8 +216,8 @@ static int try_recover(struct userdata *u, const char *call, int err) {
static size_t check_left_to_play(struct userdata *u, snd_pcm_sframes_t n) {
size_t left_to_play;
- if (n*u->frame_size < u->hwbuf_size)
- left_to_play = u->hwbuf_size - (n*u->frame_size);
+ if ((size_t) n*u->frame_size < u->hwbuf_size)
+ left_to_play = u->hwbuf_size - ((size_t) n*u->frame_size);
else
left_to_play = 0;
@@ -263,7 +263,7 @@ static int mmap_write(struct userdata *u, pa_usec_t *sleep_usec) {
if (PA_UNLIKELY((n = snd_pcm_avail_update(u->pcm_handle)) < 0)) {
- if ((r = try_recover(u, "snd_pcm_avail_update", n)) == 0)
+ if ((r = try_recover(u, "snd_pcm_avail_update", (int) n)) == 0)
continue;
return r;
@@ -295,6 +295,7 @@ static int mmap_write(struct userdata *u, pa_usec_t *sleep_usec) {
int err;
const snd_pcm_channel_area_t *areas;
snd_pcm_uframes_t offset, frames = (snd_pcm_uframes_t) n;
+ snd_pcm_sframes_t sframes;
/* pa_log_debug("%lu frames to write", (unsigned long) frames); */
@@ -330,9 +331,9 @@ static int mmap_write(struct userdata *u, pa_usec_t *sleep_usec) {
* a little bit longer around? */
pa_memblock_unref_fixed(chunk.memblock);
- if (PA_UNLIKELY((err = snd_pcm_mmap_commit(u->pcm_handle, offset, frames)) < 0)) {
+ if (PA_UNLIKELY((sframes = snd_pcm_mmap_commit(u->pcm_handle, offset, frames)) < 0)) {
- if ((r = try_recover(u, "snd_pcm_mmap_commit", err)) == 0)
+ if ((r = try_recover(u, "snd_pcm_mmap_commit", (int) sframes)) == 0)
continue;
return r;
@@ -340,7 +341,7 @@ static int mmap_write(struct userdata *u, pa_usec_t *sleep_usec) {
work_done = 1;
- u->frame_index += frames;
+ u->frame_index += (int64_t) frames;
u->since_start += frames * u->frame_size;
/* pa_log_debug("wrote %lu frames", (unsigned long) frames); */
@@ -348,7 +349,7 @@ static int mmap_write(struct userdata *u, pa_usec_t *sleep_usec) {
if (frames >= (snd_pcm_uframes_t) n)
break;
- n -= frames;
+ n -= (snd_pcm_sframes_t) frames;
}
}
@@ -375,7 +376,7 @@ static int unix_write(struct userdata *u, pa_usec_t *sleep_usec) {
if (PA_UNLIKELY((n = snd_pcm_avail_update(u->pcm_handle)) < 0)) {
- if ((r = try_recover(u, "snd_pcm_avail_update", n)) == 0)
+ if ((r = try_recover(u, "snd_pcm_avail_update", (int) n)) == 0)
continue;
return r;
@@ -406,31 +407,31 @@ static int unix_write(struct userdata *u, pa_usec_t *sleep_usec) {
/* pa_log_debug("%lu frames to write", (unsigned long) frames); */
if (u->memchunk.length <= 0)
- pa_sink_render(u->sink, n * u->frame_size, &u->memchunk);
+ pa_sink_render(u->sink, (size_t) n * u->frame_size, &u->memchunk);
pa_assert(u->memchunk.length > 0);
- frames = u->memchunk.length / u->frame_size;
+ frames = (snd_pcm_sframes_t) (u->memchunk.length / u->frame_size);
if (frames > n)
frames = n;
p = pa_memblock_acquire(u->memchunk.memblock);
- frames = snd_pcm_writei(u->pcm_handle, (const uint8_t*) p + u->memchunk.index, frames);
+ frames = snd_pcm_writei(u->pcm_handle, (const uint8_t*) p + u->memchunk.index, (snd_pcm_uframes_t) frames);
pa_memblock_release(u->memchunk.memblock);
pa_assert(frames != 0);
if (PA_UNLIKELY(frames < 0)) {
- if ((r = try_recover(u, "snd_pcm_writei", n)) == 0)
+ if ((r = try_recover(u, "snd_pcm_writei", (int) frames)) == 0)
continue;
return r;
}
- u->memchunk.index += frames * u->frame_size;
- u->memchunk.length -= frames * u->frame_size;
+ u->memchunk.index += (size_t) frames * u->frame_size;
+ u->memchunk.length -= (size_t) frames * u->frame_size;
if (u->memchunk.length <= 0) {
pa_memblock_unref(u->memchunk.memblock);
@@ -440,7 +441,7 @@ static int unix_write(struct userdata *u, pa_usec_t *sleep_usec) {
work_done = 1;
u->frame_index += frames;
- u->since_start += frames * u->frame_size;
+ u->since_start += (size_t) frames * u->frame_size;
/* pa_log_debug("wrote %lu frames", (unsigned long) frames); */
@@ -494,7 +495,7 @@ static void update_smoother(struct userdata *u) {
/* now1 = pa_timeval_load(&timestamp); */
now1 = pa_rtclock_usec();
- now2 = pa_bytes_to_usec(frames * u->frame_size, &u->sink->sample_spec);
+ now2 = pa_bytes_to_usec((uint64_t) frames * u->frame_size, &u->sink->sample_spec);
pa_smoother_put(u->smoother, now1, now2);
}
@@ -508,7 +509,7 @@ static pa_usec_t sink_get_latency(struct userdata *u) {
now1 = pa_rtclock_usec();
now2 = pa_smoother_get(u->smoother, now1);
- delay = (int64_t) pa_bytes_to_usec(u->frame_index * u->frame_size, &u->sink->sample_spec) - (int64_t) now2;
+ delay = (int64_t) pa_bytes_to_usec((uint64_t) u->frame_index * u->frame_size, &u->sink->sample_spec) - (int64_t) now2;
if (delay > 0)
r = (pa_usec_t) delay;
@@ -577,9 +578,9 @@ static int update_sw_params(struct userdata *u) {
if (PA_UNLIKELY(b < u->frame_size))
b = u->frame_size;
- u->hwbuf_unused_frames =
- PA_LIKELY(b < u->hwbuf_size) ?
- ((u->hwbuf_size - b) / u->frame_size) : 0;
+ u->hwbuf_unused_frames = (snd_pcm_sframes_t)
+ (PA_LIKELY(b < u->hwbuf_size) ?
+ ((u->hwbuf_size - b) / u->frame_size) : 0);
fix_tsched_watermark(u);
}
@@ -588,7 +589,7 @@ static int update_sw_params(struct userdata *u) {
pa_log_debug("hwbuf_unused_frames=%lu", (unsigned long) u->hwbuf_unused_frames);
/* We need at last one frame in the used part of the buffer */
- avail_min = u->hwbuf_unused_frames + 1;
+ avail_min = (snd_pcm_uframes_t) u->hwbuf_unused_frames + 1;
if (u->use_tsched) {
pa_usec_t sleep_usec, process_usec;
@@ -604,7 +605,7 @@ static int update_sw_params(struct userdata *u) {
return err;
}
- pa_sink_set_max_request(u->sink, u->hwbuf_size - u->hwbuf_unused_frames * u->frame_size);
+ pa_sink_set_max_request(u->sink, u->hwbuf_size - (size_t) u->hwbuf_unused_frames * u->frame_size);
return 0;
}
@@ -780,7 +781,7 @@ static int sink_get_volume_cb(pa_sink *s) {
if ((err = snd_mixer_selem_get_playback_volume(u->mixer_elem, u->mixer_map[i], &alsa_vol)) < 0)
goto fail;
- r.values[i] = (pa_volume_t) round(((double) (alsa_vol - u->hw_volume_min) * PA_VOLUME_NORM) / (u->hw_volume_max - u->hw_volume_min));
+ r.values[i] = (pa_volume_t) round(((double) (alsa_vol - u->hw_volume_min) * PA_VOLUME_NORM) / (double) (u->hw_volume_max - u->hw_volume_min));
}
}
@@ -856,7 +857,7 @@ static int sink_set_volume_cb(pa_sink *s) {
r.values[i] = pa_sw_volume_from_dB((double) alsa_vol / 100.0);
} else {
- alsa_vol = (long) round(((double) vol * (u->hw_volume_max - u->hw_volume_min)) / PA_VOLUME_NORM) + u->hw_volume_min;
+ alsa_vol = (long) round(((double) vol * (double) (u->hw_volume_max - u->hw_volume_min)) / PA_VOLUME_NORM) + u->hw_volume_min;
alsa_vol = PA_CLAMP_UNLIKELY(alsa_vol, u->hw_volume_min, u->hw_volume_max);
if ((err = snd_mixer_selem_set_playback_volume(u->mixer_elem, u->mixer_map[i], alsa_vol)) < 0)
@@ -865,7 +866,7 @@ static int sink_set_volume_cb(pa_sink *s) {
if ((err = snd_mixer_selem_get_playback_volume(u->mixer_elem, u->mixer_map[i], &alsa_vol)) < 0)
goto fail;
- r.values[i] = (pa_volume_t) round(((double) (alsa_vol - u->hw_volume_min) * PA_VOLUME_NORM) / (u->hw_volume_max - u->hw_volume_min));
+ r.values[i] = (pa_volume_t) round(((double) (alsa_vol - u->hw_volume_min) * PA_VOLUME_NORM) / (double) (u->hw_volume_max - u->hw_volume_min));
}
}
@@ -990,7 +991,7 @@ static int process_rewind(struct userdata *u) {
snd_pcm_hwsync(u->pcm_handle);
if ((unused = snd_pcm_avail_update(u->pcm_handle)) < 0) {
- pa_log("snd_pcm_avail_update() failed: %s", snd_strerror(unused));
+ pa_log("snd_pcm_avail_update() failed: %s", snd_strerror((int) unused));
return -1;
}
@@ -1009,15 +1010,15 @@ static int process_rewind(struct userdata *u) {
pa_log_debug("Limited to %lu bytes.", (unsigned long) rewind_nbytes);
- in_frames = (snd_pcm_sframes_t) rewind_nbytes / u->frame_size;
+ in_frames = (snd_pcm_sframes_t) (rewind_nbytes / u->frame_size);
pa_log_debug("before: %lu", (unsigned long) in_frames);
- if ((out_frames = snd_pcm_rewind(u->pcm_handle, in_frames)) < 0) {
- pa_log("snd_pcm_rewind() failed: %s", snd_strerror(out_frames));
+ if ((out_frames = snd_pcm_rewind(u->pcm_handle, (snd_pcm_uframes_t) in_frames)) < 0) {
+ pa_log("snd_pcm_rewind() failed: %s", snd_strerror((int) out_frames));
return -1;
}
pa_log_debug("after: %lu", (unsigned long) out_frames);
- rewind_nbytes = out_frames * u->frame_size;
+ rewind_nbytes = (size_t) out_frames * u->frame_size;
if (rewind_nbytes <= 0)
pa_log_info("Tried rewind, but was apparently not possible.");
@@ -1211,11 +1212,11 @@ int pa__init(pa_module*m) {
frame_size = pa_frame_size(&ss);
nfrags = m->core->default_n_fragments;
- frag_size = pa_usec_to_bytes(m->core->default_fragment_size_msec*PA_USEC_PER_MSEC, &ss);
+ frag_size = (uint32_t) pa_usec_to_bytes(m->core->default_fragment_size_msec*PA_USEC_PER_MSEC, &ss);
if (frag_size <= 0)
- frag_size = frame_size;
- tsched_size = pa_usec_to_bytes(DEFAULT_TSCHED_BUFFER_USEC, &ss);
- tsched_watermark = pa_usec_to_bytes(DEFAULT_TSCHED_WATERMARK_USEC, &ss);
+ frag_size = (uint32_t) frame_size;
+ tsched_size = (uint32_t) pa_usec_to_bytes(DEFAULT_TSCHED_BUFFER_USEC, &ss);
+ tsched_watermark = (uint32_t) pa_usec_to_bytes(DEFAULT_TSCHED_WATERMARK_USEC, &ss);
if (pa_modargs_get_value_u32(ma, "fragments", &nfrags) < 0 ||
pa_modargs_get_value_u32(ma, "fragment_size", &frag_size) < 0 ||
@@ -1395,7 +1396,7 @@ int pa__init(pa_module*m) {
pa_sink_set_rtpoll(u->sink, u->rtpoll);
u->frame_size = frame_size;
- u->fragment_size = frag_size = period_frames * frame_size;
+ u->fragment_size = frag_size = (uint32_t) (period_frames * frame_size);
u->nfragments = nfrags;
u->hwbuf_size = u->fragment_size * nfrags;
u->hwbuf_unused_frames = 0;
@@ -1452,7 +1453,7 @@ int pa__init(pa_module*m) {
VALGRIND_MAKE_MEM_DEFINED(&u->hw_dB_max, sizeof(u->hw_dB_max));
#endif
- pa_log_info("Volume ranges from %0.2f dB to %0.2f dB.", u->hw_dB_min/100.0, u->hw_dB_max/100.0);
+ pa_log_info("Volume ranges from %0.2f dB to %0.2f dB.", (double) u->hw_dB_min/100.0, (double) u->hw_dB_max/100.0);
pa_assert(u->hw_dB_min < u->hw_dB_max);
u->hw_dB_supported = TRUE;
}
diff --git a/src/modules/module-alsa-source.c b/src/modules/module-alsa-source.c
index 9cf5aaf6..54ffde57 100644
--- a/src/modules/module-alsa-source.c
+++ b/src/modules/module-alsa-source.c
@@ -141,7 +141,7 @@ static void fix_tsched_watermark(struct userdata *u) {
size_t min_sleep, min_wakeup;
pa_assert(u);
- max_use = u->hwbuf_size - u->hwbuf_unused_frames * u->frame_size;
+ max_use = u->hwbuf_size - (size_t) u->hwbuf_unused_frames * u->frame_size;
min_sleep = pa_usec_to_bytes(TSCHED_MIN_SLEEP_USEC, &u->source->sample_spec);
min_wakeup = pa_usec_to_bytes(TSCHED_MIN_WAKEUP_USEC, &u->source->sample_spec);
@@ -212,8 +212,8 @@ static int try_recover(struct userdata *u, const char *call, int err) {
static size_t check_left_to_record(struct userdata *u, snd_pcm_sframes_t n) {
size_t left_to_record;
- if (n*u->frame_size < u->hwbuf_size)
- left_to_record = u->hwbuf_size - (n*u->frame_size);
+ if ((size_t) n*u->frame_size < u->hwbuf_size)
+ left_to_record = u->hwbuf_size - ((size_t) n*u->frame_size);
else
left_to_record = 0;
@@ -256,7 +256,7 @@ static int mmap_read(struct userdata *u, pa_usec_t *sleep_usec) {
if (PA_UNLIKELY((n = snd_pcm_avail_update(u->pcm_handle)) < 0)) {
- if ((r = try_recover(u, "snd_pcm_avail_update", n)) == 0)
+ if ((r = try_recover(u, "snd_pcm_avail_update", (int) n)) == 0)
continue;
return r;
@@ -277,6 +277,7 @@ static int mmap_read(struct userdata *u, pa_usec_t *sleep_usec) {
snd_pcm_uframes_t offset, frames = (snd_pcm_uframes_t) n;
pa_memchunk chunk;
void *p;
+ snd_pcm_sframes_t sframes;
/* pa_log_debug("%lu frames to read", (unsigned long) frames); */
@@ -309,9 +310,9 @@ static int mmap_read(struct userdata *u, pa_usec_t *sleep_usec) {
pa_source_post(u->source, &chunk);
pa_memblock_unref_fixed(chunk.memblock);
- if (PA_UNLIKELY((err = snd_pcm_mmap_commit(u->pcm_handle, offset, frames)) < 0)) {
+ if (PA_UNLIKELY((sframes = snd_pcm_mmap_commit(u->pcm_handle, offset, frames)) < 0)) {
- if ((r = try_recover(u, "snd_pcm_mmap_commit", err)) == 0)
+ if ((r = try_recover(u, "snd_pcm_mmap_commit", (int) sframes)) == 0)
continue;
return r;
@@ -319,14 +320,14 @@ static int mmap_read(struct userdata *u, pa_usec_t *sleep_usec) {
work_done = 1;
- u->frame_index += frames;
+ u->frame_index += (int64_t) frames;
/* pa_log_debug("read %lu frames", (unsigned long) frames); */
if (frames >= (snd_pcm_uframes_t) n)
break;
- n -= frames;
+ n -= (snd_pcm_sframes_t) frames;
}
}
@@ -353,7 +354,7 @@ static int unix_read(struct userdata *u, pa_usec_t *sleep_usec) {
if (PA_UNLIKELY((n = snd_pcm_avail_update(u->pcm_handle)) < 0)) {
- if ((r = try_recover(u, "snd_pcm_avail_update", n)) == 0)
+ if ((r = try_recover(u, "snd_pcm_avail_update", (int) n)) == 0)
continue;
return r;
@@ -375,7 +376,7 @@ static int unix_read(struct userdata *u, pa_usec_t *sleep_usec) {
chunk.memblock = pa_memblock_new(u->core->mempool, (size_t) -1);
- frames = pa_memblock_get_length(chunk.memblock) / u->frame_size;
+ frames = (snd_pcm_sframes_t) (pa_memblock_get_length(chunk.memblock) / u->frame_size);
if (frames > n)
frames = n;
@@ -383,7 +384,7 @@ static int unix_read(struct userdata *u, pa_usec_t *sleep_usec) {
/* pa_log_debug("%lu frames to read", (unsigned long) n); */
p = pa_memblock_acquire(chunk.memblock);
- frames = snd_pcm_readi(u->pcm_handle, (uint8_t*) p, frames);
+ frames = snd_pcm_readi(u->pcm_handle, (uint8_t*) p, (snd_pcm_uframes_t) frames);
pa_memblock_release(chunk.memblock);
pa_assert(frames != 0);
@@ -391,14 +392,14 @@ static int unix_read(struct userdata *u, pa_usec_t *sleep_usec) {
if (PA_UNLIKELY(frames < 0)) {
pa_memblock_unref(chunk.memblock);
- if ((r = try_recover(u, "snd_pcm_readi", n)) == 0)
+ if ((r = try_recover(u, "snd_pcm_readi", (int) (frames))) == 0)
continue;
return r;
}
chunk.index = 0;
- chunk.length = frames * u->frame_size;
+ chunk.length = (size_t) frames * u->frame_size;
pa_source_post(u->source, &chunk);
pa_memblock_unref(chunk.memblock);
@@ -442,7 +443,7 @@ static void update_smoother(struct userdata *u) {
frames = u->frame_index + delay;
now1 = pa_rtclock_usec();
- now2 = pa_bytes_to_usec(frames * u->frame_size, &u->source->sample_spec);
+ now2 = pa_bytes_to_usec((uint64_t) frames * u->frame_size, &u->source->sample_spec);
pa_smoother_put(u->smoother, now1, now2);
}
@@ -457,7 +458,7 @@ static pa_usec_t source_get_latency(struct userdata *u) {
now1 = pa_rtclock_usec();
now2 = pa_smoother_get(u->smoother, now1);
- delay = (int64_t) now2 - pa_bytes_to_usec(u->frame_index * u->frame_size, &u->source->sample_spec);
+ delay = (int64_t) now2 - (int64_t) pa_bytes_to_usec((uint64_t) u->frame_index * u->frame_size, &u->source->sample_spec);
if (delay > 0)
r = (pa_usec_t) delay;
@@ -522,9 +523,9 @@ static int update_sw_params(struct userdata *u) {
if (PA_UNLIKELY(b < u->frame_size))
b = u->frame_size;
- u->hwbuf_unused_frames =
- PA_LIKELY(b < u->hwbuf_size) ?
- ((u->hwbuf_size - b) / u->frame_size) : 0;
+ u->hwbuf_unused_frames = (snd_pcm_sframes_t)
+ (PA_LIKELY(b < u->hwbuf_size) ?
+ ((u->hwbuf_size - b) / u->frame_size) : 0);
fix_tsched_watermark(u);
}
@@ -724,7 +725,7 @@ static int source_get_volume_cb(pa_source *s) {
if ((err = snd_mixer_selem_get_capture_volume(u->mixer_elem, u->mixer_map[i], &alsa_vol)) < 0)
goto fail;
- r.values[i] = (pa_volume_t) round(((double) (alsa_vol - u->hw_volume_min) * PA_VOLUME_NORM) / (u->hw_volume_max - u->hw_volume_min));
+ r.values[i] = (pa_volume_t) round(((double) (alsa_vol - u->hw_volume_min) * PA_VOLUME_NORM) / (double) (u->hw_volume_max - u->hw_volume_min));
}
}
@@ -800,7 +801,7 @@ static int source_set_volume_cb(pa_source *s) {
r.values[i] = pa_sw_volume_from_dB((double) alsa_vol / 100.0);
} else {
- alsa_vol = (long) round(((double) vol * (u->hw_volume_max - u->hw_volume_min)) / PA_VOLUME_NORM) + u->hw_volume_min;
+ alsa_vol = (long) round(((double) vol * (double) (u->hw_volume_max - u->hw_volume_min)) / PA_VOLUME_NORM) + u->hw_volume_min;
alsa_vol = PA_CLAMP_UNLIKELY(alsa_vol, u->hw_volume_min, u->hw_volume_max);
if ((err = snd_mixer_selem_set_capture_volume(u->mixer_elem, u->mixer_map[i], alsa_vol)) < 0)
@@ -809,7 +810,7 @@ static int source_set_volume_cb(pa_source *s) {
if ((err = snd_mixer_selem_get_capture_volume(u->mixer_elem, u->mixer_map[i], &alsa_vol)) < 0)
goto fail;
- r.values[i] = (pa_volume_t) round(((double) (alsa_vol - u->hw_volume_min) * PA_VOLUME_NORM) / (u->hw_volume_max - u->hw_volume_min));
+ r.values[i] = (pa_volume_t) round(((double) (alsa_vol - u->hw_volume_min) * PA_VOLUME_NORM) / (double) (u->hw_volume_max - u->hw_volume_min));
}
}
@@ -1043,11 +1044,11 @@ int pa__init(pa_module*m) {
frame_size = pa_frame_size(&ss);
nfrags = m->core->default_n_fragments;
- frag_size = pa_usec_to_bytes(m->core->default_fragment_size_msec*PA_USEC_PER_MSEC, &ss);
+ frag_size = (uint32_t) pa_usec_to_bytes(m->core->default_fragment_size_msec*PA_USEC_PER_MSEC, &ss);
if (frag_size <= 0)
- frag_size = frame_size;
- tsched_size = pa_usec_to_bytes(DEFAULT_TSCHED_BUFFER_USEC, &ss);
- tsched_watermark = pa_usec_to_bytes(DEFAULT_TSCHED_WATERMARK_USEC, &ss);
+ frag_size = (uint32_t) frame_size;
+ tsched_size = (uint32_t) pa_usec_to_bytes(DEFAULT_TSCHED_BUFFER_USEC, &ss);
+ tsched_watermark = (uint32_t) pa_usec_to_bytes(DEFAULT_TSCHED_WATERMARK_USEC, &ss);
if (pa_modargs_get_value_u32(ma, "fragments", &nfrags) < 0 ||
pa_modargs_get_value_u32(ma, "fragment_size", &frag_size) < 0 ||
@@ -1220,7 +1221,7 @@ int pa__init(pa_module*m) {
pa_source_set_rtpoll(u->source, u->rtpoll);
u->frame_size = frame_size;
- u->fragment_size = frag_size = period_frames * frame_size;
+ u->fragment_size = frag_size = (uint32_t) (period_frames * frame_size);
u->nfragments = nfrags;
u->hwbuf_size = u->fragment_size * nfrags;
u->hwbuf_unused_frames = 0;
@@ -1272,7 +1273,7 @@ int pa__init(pa_module*m) {
VALGRIND_MAKE_MEM_DEFINED(&u->hw_dB_max, sizeof(u->hw_dB_max));
#endif
- pa_log_info("Volume ranges from %0.2f dB to %0.2f dB.", u->hw_dB_min/100.0, u->hw_dB_max/100.0);
+ pa_log_info("Volume ranges from %0.2f dB to %0.2f dB.", (double) u->hw_dB_min/100.0, (double) u->hw_dB_max/100.0);
pa_assert(u->hw_dB_min < u->hw_dB_max);
u->hw_dB_supported = TRUE;
}
diff --git a/src/modules/module-combine.c b/src/modules/module-combine.c
index 1bfe4b4c..9fd12e30 100644
--- a/src/modules/module-combine.c
+++ b/src/modules/module-combine.c
@@ -206,9 +206,9 @@ static void adjust_rates(struct userdata *u) {
continue;
if (o->total_latency < target_latency)
- r -= (uint32_t) (((((double) target_latency - o->total_latency))/u->adjust_time)*r/PA_USEC_PER_SEC);
+ r -= (uint32_t) ((((double) (target_latency - o->total_latency))/(double)u->adjust_time)*(double)r/PA_USEC_PER_SEC);
else if (o->total_latency > target_latency)
- r += (uint32_t) (((((double) o->total_latency - target_latency))/u->adjust_time)*r/PA_USEC_PER_SEC);
+ r += (uint32_t) ((((double) (o->total_latency - target_latency))/(double)u->adjust_time)*(double)r/PA_USEC_PER_SEC);
if (r < (uint32_t) (base_rate*0.9) || r > (uint32_t) (base_rate*1.1)) {
pa_log_warn("[%s] sample rates too different, not adjusting (%u vs. %u).", pa_proplist_gets(o->sink_input->proplist, PA_PROP_MEDIA_NAME), base_rate, r);
@@ -389,7 +389,7 @@ static void request_memblock(struct output *o, size_t length) {
/* OK, we need to prepare new data, but only if the sink is actually running */
if (pa_atomic_load(&o->userdata->thread_info.running))
- pa_asyncmsgq_send(o->outq, PA_MSGOBJECT(o->userdata->sink), SINK_MESSAGE_NEED, o, length, NULL);
+ pa_asyncmsgq_send(o->outq, PA_MSGOBJECT(o->userdata->sink), SINK_MESSAGE_NEED, o, (int64_t) length, NULL);
}
/* Called from I/O thread context */
diff --git a/src/modules/module-detect.c b/src/modules/module-detect.c
index 09b720df..1616d47c 100644
--- a/src/modules/module-detect.c
+++ b/src/modules/module-detect.c
@@ -236,16 +236,16 @@ int pa__init(pa_module*m) {
goto fail;
}
-#if HAVE_ALSA
+#ifdef HAVE_ALSA
if ((n = detect_alsa(m->core, just_one)) <= 0)
#endif
#if HAVE_OSS
if ((n = detect_oss(m->core, just_one)) <= 0)
#endif
-#if HAVE_SOLARIS
+#ifdef HAVE_SOLARIS
if ((n = detect_solaris(m->core, just_one)) <= 0)
#endif
-#if OS_IS_WIN32
+#ifdef OS_IS_WIN32
if ((n = detect_waveout(m->core, just_one)) <= 0)
#endif
{
diff --git a/src/modules/module-device-restore.c b/src/modules/module-device-restore.c
index f7d82e4d..920b4517 100644
--- a/src/modules/module-device-restore.c
+++ b/src/modules/module-device-restore.c
@@ -106,7 +106,7 @@ static struct entry* read_entry(struct userdata *u, char *name) {
pa_assert(name);
key.dptr = name;
- key.dsize = strlen(name);
+ key.dsize = (int) strlen(name);
data = gdbm_fetch(u->gdbm_file, key);
@@ -210,7 +210,7 @@ static void subscribe_callback(pa_core *c, pa_subscription_event_type_t t, uint3
}
key.dptr = name;
- key.dsize = strlen(name);
+ key.dsize = (int) strlen(name);
data.dptr = (void*) &entry;
data.dsize = sizeof(entry);
diff --git a/src/modules/module-esound-compat-spawnpid.c b/src/modules/module-esound-compat-spawnpid.c
index f75335d5..882dba8c 100644
--- a/src/modules/module-esound-compat-spawnpid.c
+++ b/src/modules/module-esound-compat-spawnpid.c
@@ -62,7 +62,7 @@ int pa__init(pa_module*m) {
goto finish;
}
- if (kill(pid, SIGUSR1) < 0)
+ if (kill((pid_t) pid, SIGUSR1) < 0)
pa_log_warn("kill(%u) failed: %s", pid, pa_cstrerror(errno));
pa_module_unload_request(m, TRUE);
diff --git a/src/modules/module-esound-sink.c b/src/modules/module-esound-sink.c
index e0c07d56..14f1810a 100644
--- a/src/modules/module-esound-sink.c
+++ b/src/modules/module-esound-sink.c
@@ -165,7 +165,7 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse
pa_usec_t w, r;
r = pa_smoother_get(u->smoother, pa_rtclock_usec());
- w = pa_bytes_to_usec(u->offset + u->memchunk.length, &u->sink->sample_spec);
+ w = pa_bytes_to_usec((uint64_t) u->offset + u->memchunk.length, &u->sink->sample_spec);
*((pa_usec_t*) data) = w > r ? w - r : 0;
break;
@@ -250,8 +250,8 @@ static void thread_func(void *userdata) {
} else {
u->offset += l;
- u->memchunk.index += l;
- u->memchunk.length -= l;
+ u->memchunk.index += (size_t) l;
+ u->memchunk.length -= (size_t) l;
if (u->memchunk.length <= 0) {
pa_memblock_unref(u->memchunk.memblock);
@@ -285,7 +285,7 @@ static void thread_func(void *userdata) {
}
#endif
- usec = pa_bytes_to_usec(n, &u->sink->sample_spec);
+ usec = pa_bytes_to_usec((uint64_t) n, &u->sink->sample_spec);
if (usec > u->latency)
usec -= u->latency;
@@ -296,7 +296,7 @@ static void thread_func(void *userdata) {
}
/* Hmm, nothing to do. Let's sleep */
- pollfd->events = PA_SINK_IS_OPENED(u->sink->thread_info.state) ? POLLOUT : 0;
+ pollfd->events = (short) (PA_SINK_IS_OPENED(u->sink->thread_info.state) ? POLLOUT : 0);
}
if ((ret = pa_rtpoll_run(u->rtpoll, TRUE)) < 0)
@@ -342,7 +342,7 @@ static int do_write(struct userdata *u) {
return -1;
}
- u->write_index += r;
+ u->write_index += (size_t) r;
pa_assert(u->write_index <= u->write_length);
if (u->write_index == u->write_length) {
@@ -458,7 +458,7 @@ static int do_read(struct userdata *u) {
return -1;
}
- u->read_index += r;
+ u->read_index += (size_t) r;
pa_assert(u->read_index <= u->read_length);
if (u->read_index == u->read_length)
@@ -545,7 +545,7 @@ int pa__init(pa_module*m) {
u->format =
(ss.format == PA_SAMPLE_U8 ? ESD_BITS8 : ESD_BITS16) |
(ss.channels == 2 ? ESD_STEREO : ESD_MONO);
- u->rate = ss.rate;
+ u->rate = (int32_t) ss.rate;
u->block_size = pa_usec_to_bytes(PA_USEC_PER_SEC/20, &ss);
u->read_data = u->write_data = NULL;
diff --git a/src/modules/module-hal-detect.c b/src/modules/module-hal-detect.c
index ce766258..c76a366c 100644
--- a/src/modules/module-hal-detect.c
+++ b/src/modules/module-hal-detect.c
@@ -405,7 +405,7 @@ static void device_added_time_cb(pa_mainloop_api *ea, pa_time_event *ev, const s
dbus_error_init(&error);
if (!pa_hashmap_get(td->u->devices, td->udi)) {
- int b;
+ dbus_bool_t b;
struct device *d;
b = libhal_device_exists(td->u->context, td->udi, &error);
@@ -433,7 +433,7 @@ static void device_added_cb(LibHalContext *context, const char *udi) {
struct timeval tv;
struct timerdata *t;
struct userdata *u;
- int good = 0;
+ pa_bool_t good = FALSE;
pa_assert_se(u = libhal_ctx_get_user_data(context));
@@ -749,17 +749,17 @@ int pa__init(pa_module*m) {
}
if ((api = pa_modargs_get_value(ma, "api", NULL))) {
- int good = 0;
+ pa_bool_t good = FALSE;
#ifdef HAVE_ALSA
if (strcmp(api, CAPABILITY_ALSA) == 0) {
- good = 1;
+ good = TRUE;
api = CAPABILITY_ALSA;
}
#endif
#ifdef HAVE_OSS
if (strcmp(api, CAPABILITY_OSS) == 0) {
- good = 1;
+ good = TRUE;
api = CAPABILITY_OSS;
}
#endif
diff --git a/src/modules/module-jack-sink.c b/src/modules/module-jack-sink.c
index edc543a8..555cb825 100644
--- a/src/modules/module-jack-sink.c
+++ b/src/modules/module-jack-sink.c
@@ -130,12 +130,12 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse
void *p;
pa_assert(offset > 0);
- nbytes = offset * pa_frame_size(&u->sink->sample_spec);
+ nbytes = (size_t) offset * pa_frame_size(&u->sink->sample_spec);
pa_sink_render_full(u->sink, nbytes, &chunk);
p = (uint8_t*) pa_memblock_acquire(chunk.memblock) + chunk.index;
- pa_deinterleave(p, u->buffer, u->channels, sizeof(float), offset);
+ pa_deinterleave(p, u->buffer, u->channels, sizeof(float), (unsigned) offset);
pa_memblock_release(chunk.memblock);
pa_memblock_unref(chunk.memblock);
@@ -149,10 +149,10 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse
ss.channels = 1;
for (c = 0; c < u->channels; c++)
- pa_silence_memory(u->buffer[c], offset * pa_sample_size(&ss), &ss);
+ pa_silence_memory(u->buffer[c], (size_t) offset * pa_sample_size(&ss), &ss);
}
- u->frames_in_buffer = offset;
+ u->frames_in_buffer = (jack_nframes_t) offset;
u->saved_frame_time = * (jack_nframes_t*) data;
u->saved_frame_time_valid = TRUE;
@@ -342,7 +342,7 @@ int pa__init(pa_module*m) {
pa_log_info("Successfully connected as '%s'", jack_get_client_name(u->client));
- ss.channels = u->channels = channels;
+ u->channels = ss.channels = (uint8_t) channels;
ss.rate = jack_get_sample_rate(u->client);
ss.format = PA_SAMPLE_FLOAT32NE;
diff --git a/src/modules/module-jack-source.c b/src/modules/module-jack-source.c
index 03f9d15c..9eccbbfa 100644
--- a/src/modules/module-jack-source.c
+++ b/src/modules/module-jack-source.c
@@ -116,7 +116,7 @@ static int source_process_msg(pa_msgobject *o, int code, void *data, int64_t off
if (u->source->thread_info.state == PA_SOURCE_RUNNING)
pa_source_post(u->source, chunk);
- u->saved_frame_time = offset;
+ u->saved_frame_time = (jack_nframes_t) offset;
u->saved_frame_time_valid = TRUE;
return 0;
@@ -309,7 +309,7 @@ int pa__init(pa_module*m) {
pa_log_info("Successfully connected as '%s'", jack_get_client_name(u->client));
- ss.channels = u->channels = channels;
+ u->channels = ss.channels = (uint8_t) channels;
ss.rate = jack_get_sample_rate(u->client);
ss.format = PA_SAMPLE_FLOAT32NE;
diff --git a/src/modules/module-ladspa-sink.c b/src/modules/module-ladspa-sink.c
index 23eeb340..9127af01 100644
--- a/src/modules/module-ladspa-sink.c
+++ b/src/modules/module-ladspa-sink.c
@@ -187,7 +187,7 @@ static int sink_input_pop_cb(pa_sink_input *i, size_t nbytes, pa_memchunk *chunk
pa_assert(tchunk.length > 0);
fs = pa_frame_size(&i->sample_spec);
- n = PA_MIN(tchunk.length, u->block_size) / fs;
+ n = (unsigned) (PA_MIN(tchunk.length, u->block_size) / fs);
pa_assert(n > 0);
@@ -502,9 +502,9 @@ int pa__init(pa_module*m) {
u->block_size = pa_frame_align(pa_mempool_block_size_max(m->core->mempool), &ss);
- u->input = (LADSPA_Data*) pa_xnew(uint8_t, u->block_size);
+ u->input = (LADSPA_Data*) pa_xnew(uint8_t, (unsigned) u->block_size);
if (LADSPA_IS_INPLACE_BROKEN(d->Properties))
- u->output = (LADSPA_Data*) pa_xnew(uint8_t, u->block_size);
+ u->output = (LADSPA_Data*) pa_xnew(uint8_t, (unsigned) u->block_size);
else
u->output = u->input;
@@ -530,8 +530,8 @@ int pa__init(pa_module*m) {
char *k;
unsigned long h;
- u->control = pa_xnew(LADSPA_Data, n_control);
- use_default = pa_xnew(pa_bool_t, n_control);
+ u->control = pa_xnew(LADSPA_Data, (unsigned) n_control);
+ use_default = pa_xnew(pa_bool_t, (unsigned) n_control);
p = 0;
while ((k = pa_split(cdata, ",", &state)) && p < n_control) {
@@ -552,7 +552,7 @@ int pa__init(pa_module*m) {
pa_xfree(k);
use_default[p] = FALSE;
- u->control[p++] = f;
+ u->control[p++] = (LADSPA_Data) f;
}
/* The previous loop doesn't take the last control value into account
@@ -601,8 +601,8 @@ int pa__init(pa_module*m) {
upper = d->PortRangeHints[p].UpperBound;
if (LADSPA_IS_HINT_SAMPLE_RATE(hint)) {
- lower *= ss.rate;
- upper *= ss.rate;
+ lower *= (LADSPA_Data) ss.rate;
+ upper *= (LADSPA_Data) ss.rate;
}
switch (hint & LADSPA_HINT_DEFAULT_MASK) {
@@ -617,23 +617,23 @@ int pa__init(pa_module*m) {
case LADSPA_HINT_DEFAULT_LOW:
if (LADSPA_IS_HINT_LOGARITHMIC(hint))
- u->control[h] = exp(log(lower) * 0.75 + log(upper) * 0.25);
+ u->control[h] = (LADSPA_Data) exp(log(lower) * 0.75 + log(upper) * 0.25);
else
- u->control[h] = lower * 0.75 + upper * 0.25;
+ u->control[h] = (LADSPA_Data) (lower * 0.75 + upper * 0.25);
break;
case LADSPA_HINT_DEFAULT_MIDDLE:
if (LADSPA_IS_HINT_LOGARITHMIC(hint))
- u->control[h] = exp(log(lower) * 0.5 + log(upper) * 0.5);
+ u->control[h] = (LADSPA_Data) exp(log(lower) * 0.5 + log(upper) * 0.5);
else
- u->control[h] = lower * 0.5 + upper * 0.5;
+ u->control[h] = (LADSPA_Data) (lower * 0.5 + upper * 0.5);
break;
case LADSPA_HINT_DEFAULT_HIGH:
if (LADSPA_IS_HINT_LOGARITHMIC(hint))
- u->control[h] = exp(log(lower) * 0.25 + log(upper) * 0.75);
+ u->control[h] = (LADSPA_Data) exp(log(lower) * 0.25 + log(upper) * 0.75);
else
- u->control[h] = lower * 0.25 + upper * 0.75;
+ u->control[h] = (LADSPA_Data) (lower * 0.25 + upper * 0.75);
break;
case LADSPA_HINT_DEFAULT_0:
diff --git a/src/modules/module-oss.c b/src/modules/module-oss.c
index 15b1e956..3333eb83 100644
--- a/src/modules/module-oss.c
+++ b/src/modules/module-oss.c
@@ -258,7 +258,7 @@ static int mmap_write(struct userdata *u) {
u->out_mmap_saved_nfrags = 0;
if (info.blocks > 0)
- mmap_fill_memblocks(u, info.blocks);
+ mmap_fill_memblocks(u, (unsigned) info.blocks);
return info.blocks;
}
@@ -336,7 +336,7 @@ static int mmap_read(struct userdata *u) {
u->in_mmap_saved_nfrags = 0;
if (info.blocks > 0) {
- mmap_post_memblocks(u, info.blocks);
+ mmap_post_memblocks(u, (unsigned) info.blocks);
mmap_clear_memblocks(u, u->in_nfrags/2);
}
@@ -356,12 +356,12 @@ static pa_usec_t mmap_sink_get_latency(struct userdata *u) {
u->out_mmap_saved_nfrags += info.blocks;
- bpos = ((u->out_mmap_current + u->out_mmap_saved_nfrags) * u->out_fragment_size) % u->out_hwbuf_size;
+ bpos = ((u->out_mmap_current + (unsigned) u->out_mmap_saved_nfrags) * u->out_fragment_size) % u->out_hwbuf_size;
if (bpos <= (size_t) info.ptr)
- n = u->out_hwbuf_size - (info.ptr - bpos);
+ n = u->out_hwbuf_size - ((size_t) info.ptr - bpos);
else
- n = bpos - info.ptr;
+ n = bpos - (size_t) info.ptr;
/* pa_log("n = %u, bpos = %u, ptr = %u, total=%u, fragsize = %u, n_frags = %u\n", n, bpos, (unsigned) info.ptr, total, u->out_fragment_size, u->out_fragments); */
@@ -380,12 +380,12 @@ static pa_usec_t mmap_source_get_latency(struct userdata *u) {
}
u->in_mmap_saved_nfrags += info.blocks;
- bpos = ((u->in_mmap_current + u->in_mmap_saved_nfrags) * u->in_fragment_size) % u->in_hwbuf_size;
+ bpos = ((u->in_mmap_current + (unsigned) u->in_mmap_saved_nfrags) * u->in_fragment_size) % u->in_hwbuf_size;
if (bpos <= (size_t) info.ptr)
- n = info.ptr - bpos;
+ n = (size_t) info.ptr - bpos;
else
- n = u->in_hwbuf_size - bpos + info.ptr;
+ n = u->in_hwbuf_size - bpos + (size_t) info.ptr;
/* pa_log("n = %u, bpos = %u, ptr = %u, total=%u, fragsize = %u, n_frags = %u\n", n, bpos, (unsigned) info.ptr, total, u->in_fragment_size, u->in_fragments); */
@@ -404,7 +404,7 @@ static pa_usec_t io_sink_get_latency(struct userdata *u) {
pa_log_info("Device doesn't support SNDCTL_DSP_GETODELAY: %s", pa_cstrerror(errno));
u->use_getodelay = 0;
} else
- r = pa_bytes_to_usec(arg, &u->sink->sample_spec);
+ r = pa_bytes_to_usec((size_t) arg, &u->sink->sample_spec);
}
@@ -415,7 +415,7 @@ static pa_usec_t io_sink_get_latency(struct userdata *u) {
pa_log_info("Device doesn't support SNDCTL_DSP_GETOSPACE: %s", pa_cstrerror(errno));
u->use_getospace = 0;
} else
- r = pa_bytes_to_usec(info.bytes, &u->sink->sample_spec);
+ r = pa_bytes_to_usec((size_t) info.bytes, &u->sink->sample_spec);
}
if (u->memchunk.memblock)
@@ -437,7 +437,7 @@ static pa_usec_t io_source_get_latency(struct userdata *u) {
pa_log_info("Device doesn't support SNDCTL_DSP_GETISPACE: %s", pa_cstrerror(errno));
u->use_getispace = 0;
} else
- r = pa_bytes_to_usec(info.bytes, &u->source->sample_spec);
+ r = pa_bytes_to_usec((size_t) info.bytes, &u->source->sample_spec);
}
return r;
@@ -528,8 +528,9 @@ static int unsuspend(struct userdata *u) {
if ((u->fd = pa_oss_open(u->device_name, &m, NULL)) < 0) {
pa_log_warn("Resume failed, device busy (%s)", pa_cstrerror(errno));
return -1;
+ }
- if (m != u->mode)
+ if (m != u->mode) {
pa_log_warn("Resume failed, couldn't open device with original access mode.");
goto fail;
}
@@ -859,7 +860,7 @@ static int source_set_volume(pa_source *s) {
static void thread_func(void *userdata) {
struct userdata *u = userdata;
int write_type = 0, read_type = 0;
- unsigned short revents = 0;
+ short revents = 0;
pa_assert(u);
@@ -935,7 +936,7 @@ static void thread_func(void *userdata) {
ssize_t t;
if (u->memchunk.length <= 0)
- pa_sink_render(u->sink, l, &u->memchunk);
+ pa_sink_render(u->sink, (size_t) l, &u->memchunk);
pa_assert(u->memchunk.length > 0);
@@ -965,8 +966,8 @@ static void thread_func(void *userdata) {
} else {
- u->memchunk.index += t;
- u->memchunk.length -= t;
+ u->memchunk.index += (size_t) t;
+ u->memchunk.length -= (size_t) t;
if (u->memchunk.length <= 0) {
pa_memblock_unref(u->memchunk.memblock);
@@ -1031,7 +1032,8 @@ static void thread_func(void *userdata) {
}
while (l > 0) {
- ssize_t t, k;
+ ssize_t t;
+ size_t k;
pa_assert(l > 0);
@@ -1039,8 +1041,8 @@ static void thread_func(void *userdata) {
k = pa_memblock_get_length(memchunk.memblock);
- if (k > l)
- k = l;
+ if (k > (size_t) l)
+ k = (size_t) l;
k = (k/u->frame_size)*u->frame_size;
@@ -1071,7 +1073,7 @@ static void thread_func(void *userdata) {
} else {
memchunk.index = 0;
- memchunk.length = t;
+ memchunk.length = (size_t) t;
pa_source_post(u->source, &memchunk);
pa_memblock_unref(memchunk.memblock);
@@ -1099,9 +1101,9 @@ static void thread_func(void *userdata) {
pa_assert(u->fd >= 0);
pollfd = pa_rtpoll_item_get_pollfd(u->rtpoll_item, NULL);
- pollfd->events =
- ((u->source && PA_SOURCE_IS_OPENED(u->source->thread_info.state)) ? POLLIN : 0) |
- ((u->sink && PA_SINK_IS_OPENED(u->sink->thread_info.state)) ? POLLOUT : 0);
+ pollfd->events = (short)
+ (((u->source && PA_SOURCE_IS_OPENED(u->source->thread_info.state)) ? POLLIN : 0) |
+ ((u->sink && PA_SINK_IS_OPENED(u->sink->thread_info.state)) ? POLLOUT : 0));
}
/* Hmm, nothing to do. Let's sleep */
@@ -1179,10 +1181,10 @@ int pa__init(pa_module*m) {
goto fail;
}
- nfrags = m->core->default_n_fragments;
- frag_size = pa_usec_to_bytes(m->core->default_fragment_size_msec*1000, &ss);
+ nfrags = (int) m->core->default_n_fragments;
+ frag_size = (int) pa_usec_to_bytes(m->core->default_fragment_size_msec*1000, &ss);
if (frag_size <= 0)
- frag_size = pa_frame_size(&ss);
+ frag_size = (int) pa_frame_size(&ss);
if (pa_modargs_get_value_s32(ma, "fragments", &nfrags) < 0 || pa_modargs_get_value_s32(ma, "fragment_size", &frag_size) < 0) {
pa_log("Failed to parse fragments arguments");
@@ -1238,8 +1240,8 @@ int pa__init(pa_module*m) {
u->mode = mode;
u->frame_size = pa_frame_size(&ss);
u->device_name = pa_xstrdup(dev);
- u->in_nfrags = u->out_nfrags = u->nfrags = nfrags;
- u->out_fragment_size = u->in_fragment_size = u->frag_size = frag_size;
+ u->in_nfrags = u->out_nfrags = (uint32_t) (u->nfrags = nfrags);
+ u->out_fragment_size = u->in_fragment_size = (uint32_t) (u->frag_size = frag_size);
u->use_mmap = use_mmap;
u->rtpoll = pa_rtpoll_new();
pa_thread_mq_init(&u->thread_mq, m->core->mainloop, u->rtpoll);
@@ -1248,15 +1250,15 @@ int pa__init(pa_module*m) {
if (ioctl(fd, SNDCTL_DSP_GETISPACE, &info) >= 0) {
pa_log_info("Input -- %u fragments of size %u.", info.fragstotal, info.fragsize);
- u->in_fragment_size = info.fragsize;
- u->in_nfrags = info.fragstotal;
+ u->in_fragment_size = (uint32_t) info.fragsize;
+ u->in_nfrags = (uint32_t) info.fragstotal;
u->use_getispace = TRUE;
}
if (ioctl(fd, SNDCTL_DSP_GETOSPACE, &info) >= 0) {
pa_log_info("Output -- %u fragments of size %u.", info.fragstotal, info.fragsize);
- u->out_fragment_size = info.fragsize;
- u->out_nfrags = info.fragstotal;
+ u->out_fragment_size = (uint32_t) info.fragsize;
+ u->out_nfrags = (uint32_t) info.fragstotal;
u->use_getospace = TRUE;
}
diff --git a/src/modules/module-pipe-sink.c b/src/modules/module-pipe-sink.c
index f389cd06..ae230b2c 100644
--- a/src/modules/module-pipe-sink.c
+++ b/src/modules/module-pipe-sink.c
@@ -145,8 +145,8 @@ static int process_render(struct userdata *u) {
} else {
- u->memchunk.index += l;
- u->memchunk.length -= l;
+ u->memchunk.index += (size_t) l;
+ u->memchunk.length -= (size_t) l;
if (u->memchunk.length <= 0) {
pa_memblock_unref(u->memchunk.memblock);
@@ -189,7 +189,7 @@ static void thread_func(void *userdata) {
}
/* Hmm, nothing to do. Let's sleep */
- pollfd->events = u->sink->thread_info.state == PA_SINK_RUNNING ? POLLOUT : 0;
+ pollfd->events = (short) (u->sink->thread_info.state == PA_SINK_RUNNING ? POLLOUT : 0);
if ((ret = pa_rtpoll_run(u->rtpoll, TRUE)) < 0)
goto fail;
diff --git a/src/modules/module-pipe-source.c b/src/modules/module-pipe-source.c
index b0de34ca..25151d95 100644
--- a/src/modules/module-pipe-source.c
+++ b/src/modules/module-pipe-source.c
@@ -135,9 +135,9 @@ static void thread_func(void *userdata) {
} else {
- u->memchunk.length = l;
+ u->memchunk.length = (size_t) l;
pa_source_post(u->source, &u->memchunk);
- u->memchunk.index += l;
+ u->memchunk.index += (size_t) l;
if (u->memchunk.index >= pa_memblock_get_length(u->memchunk.memblock)) {
pa_memblock_unref(u->memchunk.memblock);
@@ -149,7 +149,7 @@ static void thread_func(void *userdata) {
}
/* Hmm, nothing to do. Let's sleep */
- pollfd->events = u->source->thread_info.state == PA_SOURCE_RUNNING ? POLLIN : 0;
+ pollfd->events = (short) (u->source->thread_info.state == PA_SOURCE_RUNNING ? POLLIN : 0);
if ((ret = pa_rtpoll_run(u->rtpoll, TRUE)) < 0)
goto fail;
diff --git a/src/modules/module-protocol-stub.c b/src/modules/module-protocol-stub.c
index 4fe439f9..0e98b1c3 100644
--- a/src/modules/module-protocol-stub.c
+++ b/src/modules/module-protocol-stub.c
@@ -299,11 +299,11 @@ int pa__init(pa_module*m) {
listen_on = pa_modargs_get_value(ma, "listen", NULL);
if (listen_on) {
- u->socket_server_ipv6 = pa_socket_server_new_ipv6_string(m->core->mainloop, listen_on, port, TCPWRAP_SERVICE);
- u->socket_server_ipv4 = pa_socket_server_new_ipv4_string(m->core->mainloop, listen_on, port, TCPWRAP_SERVICE);
+ u->socket_server_ipv6 = pa_socket_server_new_ipv6_string(m->core->mainloop, listen_on, (uint16_t) port, TCPWRAP_SERVICE);
+ u->socket_server_ipv4 = pa_socket_server_new_ipv4_string(m->core->mainloop, listen_on, (uint16_t) port, TCPWRAP_SERVICE);
} else {
- u->socket_server_ipv6 = pa_socket_server_new_ipv6_any(m->core->mainloop, port, TCPWRAP_SERVICE);
- u->socket_server_ipv4 = pa_socket_server_new_ipv4_any(m->core->mainloop, port, TCPWRAP_SERVICE);
+ u->socket_server_ipv6 = pa_socket_server_new_ipv6_any(m->core->mainloop, (uint16_t) port, TCPWRAP_SERVICE);
+ u->socket_server_ipv4 = pa_socket_server_new_ipv4_any(m->core->mainloop, (uint16_t) port, TCPWRAP_SERVICE);
}
if (!u->socket_server_ipv4 && !u->socket_server_ipv6)
@@ -327,7 +327,7 @@ int pa__init(pa_module*m) {
/* This socket doesn't reside in our own runtime dir but in
* /tmp/.esd/, hence we have to create the dir first */
- if (pa_make_secure_parent_dir(u->socket_path, pa_in_system_mode() ? 0755 : 0700, (uid_t)-1, (gid_t)-1) < 0) {
+ if (pa_make_secure_parent_dir(u->socket_path, pa_in_system_mode() ? 0755U : 0700U, (uid_t)-1, (gid_t)-1) < 0) {
pa_log("Failed to create socket directory '%s': %s\n", u->socket_path, pa_cstrerror(errno));
goto fail;
}
diff --git a/src/modules/module-sine.c b/src/modules/module-sine.c
index a6324526..21565cc4 100644
--- a/src/modules/module-sine.c
+++ b/src/modules/module-sine.c
@@ -116,13 +116,13 @@ static void sink_input_state_change_cb(pa_sink_input *i, pa_sink_input_state_t s
pa_sink_input_request_rewind(i, 0, FALSE, TRUE);
}
-static void calc_sine(float *f, size_t l, float freq) {
+static void calc_sine(float *f, size_t l, double freq) {
size_t i;
l /= sizeof(float);
for (i = 0; i < l; i++)
- f[i] = (float) sin((double) i/l*M_PI*2*freq)/2;
+ f[i] = (float) sin((double) i/(double)l*M_PI*2*freq)/2;
}
int pa__init(pa_module*m) {
@@ -163,7 +163,7 @@ int pa__init(pa_module*m) {
u->memblock = pa_memblock_new(m->core->mempool, pa_bytes_per_second(&ss));
p = pa_memblock_acquire(u->memblock);
- calc_sine(p, pa_memblock_get_length(u->memblock), frequency);
+ calc_sine(p, pa_memblock_get_length(u->memblock), (double) frequency);
pa_memblock_release(u->memblock);
pa_sink_input_new_data_init(&data);
diff --git a/src/modules/module-stream-restore.c b/src/modules/module-stream-restore.c
index 7bbb47d5..37e8b067 100644
--- a/src/modules/module-stream-restore.c
+++ b/src/modules/module-stream-restore.c
@@ -145,7 +145,7 @@ static struct entry* read_entry(struct userdata *u, char *name) {
pa_assert(name);
key.dptr = name;
- key.dsize = strlen(name);
+ key.dsize = (int) strlen(name);
data = gdbm_fetch(u->gdbm_file, key);
@@ -277,7 +277,7 @@ static void subscribe_callback(pa_core *c, pa_subscription_event_type_t t, uint3
}
key.dptr = name;
- key.dsize = strlen(name);
+ key.dsize = (int) strlen(name);
data.dptr = (void*) &entry;
data.dsize = sizeof(entry);
@@ -544,7 +544,7 @@ static int extension_cb(pa_native_protocol *p, pa_module *m, pa_native_connectio
next_key = gdbm_nextkey(u->gdbm_file, key);
- name = pa_xstrndup(key.dptr, key.dsize);
+ name = pa_xstrndup(key.dptr, (size_t) key.dsize);
pa_xfree(key.dptr);
if ((e = read_entry(u, name))) {
@@ -604,7 +604,7 @@ static int extension_cb(pa_native_protocol *p, pa_module *m, pa_native_connectio
pa_strlcpy(entry.device, device, sizeof(entry.device));
key.dptr = (void*) name;
- key.dsize = strlen(name);
+ key.dsize = (int) strlen(name);
data.dptr = (void*) &entry;
data.dsize = sizeof(entry);
@@ -629,7 +629,7 @@ static int extension_cb(pa_native_protocol *p, pa_module *m, pa_native_connectio
goto fail;
key.dptr = (void*) name;
- key.dsize = strlen(name);
+ key.dsize = (int) strlen(name);
gdbm_delete(u->gdbm_file, key);
}
diff --git a/src/modules/module-tunnel.c b/src/modules/module-tunnel.c
index 79ce1dd2..de3c7274 100644
--- a/src/modules/module-tunnel.c
+++ b/src/modules/module-tunnel.c
@@ -178,7 +178,7 @@ struct userdata {
#ifdef TUNNEL_SINK
char *sink_name;
pa_sink *sink;
- int32_t requested_bytes;
+ size_t requested_bytes;
#else
char *source_name;
pa_source *source;
@@ -389,7 +389,7 @@ static void send_data(struct userdata *u) {
u->requested_bytes -= memchunk.length;
- u->counter += memchunk.length;
+ u->counter += (int64_t) memchunk.length;
}
}
@@ -417,7 +417,7 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse
case PA_SINK_MESSAGE_GET_LATENCY: {
pa_usec_t yl, yr, *usec = data;
- yl = pa_bytes_to_usec(u->counter, &u->sink->sample_spec);
+ yl = pa_bytes_to_usec((uint64_t) u->counter, &u->sink->sample_spec);
yr = pa_smoother_get(u->smoother, pa_rtclock_usec());
*usec = yl > yr ? yl - yr : 0;
@@ -444,10 +444,10 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse
case SINK_MESSAGE_UPDATE_LATENCY: {
pa_usec_t y;
- y = pa_bytes_to_usec(u->counter, &u->sink->sample_spec);
+ y = pa_bytes_to_usec((uint64_t) u->counter, &u->sink->sample_spec);
if (y > (pa_usec_t) offset || offset < 0)
- y -= offset;
+ y -= (pa_usec_t) offset;
else
y = 0;
@@ -465,7 +465,7 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse
pa_pstream_send_memblock(u->pstream, u->channel, 0, PA_SEEK_RELATIVE, chunk);
- u->counter_delta += chunk->length;
+ u->counter_delta += (int64_t) chunk->length;
return 0;
}
@@ -520,7 +520,7 @@ static int source_process_msg(pa_msgobject *o, int code, void *data, int64_t off
case PA_SOURCE_MESSAGE_GET_LATENCY: {
pa_usec_t yr, yl, *usec = data;
- yl = pa_bytes_to_usec(u->counter, &PA_SINK(o)->sample_spec);
+ yl = pa_bytes_to_usec((uint64_t) u->counter, &PA_SINK(o)->sample_spec);
yr = pa_smoother_get(u->smoother, pa_rtclock_usec());
*usec = yr > yl ? yr - yl : 0;
@@ -532,7 +532,7 @@ static int source_process_msg(pa_msgobject *o, int code, void *data, int64_t off
if (PA_SOURCE_IS_OPENED(u->source->thread_info.state))
pa_source_post(u->source, chunk);
- u->counter += chunk->length;
+ u->counter += (int64_t) chunk->length;
return 0;
@@ -544,10 +544,10 @@ static int source_process_msg(pa_msgobject *o, int code, void *data, int64_t off
case SOURCE_MESSAGE_UPDATE_LATENCY: {
pa_usec_t y;
- y = pa_bytes_to_usec(u->counter, &u->source->sample_spec);
+ y = pa_bytes_to_usec((uint64_t) u->counter, &u->source->sample_spec);
if (offset >= 0 || y > (pa_usec_t) -offset)
- y += offset;
+ y += (pa_usec_t) offset;
else
y = 0;
@@ -736,9 +736,9 @@ static void stream_get_latency_callback(pa_pdispatch *pd, uint32_t command, uint
/* Add the length of our server-side buffer */
if (write_index >= read_index)
- delay += (int64_t) pa_bytes_to_usec(write_index-read_index, ss);
+ delay += (int64_t) pa_bytes_to_usec((uint64_t) (write_index-read_index), ss);
else
- delay -= (int64_t) pa_bytes_to_usec(read_index-write_index, ss);
+ delay -= (int64_t) pa_bytes_to_usec((uint64_t) (read_index-write_index), ss);
/* Our measurements are already out of date, hence correct by the *
* transport latency */
@@ -750,9 +750,9 @@ static void stream_get_latency_callback(pa_pdispatch *pd, uint32_t command, uint
/* Now correct by what we have have read/written since we requested the update */
#ifdef TUNNEL_SINK
- delay += (int64_t) pa_bytes_to_usec(u->counter_delta, ss);
+ delay += (int64_t) pa_bytes_to_usec((uint64_t) u->counter_delta, ss);
#else
- delay -= (int64_t) pa_bytes_to_usec(u->counter_delta, ss);
+ delay -= (int64_t) pa_bytes_to_usec((uint64_t) u->counter_delta, ss);
#endif
#ifdef TUNNEL_SINK
@@ -1425,11 +1425,11 @@ static void setup_complete_callback(pa_pdispatch *pd, uint32_t command, uint32_t
u->maxlength = 4*1024*1024;
#ifdef TUNNEL_SINK
- u->tlength = pa_usec_to_bytes(PA_USEC_PER_MSEC * DEFAULT_TLENGTH_MSEC, &u->sink->sample_spec);
- u->minreq = pa_usec_to_bytes(PA_USEC_PER_MSEC * DEFAULT_MINREQ_MSEC, &u->sink->sample_spec);
+ u->tlength = (uint32_t) pa_usec_to_bytes(PA_USEC_PER_MSEC * DEFAULT_TLENGTH_MSEC, &u->sink->sample_spec);
+ u->minreq = (uint32_t) pa_usec_to_bytes(PA_USEC_PER_MSEC * DEFAULT_MINREQ_MSEC, &u->sink->sample_spec);
u->prebuf = u->tlength;
#else
- u->fragsize = pa_usec_to_bytes(PA_USEC_PER_MSEC * DEFAULT_FRAGSIZE_MSEC, &u->source->sample_spec);
+ u->fragsize = (uint32_t) pa_usec_to_bytes(PA_USEC_PER_MSEC * DEFAULT_FRAGSIZE_MSEC, &u->source->sample_spec);
#endif
#ifdef TUNNEL_SINK
@@ -1548,7 +1548,7 @@ static void pstream_memblock_callback(pa_pstream *p, uint32_t channel, int64_t o
pa_asyncmsgq_send(u->source->asyncmsgq, PA_MSGOBJECT(u->source), SOURCE_MESSAGE_POST, PA_UINT_TO_PTR(seek), offset, chunk);
- u->counter_delta += chunk->length;
+ u->counter_delta += (int64_t) chunk->length;
}
#endif
diff --git a/src/modules/module-volume-restore.c b/src/modules/module-volume-restore.c
index 0fb17a0d..aac0d046 100644
--- a/src/modules/module-volume-restore.c
+++ b/src/modules/module-volume-restore.c
@@ -103,7 +103,7 @@ static pa_cvolume* parse_volume(const char *s, pa_cvolume *v) {
if (k <= 0 || k > (long) PA_CHANNELS_MAX)
return NULL;
- v->channels = (unsigned) k;
+ v->channels = (uint8_t) k;
for (i = 0; i < v->channels; i++) {
p += strspn(p, WHITESPACE);
diff --git a/src/modules/module-x11-bell.c b/src/modules/module-x11-bell.c
index ae16b9ae..e93721c1 100644
--- a/src/modules/module-x11-bell.c
+++ b/src/modules/module-x11-bell.c
@@ -82,7 +82,7 @@ static int x11_event_cb(pa_x11_wrapper *w, XEvent *e, void *userdata) {
bne = (XkbBellNotifyEvent*) e;
- if (pa_scache_play_item_by_name(u->core, u->scache_item, u->sink_name, TRUE, (bne->percent*PA_VOLUME_NORM)/100, NULL, NULL) < 0) {
+ if (pa_scache_play_item_by_name(u->core, u->scache_item, u->sink_name, TRUE, ((pa_volume_t) bne->percent*PA_VOLUME_NORM)/100U, NULL, NULL) < 0) {
pa_log_info("Ringing bell failed, reverting to X11 device bell.");
XkbForceDeviceBell(pa_x11_wrapper_get_display(w), bne->device, bne->bell_class, bne->bell_id, bne->percent);
}
diff --git a/src/modules/module-x11-xsmp.c b/src/modules/module-x11-xsmp.c
index 12e100b7..57d182fd 100644
--- a/src/modules/module-x11-xsmp.c
+++ b/src/modules/module-x11-xsmp.c
@@ -181,7 +181,7 @@ int pa__init(pa_module*m) {
prop_program.name = (char*) SmProgram;
prop_program.type = (char*) SmARRAY8;
val_program.value = (char*) PACKAGE_NAME;
- val_program.length = strlen(val_program.value);
+ val_program.length = (int) strlen(val_program.value);
prop_program.num_vals = 1;
prop_program.vals = &val_program;
prop_list[0] = &prop_program;
@@ -190,7 +190,7 @@ int pa__init(pa_module*m) {
prop_user.type = (char*) SmARRAY8;
pa_get_user_name(t, sizeof(t));
val_user.value = t;
- val_user.length = strlen(val_user.value);
+ val_user.length = (int) strlen(val_user.value);
prop_user.num_vals = 1;
prop_user.vals = &val_user;
prop_list[1] = &prop_user;
diff --git a/src/modules/module-zeroconf-discover.c b/src/modules/module-zeroconf-discover.c
index a4fbf020..c8087abb 100644
--- a/src/modules/module-zeroconf-discover.c
+++ b/src/modules/module-zeroconf-discover.c
@@ -173,9 +173,9 @@ static void resolver_cb(
device = value;
value = NULL;
} else if (strcmp(key, "rate") == 0)
- ss.rate = atoi(value);
+ ss.rate = (uint32_t) atoi(value);
else if (strcmp(key, "channels") == 0)
- ss.channels = atoi(value);
+ ss.channels = (uint8_t) atoi(value);
else if (strcmp(key, "format") == 0)
ss.format = pa_parse_sample_format(value);
else if (strcmp(key, "channel_map") == 0) {
diff --git a/src/modules/oss-util.c b/src/modules/oss-util.c
index 2791e165..f766030d 100644
--- a/src/modules/oss-util.c
+++ b/src/modules/oss-util.c
@@ -204,10 +204,10 @@ int pa_oss_auto_format(int fd, pa_sample_spec *ss) {
if (ss->channels != channels) {
pa_log_warn("device doesn't support %i channels, using %i channels.", ss->channels, channels);
- ss->channels = channels;
+ ss->channels = (uint8_t) channels;
}
- speed = ss->rate;
+ speed = (int) ss->rate;
if (ioctl(fd, SNDCTL_DSP_SPEED, &speed) < 0) {
pa_log("SNDCTL_DSP_SPEED: %s", pa_cstrerror(errno));
return -1;
@@ -219,7 +219,7 @@ int pa_oss_auto_format(int fd, pa_sample_spec *ss) {
/* If the sample rate deviates too much, we need to resample */
if (speed < ss->rate*.95 || speed > ss->rate*1.05)
- ss->rate = speed;
+ ss->rate = (uint32_t) speed;
}
return 0;
diff --git a/src/modules/rtp/module-rtp-recv.c b/src/modules/rtp/module-rtp-recv.c
index e04e4611..01637892 100644
--- a/src/modules/rtp/module-rtp-recv.c
+++ b/src/modules/rtp/module-rtp-recv.c
@@ -238,15 +238,15 @@ static int rtpoll_work_cb(pa_rtpoll_item *i) {
else
delta = j;
- pa_memblockq_seek(s->memblockq, delta * s->rtp_context.frame_size, PA_SEEK_RELATIVE);
+ pa_memblockq_seek(s->memblockq, delta * (int64_t) s->rtp_context.frame_size, PA_SEEK_RELATIVE);
pa_rtclock_get(&now);
- pa_smoother_put(s->smoother, pa_timeval_load(&now), pa_bytes_to_usec(pa_memblockq_get_write_index(s->memblockq), &s->sink_input->sample_spec));
+ pa_smoother_put(s->smoother, pa_timeval_load(&now), pa_bytes_to_usec((uint64_t) pa_memblockq_get_write_index(s->memblockq), &s->sink_input->sample_spec));
if (pa_memblockq_push(s->memblockq, &chunk) < 0) {
pa_log_warn("Queue overrun");
- pa_memblockq_seek(s->memblockq, chunk.length, PA_SEEK_RELATIVE);
+ pa_memblockq_seek(s->memblockq, (int64_t) chunk.length, PA_SEEK_RELATIVE);
}
pa_log("blocks in q: %u", pa_memblockq_get_nblocks(s->memblockq));
@@ -254,9 +254,9 @@ static int rtpoll_work_cb(pa_rtpoll_item *i) {
pa_memblock_unref(chunk.memblock);
/* The next timestamp we expect */
- s->offset = s->rtp_context.timestamp + (chunk.length / s->rtp_context.frame_size);
+ s->offset = s->rtp_context.timestamp + (uint32_t) (chunk.length / s->rtp_context.frame_size);
- pa_atomic_store(&s->timestamp, now.tv_sec);
+ pa_atomic_store(&s->timestamp, (int) now.tv_sec);
if (s->last_rate_update + RATE_UPDATE_INTERVAL < pa_timeval_load(&now)) {
pa_usec_t wi, ri, render_delay, sink_delay = 0, latency, fix;
@@ -265,7 +265,7 @@ static int rtpoll_work_cb(pa_rtpoll_item *i) {
pa_log("Updating sample rate");
wi = pa_smoother_get(s->smoother, pa_timeval_load(&now));
- ri = pa_bytes_to_usec(pa_memblockq_get_read_index(s->memblockq), &s->sink_input->sample_spec);
+ ri = pa_bytes_to_usec((uint64_t) pa_memblockq_get_read_index(s->memblockq), &s->sink_input->sample_spec);
if (PA_MSGOBJECT(s->sink_input->sink)->process_msg(PA_MSGOBJECT(s->sink_input->sink), PA_SINK_MESSAGE_GET_LATENCY, &sink_delay, 0, NULL) < 0)
sink_delay = 0;
@@ -291,7 +291,7 @@ static int rtpoll_work_cb(pa_rtpoll_item *i) {
fix = latency - s->intended_latency;
/* How many samples is this per second? */
- fix_samples = fix * s->sink_input->thread_info.sample_spec.rate / RATE_UPDATE_INTERVAL;
+ fix_samples = (unsigned) (fix * (pa_usec_t) s->sink_input->thread_info.sample_spec.rate / (pa_usec_t) RATE_UPDATE_INTERVAL);
/* Check if deviation is in bounds */
if (fix_samples > s->sink_input->sample_spec.rate*.20)
@@ -431,7 +431,7 @@ static struct session *session_new(struct userdata *u, const pa_sdp_info *sdp_in
s->smoother = pa_smoother_new(PA_USEC_PER_SEC*5, PA_USEC_PER_SEC*2, TRUE, 10);
pa_smoother_set_time_offset(s->smoother, pa_timeval_load(&now));
s->last_rate_update = pa_timeval_load(&now);
- pa_atomic_store(&s->timestamp, now.tv_sec);
+ pa_atomic_store(&s->timestamp, (int) now.tv_sec);
if ((fd = mcast_socket((const struct sockaddr*) &sdp_info->sa, sdp_info->salen)) < 0)
goto fail;
@@ -566,7 +566,7 @@ static void sap_event_cb(pa_mainloop_api *m, pa_io_event *e, int fd, pa_io_event
} else {
struct timeval now;
pa_rtclock_get(&now);
- pa_atomic_store(&s->timestamp, now.tv_sec);
+ pa_atomic_store(&s->timestamp, (int) now.tv_sec);
pa_sdp_info_destroy(&info);
}
diff --git a/src/modules/rtp/module-rtp-send.c b/src/modules/rtp/module-rtp-send.c
index 1423cbc1..280067a5 100644
--- a/src/modules/rtp/module-rtp-send.c
+++ b/src/modules/rtp/module-rtp-send.c
@@ -171,7 +171,8 @@ int pa__init(pa_module*m) {
const char *dest;
uint32_t port = DEFAULT_PORT, mtu;
uint32_t ttl = DEFAULT_TTL;
- int af, fd = -1, sap_fd = -1;
+ sa_family_t af;
+ int fd = -1, sap_fd = -1;
pa_source *s;
pa_sample_spec ss;
pa_channel_map cm;
@@ -223,14 +224,14 @@ int pa__init(pa_module*m) {
payload = pa_rtp_payload_from_sample_spec(&ss);
- mtu = pa_frame_align(DEFAULT_MTU, &ss);
+ mtu = (uint32_t) pa_frame_align(DEFAULT_MTU, &ss);
if (pa_modargs_get_value_u32(ma, "mtu", &mtu) < 0 || mtu < 1 || mtu % pa_frame_size(&ss) != 0) {
pa_log("Invalid MTU.");
goto fail;
}
- port = DEFAULT_PORT + ((rand() % 512) << 1);
+ port = DEFAULT_PORT + ((uint32_t) (rand() % 512) << 1);
if (pa_modargs_get_value_u32(ma, "port", &port) < 0 || port < 1 || port > 0xFFFF) {
pa_log("port= expects a numerical argument between 1 and 65535.");
goto fail;
@@ -248,12 +249,12 @@ int pa__init(pa_module*m) {
if (inet_pton(AF_INET6, dest, &sa6.sin6_addr) > 0) {
sa6.sin6_family = af = AF_INET6;
- sa6.sin6_port = htons(port);
+ sa6.sin6_port = htons((uint16_t) port);
sap_sa6 = sa6;
sap_sa6.sin6_port = htons(SAP_PORT);
} else if (inet_pton(AF_INET, dest, &sa4.sin_addr) > 0) {
sa4.sin_family = af = AF_INET;
- sa4.sin_port = htons(port);
+ sa4.sin_port = htons((uint16_t) port);
sap_sa4 = sa4;
sap_sa4.sin_port = htons(SAP_PORT);
} else {
@@ -266,7 +267,7 @@ int pa__init(pa_module*m) {
goto fail;
}
- if (connect(fd, af == AF_INET ? (struct sockaddr*) &sa4 : (struct sockaddr*) &sa6, af == AF_INET ? sizeof(sa4) : sizeof(sa6)) < 0) {
+ if (connect(fd, af == AF_INET ? (struct sockaddr*) &sa4 : (struct sockaddr*) &sa6, (socklen_t) (af == AF_INET ? sizeof(sa4) : sizeof(sa6))) < 0) {
pa_log("connect() failed: %s", pa_cstrerror(errno));
goto fail;
}
@@ -276,7 +277,7 @@ int pa__init(pa_module*m) {
goto fail;
}
- if (connect(sap_fd, af == AF_INET ? (struct sockaddr*) &sap_sa4 : (struct sockaddr*) &sap_sa6, af == AF_INET ? sizeof(sap_sa4) : sizeof(sap_sa6)) < 0) {
+ if (connect(sap_fd, af == AF_INET ? (struct sockaddr*) &sap_sa4 : (struct sockaddr*) &sap_sa6, (socklen_t) (af == AF_INET ? sizeof(sap_sa4) : sizeof(sap_sa6))) < 0) {
pa_log("connect() failed: %s", pa_cstrerror(errno));
goto fail;
}
@@ -354,7 +355,7 @@ int pa__init(pa_module*m) {
p = pa_sdp_build(af,
af == AF_INET ? (void*) &((struct sockaddr_in*) &sa_dst)->sin_addr : (void*) &((struct sockaddr_in6*) &sa_dst)->sin6_addr,
af == AF_INET ? (void*) &sa4.sin_addr : (void*) &sa6.sin6_addr,
- n, port, payload, &ss);
+ n, (uint16_t) port, payload, &ss);
pa_xfree(n);
diff --git a/src/modules/rtp/rtp.c b/src/modules/rtp/rtp.c
index 5a33ebc2..88351010 100644
--- a/src/modules/rtp/rtp.c
+++ b/src/modules/rtp/rtp.c
@@ -50,7 +50,7 @@ pa_rtp_context* pa_rtp_context_init_send(pa_rtp_context *c, int fd, uint32_t ssr
c->sequence = (uint16_t) (rand()*rand());
c->timestamp = 0;
c->ssrc = ssrc ? ssrc : (uint32_t) (rand()*rand());
- c->payload = payload & 127;
+ c->payload = (uint8_t) (payload & 127U);
c->frame_size = frame_size;
pa_memchunk_reset(&c->memchunk);
@@ -99,7 +99,8 @@ int pa_rtp_send(pa_rtp_context *c, size_t size, pa_memblockq *q) {
if (r < 0 || n >= size || iov_idx >= MAX_IOVECS) {
uint32_t header[3];
struct msghdr m;
- int k, i;
+ ssize_t k;
+ int i;
if (n > 0) {
header[0] = htonl(((uint32_t) 2 << 30) | ((uint32_t) c->payload << 16) | ((uint32_t) c->sequence));
@@ -112,7 +113,7 @@ int pa_rtp_send(pa_rtp_context *c, size_t size, pa_memblockq *q) {
m.msg_name = NULL;
m.msg_namelen = 0;
m.msg_iov = iov;
- m.msg_iovlen = iov_idx;
+ m.msg_iovlen = (size_t) iov_idx;
m.msg_control = NULL;
m.msg_controllen = 0;
m.msg_flags = 0;
@@ -128,7 +129,7 @@ int pa_rtp_send(pa_rtp_context *c, size_t size, pa_memblockq *q) {
} else
k = 0;
- c->timestamp += n/c->frame_size;
+ c->timestamp += (unsigned) (n/c->frame_size);
if (k < 0) {
if (errno != EAGAIN && errno != EINTR) /* If the queue is full, just ignore it */
@@ -162,7 +163,7 @@ int pa_rtp_recv(pa_rtp_context *c, pa_memchunk *chunk, pa_mempool *pool) {
struct msghdr m;
struct iovec iov;
uint32_t header;
- int cc;
+ unsigned cc;
ssize_t r;
pa_assert(c);
@@ -197,7 +198,7 @@ int pa_rtp_recv(pa_rtp_context *c, pa_memchunk *chunk, pa_mempool *pool) {
chunk->index = c->memchunk.index;
iov.iov_base = (uint8_t*) pa_memblock_acquire(chunk->memblock) + chunk->index;
- iov.iov_len = size;
+ iov.iov_len = (size_t) size;
m.msg_name = NULL;
m.msg_namelen = 0;
@@ -246,16 +247,16 @@ int pa_rtp_recv(pa_rtp_context *c, pa_memchunk *chunk, pa_mempool *pool) {
}
cc = (header >> 24) & 0xF;
- c->payload = (header >> 16) & 127;
- c->sequence = header & 0xFFFF;
+ c->payload = (uint8_t) ((header >> 16) & 127U);
+ c->sequence = (uint16_t) (header & 0xFFFFU);
- if (12 + cc*4 > size) {
+ if (12 + cc*4 > (unsigned) size) {
pa_log_warn("RTP packet too short. (CSRC)");
goto fail;
}
chunk->index += 12 + cc*4;
- chunk->length = size - 12 + cc*4;
+ chunk->length = (size_t) size - 12 + cc*4;
if (chunk->length % c->frame_size != 0) {
pa_log_warn("Bad RTP packet size.");
diff --git a/src/modules/rtp/sap.c b/src/modules/rtp/sap.c
index 5d9b58fa..b0c95aa5 100644
--- a/src/modules/rtp/sap.c
+++ b/src/modules/rtp/sap.c
@@ -76,7 +76,7 @@ int pa_sap_send(pa_sap_context *c, pa_bool_t goodbye) {
socklen_t salen = sizeof(sa_buf);
struct iovec iov[4];
struct msghdr m;
- int k;
+ ssize_t k;
if (getsockname(c->fd, sa, &salen) < 0) {
pa_log("getsockname() failed: %s\n", pa_cstrerror(errno));
@@ -94,7 +94,7 @@ int pa_sap_send(pa_sap_context *c, pa_bool_t goodbye) {
iov[0].iov_len = sizeof(header);
iov[1].iov_base = sa->sa_family == AF_INET ? (void*) &((struct sockaddr_in*) sa)->sin_addr : (void*) &((struct sockaddr_in6*) sa)->sin6_addr;
- iov[1].iov_len = sa->sa_family == AF_INET ? 4 : 16;
+ iov[1].iov_len = sa->sa_family == AF_INET ? 4U : 16U;
iov[2].iov_base = (char*) MIME_TYPE;
iov[2].iov_len = sizeof(MIME_TYPE);
@@ -113,7 +113,7 @@ int pa_sap_send(pa_sap_context *c, pa_bool_t goodbye) {
if ((k = sendmsg(c->fd, &m, MSG_DONTWAIT)) < 0)
pa_log_warn("sendmsg() failed: %s\n", pa_cstrerror(errno));
- return k;
+ return (int) k;
}
pa_sap_context* pa_sap_context_init_recv(pa_sap_context *c, int fd) {
@@ -128,10 +128,10 @@ pa_sap_context* pa_sap_context_init_recv(pa_sap_context *c, int fd) {
int pa_sap_recv(pa_sap_context *c, pa_bool_t *goodbye) {
struct msghdr m;
struct iovec iov;
- int size, k;
+ int size;
char *buf = NULL, *e;
uint32_t header;
- int six, ac;
+ unsigned six, ac, k;
ssize_t r;
pa_assert(c);
@@ -142,11 +142,11 @@ int pa_sap_recv(pa_sap_context *c, pa_bool_t *goodbye) {
goto fail;
}
- buf = pa_xnew(char, size+1);
+ buf = pa_xnew(char, (unsigned) size+1);
buf[size] = 0;
iov.iov_base = buf;
- iov.iov_len = size;
+ iov.iov_len = (size_t) size;
m.msg_name = NULL;
m.msg_namelen = 0;
@@ -184,21 +184,21 @@ int pa_sap_recv(pa_sap_context *c, pa_bool_t *goodbye) {
goto fail;
}
- six = (header >> 28) & 1;
- ac = (header >> 16) & 0xFF;
+ six = (header >> 28) & 1U;
+ ac = (header >> 16) & 0xFFU;
- k = 4 + (six ? 16 : 4) + ac*4;
- if (size < k) {
+ k = 4 + (six ? 16U : 4U) + ac*4U;
+ if ((unsigned) size < k) {
pa_log_warn("SAP packet too short (AD).");
goto fail;
}
e = buf + k;
- size -= k;
+ size -= (int) k;
if ((unsigned) size >= sizeof(MIME_TYPE) && !strcmp(e, MIME_TYPE)) {
e += sizeof(MIME_TYPE);
- size -= sizeof(MIME_TYPE);
+ size -= (int) sizeof(MIME_TYPE);
} else if ((unsigned) size < sizeof(PA_SDP_HEADER)-1 || strncmp(e, PA_SDP_HEADER, sizeof(PA_SDP_HEADER)-1)) {
pa_log_warn("Invalid SDP header.");
goto fail;
@@ -207,7 +207,7 @@ int pa_sap_recv(pa_sap_context *c, pa_bool_t *goodbye) {
if (c->sdp_data)
pa_xfree(c->sdp_data);
- c->sdp_data = pa_xstrndup(e, size);
+ c->sdp_data = pa_xstrndup(e, (unsigned) size);
pa_xfree(buf);
*goodbye = !!((header >> 26) & 1);
diff --git a/src/modules/rtp/sdp.c b/src/modules/rtp/sdp.c
index cef90433..59989e1a 100644
--- a/src/modules/rtp/sdp.c
+++ b/src/modules/rtp/sdp.c
@@ -55,7 +55,7 @@ char *pa_sdp_build(int af, const void *src, const void *dst, const char *name, u
if (!(u = pa_get_user_name(un, sizeof(un))))
u = "-";
- ntp = time(NULL) + 2208988800U;
+ ntp = (uint32_t) time(NULL) + 2208988800U;
pa_assert_se(a = inet_ntop(af, src, buf_src, sizeof(buf_src)));
pa_assert_se(a = inet_ntop(af, dst, buf_dst, sizeof(buf_dst)));
@@ -99,10 +99,10 @@ static pa_sample_spec *parse_sdp_sample_spec(pa_sample_spec *ss, char *c) {
return NULL;
if (sscanf(c, "%u/%u", &rate, &channels) == 2) {
- ss->rate = rate;
- ss->channels = channels;
+ ss->rate = (uint32_t) rate;
+ ss->channels = (uint8_t) channels;
} else if (sscanf(c, "%u", &rate) == 2) {
- ss->rate = rate;
+ ss->rate = (uint32_t) rate;
ss->channels = 1;
} else
return NULL;