Accepting request 645276 from home:wolfi323:branches:KDE:Extra

- Add fix-audio-CD-playing.patch to make Audio CD playback work
- Add Set-vlcMedia-to-NULL-after-release.patch to prevent a crash
  when the Audio CD cannot be opened for some reason

OBS-URL: https://build.opensuse.org/request/show/645276
OBS-URL: https://build.opensuse.org/package/show/KDE:Extra/kaffeine?expand=0&rev=39
This commit is contained in:
Luca Beltrame 2018-10-29 13:52:21 +00:00 committed by Git OBS Bridge
parent 3345c408ed
commit 5294b7faf1
4 changed files with 266 additions and 0 deletions

View File

@ -0,0 +1,33 @@
From dbe1593af6bfb54460d249f960936f1378224eb8 Mon Sep 17 00:00:00 2001
From: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Date: Sun, 28 Oct 2018 06:34:13 -0300
Subject: vlcmediawidget: Set vlcMedia to NULL after release
As we're now calling the code at makePlay() on two different
places, we should ensure that it will only work if vlcMedia
was created.
Without that, if someone tries to play an audio CD and it
fails for whatever reason (like if the system doesn't have
a CD device), it crashes.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
---
src/backend-vlc/vlcmediawidget.cpp | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/backend-vlc/vlcmediawidget.cpp b/src/backend-vlc/vlcmediawidget.cpp
index 1f5d61d..e7bc801 100644
--- a/src/backend-vlc/vlcmediawidget.cpp
+++ b/src/backend-vlc/vlcmediawidget.cpp
@@ -353,6 +353,7 @@ void VlcMediaWidget::makePlay()
libvlc_media_player_set_media(vlcMediaPlayer, vlcMedia);
libvlc_media_release(vlcMedia);
+ vlcMedia = NULL;
if (libvlc_media_player_play(vlcMediaPlayer) != 0)
return;
--
cgit v0.11.2

222
fix-audio-CD-playing.patch Normal file
View File

@ -0,0 +1,222 @@
From ef66906e3d3fda0144e18ed874c32266c1347ab1 Mon Sep 17 00:00:00 2001
From: Andrey Bychkov <mrdrew@altlinux.org>
Date: Fri, 26 Oct 2018 09:32:53 +0300
Subject: vlcmediawidget: fix audio CD playing
While here, also fix:
- all tracks playing
- 'next' & 'previous' working
---
src/backend-vlc/vlcmediawidget.cpp | 77 +++++++++++++++++++++++++++++++-------
src/backend-vlc/vlcmediawidget.h | 7 ++++
src/mediawidget.cpp | 4 +-
3 files changed, 72 insertions(+), 16 deletions(-)
diff --git a/src/backend-vlc/vlcmediawidget.cpp b/src/backend-vlc/vlcmediawidget.cpp
index fe320ae..568e9bc 100644
--- a/src/backend-vlc/vlcmediawidget.cpp
+++ b/src/backend-vlc/vlcmediawidget.cpp
@@ -27,6 +27,7 @@
#include <QMap>
#include <vlc/vlc.h>
#include <vlc/libvlc_version.h>
+#include <unistd.h>
#include "../configuration.h"
#include "vlcmediawidget.h"
@@ -279,6 +280,9 @@ void VlcMediaWidget::play(const MediaSource &source)
QByteArray url = source.getUrl().toEncoded();
playingDvd = false;
+ trackNumber = 1;
+ numDevType = 0;
+
switch (source.getType()) {
case MediaSource::Url:
if (url.endsWith(".iso")) {
@@ -287,6 +291,8 @@ void VlcMediaWidget::play(const MediaSource &source)
break;
case MediaSource::AudioCd:
+ numDevType=2;
+
if (url.size() >= 7) {
url.replace(0, 4, "cdda");
} else {
@@ -315,11 +321,24 @@ void VlcMediaWidget::play(const MediaSource &source)
break;
}
- libvlc_media_t *vlcMedia = libvlc_media_new_location(vlcInstance, url.constData());
+ typeOfDevice = url.constData();
+
+ vlcMedia = libvlc_media_new_location(vlcInstance, typeOfDevice);
+ if (numDevType == 2)
+ libvlc_media_add_option(vlcMedia, "cdda-track=1");
+
+ makePlay();
+
+ setCursor(Qt::BlankCursor);
+ setCursor(Qt::ArrowCursor);
+ timer->start(1000);
+ setMouseTracking(true);
+}
+void VlcMediaWidget::makePlay()
+{
if (vlcMedia == NULL) {
libvlc_media_player_stop(vlcMediaPlayer);
- qCWarning(logMediaWidget, "Cannot create media %s", qPrintable(source.getUrl().toDisplayString()));
return;
}
@@ -335,24 +354,46 @@ void VlcMediaWidget::play(const MediaSource &source)
libvlc_media_player_set_media(vlcMediaPlayer, vlcMedia);
libvlc_media_release(vlcMedia);
-// FIXME! subtitleUrl is only available for MediaSourceUrl private class
-// if (source.subtitleUrl.isValid())
-// setExternalSubtitle(source.subtitleUrl);
+ if (libvlc_media_player_play(vlcMediaPlayer) != 0)
+ return;
+}
- if (libvlc_media_player_play(vlcMediaPlayer) != 0) {
- qCWarning(logMediaWidget, "Cannot play media %s", qPrintable(source.getUrl().toDisplayString()));
- }
+void VlcMediaWidget::playDirection(int direction)
+{
+ char numBuff[256];
+ char strBuff[512] = "cdda-track=";
- setCursor(Qt::BlankCursor);
- setCursor(Qt::ArrowCursor);
- timer->start(1000);
- setMouseTracking(true);
+ if (direction == -1)
+ trackNumber--;
+ else
+ trackNumber++;
+
+ sprintf(numBuff, "%d", trackNumber);
+ strcat(strBuff, numBuff);
+
+ if (vlcMedia != NULL)
+ libvlc_media_release(vlcMedia);
+
+ vlcMedia = libvlc_media_new_location(vlcInstance, typeOfDevice);
+ libvlc_media_add_option(vlcMedia, strBuff);
+
+ makePlay();
+
+ sleep(1);
+
+ int playerState = libvlc_media_player_get_state(vlcMediaPlayer);
+
+ if (playerState != libvlc_Playing)
+ stop();
}
void VlcMediaWidget::stop()
{
libvlc_media_player_stop(vlcMediaPlayer);
+ if (trackNumber != 1)
+ trackNumber = 1;
+
timer->stop();
setCursor(Qt::BlankCursor);
setCursor(Qt::ArrowCursor);
@@ -452,7 +493,10 @@ bool VlcMediaWidget::jumpToPreviousChapter()
{
int currentTitle = libvlc_media_player_get_title(vlcMediaPlayer);
int currentChapter = libvlc_media_player_get_chapter(vlcMediaPlayer);
- libvlc_media_player_previous_chapter(vlcMediaPlayer);
+ if (numDevType == 2)
+ playDirection(-1);
+ else
+ libvlc_media_player_previous_chapter(vlcMediaPlayer);
if ((libvlc_media_player_get_title(vlcMediaPlayer) != currentTitle) ||
(libvlc_media_player_get_chapter(vlcMediaPlayer) != currentChapter)) {
@@ -466,7 +510,10 @@ bool VlcMediaWidget::jumpToNextChapter()
{
int currentTitle = libvlc_media_player_get_title(vlcMediaPlayer);
int currentChapter = libvlc_media_player_get_chapter(vlcMediaPlayer);
- libvlc_media_player_next_chapter(vlcMediaPlayer);
+ if (numDevType == 2)
+ playDirection(1);
+ else
+ libvlc_media_player_next_chapter(vlcMediaPlayer);
if ((libvlc_media_player_get_title(vlcMediaPlayer) != currentTitle) ||
(libvlc_media_player_get_chapter(vlcMediaPlayer) != currentChapter)) {
@@ -507,6 +554,8 @@ int VlcMediaWidget::updatePlaybackStatus()
playbackStatus = MediaWidget::Paused;
break;
case libvlc_Ended:
+ playDirection(1);
+ break;
case libvlc_Error:
playbackStatus = MediaWidget::Idle;
// don't keep last picture shown
diff --git a/src/backend-vlc/vlcmediawidget.h b/src/backend-vlc/vlcmediawidget.h
index 785370d..1534ed0 100644
--- a/src/backend-vlc/vlcmediawidget.h
+++ b/src/backend-vlc/vlcmediawidget.h
@@ -25,6 +25,7 @@
class libvlc_event_t;
class libvlc_instance_t;
+class libvlc_media_t;
class libvlc_media_player_t;
class QTimer;
@@ -68,6 +69,8 @@ public:
bool jumpToNextChapter();
void showDvdMenu();
void dvdNavigate(int key);
+ void playDirection(int direction);
+ void makePlay();
int updatePlaybackStatus();
void updateCurrentTotalTime();
@@ -90,10 +93,14 @@ private:
static void vlcEventHandler(const libvlc_event_t *event, void *instance);
libvlc_instance_t *vlcInstance;
+ libvlc_media_t *vlcMedia;
libvlc_media_player_t *vlcMediaPlayer;
bool playingDvd;
bool mouseVisible;
QMap<int, int> subtitleId;
+ QByteArray typeOfDevice;
+ int numDevType;
+ int trackNumber = 1;
};
#endif /* VLCMEDIAWIDGET_H */
diff --git a/src/mediawidget.cpp b/src/mediawidget.cpp
index fd84d87..f38d301 100644
--- a/src/mediawidget.cpp
+++ b/src/mediawidget.cpp
@@ -793,14 +793,14 @@ void MediaWidget::previous()
{
if (source->getType() == MediaSource::Url)
emit playlistPrevious();
- source->previous();
+ backend->jumpToPreviousChapter();
}
void MediaWidget::next()
{
if (source->getType() == MediaSource::Url)
emit playlistNext();
- source->next();
+ backend->jumpToNextChapter();
}
void MediaWidget::stop()
--
cgit v0.11.2

View File

@ -1,3 +1,10 @@
-------------------------------------------------------------------
Mon Oct 29 08:43:00 UTC 2018 - wbauer@tmo.at
- Add fix-audio-CD-playing.patch to make Audio CD playback work
- Add Set-vlcMedia-to-NULL-after-release.patch to prevent a crash
when the Audio CD cannot be opened for some reason
-------------------------------------------------------------------
Sun Jun 3 19:46:42 UTC 2018 - christophe@krop.fr

View File

@ -30,6 +30,10 @@ Patch0: kaffeine-fixsplitter.patch
Patch1: 0001-only-use-qPrintable-for-debug-messages.patch
# PATCH-FIX-UPSTREAM -- 0002-Fix-breakages-with-qt5.11-rc2.patch
Patch2: 0002-Fix-breakages-with-qt5.11-rc2.patch
# PATCH-FIX-UPSTREAM
Patch3: fix-audio-CD-playing.patch
# PATCH-FIX-UPSTREAM
Patch4: Set-vlcMedia-to-NULL-after-release.patch
BuildRequires: extra-cmake-modules
BuildRequires: pkgconfig
BuildRequires: cmake(KF5CoreAddons)