Skip to content

Commit

Permalink
prefer PCM for stereo
Browse files Browse the repository at this point in the history
  • Loading branch information
mariotaku committed Apr 26, 2024
1 parent 53654b7 commit 9380472
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
22 changes: 11 additions & 11 deletions src/app/stream/audio/session_audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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);
}

Expand Down
14 changes: 8 additions & 6 deletions src/app/stream/video/session_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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;
}
}

Expand Down

0 comments on commit 9380472

Please sign in to comment.