Skip to content

Commit 02841a2

Browse files
committed
wasapi: show IDs only in fullhelp
the IDs shlighlyt mess up the output and may not be necessary needed to use (name is also an option now if user wants stable identifier)
1 parent 2642924 commit 02841a2

File tree

2 files changed

+31
-16
lines changed

2 files changed

+31
-16
lines changed

src/audio/capture/wasapi.cpp

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ struct state_acap_wasapi {
9797
enum { IDX_LOOP = -2, IDX_DFL = -1 };
9898

9999
string wasapi_get_name(IMMDevice *pDevice);
100-
static void show_help();
100+
static void show_help(bool full);
101101
string wasapi_get_default_device_id(EDataFlow dataFlow, IMMDeviceEnumerator *enumerator);
102102

103103
#define SAFE_RELEASE(u) \
@@ -197,10 +197,11 @@ string wasapi_get_default_device_id(EDataFlow dataFlow, IMMDeviceEnumerator *enu
197197
return ret;
198198
}
199199

200-
static void show_help() {
200+
static void show_help(bool full) {
201201
col() << "Usage:\n"
202-
<< SBOLD(SRED("\t-s wasapi") << "[:d[evice]=<index>|<ID>|<name>]")
203-
<< "\n\nAvailable devices:\n";
202+
<< SBOLD(SRED("\t-s wasapi") << "[:d[evice]=<index>|<ID>|<name>]") << "\n"
203+
<< SBOLD("\t-s wasapi:[full]help") << "\n"
204+
<< "\nAvailable devices:\n";
204205

205206
IMMDeviceEnumerator *enumerator = nullptr;
206207
IMMDeviceCollection *pEndpoints = nullptr;
@@ -225,10 +226,13 @@ static void show_help() {
225226
string dev_id = win_wstr_to_str(pwszID);
226227
color_printf(
227228
"%s\t" TBOLD("%2d") ") " TBOLD(
228-
"%s") " (ID: %s)\n",
229+
"%s"),
229230
(dev_id == default_dev_id ? "(*)" : ""), i,
230-
wasapi_get_name(pDevice).c_str(),
231-
dev_id.c_str());
231+
wasapi_get_name(pDevice).c_str());
232+
if (full) {
233+
color_printf(" (ID: %s)", dev_id.c_str());
234+
}
235+
color_printf("\n");
232236
} catch (ug_runtime_error &e) {
233237
LOG(LOG_LEVEL_WARNING) << MOD_NAME << "Device " << i << ": " << e.what() << "\n";
234238
}
@@ -241,6 +245,9 @@ static void show_help() {
241245
SAFE_RELEASE(pEndpoints);
242246
com_uninitialize(&com_initialized);
243247
col() << " " << SBOLD("loopback") << ") " << SBOLD("computer audio output") << " (ID: loopback)\n";
248+
if (!full) {
249+
printf("(use \"fullhelp\" to show device IDs)\n");
250+
}
244251
printf("\nDevice " TBOLD("name") " can be a substring (selects first matching device).\n");
245252
}
246253

@@ -272,8 +279,9 @@ parse_fmt(const char *cfg, int *req_index, char *req_dev_name,
272279

273280
static void * audio_cap_wasapi_init(struct module *parent, const char *cfg)
274281
{
275-
if (strcmp(cfg, "help") == 0) {
276-
show_help();
282+
if (strcmp(cfg, "help") == 0 ||
283+
strcmp(cfg, "fullhelp") == 0) {
284+
show_help(strcmp(cfg, "fullhelp") == 0);
277285
return INIT_NOERR;
278286
}
279287
UNUSED(parent);

src/audio/playback/wasapi.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,11 @@ static void audio_play_wasapi_probe(struct device_info **available_devices, int
147147
com_uninitialize(&com_initialized);
148148
}
149149

150-
static void audio_play_wasapi_help() {
150+
static void audio_play_wasapi_help(bool full) {
151151
col() << "Usage:\n"
152152
<< SBOLD(SRED("\t-r wasapi") << "[:d[evice]=<index>|<ID>|<name>] "
153-
"--param audio-buffer-len=<ms>")
154-
<< "\n"
153+
"--param audio-buffer-len=<ms>") << "\n"
154+
<< SBOLD("\t-r wasapi:[full]help") << "\n"
155155
<< "\nAvailable devices:\n";
156156

157157
bool com_initialized = false;
@@ -178,8 +178,11 @@ static void audio_play_wasapi_help() {
178178
string dev_id = win_wstr_to_str(pwszID);
179179
col() << (dev_id == default_dev_id ? "(*)" : "")
180180
<< "\t" << SBOLD(i) << ") "
181-
<< SBOLD(wasapi_get_name(pDevice))
182-
<< " (ID: " << dev_id << ")\n";
181+
<< SBOLD(wasapi_get_name(pDevice));
182+
if (full) {
183+
col() << " (ID: " << dev_id << ")";
184+
}
185+
col() << "\n";
183186
} catch (ug_runtime_error &e) {
184187
LOG(LOG_LEVEL_WARNING) << MOD_NAME << "Device " << i << ": " << e.what() << "\n";
185188
}
@@ -191,6 +194,9 @@ static void audio_play_wasapi_help() {
191194
SAFE_RELEASE(enumerator);
192195
SAFE_RELEASE(pEndpoints);
193196
com_uninitialize(&com_initialized);
197+
if (!full) {
198+
printf("(use \"fullhelp\" to show device IDs)\n");
199+
}
194200
printf("\nDevice " TBOLD("name") " can be a substring (selects first matching device).\n");
195201
}
196202

@@ -223,8 +229,9 @@ parse_fmt(const char *cfg, int *req_index, char *req_dev_name,
223229
static void *
224230
audio_play_wasapi_init(const struct audio_playback_opts *opts)
225231
{
226-
if (strcmp(opts->cfg, "help") == 0) {
227-
audio_play_wasapi_help();
232+
if (strcmp(opts->cfg, "help") == 0 ||
233+
strcmp(opts->cfg, "fullhelp") == 0) {
234+
audio_play_wasapi_help(strcmp(opts->cfg, "fullhelp") == 0);
228235
return INIT_NOERR;
229236
}
230237

0 commit comments

Comments
 (0)