add a few more gcc warning flags and fix quite a few problems found by doing so

This commit is contained in:
Lennart Poettering 2008-08-19 22:39:54 +02:00
parent 047eb52b52
commit b7026bf248
99 changed files with 810 additions and 776 deletions

View file

@ -201,7 +201,7 @@ pa_channel_map* pa_channel_map_init_auto(pa_channel_map *m, unsigned channels, p
pa_channel_map_init(m);
m->channels = channels;
m->channels = (uint8_t) channels;
switch (def) {
case PA_CHANNEL_MAP_AIFF:
@ -415,7 +415,7 @@ pa_channel_map* pa_channel_map_init_extend(pa_channel_map *m, unsigned channels,
i++;
}
m->channels = channels;
m->channels = (uint8_t) channels;
return m;
}
@ -460,7 +460,7 @@ int pa_channel_map_equal(const pa_channel_map *a, const pa_channel_map *b) {
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);
@ -475,7 +475,7 @@ char* pa_channel_map_snprint(char *s, size_t l, const pa_channel_map *map) {
pa_channel_position_to_string(map->map[channel]));
e = strchr(e, 0);
first = 0;
first = FALSE;
}
return s;

View file

@ -413,11 +413,11 @@ int pa_context_handle_error(pa_context *c, uint32_t command, pa_tagstruct *t, pa
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;
}
@ -788,7 +788,7 @@ static void autospawn_cb(pa_mainloop_api*a, pa_io_event *e, int fd, pa_io_event_
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);

View file

@ -195,11 +195,11 @@ static void cleanup_defer_events(pa_glib_mainloop *g, int force) {
}
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) {

View file

@ -64,7 +64,7 @@ struct pa_context {
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;

View file

@ -57,7 +57,7 @@
struct pa_io_event {
pa_mainloop *mainloop;
int dead;
pa_bool_t dead:1;
int fd;
pa_io_event_flags_t events;
@ -72,9 +72,9 @@ struct pa_io_event {
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;
@ -86,9 +86,9 @@ struct pa_time_event {
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;
@ -102,22 +102,24 @@ struct pa_mainloop {
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,
@ -133,11 +135,11 @@ struct pa_mainloop {
};
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) {
@ -169,7 +171,7 @@ static pa_io_event* mainloop_io_new(
e = pa_xnew(pa_io_event, 1);
e->mainloop = m;
e->dead = 0;
e->dead = FALSE;
e->fd = fd;
e->events = events;
@ -194,13 +196,13 @@ static pa_io_event* mainloop_io_new(
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);
@ -220,7 +222,7 @@ static void mainloop_io_enable(pa_io_event *e, pa_io_event_flags_t events) {
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);
}
@ -229,11 +231,11 @@ static void mainloop_io_free(pa_io_event *e) {
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);
}
@ -262,9 +264,9 @@ static pa_defer_event* mainloop_defer_new(
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;
@ -297,13 +299,13 @@ static void mainloop_defer_free(pa_defer_event *e) {
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;
}
}
@ -333,7 +335,7 @@ static pa_time_event* mainloop_time_new(
e = pa_xnew(pa_time_event, 1);
e->mainloop = m;
e->dead = 0;
e->dead = FALSE;
if ((e->enabled = !!tv)) {
e->timeval = *tv;
@ -388,13 +390,13 @@ static void mainloop_time_free(pa_time_event *e) {
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)
@ -462,7 +464,7 @@ pa_mainloop *pa_mainloop_new(void) {
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);
@ -476,9 +478,10 @@ pa_mainloop *pa_mainloop_new(void) {
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;
@ -492,7 +495,7 @@ pa_mainloop *pa_mainloop_new(void) {
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;
@ -515,7 +518,7 @@ static void cleanup_io_events(pa_mainloop *m, int force) {
pa_xfree(e);
m->rebuild_pollfds = 1;
m->rebuild_pollfds = TRUE;
}
e = n;
@ -524,7 +527,7 @@ static void cleanup_io_events(pa_mainloop *m, int force) {
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;
@ -545,7 +548,7 @@ static void cleanup_time_events(pa_mainloop *m, int force) {
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)
@ -560,7 +563,7 @@ static void cleanup_time_events(pa_mainloop *m, int force) {
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;
@ -581,7 +584,7 @@ static void cleanup_defer_events(pa_mainloop *m, int force) {
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)
@ -600,9 +603,9 @@ static void cleanup_defer_events(pa_mainloop *m, int force) {
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);
@ -615,13 +618,13 @@ static void scan_dead(pa_mainloop *m) {
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) {
@ -662,7 +665,7 @@ 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) {
@ -948,7 +951,7 @@ int pa_mainloop_run(pa_mainloop *m, int *retval) {
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);
}

View file

@ -280,7 +280,7 @@ char *pa_proplist_to_string(pa_proplist *p) {
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);

View file

@ -47,6 +47,7 @@ int pa_stream_connect_upload(pa_stream *s, size_t length) {
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);
@ -63,7 +64,7 @@ int pa_stream_connect_upload(pa_stream *s, size_t length) {
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);

View file

@ -124,7 +124,7 @@ pa_stream *pa_stream_new_with_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;
@ -694,7 +694,7 @@ static void create_stream_complete(pa_stream *s) {
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);
@ -722,7 +722,7 @@ static void automatic_buffer_attr(pa_stream *s, pa_buffer_attr *attr, const pa_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 */
@ -931,7 +931,7 @@ static int create_stream(
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)
@ -1105,7 +1105,7 @@ int pa_stream_write(
free_cb((void*) data);
if (length < s->requested_bytes)
s->requested_bytes -= length;
s->requested_bytes -= (uint32_t) length;
else
s->requested_bytes = 0;
@ -1119,10 +1119,10 @@ int pa_stream_write(
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;
}
@ -1132,10 +1132,10 @@ int pa_stream_write(
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;
}
@ -1185,7 +1185,7 @@ int pa_stream_drop(pa_stream *s) {
/* 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);
@ -1354,7 +1354,7 @@ static void stream_get_timing_info_callback(pa_pdispatch *pd, uint32_t command,
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);
@ -1432,7 +1432,7 @@ static void stream_get_timing_info_callback(pa_pdispatch *pd, uint32_t command,
/* 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 */
@ -1449,7 +1449,7 @@ static void stream_get_timing_info_callback(pa_pdispatch *pd, uint32_t command,
* 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;
@ -1508,7 +1508,7 @@ pa_operation* pa_stream_update_timing_info(pa_stream *s, pa_stream_success_cb_t
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));
@ -1571,8 +1571,8 @@ int pa_stream_disconnect(pa_stream *s) {
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);
@ -1729,7 +1729,7 @@ pa_operation* pa_stream_cork(pa_stream *s, int b, pa_stream_success_cb_t cb, voi
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);
@ -1774,7 +1774,7 @@ pa_operation* pa_stream_flush(pa_stream *s, pa_stream_success_cb_t cb, void *use
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) {
@ -1860,7 +1860,7 @@ pa_operation* pa_stream_set_name(pa_stream *s, const char *name, pa_stream_succe
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);
@ -1946,7 +1946,7 @@ int pa_stream_get_latency(pa_stream *s, pa_usec_t *r_usec, int *negative) {
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);
@ -2060,7 +2060,7 @@ pa_operation* pa_stream_set_buffer_attr(pa_stream *s, const pa_buffer_attr *attr
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);
@ -2191,7 +2191,7 @@ pa_operation *pa_stream_update_sample_rate(pa_stream *s, uint32_t rate, pa_strea
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);
@ -2219,7 +2219,7 @@ pa_operation *pa_stream_proplist_update(pa_stream *s, pa_update_mode_t mode, pa_
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);
@ -2252,7 +2252,7 @@ pa_operation *pa_stream_proplist_remove(pa_stream *s, const char *const keys[],
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);

View file

@ -90,13 +90,13 @@ pa_usec_t pa_timeval_diff(const struct timeval *a, const struct timeval *b) {
}
/* 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;
}
@ -132,7 +132,7 @@ struct timeval* pa_timeval_add(struct timeval *tv, pa_usec_t v) {
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;
@ -140,7 +140,7 @@ struct timeval* pa_timeval_add(struct timeval *tv, pa_usec_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;
@ -151,14 +151,14 @@ struct timeval* pa_timeval_sub(struct timeval *tv, pa_usec_t v) {
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;
@ -167,8 +167,8 @@ struct timeval* pa_timeval_sub(struct timeval *tv, pa_usec_t v) {
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;
}

View file

@ -109,17 +109,17 @@ static char* utf8_validate(const char *str, char *output) {
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;
@ -149,7 +149,7 @@ ONE_REMAINING:
goto error;
if (o) {
memcpy(o, last, size);
memcpy(o, last, (size_t) size);
o += size - 1;
}
@ -189,7 +189,7 @@ char* pa_utf8_filter (const char *str) {
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);
}
@ -212,7 +212,7 @@ static char* iconv_simple(const char *str, const char *to, const char *from) {
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() */

View file

@ -260,8 +260,8 @@ int pa_msleep(unsigned long t) {
#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

View file

@ -53,7 +53,7 @@ pa_cvolume* pa_cvolume_set(pa_cvolume *a, unsigned channels, pa_volume_t v) {
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;
@ -175,7 +175,7 @@ pa_cvolume *pa_sw_cvolume_multiply(pa_cvolume *dest, const pa_cvolume *a, const
i < b->channels ? b->values[i] : PA_VOLUME_NORM);
}
dest->channels = i;
dest->channels = (uint8_t) i;
return dest;
}

View file

@ -113,7 +113,7 @@ char *pa_xstrndup(const char *s, size_t l) {
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);