From 80809212a16d5a093b0ccbec0ef8b7720985213f Mon Sep 17 00:00:00 2001 From: Magnus Ekhall Date: Sun, 11 Aug 2013 21:21:41 +0200 Subject: Added support to record from one specific sink input, feature request 66326. --- src/utils/pacat.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/utils/pacat.c b/src/utils/pacat.c index a712ccf..4eabad5 100644 --- a/src/utils/pacat.c +++ b/src/utils/pacat.c @@ -95,6 +95,8 @@ static int32_t latency_msec = 0, process_time_msec = 0; static bool raw = true; static int file_format = -1; +static int32_t monitor_source = -1; + static uint32_t cork_requests = 0; /* A shortcut for terminating the application */ @@ -508,12 +510,15 @@ static void context_state_callback(pa_context *c, void *userdata) { } } else { + if (monitor_source != -1 && (pa_stream_set_monitor_stream(stream, monitor_source) < 0)) { + pa_log(_("Failed to set monitor stream: %s"), pa_strerror(pa_context_errno(c))); + goto fail; + } if (pa_stream_connect_record(stream, device, &buffer_attr, flags) < 0) { pa_log(_("pa_stream_connect_record() failed: %s"), pa_strerror(pa_context_errno(c))); goto fail; } - } - + } break; } @@ -698,7 +703,8 @@ static void help(const char *argv0) { " --raw Record/play raw PCM data.\n" " --passthrough passthrough data \n" " --file-format[=FFORMAT] Record/play formatted PCM data.\n" - " --list-file-formats List available file formats.\n") + " --list-file-formats List available file formats.\n" + " --set-monitor-stream Set a specific sink input to record.\n") , argv0); } @@ -723,7 +729,8 @@ enum { ARG_FILE_FORMAT, ARG_LIST_FILE_FORMATS, ARG_LATENCY_MSEC, - ARG_PROCESS_TIME_MSEC + ARG_PROCESS_TIME_MSEC, + ARG_MONITOR_STREAM, }; int main(int argc, char *argv[]) { @@ -764,6 +771,7 @@ int main(int argc, char *argv[]) { {"list-file-formats", 0, NULL, ARG_LIST_FILE_FORMATS}, {"latency-msec", 1, NULL, ARG_LATENCY_MSEC}, {"process-time-msec", 1, NULL, ARG_PROCESS_TIME_MSEC}, + {"set-monitor-stream", 1, NULL, ARG_MONITOR_STREAM}, {NULL, 0, NULL, 0} }; @@ -978,6 +986,11 @@ int main(int argc, char *argv[]) { ret = 0; goto quit; + case ARG_MONITOR_STREAM: + pa_log("ARG: %s\n", optarg); + monitor_source = (int32_t) atoi(optarg); + break; + default: goto quit; } -- 1.8.1.2