Dominique Leuenberger 2019-05-06 11:27:13 +00:00 committed by Git OBS Bridge
commit 64dd63db68
4 changed files with 190 additions and 1 deletions

View File

@ -0,0 +1,106 @@
From 402cbee5e675cf795b619b834f92aac086972afc Mon Sep 17 00:00:00 2001
From: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Date: Fri, 3 May 2019 08:41:36 -0300
Subject: vlc: fix support for vlc 2.x
As reported by Wolfgang, the changes made on Kaffeine 2.0.16 to
solve issues with audio CDs broke Kaffeine when building it with
legacy vlc 2.2.x.
The fix here is simple: just place two libVlc 3.0 events at the
print logic inside the Vlc3 block is enough to make it build
again.
The libvlc_MediaMetaChanged is used to report when a new media is
playing.
With vlc 2.0, such event should be enabled only inside mediaPlay()
routine. Doing it early causes the play to not work.
So, re-add such logic, with got removed on changeset d03abc77ad40
("backend-vlc: simplify events handling logic").
BUG: 407153
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
---
src/backend-vlc/vlcmediawidget.cpp | 26 ++++++++++++++++++++------
1 file changed, 20 insertions(+), 6 deletions(-)
diff --git a/src/backend-vlc/vlcmediawidget.cpp b/src/backend-vlc/vlcmediawidget.cpp
index e47a44d..7917417 100644
--- a/src/backend-vlc/vlcmediawidget.cpp
+++ b/src/backend-vlc/vlcmediawidget.cpp
@@ -113,10 +113,6 @@ const char *vlcEventName(int event)
return "MediaListPlayerNextItemSet";
case libvlc_MediaListPlayerStopped:
return "MediaListPlayerStopped";
- case libvlc_RendererDiscovererItemAdded:
- return "RendererDiscovererItemAdded";
- case libvlc_RendererDiscovererItemDeleted:
- return "RendererDiscovererItemDeleted";
case libvlc_VlmMediaAdded:
return "VlmMediaAdded";
case libvlc_VlmMediaRemoved:
@@ -140,6 +136,10 @@ const char *vlcEventName(int event)
case libvlc_VlmMediaInstanceStatusError:
return "VlmMediaInstanceStatusError";
#if LIBVLC_VERSION_MAJOR > 2
+ case libvlc_RendererDiscovererItemAdded:
+ return "RendererDiscovererItemAdded";
+ case libvlc_RendererDiscovererItemDeleted:
+ return "RendererDiscovererItemDeleted";
case libvlc_MediaPlayerAudioVolume:
return "MediaPlayerAudioVolume";
case libvlc_MediaPlayerAudioDevice:
@@ -171,17 +171,17 @@ VlcMediaWidget::VlcMediaWidget(QWidget *parent) : AbstractMediaWidget(parent),
typeOfDevice(""), trackNumber(1), numTracks(1)
{
libvlc_event_e events[] = {
- libvlc_MediaMetaChanged,
libvlc_MediaPlayerEncounteredError,
libvlc_MediaPlayerEndReached,
libvlc_MediaPlayerLengthChanged,
libvlc_MediaPlayerSeekableChanged,
libvlc_MediaPlayerStopped,
+ libvlc_MediaPlayerTimeChanged,
#if LIBVLC_VERSION_MAJOR > 2
+ libvlc_MediaMetaChanged,
libvlc_MediaPlayerESAdded,
libvlc_MediaPlayerESDeleted,
#endif
- libvlc_MediaPlayerTimeChanged,
#if 0 // all other possible events
libvlc_MediaSubItemAdded,
libvlc_MediaDurationChanged,
@@ -558,6 +558,10 @@ void VlcMediaWidget::unregisterEvents()
for (int i = 0; i < eventType.size(); ++i)
libvlc_event_detach(eventManager, eventType.at(i),
vlcEventHandler, this);
+#if LIBVLC_VERSION_MAJOR <= 2
+ libvlc_event_detach(eventManager, libvlc_MediaMetaChanged,
+ vlcEventHandler, this);
+#endif
}
bool VlcMediaWidget::registerEvents()
@@ -578,6 +582,16 @@ int VlcMediaWidget::makePlay()
return -1;
}
+#if LIBVLC_VERSION_MAJOR <= 2
+ // For libVlc 2.x to work, we need to add the
+ // MediaMetaChanged event only here
+ if (libvlc_event_attach(eventManager, libvlc_MediaMetaChanged,
+ vlcEventHandler, this) != 0) {
+ qCWarning(logMediaWidget, "Cannot attach event handler %d",
+ libvlc_MediaMetaChanged);
+ }
+#endif
+
libvlc_media_player_set_media(vlcMediaPlayer, vlcMedia);
/*
--
cgit v1.1

View File

@ -1,3 +1,11 @@
-------------------------------------------------------------------
Sat May 4 17:01:52 UTC 2019 - wbauer@tmo.at
- Add upstream patches to make it build (and work) with vlc 2.2 on
Leap 42.3 (kde#407153):
* fix-support-for-vlc-2.x.patch
* with-vlc-2.x-use-vlcMedia-for-libvlc_MediaMetaChanged-event.patch
-------------------------------------------------------------------
Thu May 2 09:56:38 UTC 2019 - wbauer@tmo.at

View File

@ -26,6 +26,9 @@ URL: http://kaffeine.kde.org/
Source0: https://download.kde.org/stable/%{name}/%{name}-%{version}.tar.xz
# PATCH-FEATURE-OPENSUSE kaffeine-fixsplitter.patch -- GUI improvement (allow more flexibly set splitters)
Patch0: kaffeine-fixsplitter.patch
# PATCH-FIX-UPSTREAM
Patch1: fix-support-for-vlc-2.x.patch
Patch2: with-vlc-2.x-use-vlcMedia-for-libvlc_MediaMetaChanged-event.patch
BuildRequires: extra-cmake-modules
BuildRequires: pkgconfig
BuildRequires: cmake(KF5CoreAddons)
@ -42,7 +45,7 @@ BuildRequires: pkgconfig(Qt5Network)
BuildRequires: pkgconfig(Qt5Sql)
BuildRequires: pkgconfig(Qt5Widgets)
BuildRequires: pkgconfig(Qt5X11Extras)
BuildRequires: pkgconfig(libvlc) >= 3.0
BuildRequires: pkgconfig(libvlc)
BuildRequires: pkgconfig(x11)
BuildRequires: pkgconfig(xscrnsaver)
Requires: libQt5Sql5-sqlite

View File

@ -0,0 +1,72 @@
From 2644cbf02ed39bb6b194bc6b7935b069b5769364 Mon Sep 17 00:00:00 2001
From: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Date: Sat, 4 May 2019 09:28:23 -0300
Subject: vlc: with vlc 2.x, use vlcMedia for libvlc_MediaMetaChanged event
As reported by Wolfgang, the libVlc 2.x fix applied at
402cbee5e675 ("vlc: fix support for vlc 2.x") still have issues,
causing some troubles at least on audio CDs.
The root cause seems to be that, on vlc 2.x, the event
libvlc_MediaMetaChanged should be registered against the
vlcMedia instance, instead of vlcMediaPlayer instance.
Document that inside the code, as this is not obvious.
While the old way is still supported on vlc 3.x, I opted to
keep the code inside #ifs, as some day we'll drop support for
vlc 2.x, making the code simpler.
Also, since this event is registered aganst a vlcMedia object
and behaves different than when applied against a vlcMediaPlayer
object, I'm also using a different name there, in order to avoid
confusion.
BUG: 407153
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
---
src/backend-vlc/vlcmediawidget.cpp | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/src/backend-vlc/vlcmediawidget.cpp b/src/backend-vlc/vlcmediawidget.cpp
index 7917417..6f5e50f 100644
--- a/src/backend-vlc/vlcmediawidget.cpp
+++ b/src/backend-vlc/vlcmediawidget.cpp
@@ -559,7 +559,10 @@ void VlcMediaWidget::unregisterEvents()
libvlc_event_detach(eventManager, eventType.at(i),
vlcEventHandler, this);
#if LIBVLC_VERSION_MAJOR <= 2
- libvlc_event_detach(eventManager, libvlc_MediaMetaChanged,
+ if (!vlcMedia)
+ return;
+ libvlc_event_manager_t *mediaEvent = libvlc_media_event_manager(vlcMedia);
+ libvlc_event_detach(mediaEvent, libvlc_MediaMetaChanged,
vlcEventHandler, this);
#endif
}
@@ -583,9 +586,18 @@ int VlcMediaWidget::makePlay()
}
#if LIBVLC_VERSION_MAJOR <= 2
- // For libVlc 2.x to work, we need to add the
- // MediaMetaChanged event only here
- if (libvlc_event_attach(eventManager, libvlc_MediaMetaChanged,
+ /*
+ * There is a difference between libVlc 2.x and 3.x:
+ * With version 2.x, the event needs to be registered at the
+ * vlcMedia object, just before calling libvlc_media_player_set_media()
+ *
+ * On version 3.x, while this still works, you can simply register the
+ * event directly at vlcMediaPlayer, together with all other events,
+ * with simplifies the code.
+ */
+ libvlc_event_manager_t *mediaEvent = libvlc_media_event_manager(vlcMedia);
+
+ if (libvlc_event_attach(mediaEvent, libvlc_MediaMetaChanged,
vlcEventHandler, this) != 0) {
qCWarning(logMediaWidget, "Cannot attach event handler %d",
libvlc_MediaMetaChanged);
--
cgit v1.1