diff options
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/pacat.c | 35 | ||||
-rw-r--r-- | src/utils/pacmd.c | 2 | ||||
-rw-r--r-- | src/utils/pactl.c | 18 | ||||
-rw-r--r-- | src/utils/padsp.c | 47 | ||||
-rw-r--r-- | src/utils/paplay.c | 14 |
5 files changed, 63 insertions, 53 deletions
diff --git a/src/utils/pacat.c b/src/utils/pacat.c index 32fa6bcf..ea736e23 100644 --- a/src/utils/pacat.c +++ b/src/utils/pacat.c @@ -57,6 +57,7 @@ static char *stream_name = NULL, *client_name = NULL, *device = NULL; static int verbose = 0; static pa_volume_t volume = PA_VOLUME_NORM; +static int volume_is_set = 0; static pa_sample_spec sample_spec = { .format = PA_SAMPLE_S16LE, @@ -274,8 +275,8 @@ static void context_state_callback(pa_context *c, void *userdata) { if (latency > 0) { memset(&buffer_attr, 0, sizeof(buffer_attr)); - buffer_attr.tlength = latency; - buffer_attr.minreq = process_time; + buffer_attr.tlength = (uint32_t) latency; + buffer_attr.minreq = (uint32_t) process_time; buffer_attr.maxlength = (uint32_t) -1; buffer_attr.prebuf = (uint32_t) -1; flags |= PA_STREAM_ADJUST_LATENCY; @@ -283,7 +284,7 @@ static void context_state_callback(pa_context *c, void *userdata) { if (mode == PLAYBACK) { pa_cvolume cv; - if ((r = pa_stream_connect_playback(stream, device, latency > 0 ? &buffer_attr : NULL, flags, pa_cvolume_set(&cv, sample_spec.channels, volume), NULL)) < 0) { + if ((r = pa_stream_connect_playback(stream, device, latency > 0 ? &buffer_attr : NULL, flags, volume_is_set ? pa_cvolume_set(&cv, sample_spec.channels, volume) : NULL, NULL)) < 0) { fprintf(stderr, _("pa_stream_connect_playback() failed: %s\n"), pa_strerror(pa_context_errno(c))); goto fail; } @@ -391,7 +392,7 @@ static void stdin_callback(pa_mainloop_api*a, pa_io_event *e, int fd, pa_io_even return; } - buffer_length = r; + buffer_length = (uint32_t) r; buffer_index = 0; if (w) @@ -422,8 +423,8 @@ static void stdout_callback(pa_mainloop_api*a, pa_io_event *e, int fd, pa_io_eve return; } - buffer_length -= r; - buffer_index += r; + buffer_length -= (uint32_t) r; + buffer_index += (uint32_t) r; if (!buffer_length) { pa_xfree(buffer); @@ -456,7 +457,7 @@ static void stream_update_timing_callback(pa_stream *s, int success, void *userd fprintf(stderr, _("Time: %0.3f sec; Latency: %0.0f usec. \r"), (float) usec / 1000000, - (float) l * (negative?-1:1)); + (float) l * (negative?-1.0f:1.0f)); } /* Someone requested that the latency is shown */ @@ -500,7 +501,7 @@ static void help(const char *argv0) { " --volume=VOLUME Specify the initial (linear) volume in range 0...65536\n" " --rate=SAMPLERATE The sample rate in Hz (defaults to 44100)\n" " --format=SAMPLEFORMAT The sample type, one of s16le, s16be, u8, float32le,\n" - " float32be, ulaw, alaw (defaults to s16ne)\n" + " float32be, ulaw, alaw, s32le, s32be (defaults to s16ne)\n" " --channels=CHANNELS The number of channels, 1 for mono, 2 for stereo\n" " (defaults to 2)\n" " --channel-map=CHANNELMAP Channel map to use instead of the default\n" @@ -626,12 +627,13 @@ int main(int argc, char *argv[]) { case ARG_VOLUME: { int v = atoi(optarg); - volume = v < 0 ? 0 : v; + volume = v < 0 ? 0U : (pa_volume_t) v; + volume_is_set = 1; break; } case ARG_CHANNELS: - sample_spec.channels = atoi(optarg); + sample_spec.channels = (uint8_t) atoi(optarg); break; case ARG_SAMPLEFORMAT: @@ -639,7 +641,7 @@ int main(int argc, char *argv[]) { break; case ARG_SAMPLERATE: - sample_spec.rate = atoi(optarg); + sample_spec.rate = (uint32_t) atoi(optarg); break; case ARG_CHANNELMAP: @@ -672,14 +674,14 @@ int main(int argc, char *argv[]) { break; case ARG_LATENCY: - if (((latency = atoi(optarg))) <= 0) { + if (((latency = (size_t) atoi(optarg))) <= 0) { fprintf(stderr, _("Invalid latency specification '%s'\n"), optarg); goto quit; } break; case ARG_PROCESS_TIME: - if (((process_time = atoi(optarg))) <= 0) { + if (((process_time = (size_t) atoi(optarg))) <= 0) { fprintf(stderr, _("Invalid process time specification '%s'\n"), optarg); goto quit; } @@ -695,7 +697,7 @@ int main(int argc, char *argv[]) { goto quit; } - if (channel_map_set && channel_map.channels != sample_spec.channels) { + if (channel_map_set && pa_channel_map_compatible(&channel_map, &sample_spec)) { fprintf(stderr, _("Channel map doesn't match sample specification\n")); goto quit; } @@ -773,7 +775,10 @@ int main(int argc, char *argv[]) { pa_context_set_state_callback(context, context_state_callback, NULL); /* Connect the context */ - pa_context_connect(context, server, 0, NULL); + if (pa_context_connect(context, server, 0, NULL) < 0) { + fprintf(stderr, _("pa_context_connect() failed: %s"), pa_strerror(pa_context_errno(context))); + goto quit; + } if (verbose) { struct timeval tv; diff --git a/src/utils/pacmd.c b/src/utils/pacmd.c index 24cddaa3..2c89c8d9 100644 --- a/src/utils/pacmd.c +++ b/src/utils/pacmd.c @@ -42,7 +42,7 @@ #include <pulsecore/log.h> #include <pulsecore/pid.h> -int main(PA_GCC_UNUSED int argc, PA_GCC_UNUSED char*argv[]) { +int main(int argc, char*argv[]) { pid_t pid ; int fd = -1; int ret = 1, i; diff --git a/src/utils/pactl.c b/src/utils/pactl.c index 3f00df1b..2f430ca7 100644 --- a/src/utils/pactl.c +++ b/src/utils/pactl.c @@ -555,7 +555,7 @@ static void stream_write_callback(pa_stream *s, size_t length, void *userdata) { d = pa_xmalloc(length); assert(sample_length >= length); - l = length/pa_frame_size(&sample_spec); + l = (sf_count_t) (length/pa_frame_size(&sample_spec)); if ((sf_readf_float(sndfile, d, l)) != l) { pa_xfree(d); @@ -791,11 +791,11 @@ int main(int argc, char *argv[]) { goto quit; } - sample_spec.format = PA_SAMPLE_FLOAT32; - sample_spec.rate = sfinfo.samplerate; - sample_spec.channels = sfinfo.channels; + sample_spec.format = PA_SAMPLE_FLOAT32; + sample_spec.rate = (uint32_t) sfinfo.samplerate; + sample_spec.channels = (uint8_t) sfinfo.channels; - sample_length = sfinfo.frames*pa_frame_size(&sample_spec); + sample_length = (size_t)sfinfo.frames*pa_frame_size(&sample_spec); } else if (!strcmp(argv[optind], "play-sample")) { action = PLAY_SAMPLE; if (argc != optind+2 && argc != optind+3) { @@ -823,7 +823,7 @@ int main(int argc, char *argv[]) { goto quit; } - sink_input_idx = atoi(argv[optind+1]); + sink_input_idx = (uint32_t) atoi(argv[optind+1]); sink_name = pa_xstrdup(argv[optind+2]); } else if (!strcmp(argv[optind], "move-source-output")) { action = MOVE_SOURCE_OUTPUT; @@ -832,7 +832,7 @@ int main(int argc, char *argv[]) { goto quit; } - source_output_idx = atoi(argv[optind+1]); + source_output_idx = (uint32_t) atoi(argv[optind+1]); source_name = pa_xstrdup(argv[optind+2]); } else if (!strcmp(argv[optind], "load-module")) { int i; @@ -852,7 +852,7 @@ int main(int argc, char *argv[]) { n += strlen(argv[i])+1; if (n > 0) { - p = module_args = pa_xnew0(char, n); + p = module_args = pa_xmalloc(n); for (i = optind+2; i < argc; i++) p += sprintf(p, "%s%s", p == module_args ? "" : " ", argv[i]); @@ -866,7 +866,7 @@ int main(int argc, char *argv[]) { goto quit; } - module_index = atoi(argv[optind+1]); + module_index = (uint32_t) atoi(argv[optind+1]); } else if (!strcmp(argv[optind], "suspend-sink")) { action = SUSPEND_SINK; diff --git a/src/utils/padsp.c b/src/utils/padsp.c index c82fde64..2e6e5575 100644 --- a/src/utils/padsp.c +++ b/src/utils/padsp.c @@ -422,7 +422,7 @@ static void fd_info_unref(fd_info *i) { pthread_mutex_lock(&i->mutex); assert(i->ref >= 1); r = --i->ref; - debug(DEBUG_LEVEL_VERBOSE, __FILE__": ref--, now %i\n", i->ref); + debug(DEBUG_LEVEL_VERBOSE, __FILE__": ref--, now %i\n", i->ref); pthread_mutex_unlock(&i->mutex); if (r <= 0) @@ -498,7 +498,6 @@ static void atfork_prepare(void) { pthread_mutex_lock(&func_mutex); - debug(DEBUG_LEVEL_NORMAL, __FILE__": atfork_prepare() exit\n"); } @@ -550,12 +549,14 @@ static void atfork_child(void) { } if (i->app_fd >= 0) { - close(i->app_fd); + LOAD_CLOSE_FUNC(); + _close(i->app_fd); i->app_fd = -1; } if (i->thread_fd >= 0) { - close(i->thread_fd); + LOAD_CLOSE_FUNC(); + _close(i->thread_fd); i->thread_fd = -1; } @@ -748,7 +749,7 @@ static void fix_metrics(fd_info *i) { /* Number of fragments set? */ if (i->n_fragments < 2) { if (i->fragment_size > 0) { - i->n_fragments = pa_bytes_per_second(&i->sample_spec) / 2 / i->fragment_size; + i->n_fragments = (unsigned) (pa_bytes_per_second(&i->sample_spec) / 2 / i->fragment_size); if (i->n_fragments < 2) i->n_fragments = 2; } else @@ -864,7 +865,7 @@ static int fd_info_copy_data(fd_info *i, int force) { return -1; } - if (pa_stream_write(i->play_stream, i->buf, r, free, 0, PA_SEEK_RELATIVE) < 0) { + if (pa_stream_write(i->play_stream, i->buf, (size_t) r, free, 0LL, PA_SEEK_RELATIVE) < 0) { debug(DEBUG_LEVEL_NORMAL, __FILE__": pa_stream_write(): %s\n", pa_strerror(pa_context_errno(i->context))); return -1; } @@ -872,7 +873,7 @@ static int fd_info_copy_data(fd_info *i, int force) { i->buf = NULL; assert(n >= (size_t) r); - n -= r; + n -= (size_t) r; } if (n >= i->fragment_size) @@ -916,7 +917,7 @@ static int fd_info_copy_data(fd_info *i, int force) { } assert((size_t)r <= len - i->rec_offset); - i->rec_offset += r; + i->rec_offset += (size_t) r; if (i->rec_offset == len) { if (pa_stream_drop(i->rec_stream) < 0) { @@ -927,7 +928,7 @@ static int fd_info_copy_data(fd_info *i, int force) { } assert(n >= (size_t) r); - n -= r; + n -= (size_t) r; } if (n >= i->fragment_size) @@ -943,6 +944,10 @@ static int fd_info_copy_data(fd_info *i, int force) { api->io_enable(i->io_event, i->io_flags); } + /* So, we emptied the socket now, let's tell dsp_empty_socket() + * about this */ + pa_threaded_mainloop_signal(i->mainloop, 0); + return 0; } @@ -998,12 +1003,12 @@ static int create_playback_stream(fd_info *i) { pa_stream_set_latency_update_callback(i->play_stream, stream_latency_update_cb, i); memset(&attr, 0, sizeof(attr)); - attr.maxlength = i->fragment_size * (i->n_fragments+1); - attr.tlength = i->fragment_size * i->n_fragments; - attr.prebuf = i->fragment_size; - attr.minreq = i->fragment_size; + attr.maxlength = (uint32_t) (i->fragment_size * (i->n_fragments+1)); + attr.tlength = (uint32_t) (i->fragment_size * i->n_fragments); + attr.prebuf = (uint32_t) i->fragment_size; + attr.minreq = (uint32_t) i->fragment_size; - flags = PA_STREAM_INTERPOLATE_TIMING|PA_STREAM_AUTO_TIMING_UPDATE; + flags = PA_STREAM_INTERPOLATE_TIMING|PA_STREAM_AUTO_TIMING_UPDATE|PA_STREAM_EARLY_REQUESTS; if (i->play_precork) { flags |= PA_STREAM_START_CORKED; debug(DEBUG_LEVEL_NORMAL, __FILE__": creating stream corked\n"); @@ -1013,9 +1018,9 @@ static int create_playback_stream(fd_info *i) { goto fail; } - n = i->fragment_size; + n = (int) i->fragment_size; setsockopt(i->app_fd, SOL_SOCKET, SO_SNDBUF, &n, sizeof(n)); - n = i->fragment_size; + n = (int) i->fragment_size; setsockopt(i->thread_fd, SOL_SOCKET, SO_RCVBUF, &n, sizeof(n)); return 0; @@ -1042,8 +1047,8 @@ static int create_record_stream(fd_info *i) { pa_stream_set_latency_update_callback(i->rec_stream, stream_latency_update_cb, i); memset(&attr, 0, sizeof(attr)); - attr.maxlength = i->fragment_size * (i->n_fragments+1); - attr.fragsize = i->fragment_size; + attr.maxlength = (uint32_t) (i->fragment_size * (i->n_fragments+1)); + attr.fragsize = (uint32_t) i->fragment_size; flags = PA_STREAM_INTERPOLATE_TIMING|PA_STREAM_AUTO_TIMING_UPDATE; if (i->rec_precork) { @@ -1055,9 +1060,9 @@ static int create_record_stream(fd_info *i) { goto fail; } - n = i->fragment_size; + n = (int) i->fragment_size; setsockopt(i->app_fd, SOL_SOCKET, SO_RCVBUF, &n, sizeof(n)); - n = i->fragment_size; + n = (int) i->fragment_size; setsockopt(i->thread_fd, SOL_SOCKET, SO_SNDBUF, &n, sizeof(n)); return 0; @@ -1474,7 +1479,7 @@ int open(const char *filename, int flags, ...) { if (flags & O_CREAT) { va_start(args, flags); if (sizeof(mode_t) < sizeof(int)) - mode = va_arg(args, int); + mode = (mode_t) va_arg(args, int); else mode = va_arg(args, mode_t); va_end(args); diff --git a/src/utils/paplay.c b/src/utils/paplay.c index 9264a940..df2edf62 100644 --- a/src/utils/paplay.c +++ b/src/utils/paplay.c @@ -107,14 +107,14 @@ static void stream_write_callback(pa_stream *s, size_t length, void *userdata) { if (readf_function) { size_t k = pa_frame_size(&sample_spec); - if ((bytes = readf_function(sndfile, data, length/k)) > 0) - bytes *= k; + if ((bytes = readf_function(sndfile, data, (sf_count_t) (length/k))) > 0) + bytes *= (sf_count_t) k; } else - bytes = sf_read_raw(sndfile, data, length); + bytes = sf_read_raw(sndfile, data, (sf_count_t) length); if (bytes > 0) - pa_stream_write(s, data, bytes, pa_xfree, 0, PA_SEEK_RELATIVE); + pa_stream_write(s, data, (size_t) bytes, pa_xfree, 0, PA_SEEK_RELATIVE); else pa_xfree(data); @@ -283,7 +283,7 @@ int main(int argc, char *argv[]) { case ARG_VOLUME: { int v = atoi(optarg); - volume = v < 0 ? 0 : v; + volume = v < 0 ? 0U : (pa_volume_t) v; break; } @@ -315,8 +315,8 @@ int main(int argc, char *argv[]) { goto quit; } - sample_spec.rate = sfinfo.samplerate; - sample_spec.channels = sfinfo.channels; + sample_spec.rate = (uint32_t) sfinfo.samplerate; + sample_spec.channels = (uint8_t) sfinfo.channels; readf_function = NULL; |