diff --git a/src/app/stream/audio/session_audio.c b/src/app/stream/audio/session_audio.c index c616fb56..aaf14562 100644 --- a/src/app/stream/audio/session_audio.c +++ b/src/app/stream/audio/session_audio.c @@ -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, @@ -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); } diff --git a/src/app/stream/session.c b/src/app/stream/session.c index 5e50926c..5c6ef3e0 100644 --- a/src/app/stream/session.c +++ b/src/app/stream/session.c @@ -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; diff --git a/src/main.c b/src/main.c index dacf315e..18e64fe6 100644 --- a/src/main.c +++ b/src/main.c @@ -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);