Kaynağa Gözat

Make audio passthrough display on debug overlay less confusing (try 2)

Mangle output on passthrough not only for the output channels display,
but also for the input one.

Remove the "spdif-" format prefix.
Vincent Lang 9 yıl önce
ebeveyn
işleme
1e5f9873a3
2 değiştirilmiş dosya ile 29 ekleme ve 15 silme
  1. 28 15
      src/player/PlayerComponent.cpp
  2. 1 0
      src/player/PlayerComponent.h

+ 28 - 15
src/player/PlayerComponent.cpp

@@ -785,9 +785,9 @@ void PlayerComponent::userCommand(const QString& command)
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////
-static QString get_mpv_osd(mpv_handle *ctx, const char *property)
+static QString get_mpv_osd(mpv_handle *ctx, const QString& property)
 {
-  char *s = mpv_get_property_osd_string(ctx, property);
+  char *s = mpv_get_property_osd_string(ctx, property.toUtf8().data());
   if (!s)
     return "-";
   QString r = QString::fromUtf8(s);
@@ -798,6 +798,26 @@ static QString get_mpv_osd(mpv_handle *ctx, const char *property)
 #define MPV_PROPERTY(p) get_mpv_osd(m_mpv, p)
 #define MPV_PROPERTY_BOOL(p) (mpv::qt::get_property_variant(m_mpv, p).toBool())
 
+/////////////////////////////////////////////////////////////////////////////////////////
+void PlayerComponent::appendAudioFormat(QTextStream& info, const QString& property) const
+{
+  // Guess if it's a passthrough format. Don't show the channel layout in this
+  // case, because it's confusing.
+  QString audio_format = MPV_PROPERTY(property + "/format");
+  if (audio_format.startsWith("spdif-"))
+  {
+    info << "passthrough (" << audio_format.mid(6) << ")";
+  }
+  else
+  {
+    QString hr = MPV_PROPERTY(property + "/hr-channels");
+    QString full = MPV_PROPERTY(property + "/channels");
+    info << hr;
+    if (hr != full)
+      info << " (" << full << ")";
+  }
+}
+
 /////////////////////////////////////////////////////////////////////////////////////////
 QString PlayerComponent::videoInformation() const
 {
@@ -832,19 +852,12 @@ QString PlayerComponent::videoInformation() const
   info << "Audio: " << endl;
   info << "Codec: " << MPV_PROPERTY("audio-codec") << endl;
   info << "Bitrate: " << MPV_PROPERTY("audio-bitrate") << endl;
-  info << "Channels (input): " << MPV_PROPERTY("audio-params/channels") << endl;
-  // Guess if it's a passthrough format. Don't show the channel layout in this
-  // case, because it's confusing.
-  QString audio_format = MPV_PROPERTY("audio-out-params/format");
-  if (audio_format.startsWith("spdif-"))
-  {
-    info << "Channels (output): passthrough (" << audio_format << ")" << endl;
-  }
-  else
-  {
-    info << "Channels (output): " << MPV_PROPERTY("audio-out-params/hr-channels")
-                                  << " (" << MPV_PROPERTY("audio-out-params/channels") << ")" << endl;
-  }
+  info << "Channels (input): ";
+  appendAudioFormat(info, "audio-params");
+  info << endl;
+  info << "Channels (output): ";
+  appendAudioFormat(info, "audio-out-params");
+  info << endl;
   info << endl;
   info << "Performance: " << endl;
   info << "A/V: " << MPV_PROPERTY("avsync") << endl;

+ 1 - 0
src/player/PlayerComponent.h

@@ -150,6 +150,7 @@ private:
   // was actually changed.
   bool switchDisplayFrameRate();
   void checkCurrentAudioDevice(const QSet<QString>& old_devs, const QSet<QString>& new_devs);
+  void appendAudioFormat(QTextStream& info, const QString& property) const;
 
   mpv::qt::Handle m_mpv;