Skip to content

Commit 227c6d1

Browse files
committed
acap,aplay/portaudio: print index hint just if numeric
If given by name, the info was that the invalid index was -2, which is an internal value. The message that a device with given name could not have been found is already printed.
1 parent d21c44c commit 227c6d1

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

src/audio/capture/portaudio.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,12 +216,17 @@ static void * audio_cap_portaudio_init(struct module *parent, const char *cfg)
216216
portaudio_get_device_name(input_device_idx));
217217
inputParameters.device = input_device_idx;
218218
device_info = Pa_GetDeviceInfo(input_device_idx);
219+
if (device_info == NULL) {
220+
MSG(ERROR,
221+
"Couldn't obtain requested portaudio device index "
222+
"%d.\nFollows list of available Portaudio "
223+
"devices.\n",
224+
input_device_idx);
225+
portaudio_print_help(PORTAUDIO_IN, false);
226+
}
219227
}
220228

221229
if(device_info == NULL) {
222-
log_msg(LOG_LEVEL_ERROR, MOD_NAME "Couldn't obtain requested portaudio device index %d.\n"
223-
MOD_NAME "Follows list of available Portaudio devices.\n", input_device_idx);
224-
portaudio_print_help(PORTAUDIO_IN, false);
225230
free(s);
226231
Pa_Terminate();
227232
return NULL;

src/audio/playback/portaudio.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,13 +206,17 @@ audio_play_portaudio_init(const struct audio_playback_opts *opts)
206206
const PaDeviceInfo *device_info = NULL;
207207
if (output_device_idx >= 0) {
208208
device_info = Pa_GetDeviceInfo(output_device_idx);
209+
if (device_info == NULL) {
210+
MSG(ERROR,
211+
"Couldn't obtain requested portaudio index %d.\n"
212+
"Follows list of available Portaudio devices.\n",
213+
output_device_idx);
214+
audio_play_portaudio_help(false);
215+
}
209216
} else if (output_device_idx == -1) {
210217
device_info = Pa_GetDeviceInfo(Pa_GetDefaultOutputDevice());
211218
}
212219
if (device_info == NULL) {
213-
log_msg(LOG_LEVEL_ERROR, MOD_NAME "Couldn't obtain requested portaudio index %d.\n"
214-
MOD_NAME "Follows list of available Portaudio devices.\n", output_device_idx);
215-
audio_play_portaudio_help(false);
216220
Pa_Terminate();
217221
free(s);
218222
return NULL;

0 commit comments

Comments
 (0)