static SNDFILE* sndfile = NULL;
-static pa_bool_t verbose = FALSE;
+static bool verbose = false;
static pa_volume_t volume = PA_VOLUME_NORM;
-static pa_bool_t volume_is_set = FALSE;
+static bool volume_is_set = false;
static pa_sample_spec sample_spec = {
.format = PA_SAMPLE_S16LE,
.rate = 44100,
.channels = 2
};
-static pa_bool_t sample_spec_set = FALSE;
+static bool sample_spec_set = false;
static pa_channel_map channel_map;
-static pa_bool_t channel_map_set = FALSE;
+static bool channel_map_set = false;
static sf_count_t (*readf_function)(SNDFILE *_sndfile, void *ptr, sf_count_t frames) = NULL;
static sf_count_t (*writef_function)(SNDFILE *_sndfile, const void *ptr, sf_count_t frames) = NULL;
static size_t latency = 0, process_time = 0;
static int32_t latency_msec = 0, process_time_msec = 0;
-static pa_bool_t raw = TRUE;
+static bool raw = true;
static int file_format = -1;
+static uint32_t monitor_stream = PA_INVALID_INDEX;
+
static uint32_t cork_requests = 0;
/* A shortcut for terminating the application */
pa_sample_spec_snprint(sst, sizeof(sst), pa_stream_get_sample_spec(s)),
pa_channel_map_snprint(cmt, sizeof(cmt), pa_stream_get_channel_map(s)));
- pa_log(_("Connected to device %s (%u, %ssuspended)."),
+ pa_log(_("Connected to device %s (index: %u, suspended: %s)."),
pa_stream_get_device_name(s),
pa_stream_get_device_index(s),
- pa_stream_is_suspended(s) ? "" : "not ");
+ pa_yes_no(pa_stream_is_suspended(s)));
}
break;
}
} else {
+ if (monitor_stream != PA_INVALID_INDEX && (pa_stream_set_monitor_stream(stream, monitor_stream) < 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;
}
" --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"
+ " --monitor-stream=INDEX Record from the sink input with index INDEX.\n")
, argv0);
}
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[]) {
{"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},
+ {"monitor-stream", 1, NULL, ARG_MONITOR_STREAM},
{NULL, 0, NULL, 0}
};
if (strstr(bn, "play")) {
mode = PLAYBACK;
- raw = FALSE;
+ raw = false;
} else if (strstr(bn, "record")) {
mode = RECORD;
- raw = FALSE;
+ raw = false;
} else if (strstr(bn, "cat")) {
mode = PLAYBACK;
- raw = TRUE;
+ raw = true;
} else if (strstr(bn, "rec") || strstr(bn, "mon")) {
mode = RECORD;
- raw = TRUE;
+ raw = true;
}
proplist = pa_proplist_new();
case ARG_VOLUME: {
int v = atoi(optarg);
volume = v < 0 ? 0U : (pa_volume_t) v;
- volume_is_set = TRUE;
+ volume_is_set = true;
break;
}
case ARG_CHANNELS:
sample_spec.channels = (uint8_t) atoi(optarg);
- sample_spec_set = TRUE;
+ sample_spec_set = true;
break;
case ARG_SAMPLEFORMAT:
sample_spec.format = pa_parse_sample_format(optarg);
- sample_spec_set = TRUE;
+ sample_spec_set = true;
break;
case ARG_SAMPLERATE:
sample_spec.rate = (uint32_t) atoi(optarg);
- sample_spec_set = TRUE;
+ sample_spec_set = true;
break;
case ARG_CHANNELMAP:
goto quit;
}
- channel_map_set = TRUE;
+ channel_map_set = true;
break;
case ARG_FIX_CHANNELS:
}
case ARG_RAW:
- raw = TRUE;
+ raw = true;
break;
case ARG_PASSTHROUGH:
}
}
- raw = FALSE;
+ raw = false;
break;
case ARG_LIST_FILE_FORMATS:
ret = 0;
goto quit;
+ case ARG_MONITOR_STREAM:
+ if (pa_atou(optarg, &monitor_stream) < 0) {
+ pa_log(_("Failed to parse the argument for --monitor-stream"));
+ goto quit;
+ }
+ break;
+
default:
goto quit;
}
pa_log(_("Failed to determine sample specification from file."));
goto quit;
}
- sample_spec_set = TRUE;
+ sample_spec_set = true;
if (!channel_map_set) {
/* Allow the user to overwrite the channel map on the command line */
if (sample_spec.channels > 2)
pa_log(_("Warning: Failed to determine channel map from file."));
} else
- channel_map_set = TRUE;
+ channel_map_set = true;
}
}
}