diff --git a/app/src/cli.c b/app/src/cli.c index 4b54b401..7f2b3d49 100644 --- a/app/src/cli.c +++ b/app/src/cli.c @@ -2219,6 +2219,16 @@ parse_args_with_getopt(struct scrcpy_cli_args *args, int argc, char *argv[], return false; } + if (opts->audio && opts->audio_source == SC_AUDIO_SOURCE_AUTO) { + // Select the audio source according to the video source + if (opts->video_source == SC_VIDEO_SOURCE_DISPLAY) { + opts->audio_source = SC_AUDIO_SOURCE_OUTPUT; + } else { + opts->audio_source = SC_AUDIO_SOURCE_MIC; + LOGI("Camera video source: microphone audio source selected"); + } + } + if (opts->record_format && !opts->record_filename) { LOGE("Record format specified without recording"); return false; diff --git a/app/src/options.c b/app/src/options.c index 22be9f36..96741a7d 100644 --- a/app/src/options.c +++ b/app/src/options.c @@ -17,7 +17,7 @@ const struct scrcpy_options scrcpy_options_default = { .video_codec = SC_CODEC_H264, .audio_codec = SC_CODEC_OPUS, .video_source = SC_VIDEO_SOURCE_DISPLAY, - .audio_source = SC_AUDIO_SOURCE_OUTPUT, + .audio_source = SC_AUDIO_SOURCE_AUTO, .record_format = SC_RECORD_FORMAT_AUTO, .keyboard_input_mode = SC_KEYBOARD_INPUT_MODE_INJECT, .mouse_input_mode = SC_MOUSE_INPUT_MODE_INJECT, diff --git a/app/src/options.h b/app/src/options.h index af195793..afc6aa49 100644 --- a/app/src/options.h +++ b/app/src/options.h @@ -50,6 +50,7 @@ enum sc_video_source { }; enum sc_audio_source { + SC_AUDIO_SOURCE_AUTO, // OUTPUT for video DISPLAY, MIC for video CAMERA SC_AUDIO_SOURCE_OUTPUT, SC_AUDIO_SOURCE_MIC, }; diff --git a/app/src/server.c b/app/src/server.c index 413103ef..81a371ae 100644 --- a/app/src/server.c +++ b/app/src/server.c @@ -253,8 +253,7 @@ execute_server(struct sc_server *server, assert(params->video_source == SC_VIDEO_SOURCE_CAMERA); ADD_PARAM("video_source=camera"); } - if (params->audio_source != SC_AUDIO_SOURCE_OUTPUT) { - assert(params->audio_source == SC_AUDIO_SOURCE_MIC); + if (params->audio_source == SC_AUDIO_SOURCE_MIC) { ADD_PARAM("audio_source=mic"); } if (params->max_size) {