summaryrefslogtreecommitdiffstats
path: root/src/utils/pacat.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/pacat.c')
-rw-r--r--src/utils/pacat.c35
1 files changed, 20 insertions, 15 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;