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

Code before:
      m_processInfo.SetAudioBitsPerSample(audioHint.bitspersample);
      if (Supports(audioHint.codec, audioHint.cryptoSession != nullptr))
        m_processInfo.SetAudioDecoderName("starfish-" +
                                          std::string(ms_codecMap.at(audioHint.codec).name));
      else if (m_audioEncoder)
        m_processInfo.SetAudioDecoderName("starfish-AC3 (transcoding)");

      return true;
    }
    // API introduced in webOS 6.0, so we need to handle older versions differently
    Unload(true);

    m_mediaAPIs = std::make_unique<StarfishMediaAPIs>();
  }

  if (m_audioHint.codec && m_videoHint.codec)
    return Load(m_videoHint, m_audioHint);
  return true;
}

bool CMediaPipelineWebOS::OpenVideoStream(CDVDStreamInfo hint)
{
  if (!Supports(hint.codec))
  {
    CLog::LogF(LOGERROR, "Unsupported codec: {}", hint.codec);
    return false;
  }

  if (m_loaded)
  {
    if (m_videoHint.codec == hint.codec)
    {
      std::scoped_lock lock(m_videoCriticalSection);
      SetupBitstreamConverter(hint);
      bool flush = true;

      // avoid flush if only resolution of adaptive stream changed
      if (m_videoHint.uniqueId == hint.uniqueId &&
          (m_videoHint.width != hint.width || m_videoHint.height != hint.height))
        flush = false;

      m_videoHint = hint;

      if (flush)
        Flush(true);

      m_processInfo.SetVideoInterlaced(hint.interlaced);
      m_processInfo.SetVideoDimensions(hint.width, hint.height);
      m_processInfo.SetVideoDAR(static_cast<float>(hint.aspect));
      if (m_videoHint.fpsrate && m_videoHint.fpsscale)
      {

Review comment (suggestion):
```suggestion
      if (m_videoHint.uniqueId != hint.uniqueId ||
          (m_videoHint.width == hint.width && m_videoHint.height == hint.height))
      {
        Flush(true);
      }

      m_videoHint = hint;
```

Code after:

    m_mediaAPIs = std::make_unique<StarfishMediaAPIs>();
  }

  if (m_audioHint.codec && m_videoHint.codec)
    return Load(m_videoHint, m_audioHint);
  return true;
}

bool CMediaPipelineWebOS::OpenVideoStream(CDVDStreamInfo hint)
{
  if (!Supports(hint.codec))
  {
    CLog::LogF(LOGERROR, "Unsupported codec: {}", hint.codec);
    return false;
  }

  if (m_loaded)
  {
    if (m_videoHint.codec == hint.codec && m_videoHint.hdrType == hint.hdrType)
    {
      std::scoped_lock lock(m_videoCriticalSection);
      SetupBitstreamConverter(hint);
      m_videoHint = hint;

      m_processInfo.SetVideoInterlaced(hint.interlaced);
      m_processInfo.SetVideoDimensions(hint.width, hint.height);
      m_processInfo.SetVideoDAR(static_cast<float>(hint.aspect));
      if (m_videoHint.fpsrate && m_videoHint.fpsscale)
      {
        m_processInfo.SetVideoFps(static_cast<float>(hint.fpsrate) /
                                  static_cast<float>(hint.fpsscale));
      }
      else
      {
        m_processInfo.SetVideoFps(1.0);
      }

      return true;
    }

    // Different codec => unload the current stream
    Unload(true);

    m_mediaAPIs = std::make_unique<StarfishMediaAPIs>();
  }

  m_videoHint = hint;

  if ((m_audioHint.codec || !m_hasAudio) && m_videoHint.codec)
    return Load(m_videoHint, m_audioHint);