Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved Audio Performance for webOS 5+ #421

Merged
merged 2 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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