]> Some of my projects - aniplayer.git/commitdiff
Turn off deprecated MPV features
authorAPTX <marek321@gmail.com>
Sat, 19 Feb 2022 09:14:27 +0000 (18:14 +0900)
committerAPTX <marek321@gmail.com>
Mon, 21 Feb 2022 15:10:20 +0000 (00:10 +0900)
Also removes use of the deprecated features

qthelper.hpp is no longer part of MPV, so the deprecation
no longer applies.

backendplugins/backend_mpv/CMakeLists.txt
backendplugins/backend_mpv/backendmpv.cpp
backendplugins/backend_mpv/qthelper.hpp

index 31b0736ba339c3798c65f853bef00ebf53a0bd42..81d551911dbe4230c1f3334d456f05684a9e44b4 100644 (file)
@@ -41,6 +41,8 @@ target_link_libraries(backend_mpv ${backend_mpv_LIBS})
 
 add_definitions(-DBACKEND_MPV_LIBRARY)
 
+add_definitions(-DMPV_ENABLE_DEPRECATED=0)
+
 install(TARGETS backend_mpv
     LIBRARY DESTINATION ${INSTALL_DESTINATION}
     ARCHIVE DESTINATION ${INSTALL_DESTINATION}
index ef9c3d2b5b78ecbbc1e88cf6ce0126c0686ddf09..75b655b312e3b9821e2ce0b37f160b29dd1ebf51 100644 (file)
@@ -94,6 +94,11 @@ MpvInstance::MpvInstance(PlayerPluginInterface *playerInterface,
         mpv_observe_property(m_handle, 0, "chapter-list", MPV_FORMAT_NODE);
     qCDebug(mpvBackend) << "register chapter-list" << ret;
   }
+  {
+    const auto ret =
+        mpv_observe_property(m_handle, 0, "idle-active", MPV_FORMAT_NODE);
+    qCDebug(mpvBackend) << "register chapter-list" << ret;
+  }
   {
     const auto ret = mpv_request_log_messages(m_handle, "info");
     qCDebug(mpvBackend) << "request log messages" << ret;
@@ -350,6 +355,9 @@ void MpvInstance::processMpvEvents() {
                                                      map["time"].toDouble()};
         }
         m_player->backendChaptersChanged(chapters);
+      } else if (strcmp(property->name, "idle-active") == 0) {
+        m_player->playStateChanged(PlayerPluginInterface::PlayState::Stopped);
+        m_player->backendReadyToPlay();
       } else {
         qCWarning(mpvBackend)
             << "Change notification for not handled property" << property->name;
@@ -397,10 +405,6 @@ void MpvInstance::processMpvEvents() {
         m_player->playbackEndOfFileReached();
       }
     } break;
-    case MPV_EVENT_IDLE: {
-      m_player->playStateChanged(PlayerPluginInterface::PlayState::Stopped);
-      m_player->backendReadyToPlay();
-    } break;
     case MPV_EVENT_AUDIO_RECONFIG: {
       if (m_volumeToSet >= 0) {
         qCDebug(mpvBackend) << "Audio reconfigured, maybe it's ready now?";
index 3af86e36e719339ec6959dc63f442f7fe68f2c20..0f664906022b3182c3f16bfb87e3067d03e54fa7 100644 (file)
 
 #include <mpv/client.h>
 
-#if !MPV_ENABLE_DEPRECATED
-#error "This helper is deprecated. Copy it into your project instead."
-#else
-
 /**
  * Note: these helpers are provided for convenience for C++/Qt applications.
  * This is based on the public API in client.h, and it does not encode any
@@ -381,6 +377,4 @@ static inline QVariant command(mpv_handle *ctx, const QVariant &args)
 
 Q_DECLARE_METATYPE(mpv::qt::ErrorReturn)
 
-#endif /* else #if MPV_ENABLE_DEPRECATED */
-
 #endif