diff --git a/src/app/stream/audio/session_audio.c b/src/app/stream/audio/session_audio.c index 7e4461d2..ee2ecc92 100644 --- a/src/app/stream/audio/session_audio.c +++ b/src/app/stream/audio/session_audio.c @@ -29,7 +29,14 @@ static int aud_init(int audioConfiguration, const POPUS_MULTISTREAM_CONFIGURATIO player = session->player; SS4S_AudioCodec codec = SS4S_AUDIO_PCM_S16LE; size_t codecDataLen = 0; - if (session->audio_cap.codecs & SS4S_AUDIO_OPUS) { + SS4S_AudioInfo info = { + .numOfChannels = opusConfig->channelCount, + .appName = "Moonlight", + .streamName = "Streaming", + .sampleRate = opusConfig->sampleRate, + .samplesPerFrame = SAMPLES_PER_FRAME, + }; + if (session->audio_cap.codecs & SS4S_AUDIO_OPUS && SS4S_GetAudioPreferredCodecs(&info) & SS4S_AUDIO_OPUS) { codec = SS4S_AUDIO_OPUS; decoder = NULL; buffer = calloc(1024, sizeof(unsigned char)); @@ -47,16 +54,9 @@ static int aud_init(int audioConfiguration, const POPUS_MULTISTREAM_CONFIGURATIO buffer = calloc(unit_size, frame_size); } audio_stream_info.format = SS4S_AudioCodecName(codec); - SS4S_AudioInfo info = { - .numOfChannels = opusConfig->channelCount, - .codec = codec, - .appName = "Moonlight", - .streamName = "Streaming", - .sampleRate = opusConfig->sampleRate, - .samplesPerFrame = SAMPLES_PER_FRAME, - .codecData = buffer, - .codecDataLen = codecDataLen, - }; + info.codec = codec; + info.codecData = buffer; + info.codecDataLen = codecDataLen; return SS4S_PlayerAudioOpen(player, &info); } diff --git a/src/app/stream/video/session_video.c b/src/app/stream/video/session_video.c index 7a66b0fa..96e5d8cd 100644 --- a/src/app/stream/video/session_video.c +++ b/src/app/stream/video/session_video.c @@ -104,12 +104,13 @@ int vdec_delegate_setup(int videoFormat, int width, int height, int redrawRate, } switch (SS4S_PlayerVideoOpen(player, &info)) { - case SS4S_VIDEO_OPEN_ERROR: - return CALLBACKS_SESSION_ERROR_VDEC_ERROR; + case SS4S_VIDEO_OPEN_OK: { + return 0; + } case SS4S_VIDEO_OPEN_UNSUPPORTED_CODEC: return CALLBACKS_SESSION_ERROR_VDEC_UNSUPPORTED; default: - return 0; + return CALLBACKS_SESSION_ERROR_VDEC_ERROR; } } @@ -166,11 +167,12 @@ int vdec_delegate_submit(PDECODE_UNIT decodeUnit) { vdec_temp_stats.totalSubmitTime += LiGetMillis() - decodeUnit->enqueueTimeMs; vdec_temp_stats.submittedFrames++; return DR_OK; - } else if (result == SS4S_VIDEO_FEED_ERROR) { + } else if (result == SS4S_VIDEO_FEED_REQUEST_KEYFRAME) { + return DR_NEED_IDR; + } else { + commons_log_error("Session", "Video feed error %d", result); session_interrupt(session, false, STREAMING_INTERRUPT_DECODER); return DR_OK; - } else { - return DR_NEED_IDR; } }