From 1a7278f1d37612e6834ba17cb70fd88b127a8c90 Mon Sep 17 00:00:00 2001 From: lazypingu <126294998+lazypingu@users.noreply.github.com> Date: Mon, 26 Feb 2024 10:29:44 +0100 Subject: [PATCH 1/4] Move cddap_speed_set below cddap_open to make sure that the drive was initialized and opened before attemting to set the speed --- src/input/plugins/CdioParanoiaInputPlugin.cxx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/input/plugins/CdioParanoiaInputPlugin.cxx b/src/input/plugins/CdioParanoiaInputPlugin.cxx index 3680743c9..335b51810 100644 --- a/src/input/plugins/CdioParanoiaInputPlugin.cxx +++ b/src/input/plugins/CdioParanoiaInputPlugin.cxx @@ -214,11 +214,6 @@ input_cdio_open(const char *uri, } cdio_cddap_verbose_set(drv, CDDA_MESSAGE_FORGETIT, CDDA_MESSAGE_FORGETIT); - if (speed > 0) { - FmtDebug(cdio_domain, "Attempting to set CD speed to {}x", - speed); - cdio_cddap_speed_set(drv,speed); - } if (0 != cdio_cddap_open(drv)) { cdio_cddap_close_no_free_cdio(drv); @@ -226,6 +221,12 @@ input_cdio_open(const char *uri, throw std::runtime_error("Unable to open disc."); } + if (speed > 0) { + FmtDebug(cdio_domain, "Attempting to set CD speed to {}x", + speed); + cdio_cddap_speed_set(drv,speed); + } + bool reverse_endian; const int be = data_bigendianp(drv); switch (be) { From 88c77f9c8ab6d5aec78acc010d2769898fe28cd4 Mon Sep 17 00:00:00 2001 From: lazypingu <126294998+lazypingu@users.noreply.github.com> Date: Mon, 26 Feb 2024 10:30:43 +0100 Subject: [PATCH 2/4] Add debug logging if setting speed failed --- src/input/plugins/CdioParanoiaInputPlugin.cxx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/input/plugins/CdioParanoiaInputPlugin.cxx b/src/input/plugins/CdioParanoiaInputPlugin.cxx index 335b51810..a5b193454 100644 --- a/src/input/plugins/CdioParanoiaInputPlugin.cxx +++ b/src/input/plugins/CdioParanoiaInputPlugin.cxx @@ -224,7 +224,10 @@ input_cdio_open(const char *uri, if (speed > 0) { FmtDebug(cdio_domain, "Attempting to set CD speed to {}x", speed); - cdio_cddap_speed_set(drv,speed); + /* Negative value indicate error (e.g. -405: not supported) */ + if (cdio_cddap_speed_set(drv,speed) < 0) + FmtDebug(cdio_domain, "Failed to set CD speed to {}x", + speed); } bool reverse_endian; From 9d853897cd9081445a0edec92ceaf508c5782886 Mon Sep 17 00:00:00 2001 From: lazypingu <126294998+lazypingu@users.noreply.github.com> Date: Mon, 26 Feb 2024 10:34:37 +0100 Subject: [PATCH 3/4] Use track and disc functions from libcdio-paranoia to enable playback of hidden tracks and audio tracks on multisession CDs --- src/input/plugins/CdioParanoiaInputPlugin.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/input/plugins/CdioParanoiaInputPlugin.cxx b/src/input/plugins/CdioParanoiaInputPlugin.cxx index a5b193454..56de50808 100644 --- a/src/input/plugins/CdioParanoiaInputPlugin.cxx +++ b/src/input/plugins/CdioParanoiaInputPlugin.cxx @@ -257,11 +257,11 @@ input_cdio_open(const char *uri, lsn_t lsn_from, lsn_to; if (parsed_uri.track >= 0) { - lsn_from = cdio_get_track_lsn(cdio, parsed_uri.track); - lsn_to = cdio_get_track_last_lsn(cdio, parsed_uri.track); + lsn_from = cdio_cddap_track_firstsector(drv, parsed_uri.track); + lsn_to = cdio_cddap_track_lastsector(drv, parsed_uri.track); } else { - lsn_from = 0; - lsn_to = cdio_get_disc_last_lsn(cdio); + lsn_from = cdio_cddap_disc_firstsector(drv); + lsn_to = cdio_cddap_disc_lastsector(drv); } return std::make_unique(uri, mutex, From c00d217a53fc2e9cc15385e2901259fa95f6600e Mon Sep 17 00:00:00 2001 From: lazypingu <126294998+lazypingu@users.noreply.github.com> Date: Mon, 26 Feb 2024 10:35:50 +0100 Subject: [PATCH 4/4] Skip track if returned LSNs are negative which indicates track errors or if track is not an audio track --- src/input/plugins/CdioParanoiaInputPlugin.cxx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/input/plugins/CdioParanoiaInputPlugin.cxx b/src/input/plugins/CdioParanoiaInputPlugin.cxx index 56de50808..b28505502 100644 --- a/src/input/plugins/CdioParanoiaInputPlugin.cxx +++ b/src/input/plugins/CdioParanoiaInputPlugin.cxx @@ -264,6 +264,16 @@ input_cdio_open(const char *uri, lsn_to = cdio_cddap_disc_lastsector(drv); } + /* LSNs < 0 indicate errors (e.g. -401: Invaid track, -402: no pregap) */ + if(lsn_from < 0 || lsn_to < 0) + throw FmtRuntimeError("Error {} on track {}", + lsn_from < 0 ? lsn_from : lsn_to, parsed_uri.track); + + /* Only check for audio track if not pregap or whole CD */ + if (!cdio_cddap_track_audiop(drv, parsed_uri.track) && parsed_uri.track > 0) + throw FmtRuntimeError("No audio track: {}", + parsed_uri.track); + return std::make_unique(uri, mutex, drv, cdio, reverse_endian,