summaryrefslogtreecommitdiffstats
path: root/src/pulsecore
diff options
context:
space:
mode:
Diffstat (limited to 'src/pulsecore')
-rw-r--r--src/pulsecore/asyncq.c10
-rw-r--r--src/pulsecore/cli-command.c10
-rw-r--r--src/pulsecore/cli-text.c12
-rw-r--r--src/pulsecore/core-util.c73
-rw-r--r--src/pulsecore/core-util.h4
-rw-r--r--src/pulsecore/envelope.c22
-rw-r--r--src/pulsecore/fdsem.c4
-rw-r--r--src/pulsecore/idxset.c2
-rw-r--r--src/pulsecore/ioline.c12
-rw-r--r--src/pulsecore/ipacl.c2
-rw-r--r--src/pulsecore/memblock.c30
-rw-r--r--src/pulsecore/memblockq.c67
-rw-r--r--src/pulsecore/namereg.c8
-rw-r--r--src/pulsecore/parseaddr.c21
-rw-r--r--src/pulsecore/pid.c4
-rw-r--r--src/pulsecore/protocol-esound.c68
-rw-r--r--src/pulsecore/protocol-native.c54
-rw-r--r--src/pulsecore/protocol-simple.c16
-rw-r--r--src/pulsecore/pstream.c12
-rw-r--r--src/pulsecore/resampler.c78
-rw-r--r--src/pulsecore/rtpoll.c2
-rw-r--r--src/pulsecore/rtsig.c2
-rw-r--r--src/pulsecore/sample-util.c27
-rw-r--r--src/pulsecore/sconv-s16le.c22
-rw-r--r--src/pulsecore/sconv.c22
-rw-r--r--src/pulsecore/shm.c6
-rw-r--r--src/pulsecore/sink-input.c2
-rw-r--r--src/pulsecore/socket-client.c2
-rw-r--r--src/pulsecore/socket-server.c2
-rw-r--r--src/pulsecore/sound-file-stream.c10
-rw-r--r--src/pulsecore/sound-file.c14
-rw-r--r--src/pulsecore/source-output.c2
-rw-r--r--src/pulsecore/strbuf.c14
-rw-r--r--src/pulsecore/strbuf.h2
-rw-r--r--src/pulsecore/tagstruct.c16
-rw-r--r--src/pulsecore/time-smoother.c14
-rw-r--r--src/pulsecore/x11prop.c4
37 files changed, 346 insertions, 326 deletions
diff --git a/src/pulsecore/asyncq.c b/src/pulsecore/asyncq.c
index 03e9f0df..f64931a5 100644
--- a/src/pulsecore/asyncq.c
+++ b/src/pulsecore/asyncq.c
@@ -71,7 +71,7 @@ PA_STATIC_FLIST_DECLARE(localq, 0, pa_xfree);
#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);
}
@@ -132,7 +132,7 @@ void pa_asyncq_free(pa_asyncq *l, pa_free_cb_t free_cb) {
}
static int push(pa_asyncq*l, void *p, pa_bool_t wait) {
- int idx;
+ unsigned idx;
pa_atomic_ptr_t *cells;
pa_assert(l);
@@ -220,7 +220,7 @@ void pa_asyncq_post(pa_asyncq*l, void *p) {
}
void* pa_asyncq_pop(pa_asyncq*l, pa_bool_t wait) {
- int idx;
+ unsigned idx;
void *ret;
pa_atomic_ptr_t *cells;
@@ -263,7 +263,7 @@ int pa_asyncq_read_fd(pa_asyncq *q) {
}
int pa_asyncq_read_before_poll(pa_asyncq *l) {
- int idx;
+ unsigned idx;
pa_atomic_ptr_t *cells;
pa_assert(l);
@@ -280,8 +280,6 @@ int pa_asyncq_read_before_poll(pa_asyncq *l) {
if (pa_fdsem_before_poll(l->write_fdsem) >= 0)
return 0;
}
-
- return 0;
}
void pa_asyncq_read_after_poll(pa_asyncq *l) {
diff --git a/src/pulsecore/cli-command.c b/src/pulsecore/cli-command.c
index aa05a464..1624165d 100644
--- a/src/pulsecore/cli-command.c
+++ b/src/pulsecore/cli-command.c
@@ -318,22 +318,22 @@ static int pa_cli_command_stat(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_b
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));
diff --git a/src/pulsecore/cli-text.c b/src/pulsecore/cli-text.c
index 4cbe7c34..7bbc2660 100644
--- a/src/pulsecore/cli-text.c
+++ b/src/pulsecore/cli-text.c
@@ -151,8 +151,10 @@ char *pa_sink_list_to_string(pa_core *c) {
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,
@@ -225,7 +227,9 @@ char *pa_source_list_to_string(pa_core *c) {
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),
@@ -411,7 +415,7 @@ char *pa_scache_list_to_string(pa_core *c) {
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(
diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c
index 5841df0c..41a31042 100644
--- a/src/pulsecore/core-util.c
+++ b/src/pulsecore/core-util.c
@@ -345,7 +345,7 @@ ssize_t pa_loop_read(int fd, void*data, size_t size, int *type) {
ret += r;
data = (uint8_t*) data + r;
- size -= r;
+ size -= (size_t) r;
}
return ret;
@@ -376,7 +376,7 @@ ssize_t pa_loop_write(int fd, const void*data, size_t size, int *type) {
ret += r;
data = (const uint8_t*) data + r;
- size -= r;
+ size -= (size_t) r;
}
return ret;
@@ -445,7 +445,7 @@ void pa_check_signal_is_blocked(int sig) {
/* 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);
@@ -462,11 +462,11 @@ char *pa_sprintf_malloc(const char *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;
}
@@ -475,7 +475,7 @@ char *pa_sprintf_malloc(const char *format, ...) {
/* 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);
@@ -492,11 +492,11 @@ char *pa_vsprintf_malloc(const char *format, va_list ap) {
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;
}
@@ -929,10 +929,10 @@ static int is_group(gid_t gid, const char *name) {
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)
@@ -970,14 +970,14 @@ finish:
/* 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;
}
@@ -1018,10 +1018,10 @@ int pa_uid_in_group(uid_t uid, const char *name) {
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) {
@@ -1061,7 +1061,7 @@ gid_t pa_get_gid_of_group(const char *name) {
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) {
@@ -1126,7 +1126,7 @@ int pa_lock_fd(int fd, int b) {
/* 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;
@@ -1291,7 +1291,7 @@ char *pa_get_state_dir(void) {
/* 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;
@@ -1372,9 +1372,9 @@ char *pa_get_runtime_dir(void) {
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;
}
@@ -1934,8 +1934,8 @@ int pa_atod(const char *s, double *ret_d) {
}
/* 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);
@@ -1950,7 +1950,7 @@ int pa_snprintf(char *str, size_t size, const char *format, ...) {
}
/* 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);
@@ -1962,9 +1962,12 @@ int pa_vsnprintf(char *str, size_t size, const char *format, va_list ap) {
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
@@ -1988,7 +1991,7 @@ char *pa_getcwd(void) {
size_t l = 128;
for (;;) {
- char *p = pa_xnew(char, l);
+ char *p = pa_xmalloc(l);
if (getcwd(p, l))
return p;
@@ -2013,7 +2016,7 @@ void *pa_will_need(const void *p, size_t l) {
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) {
@@ -2090,7 +2093,7 @@ char *pa_readlink(const char *p) {
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);
@@ -2109,8 +2112,8 @@ char *pa_readlink(const char *p) {
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);
@@ -2237,8 +2240,8 @@ int pa_close_allv(const int except_fds[]) {
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);
@@ -2286,8 +2289,8 @@ int pa_unblock_sigsv(const int 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);
@@ -2395,7 +2398,7 @@ char *pa_machine_id(void) {
for (;;) {
char *c;
- c = pa_xnew(char, l);
+ c = pa_xmalloc(l);
if (!pa_get_host_name(c, l)) {
diff --git a/src/pulsecore/core-util.h b/src/pulsecore/core-util.h
index 838e4ad3..7167972b 100644
--- a/src/pulsecore/core-util.h
+++ b/src/pulsecore/core-util.h
@@ -127,8 +127,8 @@ int pa_atoi(const char *s, int32_t *ret_i);
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);
diff --git a/src/pulsecore/envelope.c b/src/pulsecore/envelope.c
index e2691611..7f2252e9 100644
--- a/src/pulsecore/envelope.c
+++ b/src/pulsecore/envelope.c
@@ -153,11 +153,11 @@ void pa_envelope_free(pa_envelope *e) {
}
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) {
@@ -573,11 +573,11 @@ static float linear_get_float(pa_envelope *e, int v) {
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) {
@@ -605,7 +605,7 @@ 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;
@@ -620,13 +620,13 @@ 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;
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));
}
}
@@ -637,13 +637,13 @@ 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;
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));
}
}
@@ -659,7 +659,7 @@ void pa_envelope_apply(pa_envelope *e, pa_memchunk *chunk) {
e->x += fs;
for (c = 0; c < e->sample_spec.channels; c++, t++)
- *t = (factor * *t) / 0x10000;
+ *t = (int16_t) ((factor * *t) / 0x10000);
}
break;
@@ -674,7 +674,7 @@ void pa_envelope_apply(pa_envelope *e, pa_memchunk *chunk) {
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);
}
}
diff --git a/src/pulsecore/fdsem.c b/src/pulsecore/fdsem.c
index 1531e3db..2a7ae589 100644
--- a/src/pulsecore/fdsem.c
+++ b/src/pulsecore/fdsem.c
@@ -195,7 +195,7 @@ static void flush(pa_fdsem *f) {
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) {
@@ -265,7 +265,7 @@ void pa_fdsem_wait(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);
diff --git a/src/pulsecore/idxset.c b/src/pulsecore/idxset.c
index fb4497b8..b6423efd 100644
--- a/src/pulsecore/idxset.c
+++ b/src/pulsecore/idxset.c
@@ -66,7 +66,7 @@ unsigned pa_idxset_string_hash_func(const void *p) {
const char *c;
for (c = p; *c; c++)
- hash = 31 * hash + *c;
+ hash = 31 * hash + (unsigned) *c;
return hash;
}
diff --git a/src/pulsecore/ioline.c b/src/pulsecore/ioline.c
index 90afaafd..88174c05 100644
--- a/src/pulsecore/ioline.c
+++ b/src/pulsecore/ioline.c
@@ -164,7 +164,7 @@ void pa_ioline_puts(pa_ioline *l, const char *c) {
/* 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);
@@ -285,7 +285,7 @@ static int do_read(pa_ioline *l) {
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);
@@ -315,10 +315,10 @@ static int do_read(pa_ioline *l) {
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;
@@ -346,8 +346,8 @@ static int do_write(pa_ioline *l) {
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)
diff --git a/src/pulsecore/ipacl.c b/src/pulsecore/ipacl.c
index 7b5f865b..6d5080fb 100644
--- a/src/pulsecore/ipacl.c
+++ b/src/pulsecore/ipacl.c
@@ -122,7 +122,7 @@ pa_ip_acl* pa_ip_acl_new(const char *s) {
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;
diff --git a/src/pulsecore/memblock.c b/src/pulsecore/memblock.c
index 47909cdc..6d12acdc 100644
--- a/src/pulsecore/memblock.c
+++ b/src/pulsecore/memblock.c
@@ -162,14 +162,14 @@ static void stat_add(pa_memblock*b) {
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]);
@@ -185,14 +185,14 @@ static void stat_remove(pa_memblock *b) {
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]);
@@ -252,7 +252,7 @@ static struct mempool_slot* mempool_allocate_slot(pa_mempool *p) {
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");
@@ -280,7 +280,7 @@ static unsigned mempool_slot_idx(pa_mempool *p, void *ptr) {
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 */
@@ -659,7 +659,7 @@ static void memblock_replace_import(pa_memblock *b) {
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);
@@ -766,7 +766,7 @@ void pa_mempool_vacuum(pa_mempool *p) {
;
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))
;
@@ -979,7 +979,7 @@ void pa_memexport_free(pa_memexport *e) {
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);
@@ -1018,7 +1018,7 @@ int pa_memexport_process_release(pa_memexport *e, uint32_t id) {
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);
@@ -1046,7 +1046,7 @@ static void memexport_revoke_blocks(pa_memexport *e, pa_memimport *i) {
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);
}
@@ -1107,7 +1107,7 @@ int pa_memexport_put(pa_memexport *e, pa_memblock *b, uint32_t *block_id, uint32
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); */
@@ -1127,13 +1127,13 @@ int pa_memexport_put(pa_memexport *e, pa_memblock *b, uint32_t *block_id, uint32
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;
}
diff --git a/src/pulsecore/memblockq.c b/src/pulsecore/memblockq.c
index 841b9075..265da37f 100644
--- a/src/pulsecore/memblockq.c
+++ b/src/pulsecore/memblockq.c
@@ -84,7 +84,8 @@ pa_memblockq* pa_memblockq_new(
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);
@@ -215,7 +216,7 @@ static void drop_backlog(pa_memblockq *bq) {
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);
@@ -227,10 +228,10 @@ static pa_bool_t can_push(pa_memblockq *bq, size_t l) {
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;
}
@@ -239,7 +240,7 @@ static pa_bool_t can_push(pa_memblockq *bq, size_t l) {
/* 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;
@@ -294,7 +295,7 @@ int pa_memblockq_push(pa_memblockq* bq, const pa_memchunk *uchunk) {
/* 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 */
@@ -306,7 +307,7 @@ int pa_memblockq_push(pa_memblockq* bq, const pa_memchunk *uchunk) {
/* 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;
@@ -320,11 +321,11 @@ int pa_memblockq_push(pa_memblockq* bq, const pa_memchunk *uchunk) {
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 */
@@ -339,7 +340,7 @@ int pa_memblockq_push(pa_memblockq* bq, const pa_memchunk *uchunk) {
}
/* 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;
@@ -357,8 +358,8 @@ int pa_memblockq_push(pa_memblockq* bq, const pa_memchunk *uchunk) {
/* 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;
@@ -373,11 +374,11 @@ int pa_memblockq_push(pa_memblockq* bq, const pa_memchunk *uchunk) {
/* 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
@@ -389,7 +390,7 @@ int pa_memblockq_push(pa_memblockq* bq, const pa_memchunk *uchunk) {
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;
@@ -411,10 +412,10 @@ finish:
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;
}
@@ -471,7 +472,7 @@ int pa_memblockq_peek(pa_memblockq* bq, pa_memchunk *chunk) {
/* 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
@@ -506,8 +507,8 @@ int pa_memblockq_peek(pa_memblockq* bq, pa_memchunk *chunk) {
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;
}
@@ -533,20 +534,20 @@ void pa_memblockq_drop(pa_memblockq *bq, size_t length) {
/* 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;
}
}
@@ -563,8 +564,8 @@ void pa_memblockq_rewind(pa_memblockq *bq, size_t length) {
/* 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) {
@@ -628,10 +629,10 @@ void pa_memblockq_seek(pa_memblockq *bq, int64_t offset, pa_seek_mode_t seek) {
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;
}
@@ -652,10 +653,10 @@ void pa_memblockq_flush_write(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;
}
@@ -874,7 +875,7 @@ int pa_memblockq_splice(pa_memblockq *bq, pa_memblockq *source) {
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);
}
diff --git a/src/pulsecore/namereg.c b/src/pulsecore/namereg.c
index 30420546..ad697ed5 100644
--- a/src/pulsecore/namereg.c
+++ b/src/pulsecore/namereg.c
@@ -45,7 +45,7 @@ struct namereg_entry {
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') ||
@@ -77,10 +77,10 @@ char* pa_namereg_make_valid_name(const char *name) {
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;
@@ -136,7 +136,7 @@ const char *pa_namereg_register(pa_core *c, const char *name, pa_namereg_type_t
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);
diff --git a/src/pulsecore/parseaddr.c b/src/pulsecore/parseaddr.c
index f2b6b2cf..c5cd7fe7 100644
--- a/src/pulsecore/parseaddr.c
+++ b/src/pulsecore/parseaddr.c
@@ -51,20 +51,29 @@ static char *parse_host(const char *s, uint16_t *ret_port) {
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));
}
}
diff --git a/src/pulsecore/pid.c b/src/pulsecore/pid.c
index 81148da4..1c0851ba 100644
--- a/src/pulsecore/pid.c
+++ b/src/pulsecore/pid.c
@@ -182,9 +182,11 @@ static int proc_name_ours(pid_t pid, const char *procname) {
return !!good;
}
-#endif
+#else
return 1;
+#endif
+
}
/* Create a new PID file for the current process. */
diff --git a/src/pulsecore/protocol-esound.c b/src/pulsecore/protocol-esound.c
index 36d1b458..460119a9 100644
--- a/src/pulsecore/protocol-esound.c
+++ b/src/pulsecore/protocol-esound.c
@@ -184,7 +184,7 @@ static struct proto_handler proto_map[ESD_PROTO_MAX] = {
{ 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 */
@@ -194,8 +194,8 @@ static struct proto_handler proto_map[ESD_PROTO_MAX] = {
{ 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" },
@@ -309,7 +309,7 @@ static void connection_write(connection *c, const void *data, size_t length) {
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
@@ -397,7 +397,7 @@ static int esd_proto_stream_play(connection *c, esd_proto_t request, const void
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");
@@ -430,7 +430,7 @@ static int esd_proto_stream_play(connection *c, esd_proto_t request, const void
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,
@@ -455,7 +455,7 @@ static int esd_proto_stream_play(connection *c, esd_proto_t request, const void
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);
@@ -482,7 +482,7 @@ static int esd_proto_stream_record(connection *c, esd_proto_t request, const voi
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.");
@@ -572,7 +572,7 @@ static int esd_proto_get_latency(connection *c, esd_proto_t request, const void
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);
}
@@ -591,7 +591,7 @@ static int esd_proto_server_info(connection *c, esd_proto_t request, const void
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);
}
@@ -641,9 +641,9 @@ static int esd_proto_all_info(connection *c, esd_proto_t request, const void *da
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);
}
@@ -706,15 +706,15 @@ static int esd_proto_all_info(connection *c, esd_proto_t request, const void *da
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*/
@@ -790,7 +790,7 @@ static int esd_proto_sample_cache(connection *c, esd_proto_t request, const void
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.");
@@ -807,9 +807,9 @@ static int esd_proto_sample_cache(connection *c, esd_proto_t request, const void
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);
@@ -840,7 +840,7 @@ static int esd_proto_sample_get_id(connection *c, esd_proto_t request, const voi
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));
@@ -867,12 +867,12 @@ static int esd_proto_sample_free_or_play(connection *c, esd_proto_t request, con
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;
}
}
@@ -919,7 +919,9 @@ static int do_read(connection *c) {
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);
@@ -970,7 +972,8 @@ static int do_read(connection *c) {
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);
@@ -1000,7 +1003,7 @@ static int do_read(connection *c) {
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) {
@@ -1033,7 +1036,7 @@ static int do_read(connection *c) {
/* 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) {
@@ -1071,12 +1074,12 @@ static int do_read(connection *c) {
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;
@@ -1100,7 +1103,8 @@ static int do_write(connection *c) {
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) {
@@ -1129,7 +1133,7 @@ static int do_write(connection *c) {
return -1;
}
- pa_memblockq_drop(c->output_memblockq, r);
+ pa_memblockq_drop(c->output_memblockq, (size_t) r);
}
return 0;
@@ -1288,7 +1292,7 @@ static int sink_input_pop_cb(pa_sink_input *i, size_t length, pa_memchunk *chunk
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;
diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c
index b7466022..d4694a05 100644
--- a/src/pulsecore/protocol-native.c
+++ b/src/pulsecore/protocol-native.c
@@ -477,12 +477,12 @@ static void fix_record_buffer_attr_pre(record_stream *s, pa_bool_t adjust_latenc
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;
@@ -501,7 +501,7 @@ static void fix_record_buffer_attr_pre(record_stream *s, pa_bool_t adjust_latenc
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;
}
@@ -513,7 +513,7 @@ static void fix_record_buffer_attr_post(record_stream *s, uint32_t *maxlength, u
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);
@@ -524,7 +524,7 @@ static void fix_record_buffer_attr_post(record_stream *s, uint32_t *maxlength, u
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(
@@ -666,10 +666,10 @@ static int playback_stream_process_msg(pa_msgobject *o, int code, void*userdata,
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;
}
@@ -749,20 +749,20 @@ static void fix_playback_buffer_attr_pre(playback_stream *s, pa_bool_t adjust_la
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);
@@ -823,16 +823,16 @@ static void fix_playback_buffer_attr_pre(playback_stream *s, pa_bool_t adjust_la
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;
@@ -996,7 +996,7 @@ static void playback_stream_request_bytes(playback_stream *s) {
/* 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))
@@ -1156,7 +1156,7 @@ static void handle_seek(playback_stream *s, int64_t indexw) {
* 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);
}
}
@@ -1196,7 +1196,7 @@ static int sink_input_process_msg(pa_msgobject *o, int code, void *userdata, int
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);
@@ -2239,7 +2239,7 @@ static void command_stat(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_ta
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);
}
@@ -2593,7 +2593,7 @@ static void module_fill_tagstruct(pa_tagstruct *t, pa_module *module) {
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);
}
@@ -2666,7 +2666,7 @@ static void scache_fill_tagstruct(pa_native_connection *c, pa_tagstruct *t, pa_s
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);
@@ -3412,7 +3412,7 @@ static void command_remove_proplist(pa_pdispatch *pd, uint32_t command, uint32_t
if (!z)
break;
- changed += pa_proplist_unset(p, z) >= 0;
+ changed += (unsigned) (pa_proplist_unset(p, z) >= 0);
pa_xfree(z);
}
@@ -3669,7 +3669,7 @@ static void autoload_fill_tagstruct(pa_tagstruct *t, const pa_autoload_entry *e)
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);
}
diff --git a/src/pulsecore/protocol-simple.c b/src/pulsecore/protocol-simple.c
index 78874bb9..65e67737 100644
--- a/src/pulsecore/protocol-simple.c
+++ b/src/pulsecore/protocol-simple.c
@@ -159,7 +159,7 @@ static int do_read(connection *c) {
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) {
@@ -197,12 +197,12 @@ static int do_read(connection *c) {
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;
}
@@ -240,7 +240,7 @@ static int do_write(connection *c) {
return -1;
}
- pa_memblockq_drop(c->output_memblockq, r);
+ pa_memblockq_drop(c->output_memblockq, (size_t) r);
return 0;
}
@@ -377,7 +377,7 @@ static int sink_input_pop_cb(pa_sink_input *i, size_t length, pa_memchunk *chunk
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;
@@ -546,7 +546,7 @@ void pa_simple_protocol_connect(pa_simple_protocol *p, pa_iochannel *io, pa_simp
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,
@@ -558,7 +558,7 @@ void pa_simple_protocol_connect(pa_simple_protocol *p, pa_iochannel *io, pa_simp
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);
}
diff --git a/src/pulsecore/pstream.c b/src/pulsecore/pstream.c
index 48404cca..7ff8edc9 100644
--- a/src/pulsecore/pstream.c
+++ b/src/pulsecore/pstream.c
@@ -488,7 +488,7 @@ static void prepare_next_write_item(pa_pstream *p) {
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) {
@@ -511,7 +511,7 @@ static void prepare_next_write_item(pa_pstream *p) {
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;
@@ -542,7 +542,7 @@ static void prepare_next_write_item(pa_pstream *p) {
}
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;
@@ -607,7 +607,7 @@ static int do_write(pa_pstream *p) {
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);
@@ -675,7 +675,7 @@ static int do_read(pa_pstream *p) {
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;
@@ -769,7 +769,7 @@ static int do_read(pa_pstream *p) {
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;
diff --git a/src/pulsecore/resampler.c b/src/pulsecore/resampler.c
index c82f4c1e..ee953652 100644
--- a/src/pulsecore/resampler.c
+++ b/src/pulsecore/resampler.c
@@ -373,7 +373,7 @@ size_t pa_resampler_max_block_size(pa_resampler *r) {
/* 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);
@@ -642,7 +642,7 @@ static void calc_map_table(pa_resampler *r) {
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;
}
@@ -663,7 +663,7 @@ static void calc_map_table(pa_resampler *r) {
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;
}
@@ -684,7 +684,7 @@ static void calc_map_table(pa_resampler *r) {
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 {
@@ -701,7 +701,7 @@ static void calc_map_table(pa_resampler *r) {
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;
}
@@ -716,7 +716,7 @@ static void calc_map_table(pa_resampler *r) {
* 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. */
@@ -763,12 +763,12 @@ static void calc_map_table(pa_resampler *r) {
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;
}
}
}
@@ -788,12 +788,12 @@ static void calc_map_table(pa_resampler *r) {
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;
}
}
}
@@ -814,12 +814,12 @@ static void calc_map_table(pa_resampler *r) {
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;
}
}
@@ -840,12 +840,12 @@ static void calc_map_table(pa_resampler *r) {
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;
}
}
}
@@ -862,7 +862,7 @@ static void calc_map_table(pa_resampler *r) {
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;
}
}
}
@@ -905,7 +905,7 @@ static pa_memchunk* convert_to_work_format(pa_resampler *r, pa_memchunk *input)
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;
@@ -974,7 +974,7 @@ static pa_memchunk *remap_channels(pa_resampler *r, pa_memchunk *input) {
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;
@@ -994,8 +994,8 @@ static pa_memchunk *remap_channels(pa_resampler *r, pa_memchunk *input) {
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:
@@ -1013,7 +1013,7 @@ static pa_memchunk *remap_channels(pa_resampler *r, pa_memchunk *input) {
(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]);
}
}
@@ -1037,7 +1037,7 @@ static pa_memchunk *remap_channels(pa_resampler *r, pa_memchunk *input) {
(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
@@ -1046,7 +1046,7 @@ static pa_memchunk *remap_channels(pa_resampler *r, pa_memchunk *input) {
(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]);
}
}
@@ -1077,8 +1077,8 @@ static pa_memchunk *resample(pa_resampler *r, pa_memchunk *input) {
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;
@@ -1112,8 +1112,8 @@ static pa_memchunk *convert_from_work_format(pa_resampler *r, pa_memchunk *input
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;
@@ -1192,7 +1192,7 @@ static void libsamplerate_resample(pa_resampler *r, const pa_memchunk *input, un
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) {
@@ -1354,7 +1354,7 @@ static void trivial_resample(pa_resampler *r, const pa_memchunk *input, unsigned
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);
@@ -1430,7 +1430,7 @@ static void peaks_resample(pa_resampler *r, const pa_memchunk *input, unsigned i
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;
@@ -1523,7 +1523,7 @@ static void ffmpeg_resample(pa_resampler *r, const pa_memchunk *input, unsigned
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);
@@ -1543,18 +1543,18 @@ static void ffmpeg_resample(pa_resampler *r, const pa_memchunk *input, unsigned
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);
@@ -1562,8 +1562,8 @@ static void ffmpeg_resample(pa_resampler *r, const pa_memchunk *input, unsigned
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);
@@ -1605,7 +1605,7 @@ static int ffmpeg_init(pa_resampler *r) {
* 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;
diff --git a/src/pulsecore/rtpoll.c b/src/pulsecore/rtpoll.c
index a67a5516..543262bc 100644
--- a/src/pulsecore/rtpoll.c
+++ b/src/pulsecore/rtpoll.c
@@ -394,7 +394,7 @@ int pa_rtpoll_run(pa_rtpoll *p, pa_bool_t wait) {
#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)
diff --git a/src/pulsecore/rtsig.c b/src/pulsecore/rtsig.c
index 4df217c3..4cd6aa8f 100644
--- a/src/pulsecore/rtsig.c
+++ b/src/pulsecore/rtsig.c
@@ -40,7 +40,7 @@ static void _free_rtsig(void *p) {
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);
diff --git a/src/pulsecore/sample-util.c b/src/pulsecore/sample-util.c
index 0cdbcd02..4b2efe5e 100644
--- a/src/pulsecore/sample-util.c
+++ b/src/pulsecore/sample-util.c
@@ -85,7 +85,6 @@ static uint8_t silence_byte(pa_sample_format_t format) {
default:
pa_assert_not_reached();
}
- return 0;
}
void* pa_silence_memory(void *p, size_t length, const pa_sample_spec *spec) {
@@ -134,7 +133,7 @@ static void calc_linear_float_stream_volumes(pa_mix_info streams[], unsigned nst
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]);
}
}
}
@@ -146,7 +145,7 @@ static void calc_linear_float_volume(float linear[], const pa_cvolume *volume) {
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(
@@ -412,7 +411,7 @@ 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;
@@ -451,7 +450,7 @@ size_t pa_mix(
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;
@@ -707,7 +706,7 @@ void pa_volume_memchunk(
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;
@@ -730,7 +729,7 @@ void pa_volume_memchunk(
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;
@@ -745,8 +744,8 @@ void pa_volume_memchunk(
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;
@@ -756,7 +755,7 @@ void pa_volume_memchunk(
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;
}
@@ -834,7 +833,7 @@ void pa_interleave(const void *src[], unsigned channels, void *dst, size_t ss, u
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;
}
@@ -862,7 +861,7 @@ void pa_deinterleave(const void *src, void *dst[], unsigned channels, size_t ss,
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;
}
@@ -965,7 +964,7 @@ void pa_sample_clamp(pa_sample_format_t format, void *dst, size_t dstr, const vo
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);
@@ -974,7 +973,7 @@ void pa_sample_clamp(pa_sample_format_t format, void *dst, size_t dstr, const vo
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);
diff --git a/src/pulsecore/sconv-s16le.c b/src/pulsecore/sconv-s16le.c
index 41670f27..693d529b 100644
--- a/src/pulsecore/sconv-s16le.c
+++ b/src/pulsecore/sconv-s16le.c
@@ -70,13 +70,13 @@ void pa_sconv_s16le_to_float32ne(unsigned n, const int16_t *a, float *b) {
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
}
@@ -95,7 +95,7 @@ void pa_sconv_s32le_to_float32ne(unsigned n, const int32_t *a, float *b) {
#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
}
@@ -110,7 +110,7 @@ void pa_sconv_s16le_from_float32ne(unsigned n, const float *a, int16_t *b) {
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);
}
@@ -118,7 +118,7 @@ void pa_sconv_s16le_from_float32ne(unsigned n, const float *a, int16_t *b) {
#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
}
@@ -133,7 +133,7 @@ void pa_sconv_s32le_from_float32ne(unsigned n, const float *a, int32_t *b) {
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);
}
@@ -141,7 +141,7 @@ void pa_sconv_s32le_from_float32ne(unsigned n, const float *a, int32_t *b) {
#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
}
@@ -181,7 +181,7 @@ void pa_sconv_s16le_from_float32re(unsigned n, const float *a, int16_t *b) {
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);
}
@@ -196,7 +196,7 @@ void pa_sconv_s32le_from_float32re(unsigned n, const float *a, int32_t *b) {
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);
}
@@ -219,7 +219,7 @@ void pa_sconv_s32le_to_s16re(unsigned n, const int32_t*a, int16_t *b) {
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++;
}
@@ -241,7 +241,7 @@ void pa_sconv_s32le_from_s16re(unsigned n, const int16_t *a, int32_t *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++;
diff --git a/src/pulsecore/sconv.c b/src/pulsecore/sconv.c
index 581e4681..733a46ae 100644
--- a/src/pulsecore/sconv.c
+++ b/src/pulsecore/sconv.c
@@ -46,7 +46,7 @@ static void u8_to_float32ne(unsigned n, const uint8_t *a, float *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) {
@@ -55,7 +55,7 @@ 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) {
@@ -64,9 +64,9 @@ 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) {
@@ -84,7 +84,7 @@ static void float32ne_to_float32ne(unsigned n, const float *a, float *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) {
@@ -101,7 +101,7 @@ static void s16ne_to_s16ne(unsigned n, const int16_t *a, int16_t *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) {
@@ -109,7 +109,7 @@ 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 */
@@ -128,7 +128,7 @@ static void ulaw_from_float32ne(unsigned n, const float *a, uint8_t *b) {
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);
}
@@ -166,7 +166,7 @@ static void alaw_from_float32ne(unsigned n, const float *a, uint8_t *b) {
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);
}
@@ -177,7 +177,7 @@ static void alaw_to_s16ne(unsigned n, const int8_t *a, int16_t *b) {
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) {
diff --git a/src/pulsecore/shm.c b/src/pulsecore/shm.c
index 298bf716..b0870202 100644
--- a/src/pulsecore/shm.c
+++ b/src/pulsecore/shm.c
@@ -138,7 +138,7 @@ int pa_shm_create_rw(pa_shm *m, size_t size, pa_bool_t shared, mode_t mode) {
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;
}
@@ -235,7 +235,7 @@ void pa_shm_punch(pa_shm *m, size_t offset, size_t size) {
/* 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;
@@ -289,7 +289,7 @@ int pa_shm_attach_ro(pa_shm *m, unsigned id) {
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));
diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c
index 64a6cdf9..f4e803d0 100644
--- a/src/pulsecore/sink-input.c
+++ b/src/pulsecore/sink-input.c
@@ -535,7 +535,7 @@ int pa_sink_input_peek(pa_sink_input *i, size_t slength /* in sink frames */, pa
* 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;
diff --git a/src/pulsecore/socket-client.c b/src/pulsecore/socket-client.c
index 7be0e242..3bde40d0 100644
--- a/src/pulsecore/socket-client.c
+++ b/src/pulsecore/socket-client.c
@@ -283,7 +283,7 @@ static int sockaddr_prepare(pa_socket_client *c, const struct sockaddr *sa, size
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;
diff --git a/src/pulsecore/socket-server.c b/src/pulsecore/socket-server.c
index 9885a02b..a600e0a6 100644
--- a/src/pulsecore/socket-server.c
+++ b/src/pulsecore/socket-server.c
@@ -199,7 +199,7 @@ pa_socket_server* pa_socket_server_new_unix(pa_mainloop_api *m, const char *file
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;
}
diff --git a/src/pulsecore/sound-file-stream.c b/src/pulsecore/sound-file-stream.c
index 8b2a29b9..c30c16eb 100644
--- a/src/pulsecore/sound-file-stream.c
+++ b/src/pulsecore/sound-file-stream.c
@@ -170,10 +170,10 @@ static int sink_input_pop_cb(pa_sink_input *i, size_t length, pa_memchunk *chunk
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);
@@ -186,7 +186,7 @@ static int sink_input_pop_cb(pa_sink_input *i, size_t length, pa_memchunk *chunk
break;
}
- tchunk.length = n * fs;
+ tchunk.length = (size_t) n * fs;
pa_memblockq_push(u->memblockq, &tchunk);
pa_memblock_unref(tchunk.memblock);
@@ -310,8 +310,8 @@ int pa_play_file(
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);
diff --git a/src/pulsecore/sound-file.c b/src/pulsecore/sound-file.c
index 3183ede6..74338f9a 100644
--- a/src/pulsecore/sound-file.c
+++ b/src/pulsecore/sound-file.c
@@ -108,8 +108,8 @@ int pa_sound_file_load(
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);
@@ -119,7 +119,7 @@ int pa_sound_file_load(
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;
}
@@ -131,7 +131,7 @@ int pa_sound_file_load(
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;
}
@@ -189,15 +189,15 @@ int pa_sound_file_too_big_to_cache(const char *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);
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;
}
diff --git a/src/pulsecore/source-output.c b/src/pulsecore/source-output.c
index dbf3af94..4257154e 100644
--- a/src/pulsecore/source-output.c
+++ b/src/pulsecore/source-output.c
@@ -397,7 +397,7 @@ void pa_source_output_push(pa_source_output *o, const pa_memchunk *chunk) {
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;
diff --git a/src/pulsecore/strbuf.c b/src/pulsecore/strbuf.c
index b59b6f49..540faef9 100644
--- a/src/pulsecore/strbuf.c
+++ b/src/pulsecore/strbuf.c
@@ -77,7 +77,7 @@ char *pa_strbuf_tostring(pa_strbuf *sb) {
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);
@@ -150,8 +150,8 @@ void pa_strbuf_putsn(pa_strbuf *sb, const char *t, size_t l) {
/* 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);
@@ -168,14 +168,14 @@ int pa_strbuf_printf(pa_strbuf *sb, const char *format, ...) {
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;
}
diff --git a/src/pulsecore/strbuf.h b/src/pulsecore/strbuf.h
index 24c876d5..ac68d7be 100644
--- a/src/pulsecore/strbuf.h
+++ b/src/pulsecore/strbuf.h
@@ -31,7 +31,7 @@ void pa_strbuf_free(pa_strbuf *sb);
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);
diff --git a/src/pulsecore/tagstruct.c b/src/pulsecore/tagstruct.c
index b0ed59ef..e5b228e9 100644
--- a/src/pulsecore/tagstruct.c
+++ b/src/pulsecore/tagstruct.c
@@ -154,7 +154,7 @@ void pa_tagstruct_put_arbitrary(pa_tagstruct *t, const void *p, size_t length) {
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);
@@ -165,7 +165,7 @@ void pa_tagstruct_put_boolean(pa_tagstruct*t, pa_bool_t b) {
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;
}
@@ -175,9 +175,9 @@ void pa_tagstruct_put_timeval(pa_tagstruct*t, const struct timeval *tv) {
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;
}
@@ -228,7 +228,7 @@ void pa_tagstruct_put_channel_map(pa_tagstruct *t, const pa_channel_map *map) {
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;
@@ -435,9 +435,9 @@ int pa_tagstruct_get_timeval(pa_tagstruct*t, struct timeval *tv) {
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;
}
@@ -523,7 +523,7 @@ int pa_tagstruct_get_channel_map(pa_tagstruct *t, pa_channel_map *map) {
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;
}
diff --git a/src/pulsecore/time-smoother.c b/src/pulsecore/time-smoother.c
index d0231486..b165f4a8 100644
--- a/src/pulsecore/time-smoother.c
+++ b/src/pulsecore/time-smoother.c
@@ -209,8 +209,8 @@ static double avg_gradient(pa_smoother *s, pa_usec_t x) {
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);
@@ -236,7 +236,7 @@ static double avg_gradient(pa_smoother *s, pa_usec_t x) {
REDUCE_INC(i);
}
- r = (double) k / t;
+ r = (double) k / (double) t;
return (s->monotonic && r < 0) ? 0 : r;
}
@@ -268,8 +268,8 @@ static void calc_abc(pa_smoother *s) {
/* 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;
}
@@ -284,7 +284,7 @@ static void estimate(pa_smoother *s, pa_usec_t x, pa_usec_t *y, double *deriv) {
/* 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;
@@ -360,7 +360,7 @@ void pa_smoother_put(pa_smoother *s, pa_usec_t x, pa_usec_t y) {
/* 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;
diff --git a/src/pulsecore/x11prop.c b/src/pulsecore/x11prop.c
index 9e75f63a..7f91ba3c 100644
--- a/src/pulsecore/x11prop.c
+++ b/src/pulsecore/x11prop.c
@@ -32,7 +32,7 @@
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) {
@@ -49,7 +49,7 @@ char* pa_x11_get_prop(Display *d, const char *name, char *p, size_t l) {
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)