From 5294b7faf1b5fe107e894875a5a4040e69ea4a57f686bdec19716434b8b90756 Mon Sep 17 00:00:00 2001 From: Luca Beltrame Date: Mon, 29 Oct 2018 13:52:21 +0000 Subject: [PATCH] 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 --- Set-vlcMedia-to-NULL-after-release.patch | 33 ++++ fix-audio-CD-playing.patch | 222 +++++++++++++++++++++++ kaffeine.changes | 7 + kaffeine.spec | 4 + 4 files changed, 266 insertions(+) create mode 100644 Set-vlcMedia-to-NULL-after-release.patch create mode 100644 fix-audio-CD-playing.patch diff --git a/Set-vlcMedia-to-NULL-after-release.patch b/Set-vlcMedia-to-NULL-after-release.patch new file mode 100644 index 0000000..896a979 --- /dev/null +++ b/Set-vlcMedia-to-NULL-after-release.patch @@ -0,0 +1,33 @@ +From dbe1593af6bfb54460d249f960936f1378224eb8 Mon Sep 17 00:00:00 2001 +From: Mauro Carvalho Chehab +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 +--- + 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 + diff --git a/fix-audio-CD-playing.patch b/fix-audio-CD-playing.patch new file mode 100644 index 0000000..26a685d --- /dev/null +++ b/fix-audio-CD-playing.patch @@ -0,0 +1,222 @@ +From ef66906e3d3fda0144e18ed874c32266c1347ab1 Mon Sep 17 00:00:00 2001 +From: Andrey Bychkov +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 + #include + #include ++#include + + #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 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 + diff --git a/kaffeine.changes b/kaffeine.changes index 128c292..6635d2d 100644 --- a/kaffeine.changes +++ b/kaffeine.changes @@ -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 diff --git a/kaffeine.spec b/kaffeine.spec index 9cc7e1f..fc32feb 100644 --- a/kaffeine.spec +++ b/kaffeine.spec @@ -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)