fi
dnl Compiler flags
-DESIRED_FLAGS="-Wall -W -Wextra -pedantic -pipe -Wformat -Wold-style-definition -Wdeclaration-after-statement -Wfloat-equal -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wmissing-noreturn -Wshadow -Wendif-labels -Wpointer-arith -Wcast-align -Wwrite-strings -Winline -Wno-unused-parameter -ffast-math"
+DESIRED_FLAGS="-Wall -W -Wextra -pedantic -pipe -Wno-long-long -Wvla -Wno-overlength-strings -Wconversion -Wundef -Wformat -Wlogical-op -Wpacked -Wformat-security -Wmissing-include-dirs -Wformat-nonliteral -Wold-style-definition -Wdeclaration-after-statement -Wfloat-equal -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wmissing-noreturn -Wshadow -Wendif-labels -Wpointer-arith -Wcast-align -Wwrite-strings -Winline -Wno-unused-parameter -ffast-math"
for flag in $DESIRED_FLAGS ; do
CC_CHECK_CFLAGS([$flag], [CFLAGS="$CFLAGS $flag"])
n = ru.ru_utime.tv_sec + ru.ru_stime.tv_sec + t;
pa_assert_se(getrlimit(RLIMIT_CPU, &rl) >= 0);
- rl.rlim_cur = n;
+ rl.rlim_cur = (rlim_t) n;
pa_assert_se(setrlimit(RLIMIT_CPU, &rl) >= 0);
}
write_err(t);
#endif
- if (CPUTIME_INTERVAL_SOFT >= ((now-last_time)*(double)CPUTIME_PERCENT/100)) {
+ if ((double) CPUTIME_INTERVAL_SOFT >= ((double) (now-last_time)*(double)CPUTIME_PERCENT/100)) {
static const char c = 'X';
write_err("Soft CPU time limit exhausted, terminating.\n");
static int parse_sample_rate(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, void *userdata) {
pa_daemon_conf *c = data;
- int32_t r;
+ uint32_t r;
pa_assert(filename);
pa_assert(lvalue);
pa_assert(rvalue);
pa_assert(data);
- if (pa_atoi(rvalue, &r) < 0 || r > (int32_t) PA_RATE_MAX || r <= 0) {
+ if (pa_atou(rvalue, &r) < 0 || r > (uint32_t) PA_RATE_MAX || r <= 0) {
pa_log(_("[%s:%u] Invalid sample rate '%s'."), filename, line, rvalue);
return -1;
}
#include <config.h>
#endif
-#if HAVE_DLFCN_H
+#ifdef HAVE_DLFCN_H
#include <dlfcn.h>
#endif
-#if HAVE_SYS_DL_H
+#ifdef HAVE_SYS_DL_H
#include <sys/dl.h>
#endif
#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;
pa_defer_event *defer;
pa_io_event **ios;
- int polled;
+ pa_bool_t polled;
void (*cb)(void *userdata);
void *userdata;
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);
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;
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);
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)
return;
}
- fdl->polled = 0;
+ fdl->polled = FALSE;
if (memcmp(fdl->fds, fdl->work_fds, sizeof(struct pollfd) * num_fds) == 0)
return;
fdl->m = NULL;
fdl->defer = NULL;
fdl->ios = NULL;
- fdl->polled = 0;
+ fdl->polled = FALSE;
return 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);
}
/* 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);
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;
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);
}
}
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);
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
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;
}
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;
}
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;
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);
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;
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;
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); */
* 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;
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); */
if (frames >= (snd_pcm_uframes_t) n)
break;
- n -= frames;
+ n -= (snd_pcm_sframes_t) frames;
}
}
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;
/* 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);
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); */
/* now1 = pa_timeval_load(×tamp); */
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);
}
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;
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);
}
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;
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;
}
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));
}
}
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)
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));
}
}
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;
}
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.");
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 ||
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;
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;
}
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);
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;
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;
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); */
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;
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;
}
}
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;
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;
/* 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);
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);
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);
}
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;
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);
}
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));
}
}
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)
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));
}
}
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 ||
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;
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;
}
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);
/* 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 */
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
{
pa_assert(name);
key.dptr = name;
- key.dsize = strlen(name);
+ key.dsize = (int) strlen(name);
data = gdbm_fetch(u->gdbm_file, key);
}
key.dptr = name;
- key.dsize = strlen(name);
+ key.dsize = (int) strlen(name);
data.dptr = (void*) &entry;
data.dsize = sizeof(entry);
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);
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;
} 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);
}
#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;
}
/* 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)
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) {
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)
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;
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);
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));
}
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
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);
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;
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;
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;
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;
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);
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;
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) {
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
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) {
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:
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;
}
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);
}
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); */
}
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); */
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);
}
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)
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;
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;
}
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);
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);
} 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);
}
while (l > 0) {
- ssize_t t, k;
+ ssize_t t;
+ size_t k;
pa_assert(l > 0);
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;
} else {
memchunk.index = 0;
- memchunk.length = t;
+ memchunk.length = (size_t) t;
pa_source_post(u->source, &memchunk);
pa_memblock_unref(memchunk.memblock);
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 */
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");
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);
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;
}
} 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);
}
/* 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;
} 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);
}
/* 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;
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)
/* 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;
}
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) {
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);
pa_assert(name);
key.dptr = name;
- key.dsize = strlen(name);
+ key.dsize = (int) strlen(name);
data = gdbm_fetch(u->gdbm_file, key);
}
key.dptr = name;
- key.dsize = strlen(name);
+ key.dsize = (int) strlen(name);
data.dptr = (void*) &entry;
data.dsize = sizeof(entry);
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))) {
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);
goto fail;
key.dptr = (void*) name;
- key.dsize = strlen(name);
+ key.dsize = (int) strlen(name);
gdbm_delete(u->gdbm_file, key);
}
#ifdef TUNNEL_SINK
char *sink_name;
pa_sink *sink;
- int32_t requested_bytes;
+ size_t requested_bytes;
#else
char *source_name;
pa_source *source;
u->requested_bytes -= memchunk.length;
- u->counter += memchunk.length;
+ u->counter += (int64_t) memchunk.length;
}
}
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;
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;
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;
}
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;
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;
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;
/* 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 */
/* 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
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
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
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);
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);
}
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;
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;
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) {
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;
/* 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;
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));
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;
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;
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)
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;
} 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);
}
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;
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;
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 {
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;
}
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;
}
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);
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);
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));
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;
} 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 */
struct msghdr m;
struct iovec iov;
uint32_t header;
- int cc;
+ unsigned cc;
ssize_t r;
pa_assert(c);
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;
}
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.");
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));
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);
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) {
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);
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;
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;
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);
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)));
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;
pa_channel_map_init(m);
- m->channels = channels;
+ m->channels = (uint8_t) channels;
switch (def) {
case PA_CHANNEL_MAP_AIFF:
i++;
}
- m->channels = channels;
+ m->channels = (uint8_t) channels;
return m;
}
char* pa_channel_map_snprint(char *s, size_t l, const pa_channel_map *map) {
unsigned channel;
- int first = 1;
+ pa_bool_t first = TRUE;
char *e;
pa_assert(s);
pa_channel_position_to_string(map->map[channel]));
e = strchr(e, 0);
- first = 0;
+ first = FALSE;
}
return s;
err = PA_ERR_UNKNOWN;
if (fail) {
- pa_context_fail(c, err);
+ pa_context_fail(c, (int) err);
return -1;
}
- pa_context_set_error(c, err);
+ pa_context_set_error(c, (int) err);
return 0;
}
pa_assert(a);
pa_assert(e);
pa_assert(fd >= 0);
- pa_assert(events = PA_IO_EVENT_INPUT);
+ pa_assert(events == PA_IO_EVENT_INPUT);
pa_assert(c);
pa_assert(e == c->autospawn_event);
pa_assert(fd == c->autospawn_fd);
}
static gushort map_flags_to_glib(pa_io_event_flags_t flags) {
- return
- (flags & PA_IO_EVENT_INPUT ? G_IO_IN : 0) |
- (flags & PA_IO_EVENT_OUTPUT ? G_IO_OUT : 0) |
- (flags & PA_IO_EVENT_ERROR ? G_IO_ERR : 0) |
- (flags & PA_IO_EVENT_HANGUP ? G_IO_HUP : 0);
+ return (gushort)
+ ((flags & PA_IO_EVENT_INPUT ? G_IO_IN : 0) |
+ (flags & PA_IO_EVENT_OUTPUT ? G_IO_OUT : 0) |
+ (flags & PA_IO_EVENT_ERROR ? G_IO_ERR : 0) |
+ (flags & PA_IO_EVENT_HANGUP ? G_IO_HUP : 0));
}
static pa_io_event_flags_t map_flags_from_glib(gushort flags) {
uint32_t version;
uint32_t ctag;
uint32_t csyncid;
- uint32_t error;
+ int error;
pa_context_state_t state;
pa_context_notify_cb_t state_callback;
struct pa_io_event {
pa_mainloop *mainloop;
- int dead;
+ pa_bool_t dead:1;
int fd;
pa_io_event_flags_t events;
struct pa_time_event {
pa_mainloop *mainloop;
- int dead;
+ pa_bool_t dead:1;
- int enabled;
+ pa_bool_t enabled:1;
struct timeval timeval;
pa_time_event_cb_t callback;
struct pa_defer_event {
pa_mainloop *mainloop;
- int dead;
+ pa_bool_t dead:1;
- int enabled;
+ pa_bool_t enabled:1;
pa_defer_event_cb_t callback;
void *userdata;
PA_LLIST_HEAD(pa_time_event, time_events);
PA_LLIST_HEAD(pa_defer_event, defer_events);
- int n_enabled_defer_events, n_enabled_time_events, n_io_events;
- int io_events_please_scan, time_events_please_scan, defer_events_please_scan;
+ unsigned n_enabled_defer_events, n_enabled_time_events, n_io_events;
+ unsigned io_events_please_scan, time_events_please_scan, defer_events_please_scan;
+ pa_bool_t rebuild_pollfds:1;
struct pollfd *pollfds;
unsigned max_pollfds, n_pollfds;
- int rebuild_pollfds;
int prepared_timeout;
pa_time_event *cached_next_time_event;
- int quit, retval;
pa_mainloop_api api;
+ int retval;
+ pa_bool_t quit:1;
+
+ pa_bool_t wakeup_requested:1;
int wakeup_pipe[2];
int wakeup_pipe_type;
- int wakeup_requested;
enum {
STATE_PASSIVE,
};
static short map_flags_to_libc(pa_io_event_flags_t flags) {
- return
- (flags & PA_IO_EVENT_INPUT ? POLLIN : 0) |
- (flags & PA_IO_EVENT_OUTPUT ? POLLOUT : 0) |
- (flags & PA_IO_EVENT_ERROR ? POLLERR : 0) |
- (flags & PA_IO_EVENT_HANGUP ? POLLHUP : 0);
+ return (short)
+ ((flags & PA_IO_EVENT_INPUT ? POLLIN : 0) |
+ (flags & PA_IO_EVENT_OUTPUT ? POLLOUT : 0) |
+ (flags & PA_IO_EVENT_ERROR ? POLLERR : 0) |
+ (flags & PA_IO_EVENT_HANGUP ? POLLHUP : 0));
}
static pa_io_event_flags_t map_flags_from_libc(short flags) {
e = pa_xnew(pa_io_event, 1);
e->mainloop = m;
- e->dead = 0;
+ e->dead = FALSE;
e->fd = fd;
e->events = events;
SELECT_TYPE_ARG5 &tv) == -1) &&
(WSAGetLastError() == WSAENOTSOCK)) {
pa_log_warn("Cannot monitor non-socket file descriptors.");
- e->dead = 1;
+ e->dead = TRUE;
}
}
#endif
PA_LLIST_PREPEND(pa_io_event, m->io_events, e);
- m->rebuild_pollfds = 1;
+ m->rebuild_pollfds = TRUE;
m->n_io_events ++;
pa_mainloop_wakeup(m);
if (e->pollfd)
e->pollfd->events = map_flags_to_libc(events);
else
- e->mainloop->rebuild_pollfds = 1;
+ e->mainloop->rebuild_pollfds = TRUE;
pa_mainloop_wakeup(e->mainloop);
}
pa_assert(e);
pa_assert(!e->dead);
- e->dead = 1;
+ e->dead = TRUE;
e->mainloop->io_events_please_scan ++;
e->mainloop->n_io_events --;
- e->mainloop->rebuild_pollfds = 1;
+ e->mainloop->rebuild_pollfds = TRUE;
pa_mainloop_wakeup(e->mainloop);
}
e = pa_xnew(pa_defer_event, 1);
e->mainloop = m;
- e->dead = 0;
+ e->dead = FALSE;
- e->enabled = 1;
+ e->enabled = TRUE;
m->n_enabled_defer_events++;
e->callback = callback;
pa_assert(e);
pa_assert(!e->dead);
- e->dead = 1;
+ e->dead = TRUE;
e->mainloop->defer_events_please_scan ++;
if (e->enabled) {
pa_assert(e->mainloop->n_enabled_defer_events > 0);
e->mainloop->n_enabled_defer_events--;
- e->enabled = 0;
+ e->enabled = FALSE;
}
}
e = pa_xnew(pa_time_event, 1);
e->mainloop = m;
- e->dead = 0;
+ e->dead = FALSE;
if ((e->enabled = !!tv)) {
e->timeval = *tv;
pa_assert(e);
pa_assert(!e->dead);
- e->dead = 1;
+ e->dead = TRUE;
e->mainloop->time_events_please_scan ++;
if (e->enabled) {
pa_assert(e->mainloop->n_enabled_time_events > 0);
e->mainloop->n_enabled_time_events--;
- e->enabled = 0;
+ e->enabled = FALSE;
}
if (e->mainloop->cached_next_time_event == e)
pa_make_fd_nonblock(m->wakeup_pipe[1]);
pa_make_fd_cloexec(m->wakeup_pipe[0]);
pa_make_fd_cloexec(m->wakeup_pipe[1]);
- m->wakeup_requested = 0;
+ m->wakeup_requested = FALSE;
PA_LLIST_HEAD_INIT(pa_io_event, m->io_events);
PA_LLIST_HEAD_INIT(pa_time_event, m->time_events);
m->pollfds = NULL;
m->max_pollfds = m->n_pollfds = 0;
- m->rebuild_pollfds = 1;
+ m->rebuild_pollfds = TRUE;
- m->quit = m->retval = 0;
+ m->quit = FALSE;
+ m->retval = 0;
m->api = vtable;
m->api.userdata = m;
return m;
}
-static void cleanup_io_events(pa_mainloop *m, int force) {
+static void cleanup_io_events(pa_mainloop *m, pa_bool_t force) {
pa_io_event *e;
e = m->io_events;
pa_xfree(e);
- m->rebuild_pollfds = 1;
+ m->rebuild_pollfds = TRUE;
}
e = n;
pa_assert(m->io_events_please_scan == 0);
}
-static void cleanup_time_events(pa_mainloop *m, int force) {
+static void cleanup_time_events(pa_mainloop *m, pa_bool_t force) {
pa_time_event *e;
e = m->time_events;
if (!e->dead && e->enabled) {
pa_assert(m->n_enabled_time_events > 0);
m->n_enabled_time_events--;
- e->enabled = 0;
+ e->enabled = FALSE;
}
if (e->destroy_callback)
pa_assert(m->time_events_please_scan == 0);
}
-static void cleanup_defer_events(pa_mainloop *m, int force) {
+static void cleanup_defer_events(pa_mainloop *m, pa_bool_t force) {
pa_defer_event *e;
e = m->defer_events;
if (!e->dead && e->enabled) {
pa_assert(m->n_enabled_defer_events > 0);
m->n_enabled_defer_events--;
- e->enabled = 0;
+ e->enabled = FALSE;
}
if (e->destroy_callback)
void pa_mainloop_free(pa_mainloop* m) {
pa_assert(m);
- cleanup_io_events(m, 1);
- cleanup_defer_events(m, 1);
- cleanup_time_events(m, 1);
+ cleanup_io_events(m, TRUE);
+ cleanup_defer_events(m, TRUE);
+ cleanup_time_events(m, TRUE);
pa_xfree(m->pollfds);
pa_assert(m);
if (m->io_events_please_scan)
- cleanup_io_events(m, 0);
+ cleanup_io_events(m, FALSE);
if (m->time_events_please_scan)
- cleanup_time_events(m, 0);
+ cleanup_time_events(m, FALSE);
if (m->defer_events_please_scan)
- cleanup_defer_events(m, 0);
+ cleanup_defer_events(m, FALSE);
}
static void rebuild_pollfds(pa_mainloop *m) {
m->n_pollfds++;
}
- m->rebuild_pollfds = 0;
+ m->rebuild_pollfds = FALSE;
}
static int dispatch_pollfds(pa_mainloop *m) {
void pa_mainloop_quit(pa_mainloop *m, int retval) {
pa_assert(m);
- m->quit = 1;
+ m->quit = TRUE;
m->retval = retval;
pa_mainloop_wakeup(m);
}
char *c;
pa_assert_se(pa_proplist_get(p, key, &value, &nbytes) == 0);
- c = pa_xnew(char, nbytes*2+1);
+ c = pa_xmalloc(nbytes*2+1);
pa_hexstr((const uint8_t*) value, nbytes, c, nbytes*2+1);
pa_strbuf_printf(buf, "%s = hex:%s\n", key, c);
PA_CHECK_VALIDITY(s->context, s->state == PA_STREAM_UNCONNECTED, PA_ERR_BADSTATE);
PA_CHECK_VALIDITY(s->context, length > 0, PA_ERR_INVALID);
+ PA_CHECK_VALIDITY(s->context, length == (size_t) (uint32_t) length, PA_ERR_INVALID);
if (!(name = pa_proplist_gets(s->proplist, PA_PROP_EVENT_ID)))
name = pa_proplist_gets(s->proplist, PA_PROP_MEDIA_NAME);
pa_tagstruct_puts(t, name);
pa_tagstruct_put_sample_spec(t, &s->sample_spec);
pa_tagstruct_put_channel_map(t, &s->channel_map);
- pa_tagstruct_putu32(t, length);
+ pa_tagstruct_putu32(t, (uint32_t) length);
if (s->context->version >= 13) {
pa_init_proplist(s->proplist);
* what older PA versions provided. */
s->buffer_attr.maxlength = (uint32_t) -1;
- s->buffer_attr.tlength = pa_usec_to_bytes(250*PA_USEC_PER_MSEC, ss); /* 250ms of buffering */
+ s->buffer_attr.tlength = (uint32_t) pa_usec_to_bytes(250*PA_USEC_PER_MSEC, ss); /* 250ms of buffering */
s->buffer_attr.minreq = (uint32_t) -1;
s->buffer_attr.prebuf = (uint32_t) -1;
s->buffer_attr.fragsize = (uint32_t) -1;
if (s->flags & PA_STREAM_AUTO_TIMING_UPDATE) {
struct timeval tv;
pa_gettimeofday(&tv);
- tv.tv_usec += LATENCY_IPOL_INTERVAL_USEC; /* every 100 ms */
+ tv.tv_usec += (suseconds_t) LATENCY_IPOL_INTERVAL_USEC; /* every 100 ms */
pa_assert(!s->auto_timing_update_event);
s->auto_timing_update_event = s->mainloop->time_new(s->mainloop, &tv, &auto_timing_update_callback, s);
attr->maxlength = 4*1024*1024; /* 4MB is the maximum queue length PulseAudio <= 0.9.9 supported. */
if (attr->tlength == (uint32_t) -1)
- attr->tlength = pa_usec_to_bytes(250*PA_USEC_PER_MSEC, ss); /* 250ms of buffering */
+ attr->tlength = (uint32_t) pa_usec_to_bytes(250*PA_USEC_PER_MSEC, ss); /* 250ms of buffering */
if (attr->minreq == (uint32_t) -1)
attr->minreq = (attr->tlength)/5; /* Ask for more data when there are only 200ms left in the playback buffer */
t = pa_tagstruct_command(
s->context,
- s->direction == PA_STREAM_PLAYBACK ? PA_COMMAND_CREATE_PLAYBACK_STREAM : PA_COMMAND_CREATE_RECORD_STREAM,
+ (uint32_t) (s->direction == PA_STREAM_PLAYBACK ? PA_COMMAND_CREATE_PLAYBACK_STREAM : PA_COMMAND_CREATE_RECORD_STREAM),
&tag);
if (s->context->version < 13)
free_cb((void*) data);
if (length < s->requested_bytes)
- s->requested_bytes -= length;
+ s->requested_bytes -= (uint32_t) length;
else
s->requested_bytes = 0;
if (seek == PA_SEEK_ABSOLUTE) {
s->write_index_corrections[s->current_write_index_correction].corrupt = FALSE;
s->write_index_corrections[s->current_write_index_correction].absolute = TRUE;
- s->write_index_corrections[s->current_write_index_correction].value = offset + length;
+ s->write_index_corrections[s->current_write_index_correction].value = offset + (int64_t) length;
} else if (seek == PA_SEEK_RELATIVE) {
if (!s->write_index_corrections[s->current_write_index_correction].corrupt)
- s->write_index_corrections[s->current_write_index_correction].value += offset + length;
+ s->write_index_corrections[s->current_write_index_correction].value += offset + (int64_t) length;
} else
s->write_index_corrections[s->current_write_index_correction].corrupt = TRUE;
}
if (seek == PA_SEEK_ABSOLUTE) {
s->timing_info.write_index_corrupt = FALSE;
- s->timing_info.write_index = offset + length;
+ s->timing_info.write_index = offset + (int64_t) length;
} else if (seek == PA_SEEK_RELATIVE) {
if (!s->timing_info.write_index_corrupt)
- s->timing_info.write_index += offset + length;
+ s->timing_info.write_index += offset + (int64_t) length;
} else
s->timing_info.write_index_corrupt = TRUE;
}
/* Fix the simulated local read index */
if (s->timing_info_valid && !s->timing_info.read_index_corrupt)
- s->timing_info.read_index += s->peek_memchunk.length;
+ s->timing_info.read_index += (int64_t) s->peek_memchunk.length;
pa_assert(s->peek_data);
pa_memblock_release(s->peek_memchunk.memblock);
i->read_index_corrupt = FALSE;
i->playing = (int) playing;
- i->since_underrun = playing ? playing_for : underrun_for;
+ i->since_underrun = (int64_t) (playing ? playing_for : underrun_for);
pa_gettimeofday(&now);
/* Read index correction */
if (!i->read_index_corrupt)
- i->read_index -= pa_memblockq_get_length(o->stream->record_memblockq);
+ i->read_index -= (int64_t) pa_memblockq_get_length(o->stream->record_memblockq);
}
/* Update smoother */
* speakers. Since we follow that timing here, we need
* to try to fix this up */
- su = pa_bytes_to_usec(i->since_underrun, &o->stream->sample_spec);
+ su = pa_bytes_to_usec((uint64_t) i->since_underrun, &o->stream->sample_spec);
if (su < i->sink_usec)
x += i->sink_usec - su;
t = pa_tagstruct_command(
s->context,
- s->direction == PA_STREAM_PLAYBACK ? PA_COMMAND_GET_PLAYBACK_LATENCY : PA_COMMAND_GET_RECORD_LATENCY,
+ (uint32_t) (s->direction == PA_STREAM_PLAYBACK ? PA_COMMAND_GET_PLAYBACK_LATENCY : PA_COMMAND_GET_RECORD_LATENCY),
&tag);
pa_tagstruct_putu32(t, s->channel);
pa_tagstruct_put_timeval(t, pa_gettimeofday(&now));
t = pa_tagstruct_command(
s->context,
- s->direction == PA_STREAM_PLAYBACK ? PA_COMMAND_DELETE_PLAYBACK_STREAM :
- (s->direction == PA_STREAM_RECORD ? PA_COMMAND_DELETE_RECORD_STREAM : PA_COMMAND_DELETE_UPLOAD_STREAM),
+ (uint32_t) (s->direction == PA_STREAM_PLAYBACK ? PA_COMMAND_DELETE_PLAYBACK_STREAM :
+ (s->direction == PA_STREAM_RECORD ? PA_COMMAND_DELETE_RECORD_STREAM : PA_COMMAND_DELETE_UPLOAD_STREAM)),
&tag);
pa_tagstruct_putu32(t, s->channel);
pa_pstream_send_tagstruct(s->context->pstream, t);
t = pa_tagstruct_command(
s->context,
- s->direction == PA_STREAM_PLAYBACK ? PA_COMMAND_CORK_PLAYBACK_STREAM : PA_COMMAND_CORK_RECORD_STREAM,
+ (uint32_t) (s->direction == PA_STREAM_PLAYBACK ? PA_COMMAND_CORK_PLAYBACK_STREAM : PA_COMMAND_CORK_RECORD_STREAM),
&tag);
pa_tagstruct_putu32(t, s->channel);
pa_tagstruct_put_boolean(t, !!b);
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE);
PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->direction != PA_STREAM_UPLOAD, PA_ERR_BADSTATE);
- if (!(o = stream_send_simple_command(s, s->direction == PA_STREAM_PLAYBACK ? PA_COMMAND_FLUSH_PLAYBACK_STREAM : PA_COMMAND_FLUSH_RECORD_STREAM, cb, userdata)))
+ if (!(o = stream_send_simple_command(s, (uint32_t) (s->direction == PA_STREAM_PLAYBACK ? PA_COMMAND_FLUSH_PLAYBACK_STREAM : PA_COMMAND_FLUSH_RECORD_STREAM), cb, userdata)))
return NULL;
if (s->direction == PA_STREAM_PLAYBACK) {
o = pa_operation_new(s->context, s, (pa_operation_cb_t) cb, userdata);
t = pa_tagstruct_command(
s->context,
- s->direction == PA_STREAM_RECORD ? PA_COMMAND_SET_RECORD_STREAM_NAME : PA_COMMAND_SET_PLAYBACK_STREAM_NAME,
+ (uint32_t) (s->direction == PA_STREAM_RECORD ? PA_COMMAND_SET_RECORD_STREAM_NAME : PA_COMMAND_SET_PLAYBACK_STREAM_NAME),
&tag);
pa_tagstruct_putu32(t, s->channel);
pa_tagstruct_puts(t, name);
if (cindex < 0)
cindex = 0;
- c = pa_bytes_to_usec(cindex, &s->sample_spec);
+ c = pa_bytes_to_usec((uint64_t) cindex, &s->sample_spec);
if (s->direction == PA_STREAM_PLAYBACK)
*r_usec = time_counter_diff(s, c, t, negative);
t = pa_tagstruct_command(
s->context,
- s->direction == PA_STREAM_RECORD ? PA_COMMAND_SET_RECORD_STREAM_BUFFER_ATTR : PA_COMMAND_SET_PLAYBACK_STREAM_BUFFER_ATTR,
+ (uint32_t) (s->direction == PA_STREAM_RECORD ? PA_COMMAND_SET_RECORD_STREAM_BUFFER_ATTR : PA_COMMAND_SET_PLAYBACK_STREAM_BUFFER_ATTR),
&tag);
pa_tagstruct_putu32(t, s->channel);
t = pa_tagstruct_command(
s->context,
- s->direction == PA_STREAM_RECORD ? PA_COMMAND_UPDATE_RECORD_STREAM_SAMPLE_RATE : PA_COMMAND_UPDATE_PLAYBACK_STREAM_SAMPLE_RATE,
+ (uint32_t) (s->direction == PA_STREAM_RECORD ? PA_COMMAND_UPDATE_RECORD_STREAM_SAMPLE_RATE : PA_COMMAND_UPDATE_PLAYBACK_STREAM_SAMPLE_RATE),
&tag);
pa_tagstruct_putu32(t, s->channel);
pa_tagstruct_putu32(t, rate);
t = pa_tagstruct_command(
s->context,
- s->direction == PA_STREAM_RECORD ? PA_COMMAND_UPDATE_RECORD_STREAM_PROPLIST : PA_COMMAND_UPDATE_PLAYBACK_STREAM_PROPLIST,
+ (uint32_t) (s->direction == PA_STREAM_RECORD ? PA_COMMAND_UPDATE_RECORD_STREAM_PROPLIST : PA_COMMAND_UPDATE_PLAYBACK_STREAM_PROPLIST),
&tag);
pa_tagstruct_putu32(t, s->channel);
pa_tagstruct_putu32(t, (uint32_t) mode);
t = pa_tagstruct_command(
s->context,
- s->direction == PA_STREAM_RECORD ? PA_COMMAND_REMOVE_RECORD_STREAM_PROPLIST : PA_COMMAND_REMOVE_PLAYBACK_STREAM_PROPLIST,
+ (uint32_t) (s->direction == PA_STREAM_RECORD ? PA_COMMAND_REMOVE_RECORD_STREAM_PROPLIST : PA_COMMAND_REMOVE_PLAYBACK_STREAM_PROPLIST),
&tag);
pa_tagstruct_putu32(t, s->channel);
}
/* Calculate the second difference*/
- r = ((pa_usec_t) a->tv_sec - b->tv_sec) * PA_USEC_PER_SEC;
+ r = ((pa_usec_t) a->tv_sec - (pa_usec_t) b->tv_sec) * PA_USEC_PER_SEC;
/* Calculate the microsecond difference */
if (a->tv_usec > b->tv_usec)
- r += ((pa_usec_t) a->tv_usec - b->tv_usec);
+ r += ((pa_usec_t) a->tv_usec - (pa_usec_t) b->tv_usec);
else if (a->tv_usec < b->tv_usec)
- r -= ((pa_usec_t) b->tv_usec - a->tv_usec);
+ r -= ((pa_usec_t) b->tv_usec - (pa_usec_t) a->tv_usec);
return r;
}
pa_assert(tv);
secs = (unsigned long) (v/PA_USEC_PER_SEC);
- tv->tv_sec += secs;
+ tv->tv_sec += (time_t) secs;
v -= ((pa_usec_t) secs) * PA_USEC_PER_SEC;
tv->tv_usec += (suseconds_t) v;
/* Normalize */
while ((unsigned) tv->tv_usec >= PA_USEC_PER_SEC) {
tv->tv_sec++;
- tv->tv_usec -= PA_USEC_PER_SEC;
+ tv->tv_usec -= (suseconds_t) PA_USEC_PER_SEC;
}
return tv;
pa_assert(tv);
secs = (unsigned long) (v/PA_USEC_PER_SEC);
- tv->tv_sec -= secs;
+ tv->tv_sec -= (time_t) secs;
v -= ((pa_usec_t) secs) * PA_USEC_PER_SEC;
if (tv->tv_usec >= (suseconds_t) v)
tv->tv_usec -= (suseconds_t) v;
else {
tv->tv_sec --;
- tv->tv_usec = tv->tv_usec + PA_USEC_PER_SEC - v;
+ tv->tv_usec += (suseconds_t) (PA_USEC_PER_SEC - v);
}
return tv;
struct timeval* pa_timeval_store(struct timeval *tv, pa_usec_t v) {
pa_assert(tv);
- tv->tv_sec = v / PA_USEC_PER_SEC;
- tv->tv_usec = v % PA_USEC_PER_SEC;
+ tv->tv_sec = (time_t) (v / PA_USEC_PER_SEC);
+ tv->tv_usec = (suseconds_t) (v % PA_USEC_PER_SEC);
return tv;
}
if ((*p & 0xe0) == 0xc0) { /* 110xxxxx two-char seq. */
size = 2;
min = 128;
- val = *p & 0x1e;
+ val = (uint32_t) (*p & 0x1e);
goto ONE_REMAINING;
} else if ((*p & 0xf0) == 0xe0) { /* 1110xxxx three-char seq.*/
size = 3;
min = (1 << 11);
- val = *p & 0x0f;
+ val = (uint32_t) (*p & 0x0f);
goto TWO_REMAINING;
} else if ((*p & 0xf8) == 0xf0) { /* 11110xxx four-char seq */
size = 4;
min = (1 << 16);
- val = *p & 0x07;
+ val = (uint32_t) (*p & 0x07);
} else {
size = 1;
goto error;
goto error;
if (o) {
- memcpy(o, last, size);
+ memcpy(o, last, (size_t) size);
o += size - 1;
}
char *new_str;
pa_assert(str);
- new_str = pa_xnew(char, strlen(str) + 1);
+ new_str = pa_xmalloc(strlen(str) + 1);
return utf8_validate(str, new_str);
}
return NULL;
inlen = len = strlen(str) + 1;
- new_str = pa_xnew(char, len);
+ new_str = pa_xmalloc(len);
for (;;) {
inbuf = (ICONV_CONST char*) str; /* Brain dead prototype for iconv() */
#elif defined(HAVE_NANOSLEEP)
struct timespec ts;
- ts.tv_sec = t/1000UL;
- ts.tv_nsec = (t % 1000UL) * 1000000UL;
+ ts.tv_sec = (time_t) (t/1000UL);
+ ts.tv_nsec = (long) ((t % 1000UL) * 1000000UL);
return nanosleep(&ts, NULL);
#else
pa_assert(channels > 0);
pa_assert(channels <= PA_CHANNELS_MAX);
- a->channels = channels;
+ a->channels = (uint8_t) channels;
for (i = 0; i < a->channels; i++)
a->values[i] = v;
i < b->channels ? b->values[i] : PA_VOLUME_NORM);
}
- dest->channels = i;
+ dest->channels = (uint8_t) i;
return dest;
}
return NULL;
if ((e = memchr(s, 0, l)))
- return pa_xmemdup(s, e-s+1);
+ return pa_xmemdup(s, (size_t) (e-s+1));
r = pa_xmalloc(l+1);
memcpy(r, s, l);
#define PA_ASYNCQ_CELLS(x) ((pa_atomic_ptr_t*) ((uint8_t*) (x) + PA_ALIGN(sizeof(struct pa_asyncq))))
-static int reduce(pa_asyncq *l, int value) {
+static unsigned reduce(pa_asyncq *l, unsigned value) {
return value & (unsigned) (l->size - 1);
}
}
static int push(pa_asyncq*l, void *p, pa_bool_t wait) {
- int idx;
+ unsigned idx;
pa_atomic_ptr_t *cells;
pa_assert(l);
}
void* pa_asyncq_pop(pa_asyncq*l, pa_bool_t wait) {
- int idx;
+ unsigned idx;
void *ret;
pa_atomic_ptr_t *cells;
}
int pa_asyncq_read_before_poll(pa_asyncq *l) {
- int idx;
+ unsigned idx;
pa_atomic_ptr_t *cells;
pa_assert(l);
if (pa_fdsem_before_poll(l->write_fdsem) >= 0)
return 0;
}
-
- return 0;
}
void pa_asyncq_read_after_poll(pa_asyncq *l) {
pa_strbuf_printf(buf, "Memory blocks currently allocated: %u, size: %s.\n",
(unsigned) pa_atomic_load(&stat->n_allocated),
- pa_bytes_snprint(s, sizeof(s), (size_t) pa_atomic_load(&stat->allocated_size)));
+ pa_bytes_snprint(s, sizeof(s), (unsigned) pa_atomic_load(&stat->allocated_size)));
pa_strbuf_printf(buf, "Memory blocks allocated during the whole lifetime: %u, size: %s.\n",
(unsigned) pa_atomic_load(&stat->n_accumulated),
- pa_bytes_snprint(s, sizeof(s), (size_t) pa_atomic_load(&stat->accumulated_size)));
+ pa_bytes_snprint(s, sizeof(s), (unsigned) pa_atomic_load(&stat->accumulated_size)));
pa_strbuf_printf(buf, "Memory blocks imported from other processes: %u, size: %s.\n",
(unsigned) pa_atomic_load(&stat->n_imported),
- pa_bytes_snprint(s, sizeof(s), (size_t) pa_atomic_load(&stat->imported_size)));
+ pa_bytes_snprint(s, sizeof(s), (unsigned) pa_atomic_load(&stat->imported_size)));
pa_strbuf_printf(buf, "Memory blocks exported to other processes: %u, size: %s.\n",
(unsigned) pa_atomic_load(&stat->n_exported),
- pa_bytes_snprint(s, sizeof(s), (size_t) pa_atomic_load(&stat->exported_size)));
+ pa_bytes_snprint(s, sizeof(s), (unsigned) pa_atomic_load(&stat->exported_size)));
pa_strbuf_printf(buf, "Total sample cache size: %s.\n",
- pa_bytes_snprint(s, sizeof(s), pa_scache_total_size(c)));
+ pa_bytes_snprint(s, sizeof(s), (unsigned) pa_scache_total_size(c)));
pa_strbuf_printf(buf, "Default sample spec: %s\n",
pa_sample_spec_snprint(s, sizeof(s), &c->default_sample_spec));
state_table[pa_sink_get_state(sink)],
pa_cvolume_snprint(cv, sizeof(cv), pa_sink_get_volume(sink, FALSE)),
pa_yes_no(pa_sink_get_mute(sink, FALSE)),
- (double) pa_sink_get_latency(sink) / PA_USEC_PER_MSEC,
- (double) pa_sink_get_requested_latency(sink) / PA_USEC_PER_MSEC, (double) min_latency / PA_USEC_PER_MSEC, (double) max_latency / PA_USEC_PER_MSEC,
+ (double) pa_sink_get_latency(sink) / (double) PA_USEC_PER_MSEC,
+ (double) pa_sink_get_requested_latency(sink) / (double) PA_USEC_PER_MSEC,
+ (double) min_latency / PA_USEC_PER_MSEC,
+ (double) max_latency / PA_USEC_PER_MSEC,
(unsigned long) pa_sink_get_max_request(sink) / 1024,
(unsigned long) pa_sink_get_max_rewind(sink) / 1024,
sink->monitor_source ? sink->monitor_source->index : PA_INVALID_INDEX,
pa_cvolume_snprint(cv, sizeof(cv), pa_source_get_volume(source, FALSE)),
pa_yes_no(pa_source_get_mute(source, FALSE)),
(double) pa_source_get_latency(source) / PA_USEC_PER_MSEC,
- (double) pa_source_get_requested_latency(source) / PA_USEC_PER_MSEC, (double) min_latency / PA_USEC_PER_MSEC, (double) max_latency / PA_USEC_PER_MSEC,
+ (double) pa_source_get_requested_latency(source) / PA_USEC_PER_MSEC,
+ (double) min_latency / PA_USEC_PER_MSEC,
+ (double) max_latency / PA_USEC_PER_MSEC,
(unsigned long) pa_source_get_max_rewind(source) / 1024,
pa_sample_spec_snprint(ss, sizeof(ss), &source->sample_spec),
pa_channel_map_snprint(cm, sizeof(cm), &source->channel_map),
if (e->memchunk.memblock) {
pa_sample_spec_snprint(ss, sizeof(ss), &e->sample_spec);
pa_channel_map_snprint(cm, sizeof(cm), &e->channel_map);
- l = (double) e->memchunk.length / pa_bytes_per_second(&e->sample_spec);
+ l = (double) e->memchunk.length / (double) pa_bytes_per_second(&e->sample_spec);
}
pa_strbuf_printf(
ret += r;
data = (uint8_t*) data + r;
- size -= r;
+ size -= (size_t) r;
}
return ret;
ret += r;
data = (const uint8_t*) data + r;
- size -= r;
+ size -= (size_t) r;
}
return ret;
/* The following function is based on an example from the GNU libc
* documentation. This function is similar to GNU's asprintf(). */
char *pa_sprintf_malloc(const char *format, ...) {
- int size = 100;
+ size_t size = 100;
char *c = NULL;
pa_assert(format);
c[size-1] = 0;
- if (r > -1 && r < size)
+ if (r > -1 && (size_t) r < size)
return c;
if (r > -1) /* glibc 2.1 */
- size = r+1;
+ size = (size_t) r+1;
else /* glibc 2.0 */
size *= 2;
}
/* Same as the previous function, but use a va_list instead of an
* ellipsis */
char *pa_vsprintf_malloc(const char *format, va_list ap) {
- int size = 100;
+ size_t size = 100;
char *c = NULL;
pa_assert(format);
c[size-1] = 0;
- if (r > -1 && r < size)
+ if (r > -1 && (size_t) r < size)
return c;
if (r > -1) /* glibc 2.1 */
- size = r+1;
+ size = (size_t) r+1;
else /* glibc 2.0 */
size *= 2;
}
if (n < 0)
n = 512;
- data = pa_xmalloc(n);
+ data = pa_xmalloc((size_t) n);
errno = 0;
- if (getgrgid_r(gid, &group, data, n, &result) < 0 || !result) {
+ if (getgrgid_r(gid, &group, data, (size_t) n, &result) < 0 || !result) {
pa_log("getgrgid_r(%u): %s", (unsigned) gid, pa_cstrerror(errno));
if (!errno)
/* Check the current user is member of the specified group */
int pa_own_uid_in_group(const char *name, gid_t *gid) {
GETGROUPS_T *gids, tgid;
- int n = sysconf(_SC_NGROUPS_MAX);
+ long n = sysconf(_SC_NGROUPS_MAX);
int r = -1, i, k;
pa_assert(n > 0);
- gids = pa_xmalloc(sizeof(GETGROUPS_T)*n);
+ gids = pa_xmalloc(sizeof(GETGROUPS_T) * (size_t) n);
- if ((n = getgroups(n, gids)) < 0) {
+ if ((n = getgroups((int) n, gids)) < 0) {
pa_log("getgroups(): %s", pa_cstrerror(errno));
goto finish;
}
int r = -1;
g_n = sysconf(_SC_GETGR_R_SIZE_MAX);
- g_buf = pa_xmalloc(g_n);
+ g_buf = pa_xmalloc((size_t) g_n);
p_n = sysconf(_SC_GETPW_R_SIZE_MAX);
- p_buf = pa_xmalloc(p_n);
+ p_buf = pa_xmalloc((size_t) p_n);
errno = 0;
if (getgrnam_r(name, &grbuf, g_buf, (size_t) g_n, &gr) != 0 || !gr) {
struct group grbuf, *gr;
g_n = sysconf(_SC_GETGR_R_SIZE_MAX);
- g_buf = pa_xmalloc(g_n);
+ g_buf = pa_xmalloc((size_t) g_n);
errno = 0;
if (getgrnam_r(name, &grbuf, g_buf, (size_t) g_n, &gr) != 0 || !gr) {
/* Try a R/W lock first */
- flock.l_type = b ? F_WRLCK : F_UNLCK;
+ flock.l_type = (short) (b ? F_WRLCK : F_UNLCK);
flock.l_whence = SEEK_SET;
flock.l_start = 0;
flock.l_len = 0;
/* If PULSE_STATE_PATH and PULSE_RUNTIME_PATH point to the same
* dir then this will break. */
- if (pa_make_secure_dir(d, 0700, (pid_t) -1, (pid_t) -1) < 0) {
+ if (pa_make_secure_dir(d, 0700U, (uid_t) -1, (gid_t) -1) < 0) {
pa_log_error("Failed to create secure directory: %s", pa_cstrerror(errno));
pa_xfree(d);
return NULL;
if ((d = getenv("PULSE_RUNTIME_PATH"))) {
mode_t m;
- m = pa_in_system_mode() ? 0755 : 0700;
+ m = pa_in_system_mode() ? 0755U : 0700U;
- if (pa_make_secure_dir(d, m, (pid_t) -1, (pid_t) -1) < 0) {
+ if (pa_make_secure_dir(d, m, (uid_t) -1, (gid_t) -1) < 0) {
pa_log_error("Failed to create secure directory: %s", pa_cstrerror(errno));
goto fail;
}
}
/* Same as snprintf, but guarantees NUL-termination on every platform */
-int pa_snprintf(char *str, size_t size, const char *format, ...) {
- int ret;
+size_t pa_snprintf(char *str, size_t size, const char *format, ...) {
+ size_t ret;
va_list ap;
pa_assert(str);
}
/* Same as vsnprintf, but guarantees NUL-termination on every platform */
-int pa_vsnprintf(char *str, size_t size, const char *format, va_list ap) {
+size_t pa_vsnprintf(char *str, size_t size, const char *format, va_list ap) {
int ret;
pa_assert(str);
str[size-1] = 0;
if (ret < 0)
- ret = strlen(str);
+ return strlen(str);
+
+ if ((size_t) ret > size-1)
+ return size-1;
- return PA_MIN((int) size-1, ret);
+ return (size_t) ret;
}
/* Truncate the specified string, but guarantee that the string
size_t l = 128;
for (;;) {
- char *p = pa_xnew(char, l);
+ char *p = pa_xmalloc(l);
if (getcwd(p, l))
return p;
pa_assert(l > 0);
a = PA_PAGE_ALIGN_PTR(p);
- size = (const uint8_t*) p + l - (const uint8_t*) a;
+ size = (size_t) ((const uint8_t*) p + l - (const uint8_t*) a);
#ifdef HAVE_POSIX_MADVISE
if ((r = posix_madvise((void*) a, size, POSIX_MADV_WILLNEED)) == 0) {
char *c;
ssize_t n;
- c = pa_xnew(char, l);
+ c = pa_xmalloc(l);
if ((n = readlink(p, c, l-1)) < 0) {
pa_xfree(c);
int pa_close_all(int except_fd, ...) {
va_list ap;
- int n = 0, i, r;
- int *p;
+ unsigned n = 0, i;
+ int r, *p;
va_start(ap, except_fd);
int pa_unblock_sigs(int except, ...) {
va_list ap;
- int n = 0, i, r;
- int *p;
+ unsigned n = 0, i;
+ int r, *p;
va_start(ap, except);
int pa_reset_sigs(int except, ...) {
va_list ap;
- int n = 0, i, r;
- int *p;
+ unsigned n = 0, i;
+ int *p, r;
va_start(ap, except);
for (;;) {
char *c;
- c = pa_xnew(char, l);
+ c = pa_xmalloc(l);
if (!pa_get_host_name(c, l)) {
int pa_atou(const char *s, uint32_t *ret_u);
int pa_atod(const char *s, double *ret_d);
-int pa_snprintf(char *str, size_t size, const char *format, ...);
-int pa_vsnprintf(char *str, size_t size, const char *format, va_list ap);
+size_t pa_snprintf(char *str, size_t size, const char *format, ...);
+size_t pa_vsnprintf(char *str, size_t size, const char *format, va_list ap);
char *pa_truncate_utf8(char *c, size_t l);
}
static int32_t linear_interpolate_int(pa_usec_t x1, int32_t _y1, pa_usec_t x2, int32_t y2, pa_usec_t x3) {
- return (int32_t) (_y1 + (x3 - x1) * (float) (y2 - _y1) / (float) (x2 - x1));
+ return (int32_t) ((double) _y1 + (double) (x3 - x1) * (double) (y2 - _y1) / (double) (x2 - x1));
}
static float linear_interpolate_float(pa_usec_t x1, float _y1, pa_usec_t x2, float y2, pa_usec_t x3) {
- return _y1 + (x3 - x1) * (y2 - _y1) / (x2 - x1);
+ return _y1 + ((float) x3 - (float) x1) * (y2 - _y1) / ((float) x2 - (float) x1);
}
static int32_t item_get_int(pa_envelope_item *i, pa_usec_t x) {
if (!e->points[v].cached_valid) {
e->points[v].cached_dy_dx =
(e->points[v].y.f[e->points[v].n_current+1] - e->points[v].y.f[e->points[v].n_current]) /
- (e->points[v].x[e->points[v].n_current+1] - e->points[v].x[e->points[v].n_current]);
+ ((float) e->points[v].x[e->points[v].n_current+1] - (float) e->points[v].x[e->points[v].n_current]);
e->points[v].cached_valid = TRUE;
}
- return e->points[v].y.f[e->points[v].n_current] + (e->x - e->points[v].x[e->points[v].n_current]) * e->points[v].cached_dy_dx;
+ return e->points[v].y.f[e->points[v].n_current] + (float) (e->x - e->points[v].x[e->points[v].n_current]) * e->points[v].cached_dy_dx;
}
void pa_envelope_apply(pa_envelope *e, pa_memchunk *chunk) {
uint8_t *t;
for (t = p; n > 0; n -= fs) {
- int16_t factor = linear_get_int(e, v);
+ int32_t factor = linear_get_int(e, v);
unsigned c;
e->x += fs;
uint8_t *t;
for (t = p; n > 0; n -= fs) {
- int16_t factor = linear_get_int(e, v);
+ int32_t factor = linear_get_int(e, v);
unsigned c;
e->x += fs;
for (c = 0; c < e->sample_spec.channels; c++, t++) {
int16_t k = st_ulaw2linear16(*t);
- *t = (uint8_t) st_14linear2ulaw(((factor * k) / 0x10000) >> 2);
+ *t = (uint8_t) st_14linear2ulaw((int16_t) (((factor * k) / 0x10000) >> 2));
}
}
uint8_t *t;
for (t = p; n > 0; n -= fs) {
- int16_t factor = linear_get_int(e, v);
+ int32_t factor = linear_get_int(e, v);
unsigned c;
e->x += fs;
for (c = 0; c < e->sample_spec.channels; c++, t++) {
int16_t k = st_alaw2linear16(*t);
- *t = (uint8_t) st_13linear2alaw(((factor * k) / 0x10000) >> 3);
+ *t = (uint8_t) st_13linear2alaw((int16_t) (((factor * k) / 0x10000) >> 3));
}
}
e->x += fs;
for (c = 0; c < e->sample_spec.channels; c++, t++)
- *t = (factor * *t) / 0x10000;
+ *t = (int16_t) ((factor * *t) / 0x10000);
}
break;
e->x += fs;
for (c = 0; c < e->sample_spec.channels; c++, t++) {
- int16_t r = (factor * PA_INT16_SWAP(*t)) / 0x10000;
+ int16_t r = (int16_t) ((factor * PA_INT16_SWAP(*t)) / 0x10000);
*t = PA_INT16_SWAP(r);
}
}
continue;
}
- } while (pa_atomic_sub(&f->data->in_pipe, r) > r);
+ } while (pa_atomic_sub(&f->data->in_pipe, (int) r) > (int) r);
}
void pa_fdsem_post(pa_fdsem *f) {
continue;
}
- pa_atomic_sub(&f->data->in_pipe, r);
+ pa_atomic_sub(&f->data->in_pipe, (int) r);
}
pa_assert_se(pa_atomic_dec(&f->data->waiting) >= 1);
const char *c;
for (c = p; *c; c++)
- hash = 31 * hash + *c;
+ hash = 31 * hash + (unsigned) *c;
return hash;
}
/* In case the allocated buffer is too small, enlarge it. */
if (l->wbuf_valid_length + len > l->wbuf_length) {
size_t n = l->wbuf_valid_length+len;
- char *new = pa_xnew(char, n);
+ char *new = pa_xnew(char, (unsigned) n);
if (l->wbuf) {
memcpy(new, l->wbuf+l->wbuf_index, l->wbuf_valid_length);
memmove(l->rbuf, l->rbuf+l->rbuf_index, l->rbuf_valid_length);
} else {
/* Enlarge the buffer */
- char *new = pa_xnew(char, n);
+ char *new = pa_xnew(char, (unsigned) n);
if (l->rbuf_valid_length)
memcpy(new, l->rbuf+l->rbuf_index, l->rbuf_valid_length);
pa_xfree(l->rbuf);
return -1;
}
- l->rbuf_valid_length += r;
+ l->rbuf_valid_length += (size_t) r;
/* Look if a line has been terminated in the newly read data */
- scan_for_lines(l, l->rbuf_valid_length - r);
+ scan_for_lines(l, l->rbuf_valid_length - (size_t) r);
}
return 0;
return -1;
}
- l->wbuf_index += r;
- l->wbuf_valid_length -= r;
+ l->wbuf_index += (size_t) r;
+ l->wbuf_valid_length -= (size_t) r;
/* A shortcut for the next time */
if (l->wbuf_valid_length == 0)
if (e.bits < 128) {
int t = 0, i;
- for (i = 0, bits = e.bits; i < 16; i++) {
+ for (i = 0, bits = (uint32_t) e.bits; i < 16; i++) {
if (bits >= 8)
bits -= 8;
pa_assert(b->pool);
pa_atomic_inc(&b->pool->stat.n_allocated);
- pa_atomic_add(&b->pool->stat.allocated_size, b->length);
+ pa_atomic_add(&b->pool->stat.allocated_size, (int) b->length);
pa_atomic_inc(&b->pool->stat.n_accumulated);
- pa_atomic_add(&b->pool->stat.accumulated_size, b->length);
+ pa_atomic_add(&b->pool->stat.accumulated_size, (int) b->length);
if (b->type == PA_MEMBLOCK_IMPORTED) {
pa_atomic_inc(&b->pool->stat.n_imported);
- pa_atomic_add(&b->pool->stat.imported_size, b->length);
+ pa_atomic_add(&b->pool->stat.imported_size, (int) b->length);
}
pa_atomic_inc(&b->pool->stat.n_allocated_by_type[b->type]);
pa_assert(pa_atomic_load(&b->pool->stat.allocated_size) >= (int) b->length);
pa_atomic_dec(&b->pool->stat.n_allocated);
- pa_atomic_sub(&b->pool->stat.allocated_size, b->length);
+ pa_atomic_sub(&b->pool->stat.allocated_size, (int) b->length);
if (b->type == PA_MEMBLOCK_IMPORTED) {
pa_assert(pa_atomic_load(&b->pool->stat.n_imported) > 0);
pa_assert(pa_atomic_load(&b->pool->stat.imported_size) >= (int) b->length);
pa_atomic_dec(&b->pool->stat.n_imported);
- pa_atomic_sub(&b->pool->stat.imported_size, b->length);
+ pa_atomic_sub(&b->pool->stat.imported_size, (int) b->length);
}
pa_atomic_dec(&b->pool->stat.n_allocated_by_type[b->type]);
if ((unsigned) (idx = pa_atomic_inc(&p->n_init)) >= p->n_blocks)
pa_atomic_dec(&p->n_init);
else
- slot = (struct mempool_slot*) ((uint8_t*) p->memory.ptr + (p->block_size * idx));
+ slot = (struct mempool_slot*) ((uint8_t*) p->memory.ptr + (p->block_size * (size_t) idx));
if (!slot) {
pa_log_info("Pool full");
pa_assert((uint8_t*) ptr >= (uint8_t*) p->memory.ptr);
pa_assert((uint8_t*) ptr < (uint8_t*) p->memory.ptr + p->memory.size);
- return ((uint8_t*) ptr - (uint8_t*) p->memory.ptr) / p->block_size;
+ return (unsigned) ((size_t) ((uint8_t*) ptr - (uint8_t*) p->memory.ptr) / p->block_size);
}
/* No lock necessary */
pa_assert(pa_atomic_load(&b->pool->stat.n_imported) > 0);
pa_assert(pa_atomic_load(&b->pool->stat.imported_size) >= (int) b->length);
pa_atomic_dec(&b->pool->stat.n_imported);
- pa_atomic_sub(&b->pool->stat.imported_size, b->length);
+ pa_atomic_sub(&b->pool->stat.imported_size, (int) b->length);
seg = b->per_type.imported.segment;
pa_assert(seg);
;
while ((slot = pa_flist_pop(list))) {
- pa_shm_punch(&p->memory, (uint8_t*) slot - (uint8_t*) p->memory.ptr, p->block_size);
+ pa_shm_punch(&p->memory, (size_t) ((uint8_t*) slot - (uint8_t*) p->memory.ptr), p->block_size);
while (pa_flist_push(p->free_slots, slot))
;
pa_mutex_lock(e->mutex);
while (e->used_slots)
- pa_memexport_process_release(e, e->used_slots - e->slots);
+ pa_memexport_process_release(e, (uint32_t) (e->used_slots - e->slots));
pa_mutex_unlock(e->mutex);
pa_mutex_lock(e->pool->mutex);
pa_assert(pa_atomic_load(&e->pool->stat.exported_size) >= (int) b->length);
pa_atomic_dec(&e->pool->stat.n_exported);
- pa_atomic_sub(&e->pool->stat.exported_size, b->length);
+ pa_atomic_sub(&e->pool->stat.exported_size, (int) b->length);
pa_memblock_unref(b);
slot->block->per_type.imported.segment->import != i)
continue;
- idx = slot - e->slots;
+ idx = (uint32_t) (slot - e->slots);
e->revoke_cb(e, idx, e->userdata);
pa_memexport_process_release(e, idx);
}
PA_LLIST_PREPEND(struct memexport_slot, e->used_slots, slot);
slot->block = b;
- *block_id = slot - e->slots;
+ *block_id = (uint32_t) (slot - e->slots);
pa_mutex_unlock(e->mutex);
/* pa_log("Got block id %u", *block_id); */
pa_assert((uint8_t*) data + b->length <= (uint8_t*) memory->ptr + memory->size);
*shm_id = memory->id;
- *offset = (uint8_t*) data - (uint8_t*) memory->ptr;
+ *offset = (size_t) ((uint8_t*) data - (uint8_t*) memory->ptr);
*size = b->length;
pa_memblock_release(b);
pa_atomic_inc(&e->pool->stat.n_exported);
- pa_atomic_add(&e->pool->stat.exported_size, b->length);
+ pa_atomic_add(&e->pool->stat.exported_size, (int) b->length);
return 0;
}
pa_log_debug("memblockq requested: maxlength=%lu, tlength=%lu, base=%lu, prebuf=%lu, minreq=%lu maxrewind=%lu",
(unsigned long) maxlength, (unsigned long) tlength, (unsigned long) base, (unsigned long) prebuf, (unsigned long) minreq, (unsigned long) maxrewind);
- bq->missing = bq->requested = bq->maxlength = bq->tlength = bq->prebuf = bq->minreq = bq->maxrewind = 0;
+ bq->missing = 0;
+ bq->requested = bq->maxlength = bq->tlength = bq->prebuf = bq->minreq = bq->maxrewind = 0;
bq->in_prebuf = TRUE;
pa_memblockq_set_maxlength(bq, maxlength);
int64_t boundary;
pa_assert(bq);
- boundary = bq->read_index - bq->maxrewind;
+ boundary = bq->read_index - (int64_t) bq->maxrewind;
while (bq->blocks && (bq->blocks->index + (int64_t) bq->blocks->chunk.length <= boundary))
drop_block(bq, bq->blocks);
pa_assert(bq);
if (bq->read_index > bq->write_index) {
- size_t d = bq->read_index - bq->write_index;
+ int64_t d = bq->read_index - bq->write_index;
- if (l > d)
- l -= d;
+ if ((int64_t) l > d)
+ l -= (size_t) d;
else
return TRUE;
}
/* Make sure that the list doesn't get too long */
if (bq->write_index + (int64_t) l > end)
- if (bq->write_index + l - bq->read_index > bq->maxlength)
+ if (bq->write_index + (int64_t) l - bq->read_index > (int64_t) bq->maxlength)
return FALSE;
return TRUE;
/* This entry isn't touched at all, let's skip it */
q = q->prev;
} else if (bq->write_index <= q->index &&
- bq->write_index + chunk.length >= q->index + q->chunk.length) {
+ bq->write_index + (int64_t) chunk.length >= q->index + (int64_t) q->chunk.length) {
/* This entry is fully replaced by the new entry, so let's drop it */
/* The write index points into this memblock, so let's
* truncate or split it */
- if (bq->write_index + chunk.length < q->index + q->chunk.length) {
+ if (bq->write_index + (int64_t) chunk.length < q->index + (int64_t) q->chunk.length) {
/* We need to save the end of this memchunk */
struct list_item *p;
pa_memblock_ref(p->chunk.memblock);
/* Calculate offset */
- d = bq->write_index + chunk.length - q->index;
+ d = (size_t) (bq->write_index + (int64_t) chunk.length - q->index);
pa_assert(d > 0);
/* Drop it from the new entry */
- p->index = q->index + d;
+ p->index = q->index + (int64_t) d;
p->chunk.length -= d;
/* Add it to the list */
}
/* Truncate the chunk */
- if (!(q->chunk.length = bq->write_index - q->index)) {
+ if (!(q->chunk.length = (size_t) (bq->write_index - q->index))) {
struct list_item *p;
p = q;
q = q->prev;
/* The job overwrites the current entry at the end, so let's drop the beginning of this entry */
- d = bq->write_index + chunk.length - q->index;
- q->index += d;
+ d = (size_t) (bq->write_index + (int64_t) chunk.length - q->index);
+ q->index += (int64_t) d;
q->chunk.index += d;
q->chunk.length -= d;
/* Try to merge memory blocks */
if (q->chunk.memblock == chunk.memblock &&
- q->chunk.index + (int64_t)q->chunk.length == chunk.index &&
- bq->write_index == q->index + (int64_t)q->chunk.length) {
+ q->chunk.index + q->chunk.length == chunk.index &&
+ bq->write_index == q->index + (int64_t) q->chunk.length) {
q->chunk.length += chunk.length;
- bq->write_index += chunk.length;
+ bq->write_index += (int64_t) chunk.length;
goto finish;
}
} else
n->chunk = chunk;
pa_memblock_ref(n->chunk.memblock);
n->index = bq->write_index;
- bq->write_index += n->chunk.length;
+ bq->write_index += (int64_t) n->chunk.length;
n->next = q ? q->next : bq->blocks;
n->prev = q;
delta = bq->write_index - old;
if (delta >= (int64_t) bq->requested) {
- delta -= bq->requested;
+ delta -= (int64_t) bq->requested;
bq->requested = 0;
} else {
- bq->requested -= delta;
+ bq->requested -= (size_t) delta;
delta = 0;
}
/* How much silence shall we return? */
if (bq->current_read)
- length = bq->current_read->index - bq->read_index;
+ length = (size_t) (bq->current_read->index - bq->read_index);
else if (bq->write_index > bq->read_index)
length = (size_t) (bq->write_index - bq->read_index);
else
pa_assert(bq->read_index >= bq->current_read->index);
d = bq->read_index - bq->current_read->index;
- chunk->index += d;
- chunk->length -= d;
+ chunk->index += (size_t) d;
+ chunk->length -= (size_t) d;
return 0;
}
/* We go through this piece by piece to make sure we don't
* drop more than allowed by prebuf */
- p = bq->current_read->index + bq->current_read->chunk.length;
+ p = bq->current_read->index + (int64_t) bq->current_read->chunk.length;
pa_assert(p >= bq->read_index);
d = p - bq->read_index;
if (d > (int64_t) length)
- d = length;
+ d = (int64_t) length;
bq->read_index += d;
- length -= d;
+ length -= (size_t) d;
} else {
/* The list is empty, there's nothing we could drop */
- bq->read_index += length;
+ bq->read_index += (int64_t) length;
break;
}
}
/* This is kind of the inverse of pa_memblockq_drop() */
- bq->read_index -= length;
- bq->missing -= length;
+ bq->read_index -= (int64_t) length;
+ bq->missing -= (int64_t) length;
}
pa_bool_t pa_memblockq_is_readable(pa_memblockq *bq) {
delta = bq->write_index - old;
if (delta >= (int64_t) bq->requested) {
- delta -= bq->requested;
+ delta -= (int64_t) bq->requested;
bq->requested = 0;
} else if (delta >= 0) {
- bq->requested -= delta;
+ bq->requested -= (size_t) delta;
delta = 0;
}
delta = bq->write_index - old;
if (delta >= (int64_t) bq->requested) {
- delta -= bq->requested;
+ delta -= (int64_t) bq->requested;
bq->requested = 0;
} else if (delta >= 0) {
- bq->requested -= delta;
+ bq->requested -= (size_t) delta;
delta = 0;
}
pa_memblock_unref(chunk.memblock);
} else
- pa_memblockq_seek(bq, chunk.length, PA_SEEK_RELATIVE);
+ pa_memblockq_seek(bq, (int64_t) chunk.length, PA_SEEK_RELATIVE);
pa_memblockq_drop(bq, chunk.length);
}
void *data;
};
-static int is_valid_char(char c) {
+static pa_bool_t is_valid_char(char c) {
return
(c >= 'a' && c <= 'z') ||
(c >= 'A' && c <= 'Z') ||
if (*name == 0)
return NULL;
- n = pa_xnew(char, strlen(name)+1);
+ n = pa_xmalloc(strlen(name)+1);
for (a = name, b = n; *a && (a-name < PA_NAME_MAX); a++, b++)
- *b = is_valid_char(*a) ? *a : '_';
+ *b = (char) (is_valid_char(*a) ? *a : '_');
*b = 0;
return NULL;
}
- k = pa_xnew(char, l+4);
+ k = pa_xmalloc(l+4);
for (i = 2; i <= 99; i++) {
pa_snprintf(k, l+4, "%s.%u", name, i);
if (!(e = strchr(s+1, ']')))
return NULL;
- if (e[1] == ':')
- *ret_port = atoi(e+2);
- else if (e[1] != 0)
+ if (e[1] == ':') {
+ uint32_t p;
+
+ if (pa_atou(e+2, &p) < 0)
+ return NULL;
+
+ *ret_port = (uint16_t) p;
+ } else if (e[1] != 0)
return NULL;
- return pa_xstrndup(s+1, e-s-1);
+ return pa_xstrndup(s+1, (size_t) (e-s-1));
} else {
char *e;
+ uint32_t p;
if (!(e = strrchr(s, ':')))
return pa_xstrdup(s);
- *ret_port = atoi(e+1);
- return pa_xstrndup(s, e-s);
+ if (pa_atou(e+1, &p) < 0)
+ return NULL;
+
+ *ret_port = (uint16_t) p;
+ return pa_xstrndup(s, (size_t) (e-s));
}
}
return !!good;
}
-#endif
+#else
return 1;
+#endif
+
}
/* Create a new PID file for the current process. */
{ sizeof(int), esd_proto_sample_free_or_play, "sample play" }, /* 8 */
{ sizeof(int), NULL, "sample loop" },
{ sizeof(int), NULL, "sample stop" },
- { -1, NULL, "TODO: sample kill" },
+ { (size_t) -1, NULL, "TODO: sample kill" },
{ ESD_KEY_LEN + sizeof(int), esd_proto_standby_or_resume, "standby" }, /* NOOP! */
{ ESD_KEY_LEN + sizeof(int), esd_proto_standby_or_resume, "resume" }, /* NOOP! */ /* 13 */
{ sizeof(int), esd_proto_server_info, "server info" },
{ sizeof(int), esd_proto_all_info, "all info" },
- { -1, NULL, "TODO: subscribe" },
- { -1, NULL, "TODO: unsubscribe" },
+ { (size_t) -1, NULL, "TODO: subscribe" },
+ { (size_t) -1, NULL, "TODO: unsubscribe" },
{ 3 * sizeof(int), esd_proto_stream_pan, "stream pan"},
{ 3 * sizeof(int), NULL, "sample pan" },
static void format_esd2native(int format, pa_bool_t swap_bytes, pa_sample_spec *ss) {
pa_assert(ss);
- ss->channels = ((format & ESD_MASK_CHAN) == ESD_STEREO) ? 2 : 1;
+ ss->channels = (uint8_t) (((format & ESD_MASK_CHAN) == ESD_STEREO) ? 2 : 1);
if ((format & ESD_MASK_BITS) == ESD_BITS16)
ss->format = swap_bytes ? PA_SAMPLE_S16RE : PA_SAMPLE_S16NE;
else
rate = PA_MAYBE_INT32_SWAP(c->swap_byte_order, rate);
data = (const char*) data + sizeof(int32_t);
- ss.rate = rate;
+ ss.rate = (uint32_t) rate;
format_esd2native(format, c->swap_byte_order, &ss);
CHECK_VALIDITY(pa_sample_spec_valid(&ss), "Invalid sample specification");
CHECK_VALIDITY(c->sink_input, "Failed to create sink input.");
- l = (size_t) (pa_bytes_per_second(&ss)*PLAYBACK_BUFFER_SECONDS);
+ l = (size_t) ((double) pa_bytes_per_second(&ss)*PLAYBACK_BUFFER_SECONDS);
c->input_memblockq = pa_memblockq_new(
0,
l,
c->protocol->n_player++;
- pa_atomic_store(&c->playback.missing, pa_memblockq_missing(c->input_memblockq));
+ pa_atomic_store(&c->playback.missing, (int) pa_memblockq_missing(c->input_memblockq));
pa_sink_input_put(c->sink_input);
rate = PA_MAYBE_INT32_SWAP(c->swap_byte_order, rate);
data = (const char*) data + sizeof(int32_t);
- ss.rate = rate;
+ ss.rate = (uint32_t) rate;
format_esd2native(format, c->swap_byte_order, &ss);
CHECK_VALIDITY(pa_sample_spec_valid(&ss), "Invalid sample specification.");
if (!(sink = pa_namereg_get(c->protocol->core, c->options->default_sink, PA_NAMEREG_SINK, 1)))
latency = 0;
else {
- double usec = pa_sink_get_latency(sink);
+ double usec = (double) pa_sink_get_latency(sink);
latency = (int) ((usec*44100)/1000000);
}
pa_assert(length == sizeof(int32_t));
if ((sink = pa_namereg_get(c->protocol->core, c->options->default_sink, PA_NAMEREG_SINK, 1))) {
- rate = sink->sample_spec.rate;
+ rate = (int32_t) sink->sample_spec.rate;
format = format_native2esd(&sink->sample_spec);
}
if (conn->sink_input) {
pa_cvolume volume = *pa_sink_input_get_volume(conn->sink_input);
- rate = conn->sink_input->sample_spec.rate;
- lvolume = (volume.values[0]*ESD_VOLUME_BASE)/PA_VOLUME_NORM;
- rvolume = (volume.values[1]*ESD_VOLUME_BASE)/PA_VOLUME_NORM;
+ rate = (int32_t) conn->sink_input->sample_spec.rate;
+ lvolume = (int32_t) ((volume.values[0]*ESD_VOLUME_BASE)/PA_VOLUME_NORM);
+ rvolume = (int32_t) ((volume.values[1]*ESD_VOLUME_BASE)/PA_VOLUME_NORM);
format = format_native2esd(&conn->sink_input->sample_spec);
}
connection_write(c, name, ESD_NAME_MAX);
/* rate */
- rate = PA_MAYBE_UINT32_SWAP(c->swap_byte_order, ce->sample_spec.rate);
+ rate = PA_MAYBE_INT32_SWAP(c->swap_byte_order, (int32_t) ce->sample_spec.rate);
connection_write(c, &rate, sizeof(int32_t));
/* left */
- lvolume = PA_MAYBE_UINT32_SWAP(c->swap_byte_order, (ce->volume.values[0]*ESD_VOLUME_BASE)/PA_VOLUME_NORM);
+ lvolume = PA_MAYBE_INT32_SWAP(c->swap_byte_order, (int32_t) ((ce->volume.values[0]*ESD_VOLUME_BASE)/PA_VOLUME_NORM));
connection_write(c, &lvolume, sizeof(int32_t));
/*right*/
- rvolume = PA_MAYBE_UINT32_SWAP(c->swap_byte_order, (ce->volume.values[0]*ESD_VOLUME_BASE)/PA_VOLUME_NORM);
+ rvolume = PA_MAYBE_INT32_SWAP(c->swap_byte_order, (int32_t) ((ce->volume.values[0]*ESD_VOLUME_BASE)/PA_VOLUME_NORM));
connection_write(c, &rvolume, sizeof(int32_t));
/*format*/
rate = PA_MAYBE_INT32_SWAP(c->swap_byte_order, rate);
data = (const char*)data + sizeof(int32_t);
- ss.rate = rate;
+ ss.rate = (uint32_t) rate;
format_esd2native(format, c->swap_byte_order, &ss);
CHECK_VALIDITY(pa_sample_spec_valid(&ss), "Invalid sample specification.");
CHECK_VALIDITY(pa_utf8_valid(name), "Invalid UTF8 in sample name.");
pa_assert(!c->scache.memchunk.memblock);
- c->scache.memchunk.memblock = pa_memblock_new(c->protocol->core->mempool, sc_length);
+ c->scache.memchunk.memblock = pa_memblock_new(c->protocol->core->mempool, (size_t) sc_length);
c->scache.memchunk.index = 0;
- c->scache.memchunk.length = sc_length;
+ c->scache.memchunk.length = (size_t) sc_length;
c->scache.sample_spec = ss;
pa_assert(!c->scache.name);
c->scache.name = pa_xstrdup(name);
ok = -1;
if ((idx = pa_scache_get_id_by_name(c->protocol->core, name)) != PA_IDXSET_INVALID)
- ok = idx + 1;
+ ok = (int32_t) idx + 1;
connection_write(c, &ok, sizeof(int32_t));
if ((sink = pa_namereg_get(c->protocol->core, c->options->default_sink, PA_NAMEREG_SINK, 1)))
if (pa_scache_play_item(c->protocol->core, name, sink, PA_VOLUME_NORM, c->client->proplist, NULL) >= 0)
- ok = idx + 1;
+ ok = (int32_t) idx + 1;
} else {
pa_assert(request == ESD_PROTO_SAMPLE_FREE);
if (pa_scache_remove_item(c->protocol->core, name) >= 0)
- ok = idx + 1;
+ ok = (int32_t) idx + 1;
}
}
return -1;
}
- if ((c->read_data_length+= r) >= sizeof(c->request)) {
+ c->read_data_length += (size_t) r;
+
+ if (c->read_data_length >= sizeof(c->request)) {
struct proto_handler *handler;
c->request = PA_MAYBE_INT32_SWAP(c->swap_byte_order, c->request);
return -1;
}
- if ((c->read_data_length += r) >= handler->data_length) {
+ c->read_data_length += (size_t) r;
+ if (c->read_data_length >= handler->data_length) {
size_t l = c->read_data_length;
pa_assert(handler->proc);
return -1;
}
- c->scache.memchunk.index += r;
+ c->scache.memchunk.index += (size_t) r;
pa_assert(c->scache.memchunk.index <= c->scache.memchunk.length);
if (c->scache.memchunk.index == c->scache.memchunk.length) {
/* pa_log("STREAMING_DATA"); */
- if (!(l = pa_atomic_load(&c->playback.missing)))
+ if (!(l = (size_t) pa_atomic_load(&c->playback.missing)))
return 0;
if (c->playback.current_memblock) {
chunk.memblock = c->playback.current_memblock;
chunk.index = c->playback.memblock_index;
- chunk.length = r;
+ chunk.length = (size_t) r;
- c->playback.memblock_index += r;
+ c->playback.memblock_index += (size_t) r;
pa_asyncmsgq_post(c->sink_input->sink->asyncmsgq, PA_MSGOBJECT(c->sink_input), SINK_INPUT_MESSAGE_POST_DATA, NULL, 0, &chunk, NULL);
- pa_atomic_sub(&c->playback.missing, r);
+ pa_atomic_sub(&c->playback.missing, (int) r);
}
return 0;
return -1;
}
- if ((c->write_data_index +=r) >= c->write_data_length)
+ c->write_data_index += (size_t) r;
+ if (c->write_data_index >= c->write_data_length)
c->write_data_length = c->write_data_index = 0;
} else if (c->state == ESD_STREAMING_DATA && c->source_output) {
return -1;
}
- pa_memblockq_drop(c->output_memblockq, r);
+ pa_memblockq_drop(c->output_memblockq, (size_t) r);
}
return 0;
m = pa_memblockq_pop_missing(c->input_memblockq);
if (m > 0)
- if (pa_atomic_add(&c->playback.missing, m) <= 0)
+ if (pa_atomic_add(&c->playback.missing, (int) m) <= 0)
pa_asyncmsgq_post(pa_thread_mq_get()->outq, PA_MSGOBJECT(c), CONNECTION_MESSAGE_REQUEST_DATA, NULL, 0, NULL, NULL);
return 0;
if (*maxlength == (uint32_t) -1 || *maxlength > MAX_MEMBLOCKQ_LENGTH)
*maxlength = MAX_MEMBLOCKQ_LENGTH;
if (*maxlength <= 0)
- *maxlength = pa_frame_size(&s->source_output->sample_spec);
+ *maxlength = (uint32_t) pa_frame_size(&s->source_output->sample_spec);
if (*fragsize == (uint32_t) -1)
- *fragsize = pa_usec_to_bytes(DEFAULT_FRAGSIZE_MSEC*PA_USEC_PER_MSEC, &s->source_output->sample_spec);
+ *fragsize = (uint32_t) pa_usec_to_bytes(DEFAULT_FRAGSIZE_MSEC*PA_USEC_PER_MSEC, &s->source_output->sample_spec);
if (*fragsize <= 0)
- *fragsize = pa_frame_size(&s->source_output->sample_spec);
+ *fragsize = (uint32_t) pa_frame_size(&s->source_output->sample_spec);
if (adjust_latency) {
pa_usec_t fragsize_usec;
else
fragsize_usec = s->source_latency;
- *fragsize = pa_usec_to_bytes(fragsize_usec, &s->source_output->sample_spec);
+ *fragsize = (uint32_t) pa_usec_to_bytes(fragsize_usec, &s->source_output->sample_spec);
} else
s->source_latency = 0;
}
pa_assert(maxlength);
pa_assert(fragsize);
- *maxlength = pa_memblockq_get_maxlength(s->memblockq);
+ *maxlength = (uint32_t) pa_memblockq_get_maxlength(s->memblockq);
base = pa_frame_size(&s->source_output->sample_spec);
if (s->fragment_size > *maxlength)
s->fragment_size = *maxlength;
- *fragsize = s->fragment_size;
+ *fragsize = (uint32_t) s->fragment_size;
}
static record_stream* record_stream_new(
uint32_t l = 0;
for (;;) {
- if ((l = pa_atomic_load(&s->missing)) <= 0)
+ if ((l = (uint32_t) pa_atomic_load(&s->missing)) <= 0)
break;
- if (pa_atomic_cmpxchg(&s->missing, l, 0))
+ if (pa_atomic_cmpxchg(&s->missing, (int) l, 0))
break;
}
if (*maxlength == (uint32_t) -1 || *maxlength > MAX_MEMBLOCKQ_LENGTH)
*maxlength = MAX_MEMBLOCKQ_LENGTH;
if (*maxlength <= 0)
- *maxlength = frame_size;
+ *maxlength = (uint32_t) frame_size;
if (*tlength == (uint32_t) -1)
- *tlength = pa_usec_to_bytes(DEFAULT_TLENGTH_MSEC*PA_USEC_PER_MSEC, &s->sink_input->sample_spec);
+ *tlength = (uint32_t) pa_usec_to_bytes(DEFAULT_TLENGTH_MSEC*PA_USEC_PER_MSEC, &s->sink_input->sample_spec);
if (*tlength <= 0)
- *tlength = frame_size;
+ *tlength = (uint32_t) frame_size;
if (*minreq == (uint32_t) -1)
- *minreq = pa_usec_to_bytes(DEFAULT_PROCESS_MSEC*PA_USEC_PER_MSEC, &s->sink_input->sample_spec);
+ *minreq = (uint32_t) pa_usec_to_bytes(DEFAULT_PROCESS_MSEC*PA_USEC_PER_MSEC, &s->sink_input->sample_spec);
if (*minreq <= 0)
- *minreq = frame_size;
+ *minreq = (uint32_t) frame_size;
if (*tlength < *minreq+frame_size)
- *tlength = *minreq+frame_size;
+ *tlength = *minreq+(uint32_t) frame_size;
tlength_usec = pa_bytes_to_usec(*tlength, &s->sink_input->sample_spec);
minreq_usec = pa_bytes_to_usec(*minreq, &s->sink_input->sample_spec);
if (tlength_usec < s->sink_latency + 2*minreq_usec)
tlength_usec = s->sink_latency + 2*minreq_usec;
- *tlength = pa_usec_to_bytes(tlength_usec, &s->sink_input->sample_spec);
- *minreq = pa_usec_to_bytes(minreq_usec, &s->sink_input->sample_spec);
+ *tlength = (uint32_t) pa_usec_to_bytes(tlength_usec, &s->sink_input->sample_spec);
+ *minreq = (uint32_t) pa_usec_to_bytes(minreq_usec, &s->sink_input->sample_spec);
if (*minreq <= 0) {
- *minreq += frame_size;
- *tlength += frame_size*2;
+ *minreq += (uint32_t) frame_size;
+ *tlength += (uint32_t) frame_size*2;
}
if (*tlength <= *minreq)
- *tlength = *minreq*2 + frame_size;
+ *tlength = *minreq*2 + (uint32_t) frame_size;
if (*prebuf == (uint32_t) -1 || *prebuf > *tlength)
*prebuf = *tlength;
/* pa_log("request_bytes(%lu)", (unsigned long) m); */
- previous_missing = pa_atomic_add(&s->missing, m);
+ previous_missing = (size_t) pa_atomic_add(&s->missing, (int) m);
if (pa_memblockq_prebuf_active(s->memblockq) ||
(previous_missing < s->minreq && previous_missing+m >= s->minreq))
* let's have it usk us again */
pa_log_debug("Requesting rewind due to rewrite.");
- pa_sink_input_request_rewind(s->sink_input, indexr - indexw, TRUE, FALSE);
+ pa_sink_input_request_rewind(s->sink_input, (size_t) (indexr - indexw), TRUE, FALSE);
}
}
if (pa_memblockq_push_align(s->memblockq, chunk) < 0) {
pa_log_warn("Failed to push data into queue");
pa_asyncmsgq_post(pa_thread_mq_get()->outq, PA_MSGOBJECT(s), PLAYBACK_STREAM_MESSAGE_OVERFLOW, NULL, 0, NULL, NULL);
- pa_memblockq_seek(s->memblockq, chunk->length, PA_SEEK_RELATIVE);
+ pa_memblockq_seek(s->memblockq, (int64_t) chunk->length, PA_SEEK_RELATIVE);
}
handle_seek(s, windex);
pa_tagstruct_putu32(reply, (uint32_t) pa_atomic_load(&stat->allocated_size));
pa_tagstruct_putu32(reply, (uint32_t) pa_atomic_load(&stat->n_accumulated));
pa_tagstruct_putu32(reply, (uint32_t) pa_atomic_load(&stat->accumulated_size));
- pa_tagstruct_putu32(reply, pa_scache_total_size(c->protocol->core));
+ pa_tagstruct_putu32(reply, (uint32_t) pa_scache_total_size(c->protocol->core));
pa_pstream_send_tagstruct(c->pstream, reply);
}
pa_tagstruct_putu32(t, module->index);
pa_tagstruct_puts(t, module->name);
pa_tagstruct_puts(t, module->argument);
- pa_tagstruct_putu32(t, module->n_used);
+ pa_tagstruct_putu32(t, (uint32_t) module->n_used);
pa_tagstruct_put_boolean(t, module->auto_unload);
}
pa_tagstruct_put_usec(t, e->memchunk.memblock ? pa_bytes_to_usec(e->memchunk.length, &e->sample_spec) : 0);
pa_tagstruct_put_sample_spec(t, &fixed_ss);
pa_tagstruct_put_channel_map(t, &e->channel_map);
- pa_tagstruct_putu32(t, e->memchunk.length);
+ pa_tagstruct_putu32(t, (uint32_t) e->memchunk.length);
pa_tagstruct_put_boolean(t, e->lazy);
pa_tagstruct_puts(t, e->filename);
if (!z)
break;
- changed += pa_proplist_unset(p, z) >= 0;
+ changed += (unsigned) (pa_proplist_unset(p, z) >= 0);
pa_xfree(z);
}
pa_tagstruct_putu32(t, e->index);
pa_tagstruct_puts(t, e->name);
- pa_tagstruct_putu32(t, e->type == PA_NAMEREG_SINK ? 0 : 1);
+ pa_tagstruct_putu32(t, e->type == PA_NAMEREG_SINK ? 0U : 1U);
pa_tagstruct_puts(t, e->module);
pa_tagstruct_puts(t, e->argument);
}
connection_assert_ref(c);
- if (!c->sink_input || (l = pa_atomic_load(&c->playback.missing)) <= 0)
+ if (!c->sink_input || (l = (size_t) pa_atomic_load(&c->playback.missing)) <= 0)
return 0;
if (c->playback.current_memblock) {
chunk.memblock = c->playback.current_memblock;
chunk.index = c->playback.memblock_index;
- chunk.length = r;
+ chunk.length = (size_t) r;
- c->playback.memblock_index += r;
+ c->playback.memblock_index += (size_t) r;
pa_asyncmsgq_post(c->sink_input->sink->asyncmsgq, PA_MSGOBJECT(c->sink_input), SINK_INPUT_MESSAGE_POST_DATA, NULL, 0, &chunk, NULL);
- pa_atomic_sub(&c->playback.missing, r);
+ pa_atomic_sub(&c->playback.missing, (int) r);
return 0;
}
return -1;
}
- pa_memblockq_drop(c->output_memblockq, r);
+ pa_memblockq_drop(c->output_memblockq, (size_t) r);
return 0;
}
m = pa_memblockq_pop_missing(c->input_memblockq);
if (m > 0)
- if (pa_atomic_add(&c->playback.missing, m) <= 0)
+ if (pa_atomic_add(&c->playback.missing, (int) m) <= 0)
pa_asyncmsgq_post(pa_thread_mq_get()->outq, PA_MSGOBJECT(c), CONNECTION_MESSAGE_REQUEST_DATA, NULL, 0, NULL, NULL);
return 0;
pa_sink_input_set_requested_latency(c->sink_input, DEFAULT_SINK_LATENCY);
- l = (size_t) (pa_bytes_per_second(&o->sample_spec)*PLAYBACK_BUFFER_SECONDS);
+ l = (size_t) ((double) pa_bytes_per_second(&o->sample_spec)*PLAYBACK_BUFFER_SECONDS);
c->input_memblockq = pa_memblockq_new(
0,
l,
NULL);
pa_iochannel_socket_set_rcvbuf(io, l);
- pa_atomic_store(&c->playback.missing, pa_memblockq_missing(c->input_memblockq));
+ pa_atomic_store(&c->playback.missing, (int) pa_memblockq_missing(c->input_memblockq));
pa_sink_input_put(c->sink_input);
}
pa_assert(p->write.current->packet);
p->write.data = p->write.current->packet->data;
- p->write.descriptor[PA_PSTREAM_DESCRIPTOR_LENGTH] = htonl(p->write.current->packet->length);
+ p->write.descriptor[PA_PSTREAM_DESCRIPTOR_LENGTH] = htonl((uint32_t) p->write.current->packet->length);
} else if (p->write.current->type == PA_PSTREAM_ITEM_SHMRELEASE) {
p->write.descriptor[PA_PSTREAM_DESCRIPTOR_OFFSET_HI] = htonl((uint32_t) (((uint64_t) p->write.current->offset) >> 32));
p->write.descriptor[PA_PSTREAM_DESCRIPTOR_OFFSET_LO] = htonl((uint32_t) ((uint64_t) p->write.current->offset));
- flags = p->write.current->seek_mode & PA_FLAG_SEEKMASK;
+ flags = (uint32_t) (p->write.current->seek_mode & PA_FLAG_SEEKMASK);
if (p->use_shm) {
uint32_t block_id, shm_id;
}
if (send_payload) {
- p->write.descriptor[PA_PSTREAM_DESCRIPTOR_LENGTH] = htonl(p->write.current->chunk.length);
+ p->write.descriptor[PA_PSTREAM_DESCRIPTOR_LENGTH] = htonl((uint32_t) p->write.current->chunk.length);
p->write.memchunk = p->write.current->chunk;
pa_memblock_ref(p->write.memchunk.memblock);
p->write.data = NULL;
if (release_memblock)
pa_memblock_release(release_memblock);
- p->write.index += r;
+ p->write.index += (size_t) r;
if (p->write.index >= PA_PSTREAM_DESCRIPTOR_SIZE + ntohl(p->write.descriptor[PA_PSTREAM_DESCRIPTOR_LENGTH])) {
pa_assert(p->write.current);
if (release_memblock)
pa_memblock_release(release_memblock);
- p->read.index += r;
+ p->read.index += (size_t) r;
if (p->read.index == PA_PSTREAM_DESCRIPTOR_SIZE) {
uint32_t flags, length, channel;
if (p->read.memblock && p->recieve_memblock_callback) {
/* Is this memblock data? Than pass it to the user */
- l = (p->read.index - r) < PA_PSTREAM_DESCRIPTOR_SIZE ? p->read.index - PA_PSTREAM_DESCRIPTOR_SIZE : (size_t) r;
+ l = (p->read.index - (size_t) r) < PA_PSTREAM_DESCRIPTOR_SIZE ? (size_t) (p->read.index - PA_PSTREAM_DESCRIPTOR_SIZE) : (size_t) r;
if (l > 0) {
pa_memchunk chunk;
/* We deduce the "largest" sample spec we're using during the
* conversion */
- ss.channels = PA_MAX(r->i_ss.channels, r->o_ss.channels);
+ ss.channels = (uint8_t) (PA_MAX(r->i_ss.channels, r->o_ss.channels));
/* We silently assume that the format enum is ordered by size */
ss.format = PA_MAX(r->i_ss.format, r->o_ss.format);
if (n > 0)
for (ic = 0; ic < r->i_ss.channels; ic++)
if (on_left(r->i_cm.map[ic])) {
- r->map_table[oc][ic] = 1.0 / n;
+ r->map_table[oc][ic] = 1.0f / (float) n;
ic_connected[ic] = TRUE;
}
if (n > 0)
for (ic = 0; ic < r->i_ss.channels; ic++)
if (on_right(r->i_cm.map[ic])) {
- r->map_table[oc][ic] = 1.0 / n;
+ r->map_table[oc][ic] = 1.0f / (float) n;
ic_connected[ic] = TRUE;
}
if (n > 0) {
for (ic = 0; ic < r->i_ss.channels; ic++)
if (on_center(r->i_cm.map[ic])) {
- r->map_table[oc][ic] = 1.0 / n;
+ r->map_table[oc][ic] = 1.0f / (float) n;
ic_connected[ic] = TRUE;
}
} else {
if (n > 0)
for (ic = 0; ic < r->i_ss.channels; ic++)
if (on_left(r->i_cm.map[ic]) || on_right(r->i_cm.map[ic])) {
- r->map_table[oc][ic] = 1.0 / n;
+ r->map_table[oc][ic] = 1.0f / (float) n;
ic_connected[ic] = TRUE;
}
* channels for LFE. */
for (ic = 0; ic < r->i_ss.channels; ic++) {
- r->map_table[oc][ic] = 1.0 / r->i_ss.channels;
+ r->map_table[oc][ic] = 1.0f / (float) r->i_ss.channels;
/* Please note that a channel connected to LFE
* doesn't really count as connected. */
for (ic = 0; ic < r->i_ss.channels; ic++) {
if (ic_connected[ic]) {
- r->map_table[oc][ic] *= .9;
+ r->map_table[oc][ic] *= .9f;
continue;
}
if (on_left(r->i_cm.map[ic]))
- r->map_table[oc][ic] = .1 / ic_unconnected_left;
+ r->map_table[oc][ic] = .1f / (float) ic_unconnected_left;
}
}
}
for (ic = 0; ic < r->i_ss.channels; ic++) {
if (ic_connected[ic]) {
- r->map_table[oc][ic] *= .9;
+ r->map_table[oc][ic] *= .9f;
continue;
}
if (on_right(r->i_cm.map[ic]))
- r->map_table[oc][ic] = .1 / ic_unconnected_right;
+ r->map_table[oc][ic] = .1f / (float) ic_unconnected_right;
}
}
}
for (ic = 0; ic < r->i_ss.channels; ic++) {
if (ic_connected[ic]) {
- r->map_table[oc][ic] *= .9;
+ r->map_table[oc][ic] *= .9f;
continue;
}
if (on_center(r->i_cm.map[ic])) {
- r->map_table[oc][ic] = .1 / ic_unconnected_center;
+ r->map_table[oc][ic] = .1f / (float) ic_unconnected_center;
mixed_in = TRUE;
}
}
for (ic = 0; ic < r->i_ss.channels; ic++) {
if (ic_connected[ic]) {
- r->map_table[oc][ic] *= .75;
+ r->map_table[oc][ic] *= .75f;
continue;
}
if (on_center(r->i_cm.map[ic]))
- r->map_table[oc][ic] = .375 / ic_unconnected_center;
+ r->map_table[oc][ic] = .375f / (float) ic_unconnected_center;
}
}
}
continue;
for (oc = 0; oc < r->o_ss.channels; oc++)
- r->map_table[oc][ic] = 0.375 / ic_unconnected_lfe;
+ r->map_table[oc][ic] = 0.375f / (float) ic_unconnected_lfe;
}
}
}
if (!r->to_work_format_func || !input->length)
return input;
- n_samples = (input->length / r->i_fz) * r->i_ss.channels;
+ n_samples = (unsigned) ((input->length / r->i_fz) * r->i_ss.channels);
r->buf1.index = 0;
r->buf1.length = r->w_sz * n_samples;
if (!r->map_required || !input->length)
return input;
- in_n_samples = input->length / r->w_sz;
+ in_n_samples = (unsigned) (input->length / r->w_sz);
n_frames = in_n_samples / r->i_ss.channels;
out_n_samples = n_frames * r->o_ss.channels;
memset(dst, 0, r->buf2.length);
- o_skip = r->w_sz * r->o_ss.channels;
- i_skip = r->w_sz * r->i_ss.channels;
+ o_skip = (int) (r->w_sz * r->o_ss.channels);
+ i_skip = (int) (r->w_sz * r->i_ss.channels);
switch (r->work_format) {
case PA_SAMPLE_FLOAT32NE:
(float*) dst + oc, o_skip,
(float*) dst + oc, o_skip,
(float*) src + ic, i_skip,
- n_frames,
+ (int) n_frames,
&one, &r->map_table[oc][ic]);
}
}
(int16_t*) dst + oc, o_skip,
(int16_t*) dst + oc, o_skip,
(int16_t*) src + ic, i_skip,
- n_frames,
+ (int) n_frames,
&one, &one);
} else
(int16_t*) dst + oc, o_skip,
(int16_t*) dst + oc, o_skip,
(int16_t*) src + ic, i_skip,
- n_frames,
+ (int) n_frames,
1.0, r->map_table[oc][ic]);
}
}
if (!r->impl_resample || !input->length)
return input;
- in_n_samples = input->length / r->w_sz;
- in_n_frames = in_n_samples / r->o_ss.channels;
+ in_n_samples = (unsigned) (input->length / r->w_sz);
+ in_n_frames = (unsigned) (in_n_samples / r->o_ss.channels);
out_n_frames = ((in_n_frames*r->o_ss.rate)/r->i_ss.rate)+EXTRA_FRAMES;
out_n_samples = out_n_frames * r->o_ss.channels;
if (!r->from_work_format_func || !input->length)
return input;
- n_samples = input->length / r->w_sz;
- n_frames = n_samples / r->o_ss.channels;
+ n_samples = (unsigned) (input->length / r->w_sz);
+ n_frames = n_samples / r->o_ss.channels;
r->buf4.index = 0;
r->buf4.length = r->o_fz * n_frames;
pa_memblock_release(input->memblock);
pa_memblock_release(output->memblock);
- *out_n_frames = data.output_frames_gen;
+ *out_n_frames = (unsigned) data.output_frames_gen;
}
static void libsamplerate_update_rates(pa_resampler *r) {
pa_assert(o_index * fz < pa_memblock_get_length(output->memblock));
oil_memcpy((uint8_t*) dst + fz * o_index,
- (uint8_t*) src + fz * j, fz);
+ (uint8_t*) src + fz * j, (int) fz);
}
pa_memblock_release(input->memblock);
for (c = 0; c < r->o_ss.channels; c++, s++) {
int16_t n;
- n = *s < 0 ? -*s : *s;
+ n = (int16_t) (*s < 0 ? -*s : *s);
if (n > r->peaks.max_i[c])
r->peaks.max_i[c] = n;
p = pa_memblock_acquire(b);
/* Copy the remaining data into it */
- l = r->ffmpeg.buf[c].length;
+ l = (unsigned) r->ffmpeg.buf[c].length;
if (r->ffmpeg.buf[c].memblock) {
t = (int16_t*) ((uint8_t*) pa_memblock_acquire(r->ffmpeg.buf[c].memblock) + r->ffmpeg.buf[c].index);
memcpy(p, t, l);
pa_memblock_release(input->memblock);
/* Calculate the resulting number of frames */
- in = in_n_frames + l / sizeof(int16_t);
+ in = (unsigned) in_n_frames + l / (unsigned) sizeof(int16_t);
/* Allocate buffer for the result */
w = pa_memblock_new(r->mempool, *out_n_frames * sizeof(int16_t));
q = pa_memblock_acquire(w);
/* Now, resample */
- used_frames = av_resample(r->ffmpeg.state,
- q, p,
- &consumed_frames,
- in, *out_n_frames,
- c >= (unsigned) r->o_ss.channels-1);
+ used_frames = (unsigned) av_resample(r->ffmpeg.state,
+ q, p,
+ &consumed_frames,
+ (int) in, (int) *out_n_frames,
+ c >= (unsigned) (r->o_ss.channels-1));
pa_memblock_release(b);
pa_assert(consumed_frames <= (int) in);
if (consumed_frames < (int) in) {
r->ffmpeg.buf[c].memblock = b;
- r->ffmpeg.buf[c].index = consumed_frames * sizeof(int16_t);
- r->ffmpeg.buf[c].length = (in - consumed_frames) * sizeof(int16_t);
+ r->ffmpeg.buf[c].index = (size_t) consumed_frames * sizeof(int16_t);
+ r->ffmpeg.buf[c].length = (size_t) (in - (unsigned) consumed_frames) * sizeof(int16_t);
} else
pa_memblock_unref(b);
* internally only uses these hardcoded values, so let's use them
* here for now as well until ffmpeg makes this configurable. */
- if (!(r->ffmpeg.state = av_resample_init(r->o_ss.rate, r->i_ss.rate, 16, 10, 0, 0.8)))
+ if (!(r->ffmpeg.state = av_resample_init((int) r->o_ss.rate, (int) r->i_ss.rate, 16, 10, 0, 0.8)))
return -1;
r->impl_free = ffmpeg_free;
#endif
#endif
- r = poll(p->pollfd, p->n_pollfd_used, (!wait || p->quit || p->timer_enabled) ? (timeout.tv_sec*1000) + (timeout.tv_usec / 1000) : -1);
+ r = poll(p->pollfd, p->n_pollfd_used, (!wait || p->quit || p->timer_enabled) ? (int) ((timeout.tv_sec*1000) + (timeout.tv_usec / 1000)) : -1);
if (r < 0) {
if (errno == EAGAIN || errno == EINTR)
pa_rtsig_put(PA_PTR_TO_INT(p));
}
-PA_STATIC_FLIST_DECLARE(rtsig_flist, pa_make_power_of_two(SIGRTMAX-SIGRTMIN+1), NULL);
+PA_STATIC_FLIST_DECLARE(rtsig_flist, pa_make_power_of_two((unsigned) (SIGRTMAX-SIGRTMIN+1)), NULL);
PA_STATIC_TLS_DECLARE(rtsig_tls, _free_rtsig);
static pa_atomic_t rtsig_current = PA_ATOMIC_INIT(-1);
default:
pa_assert_not_reached();
}
- return 0;
}
void* pa_silence_memory(void *p, size_t length, const pa_sample_spec *spec) {
for (channel = 0; channel < spec->channels; channel++) {
pa_mix_info *m = streams + k;
- m->linear[channel].f = pa_sw_volume_to_linear(m->volume.values[channel]);
+ m->linear[channel].f = (float) pa_sw_volume_to_linear(m->volume.values[channel]);
}
}
}
pa_assert(volume);
for (channel = 0; channel < volume->channels; channel++)
- linear[channel] = pa_sw_volume_to_linear(volume->values[channel]);
+ linear[channel] = (float) pa_sw_volume_to_linear(volume->values[channel]);
}
size_t pa_mix(
sum = (sum * linear[channel]) / 0x10000;
sum = PA_CLAMP_UNLIKELY(sum, -0x8000, 0x7FFF);
- *((uint8_t*) data) = (uint8_t) st_14linear2ulaw(sum >> 2);
+ *((uint8_t*) data) = (uint8_t) st_14linear2ulaw((int16_t) sum >> 2);
data = (uint8_t*) data + 1;
sum = (sum * linear[channel]) / 0x10000;
sum = PA_CLAMP_UNLIKELY(sum, -0x8000, 0x7FFF);
- *((uint8_t*) data) = (uint8_t) st_13linear2alaw(sum >> 3);
+ *((uint8_t*) data) = (uint8_t) st_13linear2alaw((int16_t) sum >> 3);
data = (uint8_t*) data + 1;
t = (int32_t) st_ulaw2linear16(*d);
t = (t * linear[channel]) / 0x10000;
t = PA_CLAMP_UNLIKELY(t, -0x8000, 0x7FFF);
- *d = (uint8_t) st_14linear2ulaw(t >> 2);
+ *d = (uint8_t) st_14linear2ulaw((int16_t) t >> 2);
if (PA_UNLIKELY(++channel >= spec->channels))
channel = 0;
t = (int32_t) st_alaw2linear16(*d);
t = (t * linear[channel]) / 0x10000;
t = PA_CLAMP_UNLIKELY(t, -0x8000, 0x7FFF);
- *d = (uint8_t) st_13linear2alaw(t >> 3);
+ *d = (uint8_t) st_13linear2alaw((int16_t) t >> 3);
if (PA_UNLIKELY(++channel >= spec->channels))
channel = 0;
unsigned channel;
d = ptr;
- skip = spec->channels * sizeof(float);
- n = c->length/sizeof(float)/spec->channels;
+ skip = (int) (spec->channels * sizeof(float));
+ n = (unsigned) (c->length/sizeof(float)/spec->channels);
for (channel = 0; channel < spec->channels; channel ++) {
float v, *t;
v = (float) pa_sw_volume_to_linear(volume->values[channel]);
t = d + channel;
- oil_scalarmult_f32(t, skip, t, skip, &v, n);
+ oil_scalarmult_f32(t, skip, t, skip, &v, (int) n);
}
break;
}
d = (uint8_t*) dst + c * ss;
for (j = 0; j < n; j ++) {
- oil_memcpy(d, s, ss);
+ oil_memcpy(d, s, (int) ss);
s = (uint8_t*) s + ss;
d = (uint8_t*) d + fs;
}
d = dst[c];
for (j = 0; j < n; j ++) {
- oil_memcpy(d, s, ss);
+ oil_memcpy(d, s, (int) ss);
s = (uint8_t*) s + fs;
d = (uint8_t*) d + ss;
}
if (format == PA_SAMPLE_FLOAT32NE) {
float minus_one = -1.0, plus_one = 1.0;
- oil_clip_f32(d, dstr, s, sstr, n, &minus_one, &plus_one);
+ oil_clip_f32(d, (int) dstr, s, (int) sstr, (int) n, &minus_one, &plus_one);
} else {
pa_assert(format == PA_SAMPLE_FLOAT32RE);
float f;
f = PA_FLOAT32_SWAP(*s);
- f = PA_CLAMP_UNLIKELY(f, -1.0, 1.0);
+ f = PA_CLAMP_UNLIKELY(f, -1.0f, 1.0f);
*d = PA_FLOAT32_SWAP(f);
s = (const float*) ((const uint8_t*) s + sstr);
for (; n > 0; n--) {
int16_t s = *(a++);
- *(b++) = ((float) INT16_FROM(s))/0x7FFF;
+ *(b++) = ((float) INT16_FROM(s))/(float) 0x7FFF;
}
#else
{
static const double add = 0, factor = 1.0/0x7FFF;
- oil_scaleconv_f32_s16(b, a, n, &add, &factor);
+ oil_scaleconv_f32_s16(b, a, (int) n, &add, &factor);
}
#endif
}
#else
{
static const double add = 0, factor = 1.0/0x7FFFFFFF;
- oil_scaleconv_f32_s32(b, a, n, &add, &factor);
+ oil_scaleconv_f32_s32(b, a, (int) n, &add, &factor);
}
#endif
}
int16_t s;
float v = *(a++);
- v = PA_CLAMP_UNLIKELY(v, -1, 1);
+ v = PA_CLAMP_UNLIKELY(v, -1.0f, 1.f);
s = (int16_t) (v * 0x7FFF);
*(b++) = INT16_TO(s);
}
#else
{
static const double add = 0, factor = 0x7FFF;
- oil_scaleconv_s16_f32(b, a, n, &add, &factor);
+ oil_scaleconv_s16_f32(b, a, (int) n, &add, &factor);
}
#endif
}
int32_t s;
float v = *(a++);
- v = PA_CLAMP_UNLIKELY(v, -1, 1);
+ v = PA_CLAMP_UNLIKELY(v, -1.0f, 1.0f);
s = (int32_t) ((double) v * (double) 0x7FFFFFFF);
*(b++) = INT32_TO(s);
}
#else
{
static const double add = 0, factor = 0x7FFFFFFF;
- oil_scaleconv_s32_f32(b, a, n, &add, &factor);
+ oil_scaleconv_s32_f32(b, a, (int) n, &add, &factor);
}
#endif
}
float v = *(a++);
uint32_t *j = (uint32_t*) &v;
*j = PA_UINT32_SWAP(*j);
- v = PA_CLAMP_UNLIKELY(v, -1, 1);
+ v = PA_CLAMP_UNLIKELY(v, -1.0f, 1.0f);
s = (int16_t) (v * 0x7FFF);
*(b++) = INT16_TO(s);
}
float v = *(a++);
uint32_t *j = (uint32_t*) &v;
*j = PA_UINT32_SWAP(*j);
- v = PA_CLAMP_UNLIKELY(v, -1, 1);
+ v = PA_CLAMP_UNLIKELY(v, -1.0f, 1.0f);
s = (int32_t) ((double) v * 0x7FFFFFFF);
*(b++) = INT32_TO(s);
}
for (; n > 0; n--) {
int16_t s = (int16_t) (INT32_FROM(*a) >> 16);
- *b = PA_UINT32_SWAP(s);
+ *b = PA_INT16_SWAP(s);
a++;
b++;
}
pa_assert(b);
for (; n > 0; n--) {
- int32_t s = ((int32_t) PA_UINT16_SWAP(*a)) << 16;
+ int32_t s = ((int32_t) PA_INT16_SWAP(*a)) << 16;
*b = INT32_TO(s);
a++;
b++;
pa_assert(a);
pa_assert(b);
- oil_scaleconv_f32_u8(b, a, n, &add, &factor);
+ oil_scaleconv_f32_u8(b, a, (int) n, &add, &factor);
}
static void u8_from_float32ne(unsigned n, const float *a, uint8_t *b) {
pa_assert(a);
pa_assert(b);
- oil_scaleconv_u8_f32(b, a, n, &add, &factor);
+ oil_scaleconv_u8_f32(b, a, (int) n, &add, &factor);
}
static void u8_to_s16ne(unsigned n, const uint8_t *a, int16_t *b) {
pa_assert(a);
pa_assert(b);
- oil_conv_s16_u8(b, 2, a, 1, n);
- oil_scalaradd_s16(b, 2, b, 2, &add, n);
- oil_scalarmult_s16(b, 2, b, 2, &factor, n);
+ oil_conv_s16_u8(b, 2, a, 1, (int) n);
+ oil_scalaradd_s16(b, 2, b, 2, &add, (int) n);
+ oil_scalarmult_s16(b, 2, b, 2, &factor, (int) n);
}
static void u8_from_s16ne(unsigned n, const int16_t *a, uint8_t *b) {
pa_assert(a);
pa_assert(b);
- oil_memcpy(b, a, sizeof(float) * n);
+ oil_memcpy(b, a, (int) (sizeof(float) * n));
}
static void float32re_to_float32ne(unsigned n, const float *a, float *b) {
pa_assert(a);
pa_assert(b);
- oil_memcpy(b, a, sizeof(int16_t) * n);
+ oil_memcpy(b, a, (int) (sizeof(int16_t) * n));
}
static void s16re_to_s16ne(unsigned n, const int16_t *a, int16_t *b) {
pa_assert(b);
for (; n > 0; n--, a++, b++)
- *b = PA_UINT16_SWAP(*a);
+ *b = PA_INT16_SWAP(*a);
}
/* ulaw */
for (; n > 0; n--) {
float v = *(a++);
- v = PA_CLAMP_UNLIKELY(v, -1, 1);
+ v = PA_CLAMP_UNLIKELY(v, -1.0f, 1.0f);
v *= 0x1FFF;
*(b++) = st_14linear2ulaw((int16_t) v);
}
for (; n > 0; n--, a++, b++) {
float v = *a;
- v = PA_CLAMP_UNLIKELY(v, -1, 1);
+ v = PA_CLAMP_UNLIKELY(v, -1.0f, 1.0f);
v *= 0xFFF;
*b = st_13linear2alaw((int16_t) v);
}
pa_assert(b);
for (; n > 0; n--, a++, b++)
- *b = st_alaw2linear16(*a);
+ *b = st_alaw2linear16((uint8_t) *a);
}
static void alaw_from_s16ne(unsigned n, const int16_t *a, uint8_t *b) {
m->size = size + PA_ALIGN(sizeof(struct shm_marker));
- if (ftruncate(fd, m->size) < 0) {
+ if (ftruncate(fd, (off_t) m->size) < 0) {
pa_log("ftruncate() failed: %s", pa_cstrerror(errno));
goto fail;
}
/* Align this to multiples of the page size */
ptr = (uint8_t*) m->ptr + offset;
- o = (uint8_t*) ptr - (uint8_t*) PA_PAGE_ALIGN_PTR(ptr);
+ o = (size_t) ((uint8_t*) ptr - (uint8_t*) PA_PAGE_ALIGN_PTR(ptr));
if (o > 0) {
ps = PA_PAGE_SIZE;
goto fail;
}
- m->size = st.st_size;
+ m->size = (size_t) st.st_size;
if ((m->ptr = mmap(NULL, m->size, PROT_READ, MAP_SHARED, fd, 0)) == MAP_FAILED) {
pa_log("mmap() failed: %s", pa_cstrerror(errno));
* data, so let's just hand out silence */
pa_atomic_store(&i->thread_info.drained, 1);
- pa_memblockq_seek(i->thread_info.render_memblockq, slength, PA_SEEK_RELATIVE);
+ pa_memblockq_seek(i->thread_info.render_memblockq, (int64_t) slength, PA_SEEK_RELATIVE);
i->thread_info.playing_for = 0;
if (i->thread_info.underrun_for != (uint64_t) -1)
i->thread_info.underrun_for += ilength;
else
pa_make_socket_low_delay(c->fd);
- if (do_connect(c, sa, salen) < 0)
+ if (do_connect(c, sa, (socklen_t) salen) < 0)
return -1;
return 0;
pa_make_socket_low_delay(fd);
- if (bind(fd, (struct sockaddr*) &sa, SUN_LEN(&sa)) < 0) {
+ if (bind(fd, (struct sockaddr*) &sa, (socklen_t) SUN_LEN(&sa)) < 0) {
pa_log("bind(): %s", pa_cstrerror(errno));
goto fail;
}
if (u->readf_function) {
fs = pa_frame_size(&i->sample_spec);
- n = u->readf_function(u->sndfile, p, length/fs);
+ n = u->readf_function(u->sndfile, p, (sf_count_t) (length/fs));
} else {
fs = 1;
- n = sf_read_raw(u->sndfile, p, length);
+ n = sf_read_raw(u->sndfile, p, (sf_count_t) length);
}
pa_memblock_release(tchunk.memblock);
break;
}
- tchunk.length = n * fs;
+ tchunk.length = (size_t) n * fs;
pa_memblockq_push(u->memblockq, &tchunk);
pa_memblock_unref(tchunk.memblock);
break;
}
- ss.rate = sfinfo.samplerate;
- ss.channels = sfinfo.channels;
+ ss.rate = (uint32_t) sfinfo.samplerate;
+ ss.channels = (uint8_t) sfinfo.channels;
if (!pa_sample_spec_valid(&ss)) {
pa_log("Unsupported sample format in file %s", fname);
break;
}
- ss->rate = sfinfo.samplerate;
- ss->channels = sfinfo.channels;
+ ss->rate = (uint32_t) sfinfo.samplerate;
+ ss->channels = (uint8_t) sfinfo.channels;
if (!pa_sample_spec_valid(ss)) {
pa_log("Unsupported sample format in file %s", fname);
if (map)
pa_channel_map_init_extend(map, ss->channels, PA_CHANNEL_MAP_DEFAULT);
- if ((l = pa_frame_size(ss) * sfinfo.frames) > PA_SCACHE_ENTRY_SIZE_MAX) {
+ if ((l = pa_frame_size(ss) * (size_t) sfinfo.frames) > PA_SCACHE_ENTRY_SIZE_MAX) {
pa_log("File too large");
goto finish;
}
ptr = pa_memblock_acquire(chunk->memblock);
if ((readf_function && readf_function(sf, ptr, sfinfo.frames) != sfinfo.frames) ||
- (!readf_function && sf_read_raw(sf, ptr, l) != (sf_count_t) l)) {
+ (!readf_function && sf_read_raw(sf, ptr, (sf_count_t) l) != (sf_count_t) l)) {
pa_log("Premature file end");
goto finish;
}
break;
}
- ss.rate = sfinfo.samplerate;
- ss.channels = sfinfo.channels;
+ ss.rate = (uint32_t) sfinfo.samplerate;
+ ss.channels = (uint8_t) sfinfo.channels;
if (!pa_sample_spec_valid(&ss)) {
pa_log("Unsupported sample format in file %s", fname);
return -1;
}
- if ((pa_frame_size(&ss) * sfinfo.frames) > PA_SCACHE_ENTRY_SIZE_MAX) {
+ if ((pa_frame_size(&ss) * (size_t) sfinfo.frames) > PA_SCACHE_ENTRY_SIZE_MAX) {
pa_log("File too large: %s", fname);
return 1;
}
if (pa_memblockq_push(o->thread_info.delay_memblockq, chunk) < 0) {
pa_log_debug("Delay queue overflow!");
- pa_memblockq_seek(o->thread_info.delay_memblockq, chunk->length, PA_SEEK_RELATIVE);
+ pa_memblockq_seek(o->thread_info.delay_memblockq, (int64_t) chunk->length, PA_SEEK_RELATIVE);
}
limit = o->process_rewind ? 0 : o->source->thread_info.max_rewind;
pa_assert(sb);
- e = t = pa_xnew(char, sb->length+1);
+ e = t = pa_xmalloc(sb->length+1);
for (c = sb->head; c; c = c->next) {
pa_assert((size_t) (e-t) <= sb->length);
/* Append a printf() style formatted string to the string buffer. */
/* The following is based on an example from the GNU libc documentation */
-int pa_strbuf_printf(pa_strbuf *sb, const char *format, ...) {
- int size = 100;
+size_t pa_strbuf_printf(pa_strbuf *sb, const char *format, ...) {
+ size_t size = 100;
struct chunk *c = NULL;
pa_assert(sb);
CHUNK_TO_TEXT(c)[size-1] = 0;
va_end(ap);
- if (r > -1 && r < size) {
- c->length = r;
+ if (r > -1 && (size_t) r < size) {
+ c->length = (size_t) r;
append(sb, c);
- return r;
+ return (size_t) r;
}
if (r > -1) /* glibc 2.1 */
- size = r+1;
+ size = (size_t) r+1;
else /* glibc 2.0 */
size *= 2;
}
char *pa_strbuf_tostring(pa_strbuf *sb);
char *pa_strbuf_tostring_free(pa_strbuf *sb);
-int pa_strbuf_printf(pa_strbuf *sb, const char *format, ...) PA_GCC_PRINTF_ATTR(2,3);
+size_t pa_strbuf_printf(pa_strbuf *sb, const char *format, ...) PA_GCC_PRINTF_ATTR(2,3);
void pa_strbuf_puts(pa_strbuf *sb, const char *t);
void pa_strbuf_putsn(pa_strbuf *sb, const char *t, size_t m);
extend(t, 5+length);
t->data[t->length] = PA_TAG_ARBITRARY;
- tmp = htonl(length);
+ tmp = htonl((uint32_t) length);
memcpy(t->data+t->length+1, &tmp, 4);
if (length)
memcpy(t->data+t->length+5, p, length);
pa_assert(t);
extend(t, 1);
- t->data[t->length] = b ? PA_TAG_BOOLEAN_TRUE : PA_TAG_BOOLEAN_FALSE;
+ t->data[t->length] = (uint8_t) (b ? PA_TAG_BOOLEAN_TRUE : PA_TAG_BOOLEAN_FALSE);
t->length += 1;
}
extend(t, 9);
t->data[t->length] = PA_TAG_TIMEVAL;
- tmp = htonl(tv->tv_sec);
+ tmp = htonl((uint32_t) tv->tv_sec);
memcpy(t->data+t->length+1, &tmp, 4);
- tmp = htonl(tv->tv_usec);
+ tmp = htonl((uint32_t) tv->tv_usec);
memcpy(t->data+t->length+5, &tmp, 4);
t->length += 9;
}
unsigned i;
pa_assert(t);
- extend(t, 2 + map->channels);
+ extend(t, 2 + (size_t) map->channels);
t->data[t->length++] = PA_TAG_CHANNEL_MAP;
t->data[t->length++] = map->channels;
return -1;
memcpy(&tv->tv_sec, t->data+t->rindex+1, 4);
- tv->tv_sec = ntohl(tv->tv_sec);
+ tv->tv_sec = ntohl((uint32_t) tv->tv_sec);
memcpy(&tv->tv_usec, t->data+t->rindex+5, 4);
- tv->tv_usec = ntohl(tv->tv_usec);
+ tv->tv_usec = ntohl((uint32_t) tv->tv_usec);
t->rindex += 9;
return 0;
}
for (i = 0; i < map->channels; i ++)
map->map[i] = (int8_t) t->data[t->rindex + 2 + i];
- t->rindex += 2 + map->channels;
+ t->rindex += 2 + (size_t) map->channels;
return 0;
}
i = s->history_idx;
for (j = s->n_history; j > 0; j--) {
- ax += s->history_x[i];
- ay += s->history_y[i];
+ ax += (int64_t) s->history_x[i];
+ ay += (int64_t) s->history_y[i];
c++;
REDUCE_INC(i);
REDUCE_INC(i);
}
- r = (double) k / t;
+ r = (double) k / (double) t;
return (s->monotonic && r < 0) ? 0 : r;
}
/* Calculate a, b, c for y=ax^3+bx^2+cx */
s->c = de;
- s->b = (((double) (3*ky)/kx - dp - 2*de)) / kx;
- s->a = (dp/kx - 2*s->b - de/kx) / (3*kx);
+ s->b = (((double) (3*ky)/ (double) kx - dp - (double) (2*de))) / (double) kx;
+ s->a = (dp/(double) kx - 2*s->b - de/(double) kx) / (double) (3*kx);
s->abc_valid = TRUE;
}
/* The requested point is right of the point where we wanted
* to be on track again, thus just linearly estimate */
- t = (int64_t) s->py + (int64_t) (s->dp * (x - s->px));
+ t = (int64_t) s->py + (int64_t) (s->dp * (double) (x - s->px));
if (t < 0)
t = 0;
/* And calculate when we want to be on track again */
s->px = s->ex + s->adjust_time;
- s->py = s->ry + s->dp *s->adjust_time;
+ s->py = s->ry + (pa_usec_t) (s->dp * (double) s->adjust_time);
s->abc_valid = FALSE;
void pa_x11_set_prop(Display *d, const char *name, const char *data) {
Atom a = XInternAtom(d, name, False);
- XChangeProperty(d, RootWindow(d, 0), a, XA_STRING, 8, PropModeReplace, (const unsigned char*) data, strlen(data)+1);
+ XChangeProperty(d, RootWindow(d, 0), a, XA_STRING, 8, PropModeReplace, (const unsigned char*) data, (int) (strlen(data)+1));
}
void pa_x11_del_prop(Display *d, const char *name) {
char *ret = NULL;
Atom a = XInternAtom(d, name, False);
- if (XGetWindowProperty(d, RootWindow(d, 0), a, 0, (l+2)/4, False, XA_STRING, &actual_type, &actual_format, &nitems, &nbytes_after, &prop) != Success)
+ if (XGetWindowProperty(d, RootWindow(d, 0), a, 0, (long) ((l+2)/4), False, XA_STRING, &actual_type, &actual_format, &nitems, &nbytes_after, &prop) != Success)
goto finish;
if (actual_type != XA_STRING)
.n_points = 2,
.points_x = { 100*PA_USEC_PER_MSEC, 300*PA_USEC_PER_MSEC },
.points_y = {
- .f = { 1.0, 0.2 },
+ .f = { 1.0f, 0.2f },
.i = { 0x10000, 0x10000/5 }
}
};
.n_points = 2,
.points_x = { 100*PA_USEC_PER_MSEC, 300*PA_USEC_PER_MSEC },
.points_y = {
- .f = { 0.2, 1.0 },
+ .f = { 0.2f, 1.0f },
.i = { 0x10000/5, 0x10000 }
}
};
.n_points = 2,
.points_x = { 50*PA_USEC_PER_MSEC, 900*PA_USEC_PER_MSEC },
.points_y = {
- .f = { 0.8, 0.7 },
+ .f = { 0.8f, 0.7f },
.i = { 0x10000*4/5, 0x10000*7/10 }
}
};
.n_points = 2,
.points_x = { 50*PA_USEC_PER_MSEC, 900*PA_USEC_PER_MSEC },
.points_y = {
- .f = { 0.7, 0.9 },
+ .f = { 0.7f, 0.9f },
.i = { 0x10000*7/10, 0x10000*9/10 }
}
};
unsigned n_samples;
block = pa_memblock_new(pool, pa_bytes_per_second(ss));
- n_samples = pa_memblock_get_length(block) / pa_sample_size(ss);
+ n_samples = (unsigned) (pa_memblock_get_length(block) / pa_sample_size(ss));
d = pa_memblock_acquire(block);
float *f;
for (f = d; n_samples > 0; n_samples--, f++)
- *f = PA_MAYBE_FLOAT32_SWAP(ss->format == PA_SAMPLE_FLOAT32RE, 1.0);
+ *f = PA_MAYBE_FLOAT32_SWAP(ss->format == PA_SAMPLE_FLOAT32RE, 1.0f);
break;
}
pa_memchunk_reset(&c);
- srand(time(NULL));
+ srand((unsigned) time(NULL));
for (;;) {
ssize_t r;
l = pa_memblock_get_length(c.memblock) - c.index;
- l = l <= 1 ? l : rand() % (l-1) +1 ;
+ l = l <= 1 ? l : (size_t) rand() % (l-1) +1;
p = pa_memblock_acquire(c.memblock);
pa_memblock_release(c.memblock);
- c.length = r;
+ c.length = (size_t) r;
pa_mcalign_push(a, &c);
fprintf(stderr, "Read %ld bytes\n", (long)r);
- c.index += r;
+ c.index += (size_t) r;
if (c.index >= pa_memblock_get_length(c.memblock)) {
pa_memblock_unref(c.memblock);
case PA_SAMPLE_FLOAT32RE: {
float *u = d;
- u[0] = 0.0;
- u[1] = -1.0;
- u[2] = 1.0;
- u[3] = 4711;
- u[4] = 0.222;
- u[5] = 0.33;
- u[6] = -.3;
- u[7] = 99;
- u[8] = -0.555;
- u[9] = -.123;
+ u[0] = 0.0f;
+ u[1] = -1.0f;
+ u[2] = 1.0f;
+ u[3] = 4711.0f;
+ u[4] = 0.222f;
+ u[5] = 0.33f;
+ u[6] = -.3f;
+ u[7] = 99.0f;
+ u[8] = -0.555f;
+ u[9] = -.123f;
if (ss->format == PA_SAMPLE_FLOAT32RE)
for (i = 0; i < 10; i++)
}
/* ... and play it */
- if (pa_simple_write(s, buf, r, &error) < 0) {
+ if (pa_simple_write(s, buf, (size_t) r, &error) < 0) {
fprintf(stderr, __FILE__": pa_simple_write() failed: %s\n", pa_strerror(error));
goto finish;
}
ret += r;
data = (const uint8_t*) data + r;
- size -= r;
+ size -= (size_t) r;
}
return ret;
goto finish;
}
+ if (r == 0)
+ break;
+
/* And write it to STDOUT */
if ((r = loop_write(STDOUT_FILENO, buf, sizeof(buf))) <= 0) {
fprintf(stderr, __FILE__": write() failed: %s\n", strerror(errno));
case PA_SAMPLE_FLOAT32RE: {
float *u = d;
- u[0] = 0.0;
- u[1] = -1.0;
- u[2] = 1.0;
- u[3] = 4711;
- u[4] = 0.222;
- u[5] = 0.33;
- u[6] = -.3;
- u[7] = 99;
- u[8] = -0.555;
- u[9] = -.123;
+ u[0] = 0.0f;
+ u[1] = -1.0f;
+ u[2] = 1.0f;
+ u[3] = 4711.0f;
+ u[4] = 0.222f;
+ u[5] = 0.33f;
+ u[6] = -.3f;
+ u[7] = 99.0f;
+ u[8] = -0.555f;
+ u[9] = -.123f;
if (ss->format == PA_SAMPLE_FLOAT32RE)
for (i = 0; i < 10; i++)
pa_assert_se(pthread_setschedparam(pthread_self(), SCHED_FIFO, ¶m) == 0);
CPU_ZERO(&mask);
- CPU_SET(PA_PTR_TO_INT(p), &mask);
+ CPU_SET((size_t) PA_PTR_TO_INT(p), &mask);
pa_assert_se(pthread_setaffinity_np(pthread_self(), sizeof(mask), &mask) == 0);
for (;;) {
pa_assert_se(clock_gettime(CLOCK_REALTIME, &end) == 0);
nsec =
- (uint64_t) ((((double) rand())*(msec_upper-msec_lower)*PA_NSEC_PER_MSEC)/RAND_MAX) +
- (uint64_t) (msec_lower*PA_NSEC_PER_MSEC);
+ (uint64_t) ((((double) rand())*(double)(msec_upper-msec_lower)*PA_NSEC_PER_MSEC)/RAND_MAX) +
+ (uint64_t) ((uint64_t) msec_lower*PA_NSEC_PER_MSEC);
pa_log_notice("CPU%i: Freezing for %ims", PA_PTR_TO_INT(p), (int) (nsec/PA_NSEC_PER_MSEC));
- end.tv_sec += nsec / PA_NSEC_PER_SEC;
- end.tv_nsec += nsec % PA_NSEC_PER_SEC;
+ end.tv_sec += (time_t) (nsec / PA_NSEC_PER_SEC);
+ end.tv_nsec += (long int) (nsec % PA_NSEC_PER_SEC);
while ((pa_usec_t) end.tv_nsec > PA_NSEC_PER_SEC) {
end.tv_sec++;
- end.tv_nsec -= PA_NSEC_PER_SEC;
+ end.tv_nsec -= (long int) PA_NSEC_PER_SEC;
}
do {
int main(int argc, char*argv[]) {
int n;
- srand(time(NULL));
+ srand((unsigned) time(NULL));
if (argc >= 3) {
msec_lower = atoi(argv[1]);
for (x = 0, u = 0; x < PA_USEC_PER_SEC * 10; x += PA_USEC_PER_MSEC) {
while (u < PA_ELEMENTSOF(msec) && (pa_usec_t) msec[u]*PA_USEC_PER_MSEC < x) {
- pa_smoother_put(s, msec[u]*PA_USEC_PER_MSEC, msec[u+1]*PA_USEC_PER_MSEC);
+ pa_smoother_put(s, (pa_usec_t) msec[u] * PA_USEC_PER_MSEC, (pa_usec_t) msec[u+1] * PA_USEC_PER_MSEC);
printf("%i\t\t%i\n", msec[u], msec[u+1]);
u += 2;
}
uint8_t *zero;
pa_assert_se(argc >= 2);
- pa_assert_se((granularity = atoi(argv[1])) >= 1);
+ pa_assert_se((granularity = (size_t) atoi(argv[1])) >= 1);
pa_assert_se((i = (argc >= 3) ? fopen(argv[2], "r") : stdin));
pa_assert_se((o = (argc >= 4) ? fopen(argv[3], "w") : stdout));
if (found)
pa_assert_se(fwrite(buffer, granularity, k, o) == k);
else {
- for (p = buffer; (p-buffer)/granularity < k; p += granularity)
+ for (p = buffer; ((size_t) (p-buffer)/granularity) < k; p += granularity)
if (memcmp(p, zero, granularity)) {
size_t left;
found = TRUE;
- left = k - (p-buffer)/granularity;
+ left = (size_t) (k - (size_t) (p-buffer)/granularity);
pa_assert_se(fwrite(p, granularity, left, o) == left);
break;
}
fprintf(stderr, "Writing data to stream %i.\n", i);
- r = pa_stream_write(s, data, sizeof(data), nop_free_cb, sizeof(data) * i, PA_SEEK_ABSOLUTE);
+ r = pa_stream_write(s, data, sizeof(data), nop_free_cb, (int64_t) sizeof(data) * (int64_t) i, PA_SEEK_ABSOLUTE);
assert(r == 0);
/* Be notified when this stream is drained */
if (latency > 0) {
memset(&buffer_attr, 0, sizeof(buffer_attr));
- buffer_attr.tlength = latency;
- buffer_attr.minreq = process_time;
+ buffer_attr.tlength = (uint32_t) latency;
+ buffer_attr.minreq = (uint32_t) process_time;
buffer_attr.maxlength = (uint32_t) -1;
buffer_attr.prebuf = (uint32_t) -1;
flags |= PA_STREAM_ADJUST_LATENCY;
return;
}
- buffer_length = r;
+ buffer_length = (uint32_t) r;
buffer_index = 0;
if (w)
return;
}
- buffer_length -= r;
- buffer_index += r;
+ buffer_length -= (uint32_t) r;
+ buffer_index += (uint32_t) r;
if (!buffer_length) {
pa_xfree(buffer);
fprintf(stderr, _("Time: %0.3f sec; Latency: %0.0f usec. \r"),
(float) usec / 1000000,
- (float) l * (negative?-1:1));
+ (float) l * (negative?-1.0f:1.0f));
}
/* Someone requested that the latency is shown */
case ARG_VOLUME: {
int v = atoi(optarg);
- volume = v < 0 ? 0 : v;
+ volume = v < 0 ? 0U : (pa_volume_t) v;
break;
}
case ARG_CHANNELS:
- sample_spec.channels = atoi(optarg);
+ sample_spec.channels = (uint8_t) atoi(optarg);
break;
case ARG_SAMPLEFORMAT:
break;
case ARG_SAMPLERATE:
- sample_spec.rate = atoi(optarg);
+ sample_spec.rate = (uint32_t) atoi(optarg);
break;
case ARG_CHANNELMAP:
break;
case ARG_LATENCY:
- if (((latency = atoi(optarg))) <= 0) {
+ if (((latency = (size_t) atoi(optarg))) <= 0) {
fprintf(stderr, _("Invalid latency specification '%s'\n"), optarg);
goto quit;
}
break;
case ARG_PROCESS_TIME:
- if (((process_time = atoi(optarg))) <= 0) {
+ if (((process_time = (size_t) atoi(optarg))) <= 0) {
fprintf(stderr, _("Invalid process time specification '%s'\n"), optarg);
goto quit;
}
d = pa_xmalloc(length);
assert(sample_length >= length);
- l = length/pa_frame_size(&sample_spec);
+ l = (sf_count_t) (length/pa_frame_size(&sample_spec));
if ((sf_readf_float(sndfile, d, l)) != l) {
pa_xfree(d);
goto quit;
}
- sample_spec.format = PA_SAMPLE_FLOAT32;
- sample_spec.rate = sfinfo.samplerate;
- sample_spec.channels = sfinfo.channels;
+ sample_spec.format = PA_SAMPLE_FLOAT32;
+ sample_spec.rate = (uint32_t) sfinfo.samplerate;
+ sample_spec.channels = (uint8_t) sfinfo.channels;
- sample_length = sfinfo.frames*pa_frame_size(&sample_spec);
+ sample_length = (size_t)sfinfo.frames*pa_frame_size(&sample_spec);
} else if (!strcmp(argv[optind], "play-sample")) {
action = PLAY_SAMPLE;
if (argc != optind+2 && argc != optind+3) {
goto quit;
}
- sink_input_idx = atoi(argv[optind+1]);
+ sink_input_idx = (uint32_t) atoi(argv[optind+1]);
sink_name = pa_xstrdup(argv[optind+2]);
} else if (!strcmp(argv[optind], "move-source-output")) {
action = MOVE_SOURCE_OUTPUT;
goto quit;
}
- source_output_idx = atoi(argv[optind+1]);
+ source_output_idx = (uint32_t) atoi(argv[optind+1]);
source_name = pa_xstrdup(argv[optind+2]);
} else if (!strcmp(argv[optind], "load-module")) {
int i;
n += strlen(argv[i])+1;
if (n > 0) {
- p = module_args = pa_xnew0(char, n);
+ p = module_args = pa_xmalloc(n);
for (i = optind+2; i < argc; i++)
p += sprintf(p, "%s%s", p == module_args ? "" : " ", argv[i]);
goto quit;
}
- module_index = atoi(argv[optind+1]);
+ module_index = (uint32_t) atoi(argv[optind+1]);
} else if (!strcmp(argv[optind], "suspend-sink")) {
action = SUSPEND_SINK;
/* Number of fragments set? */
if (i->n_fragments < 2) {
if (i->fragment_size > 0) {
- i->n_fragments = pa_bytes_per_second(&i->sample_spec) / 2 / i->fragment_size;
+ i->n_fragments = (unsigned) (pa_bytes_per_second(&i->sample_spec) / 2 / i->fragment_size);
if (i->n_fragments < 2)
i->n_fragments = 2;
} else
return -1;
}
- if (pa_stream_write(i->play_stream, i->buf, r, free, 0, PA_SEEK_RELATIVE) < 0) {
+ if (pa_stream_write(i->play_stream, i->buf, (size_t) r, free, 0, PA_SEEK_RELATIVE) < 0) {
debug(DEBUG_LEVEL_NORMAL, __FILE__": pa_stream_write(): %s\n", pa_strerror(pa_context_errno(i->context)));
return -1;
}
i->buf = NULL;
assert(n >= (size_t) r);
- n -= r;
+ n -= (size_t) r;
}
if (n >= i->fragment_size)
}
assert((size_t)r <= len - i->rec_offset);
- i->rec_offset += r;
+ i->rec_offset += (size_t) r;
if (i->rec_offset == len) {
if (pa_stream_drop(i->rec_stream) < 0) {
}
assert(n >= (size_t) r);
- n -= r;
+ n -= (size_t) r;
}
if (n >= i->fragment_size)
pa_stream_set_latency_update_callback(i->play_stream, stream_latency_update_cb, i);
memset(&attr, 0, sizeof(attr));
- attr.maxlength = i->fragment_size * (i->n_fragments+1);
- attr.tlength = i->fragment_size * i->n_fragments;
- attr.prebuf = i->fragment_size;
- attr.minreq = i->fragment_size;
+ attr.maxlength = (uint32_t) (i->fragment_size * (i->n_fragments+1));
+ attr.tlength = (uint32_t) (i->fragment_size * i->n_fragments);
+ attr.prebuf = (uint32_t) i->fragment_size;
+ attr.minreq = (uint32_t) i->fragment_size;
flags = PA_STREAM_INTERPOLATE_TIMING|PA_STREAM_AUTO_TIMING_UPDATE;
if (i->play_precork) {
goto fail;
}
- n = i->fragment_size;
+ n = (int) i->fragment_size;
setsockopt(i->app_fd, SOL_SOCKET, SO_SNDBUF, &n, sizeof(n));
- n = i->fragment_size;
+ n = (int) i->fragment_size;
setsockopt(i->thread_fd, SOL_SOCKET, SO_RCVBUF, &n, sizeof(n));
return 0;
pa_stream_set_latency_update_callback(i->rec_stream, stream_latency_update_cb, i);
memset(&attr, 0, sizeof(attr));
- attr.maxlength = i->fragment_size * (i->n_fragments+1);
- attr.fragsize = i->fragment_size;
+ attr.maxlength = (uint32_t) (i->fragment_size * (i->n_fragments+1));
+ attr.fragsize = (uint32_t) i->fragment_size;
flags = PA_STREAM_INTERPOLATE_TIMING|PA_STREAM_AUTO_TIMING_UPDATE;
if (i->rec_precork) {
goto fail;
}
- n = i->fragment_size;
+ n = (int) i->fragment_size;
setsockopt(i->app_fd, SOL_SOCKET, SO_RCVBUF, &n, sizeof(n));
- n = i->fragment_size;
+ n = (int) i->fragment_size;
setsockopt(i->thread_fd, SOL_SOCKET, SO_SNDBUF, &n, sizeof(n));
return 0;
if (flags & O_CREAT) {
va_start(args, flags);
if (sizeof(mode_t) < sizeof(int))
- mode = va_arg(args, int);
+ mode = (mode_t) va_arg(args, int);
else
mode = va_arg(args, mode_t);
va_end(args);
if (readf_function) {
size_t k = pa_frame_size(&sample_spec);
- if ((bytes = readf_function(sndfile, data, length/k)) > 0)
- bytes *= k;
+ if ((bytes = readf_function(sndfile, data, (sf_count_t) (length/k))) > 0)
+ bytes *= (sf_count_t) k;
} else
- bytes = sf_read_raw(sndfile, data, length);
+ bytes = sf_read_raw(sndfile, data, (sf_count_t) length);
if (bytes > 0)
- pa_stream_write(s, data, bytes, pa_xfree, 0, PA_SEEK_RELATIVE);
+ pa_stream_write(s, data, (size_t) bytes, pa_xfree, 0, PA_SEEK_RELATIVE);
else
pa_xfree(data);
case ARG_VOLUME: {
int v = atoi(optarg);
- volume = v < 0 ? 0 : v;
+ volume = v < 0 ? 0U : (pa_volume_t) v;
break;
}
goto quit;
}
- sample_spec.rate = sfinfo.samplerate;
- sample_spec.channels = sfinfo.channels;
+ sample_spec.rate = (uint32_t) sfinfo.samplerate;
+ sample_spec.channels = (uint8_t) sfinfo.channels;
readf_function = NULL;