mirror of
https://github.com/outbackdingo/UltraGrid.git
synced 2026-03-22 10:40:25 +00:00
poraudio: print supported APIs in fullhelp
useful mainly to check ASIO presence in Win
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
* Ian Wesley-Smith <iwsmith@cct.lsu.edu>
|
||||
* Martin Pulec <pulec@cesnet.cz>
|
||||
*
|
||||
* Copyright (c) 2005-2024 CESNET
|
||||
* Copyright (c) 2005-2025 CESNET
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, is permitted provided that the following conditions
|
||||
@@ -110,11 +110,6 @@ static void audio_cap_portaudio_probe(struct device_info **available_devices, in
|
||||
audio_portaudio_probe(available_devices, count, PORTAUDIO_IN);
|
||||
}
|
||||
|
||||
static void audio_cap_portaudio_help()
|
||||
{
|
||||
portaudio_print_help(PORTAUDIO_IN);
|
||||
}
|
||||
|
||||
static void portaudio_close(PaStream * stream) // closes and frees all audio resources
|
||||
{
|
||||
Pa_StopStream(stream); // may not be necessary
|
||||
@@ -152,17 +147,19 @@ parse_fmt(const char *cfg, PaTime *latency, int *input_device_idx,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void usage() {
|
||||
static void
|
||||
usage(bool full)
|
||||
{
|
||||
printf("PortAudio capture usage:\n");
|
||||
color_printf("\t" TBOLD("-s portaudio:[full]help") "\n");
|
||||
color_printf("\t" TBOLD(TRED("-s portaudio") "[:<index>[:latency=<l>]]") "\n");
|
||||
printf("or\n");
|
||||
color_printf("\t" TBOLD(TRED("-s portaudio") "[:device=<dev>][:latency=<l>]") "\n\n");
|
||||
printf("options:\n");
|
||||
color_printf("\t" TBOLD(" <l> ") "\tsuggested latency in sec (experimental, use in case of problems)\n");
|
||||
color_printf("\t" TBOLD("<dev>") "\tdevice name (or a part of it); device index is also accepted here\n");
|
||||
printf("\nAvailable PortAudio capture devices:\n");
|
||||
|
||||
audio_cap_portaudio_help();
|
||||
printf("\n");
|
||||
portaudio_print_help(PORTAUDIO_IN, full);
|
||||
}
|
||||
|
||||
static void * audio_cap_portaudio_init(struct module *parent, const char *cfg)
|
||||
@@ -170,8 +167,8 @@ static void * audio_cap_portaudio_init(struct module *parent, const char *cfg)
|
||||
UNUSED(parent);
|
||||
portaudio_print_version();
|
||||
|
||||
if (strcmp(cfg, "help") == 0) {
|
||||
usage();
|
||||
if (strcmp(cfg, "help") == 0 || strcmp(cfg, "fullhelp") == 0) {
|
||||
usage(strcmp(cfg, "fullhelp") == 0);
|
||||
return INIT_NOERR;
|
||||
}
|
||||
|
||||
@@ -223,7 +220,7 @@ static void * audio_cap_portaudio_init(struct module *parent, const char *cfg)
|
||||
if(device_info == NULL) {
|
||||
log_msg(LOG_LEVEL_ERROR, MOD_NAME "Couldn't obtain requested portaudio device index %d.\n"
|
||||
MOD_NAME "Follows list of available Portaudio devices.\n", input_device_idx);
|
||||
audio_cap_portaudio_help();
|
||||
portaudio_print_help(PORTAUDIO_IN, false);
|
||||
free(s);
|
||||
Pa_Terminate();
|
||||
return NULL;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
* Martin Pulec <martin.pulec@cesnet.cz>
|
||||
* Ian Wesley-Smith <iwsmith@cct.lsu.edu>
|
||||
*
|
||||
* Copyright (c) 2005-2024 CESNET
|
||||
* Copyright (c) 2005-2025 CESNET
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, is permitted provided that the following conditions
|
||||
@@ -156,15 +156,18 @@ parse_fmt(const char *cfg, int *input_device_idx,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void audio_play_portaudio_help(void) {
|
||||
static void
|
||||
audio_play_portaudio_help(bool full)
|
||||
{
|
||||
printf("PortAudio playback usage:\n");
|
||||
color_printf("\t" TBOLD("-s portaudio:[full]help") "\n");
|
||||
color_printf("\t" TBOLD(TRED("-r portaudio") "[:<index>]") "\n");
|
||||
printf("or\n");
|
||||
color_printf("\t" TBOLD(TRED("-r portaudio") "[:device=<dev>]") "\n\n");
|
||||
printf("options:\n");
|
||||
color_printf("\t" TBOLD("<dev>") "\tdevice name (or a part of it); device index is also accepted here\n");
|
||||
printf("\nAvailable PortAudio playback devices:\n");
|
||||
portaudio_print_help(PORTAUDIO_OUT);
|
||||
printf("\n");
|
||||
portaudio_print_help(PORTAUDIO_OUT, full);
|
||||
}
|
||||
|
||||
static void *
|
||||
@@ -174,9 +177,10 @@ audio_play_portaudio_init(const struct audio_playback_opts *opts)
|
||||
char output_device_name[STR_LEN] = "";
|
||||
|
||||
portaudio_print_version();
|
||||
|
||||
if (strcmp(opts->cfg, "help") == 0) {
|
||||
audio_play_portaudio_help();
|
||||
|
||||
if (strcmp(opts->cfg, "help") == 0 ||
|
||||
strcmp(opts->cfg, "fullhelp") == 0) {
|
||||
audio_play_portaudio_help(strcmp(opts->cfg, "fullhelp") == 0);
|
||||
return INIT_NOERR;
|
||||
}
|
||||
if (!parse_fmt(opts->cfg, &output_device_idx, output_device_name)) {
|
||||
@@ -206,7 +210,7 @@ audio_play_portaudio_init(const struct audio_playback_opts *opts)
|
||||
if (device_info == NULL) {
|
||||
log_msg(LOG_LEVEL_ERROR, MOD_NAME "Couldn't obtain requested portaudio index %d.\n"
|
||||
MOD_NAME "Follows list of available Portaudio devices.\n", output_device_idx);
|
||||
audio_play_portaudio_help();
|
||||
audio_play_portaudio_help(false);
|
||||
Pa_Terminate();
|
||||
free(s);
|
||||
return NULL;
|
||||
|
||||
@@ -80,8 +80,12 @@ static const char *portaudio_get_device_details(PaDeviceIndex device) {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
void portaudio_print_help(enum portaudio_device_direction kind)
|
||||
void
|
||||
portaudio_print_help(enum portaudio_device_direction kind, bool full)
|
||||
{
|
||||
printf("\nAvailable PortAudio %s devices:\n",
|
||||
kind == PORTAUDIO_OUT ? "playback" : "capture");
|
||||
|
||||
int numDevices;
|
||||
int i;
|
||||
|
||||
@@ -130,6 +134,14 @@ void portaudio_print_help(enum portaudio_device_direction kind)
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
if (full) {
|
||||
printf ("\nSupported APIs:\n");
|
||||
for (int i = 0; i < Pa_GetHostApiCount(); ++i) {
|
||||
const PaHostApiInfo *info = Pa_GetHostApiInfo(i);
|
||||
printf("\t" TBOLD("%s") "\n", info->name);
|
||||
}
|
||||
}
|
||||
|
||||
error:
|
||||
Pa_Terminate();
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ enum portaudio_device_direction {
|
||||
PORTAUDIO_OUT
|
||||
};
|
||||
|
||||
void portaudio_print_help(enum portaudio_device_direction);
|
||||
void portaudio_print_help(enum portaudio_device_direction, bool full);
|
||||
const char *portaudio_get_device_name(PaDeviceIndex device);
|
||||
void audio_portaudio_probe(struct device_info **available_devices, int *count, enum portaudio_device_direction);
|
||||
void portaudio_print_version(void);
|
||||
|
||||
Reference in New Issue
Block a user