Skip to content

Commit

Permalink
debug logging
Browse files Browse the repository at this point in the history
  • Loading branch information
mariotaku committed Apr 14, 2024
1 parent b975143 commit bb35d60
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 24 deletions.
38 changes: 23 additions & 15 deletions src/app/stream/audio/session_audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,34 @@ static int aud_init(int audioFormat, int audioConfiguration, const OPUS_MULTISTR
session = context;
player = session->player;
SS4S_AudioCodec codec = SS4S_AUDIO_PCM_S16LE;
if (audioFormat & AUDIO_FORMAT_MASK_AC3) {
codec = SS4S_AUDIO_AC3;
if (audioFormat == AUDIO_FORMAT_EAC3) {
codec = SS4S_AUDIO_EAC3;
decoder = NULL;
pcmbuf = NULL;
} else if (session->audio_cap.codecs & SS4S_AUDIO_OPUS) {
codec = SS4S_AUDIO_OPUS;
} else if (audioFormat == AUDIO_FORMAT_AC3) {
codec = SS4S_AUDIO_AC3;
decoder = NULL;
pcmbuf = NULL;
} else {
int rc;
decoder = opus_multistream_decoder_create(opusConfig->sampleRate, opusConfig->channelCount, opusConfig->streams,
opusConfig->coupledStreams, opusConfig->mapping, &rc);
if (rc != 0) {
return rc;
} else if (audioFormat & AUDIO_FORMAT_MASK_OPUS) {
if (session->audio_cap.codecs & SS4S_AUDIO_OPUS) {
codec = SS4S_AUDIO_OPUS;
decoder = NULL;
pcmbuf = NULL;
} else {
int rc;
decoder = opus_multistream_decoder_create(opusConfig->sampleRate, opusConfig->channelCount,
opusConfig->streams,
opusConfig->coupledStreams, opusConfig->mapping, &rc);
if (rc != 0) {
return rc;
}
unit_size = (int) (opusConfig->channelCount * sizeof(int16_t));
frame_size = opusConfig->samplesPerFrame;
pcmbuf = calloc(unit_size, frame_size);
}
unit_size = (int) (opusConfig->channelCount * sizeof(int16_t));
frame_size = opusConfig->samplesPerFrame;
pcmbuf = calloc(unit_size, frame_size);
} else {
commons_log_error("Audio", "Unsupported audio format: %04x", audioFormat);
return SS4S_AUDIO_OPEN_UNSUPPORTED_CODEC;
}
SS4S_AudioInfo info = {
.numOfChannels = opusConfig->channelCount,
Expand All @@ -45,8 +55,6 @@ static int aud_init(int audioFormat, int audioConfiguration, const OPUS_MULTISTR
.sampleRate = opusConfig->sampleRate,
.samplesPerFrame = opusConfig->samplesPerFrame,
};
commons_log_info("Audio", "Audio init: codec=%s, sampleRate=%d, channelCount=%d, samplesPerFrame=%d",
SS4S_AudioCodecName(codec), info.sampleRate, info.numOfChannels, info.samplesPerFrame);
return SS4S_PlayerAudioOpen(player, &info);
}

Expand Down
13 changes: 8 additions & 5 deletions src/app/stream/session.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,14 @@ void session_config_init(app_t *app, session_config_t *config, const SERVER_DATA
}
#endif
int sac = server->serverInfo.serverAudioCodecSupport;
if (sac & SAC_MASK_AC3 && audio_cap.codecs & SS4S_AUDIO_AC3) {
config->stream.supportedAudioFormats |= AUDIO_FORMAT_AC3;
}
if (sac & SAC_MASK_AAC && audio_cap.codecs & SS4S_AUDIO_AAC) {
config->stream.supportedAudioFormats |= AUDIO_FORMAT_AAC;
if (sac & SAC_MASK_AC3) {
commons_log_info("Session", "Server supports AC3: %d, EAC3: %d", (sac & SAC_AC3) != 0, (sac & SAC_EAC3) != 0);
if (audio_cap.codecs & SS4S_AUDIO_AC3) {
config->stream.supportedAudioFormats |= AUDIO_FORMAT_AC3;
}
if (audio_cap.codecs & SS4S_AUDIO_EAC3) {
config->stream.supportedAudioFormats |= AUDIO_FORMAT_EAC3;
}
}
if (config->stream.supportedAudioFormats == 0) {
config->stream.supportedAudioFormats = AUDIO_FORMAT_OPUS;
Expand Down
8 changes: 4 additions & 4 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ static int settings_load(app_settings_t *settings);

int main(int argc, char *argv[]) {
static char log_path[1024];
snprintf(log_path, sizeof(log_path), "/tmp/gst-moonlight-%d.log", getpid());
setenv("GST_DEBUG_FILE_OVERWRITE", "enable", 1);
setenv("GST_DEBUG_FILE", log_path, 1);
setenv("GST_DEBUG", "4,rtkalsa:6,rtkaudiobasesink:6", 1);
snprintf(log_path, sizeof(log_path), "/tmp/moonlight-%d.log", getpid());
FILE *log_file = fopen(log_path, "w");
dup2(fileno(log_file), STDERR_FILENO);
dup2(fileno(log_file), STDOUT_FILENO);
#ifdef TARGET_WEBOS
if (getenv("EGL_PLATFORM") == NULL) {
setenv("EGL_PLATFORM", "wayland", 0);
Expand Down

0 comments on commit bb35d60

Please sign in to comment.