diff --git a/app/src/scrcpy.c b/app/src/scrcpy.c index 944d5f05..eb70749a 100644 --- a/app/src/scrcpy.c +++ b/app/src/scrcpy.c @@ -43,6 +43,7 @@ struct scrcpy { struct sc_demuxer video_demuxer; struct sc_demuxer audio_demuxer; struct sc_decoder video_decoder; + struct sc_decoder audio_decoder; struct sc_recorder recorder; #ifdef HAVE_V4L2 struct sc_v4l2_sink v4l2_sink; @@ -437,6 +438,7 @@ scrcpy(struct scrcpy_options *options) { } bool needs_video_decoder = options->display; + bool needs_audio_decoder = options->audio && options->display; #ifdef HAVE_V4L2 needs_video_decoder |= !!options->v4l2_device; #endif @@ -444,6 +446,10 @@ scrcpy(struct scrcpy_options *options) { sc_decoder_init(&s->video_decoder, "video"); sc_demuxer_add_sink(&s->video_demuxer, &s->video_decoder.packet_sink); } + if (needs_audio_decoder) { + sc_decoder_init(&s->audio_decoder, "audio"); + sc_demuxer_add_sink(&s->audio_demuxer, &s->audio_decoder.packet_sink); + } if (options->record_filename) { static const struct sc_recorder_callbacks recorder_cbs = {