Repository: xbmc/xbmc
File: xbmc/cores/VideoPlayer/MediaPipelineWebOS.cpp (C++)

Code before:
    std::unique_lock lock(m_eventMutex);
    if (!m_eventCondition.wait_for(lock, 1s, [this] { return !m_loaded; }))
    {
      CLog::LogF(LOGERROR, "Timeout waiting for m_loaded to be false");
    }
  }
}

std::string CMediaPipelineWebOS::SetupAudio(CDVDStreamInfo& audioHint, CVariant& optInfo)
{
  m_audioCodec = nullptr;
  m_audioEncoder = nullptr;
  m_audioResample = nullptr;
  m_encoderBuffers = nullptr;

  std::string codecName = "AC3";
  if (!Supports(audioHint.codec, audioHint.cryptoSession != nullptr))
  {
    m_audioCodec = std::make_unique<CDVDAudioCodecFFmpeg>(m_processInfo);
    CDVDCodecOptions options;
    m_audioCodec->Open(audioHint, options);
    m_audioEncoder = std::make_unique<CAEEncoderFFmpeg>();
    return codecName;
  }

  codecName = ms_codecMap.at(audioHint.codec).name.data();
  if (audioHint.codec == AV_CODEC_ID_EAC3)
  {
    optInfo["ac3PlusInfo"]["channels"] = audioHint.channels;
    optInfo["ac3PlusInfo"]["frequency"] = audioHint.samplerate / 1000.0;

    if (audioHint.profile == AV_PROFILE_EAC3_DDP_ATMOS)
    {
      optInfo["ac3PlusInfo"]["channels"] = audioHint.channels + 2;
    }
  }
  if (audioHint.codec == AV_CODEC_ID_AC4)
  {
    optInfo["ac4Info"]["channels"] = audioHint.channels;
    optInfo["ac4Info"]["frequency"] = audioHint.samplerate / 1000.0;
  }
  else if (audioHint.codec == AV_CODEC_ID_DTS)
  {
    optInfo["dtsInfo"]["channels"] = audioHint.channels;
    optInfo["dtsInfo"]["frequency"] = audioHint.samplerate / 1000.0;

    if (audioHint.profile == AV_PROFILE_DTS_ES)
      codecName = "DTSE";
    if (audioHint.profile == AV_PROFILE_DTS_HD_MA_X ||
        audioHint.profile == AV_PROFILE_DTS_HD_MA_X_IMAX)
      codecName = "DTSX";

Review comment (suggestion):
```suggestion
  codecName = ms_codecMap.at(audioHint.codec).name;
```

Code after:
  }
  if (audioHint.codec == AV_CODEC_ID_AC4)
  {
    optInfo["ac4Info"]["channels"] = audioHint.channels;
    optInfo["ac4Info"]["frequency"] = audioHint.samplerate / 1000.0;
  }
  else if (audioHint.codec == AV_CODEC_ID_DTS)
  {
    optInfo["dtsInfo"]["channels"] = audioHint.channels;
    optInfo["dtsInfo"]["frequency"] = audioHint.samplerate / 1000.0;

    if (audioHint.profile == AV_PROFILE_DTS_ES)
      codecName = "DTSE";
    if (audioHint.profile == AV_PROFILE_DTS_HD_MA_X ||
        audioHint.profile == AV_PROFILE_DTS_HD_MA_X_IMAX)
      codecName = "DTSX";
  }
  else if (audioHint.codec == AV_CODEC_ID_OPUS)
  {
    optInfo["opusInfo"]["channels"] = audioHint.channels;
    optInfo["opusInfo"]["frequency"] = audioHint.samplerate / 1000.0;
    optInfo["opusInfo"]["streamHeader"] =
        Base64::Encode(reinterpret_cast<const char*>(audioHint.extradata.GetData()),
                       audioHint.extradata.GetSize());
  }
  else if (audioHint.codec == AV_CODEC_ID_AAC || audioHint.codec == AV_CODEC_ID_AAC_LATM)
  {
    optInfo["aacInfo"]["channels"] = audioHint.channels;
    optInfo["aacInfo"]["frequency"] = audioHint.samplerate / 1000.0;
    optInfo["aacInfo"]["profile"] = audioHint.profile;
    optInfo["aacInfo"]["format"] = audioHint.extradata ? "MP4" : "adts";
  }
  return codecName;
}

void CMediaPipelineWebOS::SetupBitstreamConverter(CDVDStreamInfo& hint)
{
  const std::shared_ptr<CSettings> settings = CServiceBroker::GetSettingsComponent()->GetSettings();
  const bool convertDovi =
      hint.dovi.el_present_flag || settings->GetBool(CSettings::SETTING_VIDEOPLAYER_CONVERTDOVI);

  const std::shared_ptr allowedHdrFormatsSetting(std::dynamic_pointer_cast<CSettingList>(
      settings->GetSetting(CSettings::SETTING_VIDEOPLAYER_ALLOWEDHDRFORMATS)));
  const bool removeDovi = !CSettingUtils::FindIntInList(
      allowedHdrFormatsSetting, CSettings::VIDEOPLAYER_ALLOWED_HDR_TYPE_DOLBY_VISION);

  if (hint.codec == AV_CODEC_ID_AVS || hint.codec == AV_CODEC_ID_CAVS ||
      hint.codec == AV_CODEC_ID_H264 || hint.codec == AV_CODEC_ID_HEVC)
  {
    if (hint.extradata && !hint.cryptoSession)
    {