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

Code before:
  int iStream = m_processInfo->GetVideoSettings().m_AudioStream;
  GetAudioStreamInfo(iStream, info);
  if (info.valid)
  {
    CVariant data;
    data["player"]["playerid"] = static_cast<int>(CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist());
    CVariant contentEntry(CVariant::VariantTypeObject);
    contentEntry["index"] = iStream;
    contentEntry["bitrate"] = info.bitrate;
    contentEntry["channels"] = info.channels;
    contentEntry["codec"] = info.codecDesc;
    contentEntry["isdefault"] = (info.flags & StreamFlags::FLAG_DEFAULT) != 0;
    contentEntry["isimpaired"] = (info.flags & StreamFlags::FLAG_HEARING_IMPAIRED) != 0;
    contentEntry["isoriginal"] = (info.flags & StreamFlags::FLAG_ORIGINAL) != 0;
    contentEntry["language"] = info.language;
    contentEntry["name"] = info.name;
    contentEntry["samplerate"] = info.samplerate;
    data["property"]["currentaudiostream"] = contentEntry;
    CServiceBroker::GetAnnouncementManager()->Announce(ANNOUNCEMENT::Player, "OnPropertyChanged", data);
  }
}

void CVideoPlayer::NotifyVideoUpdate()
{
  VideoStreamInfo info;
  int iStream = m_processInfo->GetVideoSettings().m_VideoStream;
  GetVideoStreamInfo(iStream, info);
  if (info.valid)
  {
    CVariant data;
    data["player"]["playerid"] = static_cast<int>(CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist());
    CVariant contentEntry(CVariant::VariantTypeObject);
    contentEntry["index"] = iStream;
    contentEntry["codec"] = info.codecName;
    contentEntry["height"] = info.height;
    contentEntry["width"] = info.width;
    contentEntry["language"] = info.language;
    contentEntry["name"] = info.name;
    data["property"]["currentvideostream"] = contentEntry;
    CServiceBroker::GetAnnouncementManager()->Announce(ANNOUNCEMENT::Player, "OnPropertyChanged", data);
  }
}


Review comment (suggestion):
const int stream = m_processInfo... please. Const and the type is not used as part of the variable name.

Code after:

void CVideoPlayer::SetUpdateStreamDetails()
{
  m_messenger.Put(std::make_shared<CDVDMsg>(CDVDMsg::PLAYER_SET_UPDATE_STREAM_DETAILS));
}

void CVideoPlayer::NotifySubtitleUpdate(int flags)
{
  CVariant data;
  data["player"]["playerid"] = m_item.GetProperty("playlist_type_hint").asInteger32(-1);
  if ((flags & SubtitleChange::FLAG_STATUS_CHANGE) != 0)
  {
    data["property"]["subtitleenabled"] = m_processInfo->GetVideoSettings().m_SubtitleOn;
  }
  if ((flags & SubtitleChange::FLAG_STREAMINFO_CHANGE) != 0)
  {
    const int stream = m_processInfo->GetVideoSettings().m_SubtitleStream;
    SubtitleStreamInfo info;
    GetSubtitleStreamInfo(stream, info);
    if (!info.valid)
    {
      // Only proceed if we're also sending status change
      if ((flags & SubtitleChange::FLAG_STATUS_CHANGE) == 0)
        return;
    }
    else
    {
      // Only add stream info if valid
      CVariant contentEntry(CVariant::VariantTypeObject);
      contentEntry["index"] = stream;
      contentEntry["isdefault"] = (info.flags & StreamFlags::FLAG_DEFAULT) != 0;
      contentEntry["isforced"] = (info.flags & StreamFlags::FLAG_FORCED) != 0;
      contentEntry["isimpaired"] = (info.flags & StreamFlags::FLAG_VISUAL_IMPAIRED) != 0;
      contentEntry["language"] = info.language;
      contentEntry["name"] = info.name;
      data["property"]["currentsubtitle"] = contentEntry;
    }
  }
  CServiceBroker::GetAnnouncementManager()->Announce(ANNOUNCEMENT::Player, "OnPropertyChanged",
                                                     data);
}

void CVideoPlayer::NotifyAudioUpdate()
{
  AudioStreamInfo info;
  const int stream = m_processInfo->GetVideoSettings().m_AudioStream;
  GetAudioStreamInfo(stream, info);
  if (!info.valid)
    return;
  CVariant data;
  data["player"]["playerid"] = m_item.GetProperty("playlist_type_hint").asInteger32(-1);