mirror of https://github.com/Genymobile/scrcpy
Automatically select audio source
If --audio-source is not specified, select the default value according to the video source: - for display mirroring, use device audio by default; - for camera mirroring, use microphone by default. PR #4213 <https://github.com/Genymobile/scrcpy/pull/4213>
This commit is contained in:
parent
bfeecc0131
commit
d544e577c0
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
};
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue