[pulseaudio-commits] r2224 - /branches/glitch-free/src/utils/pacat.c
svnmailer-noreply at 0pointer.de
svnmailer-noreply at 0pointer.de
Tue Apr 8 18:15:24 PDT 2008
Author: lennart
Date: Wed Apr 9 03:15:23 2008
New Revision: 2224
URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=2224&root=pulseaudio&view=rev
Log:
add new latency argument
Modified:
branches/glitch-free/src/utils/pacat.c
Modified: branches/glitch-free/src/utils/pacat.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/glitch-free/src/utils/pacat.c?rev=2224&root=pulseaudio&r1=2223&r2=2224&view=diff
==============================================================================
--- branches/glitch-free/src/utils/pacat.c (original)
+++ branches/glitch-free/src/utils/pacat.c Wed Apr 9 03:15:23 2008
@@ -71,6 +71,8 @@
static pa_stream_flags_t flags = 0;
+static size_t latency = 0;
+
/* A shortcut for terminating the application */
static void quit(int ret) {
assert(mainloop_api);
@@ -229,6 +231,7 @@
case PA_CONTEXT_READY: {
int r;
+ pa_buffer_attr buffer_attr;
assert(c);
assert(!stream);
@@ -247,15 +250,21 @@
pa_stream_set_suspended_callback(stream, stream_suspended_callback, NULL);
pa_stream_set_moved_callback(stream, stream_moved_callback, NULL);
+ if (latency > 0) {
+ memset(&buffer_attr, 0, sizeof(buffer_attr));
+ buffer_attr.tlength = latency;
+ flags |= PA_STREAM_ADJUST_LATENCY;
+ }
+
if (mode == PLAYBACK) {
pa_cvolume cv;
- if ((r = pa_stream_connect_playback(stream, device, 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, pa_cvolume_set(&cv, sample_spec.channels, volume), NULL)) < 0) {
fprintf(stderr, "pa_stream_connect_playback() failed: %s\n", pa_strerror(pa_context_errno(c)));
goto fail;
}
} else {
- if ((r = pa_stream_connect_record(stream, device, NULL, flags)) < 0) {
+ if ((r = pa_stream_connect_record(stream, device, latency > 0 ? &buffer_attr : NULL, flags)) < 0) {
fprintf(stderr, "pa_stream_connect_record() failed: %s\n", pa_strerror(pa_context_errno(c)));
goto fail;
}
@@ -478,6 +487,7 @@
" from the sink the stream is being connected to.\n"
" --no-remix Don't upmix or downmix channels.\n"
" --no-remap Map channels by index instead of name.\n"
+ " --latency=BYTES Request the specified latency in bytes.\n"
,
argv0);
}
@@ -494,7 +504,8 @@
ARG_FIX_RATE,
ARG_FIX_CHANNELS,
ARG_NO_REMAP,
- ARG_NO_REMIX
+ ARG_NO_REMIX,
+ ARG_LATENCY
};
int main(int argc, char *argv[]) {
@@ -523,6 +534,7 @@
{"fix-channels",0, NULL, ARG_FIX_CHANNELS},
{"no-remap", 0, NULL, ARG_NO_REMAP},
{"no-remix", 0, NULL, ARG_NO_REMIX},
+ {"latency", 0, NULL, ARG_LATENCY},
{NULL, 0, NULL, 0}
};
@@ -601,7 +613,7 @@
case ARG_CHANNELMAP:
if (!pa_channel_map_parse(&channel_map, optarg)) {
- fprintf(stderr, "Invalid channel map\n");
+ fprintf(stderr, "Invalid channel map '%s'\n", optarg);
goto quit;
}
@@ -626,6 +638,13 @@
case ARG_NO_REMAP:
flags |= PA_STREAM_NO_REMAP_CHANNELS;
+ break;
+
+ case ARG_LATENCY:
+ if (((latency = atoi(optarg))) <= 0) {
+ fprintf(stderr, "Invallid latency specification '%s'\n", optarg);
+ goto quit;
+ }
break;
default:
More information about the pulseaudio-commits
mailing list