From 2f07b8f4822644cb08d17de4011b4cb9cebe2b12 Mon Sep 17 00:00:00 2001
From: Andrew Basterfield <abasterfield@gmail.com>
Date: Sat, 6 Oct 2018 20:18:19 +0100
Subject: [PATCH 1/3] Set cdrive speed hint for cdparanoia

---
 src/input/plugins/CdioParanoiaInputPlugin.cxx | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/input/plugins/CdioParanoiaInputPlugin.cxx b/src/input/plugins/CdioParanoiaInputPlugin.cxx
index 4b08cf990..221384df1 100644
--- a/src/input/plugins/CdioParanoiaInputPlugin.cxx
+++ b/src/input/plugins/CdioParanoiaInputPlugin.cxx
@@ -104,6 +104,7 @@ class CdioParanoiaInputStream final : public InputStream {
 static constexpr Domain cdio_domain("cdio");
 
 static bool default_reverse_endian;
+static unsigned speed = 0;
 
 static void
 input_cdio_init(EventLoop &, const ConfigBlock &block)
@@ -118,6 +119,7 @@ input_cdio_init(EventLoop &, const ConfigBlock &block)
 			throw FormatRuntimeError("Unrecognized 'default_byte_order' setting: %s",
 						 value);
 	}
+	speed = block.GetBlockValue("speed",0u);
 }
 
 struct cdio_uri {
@@ -209,6 +211,12 @@ input_cdio_open(const char *uri,
 	}
 
 	cdda_verbose_set(drv, CDDA_MESSAGE_FORGETIT, CDDA_MESSAGE_FORGETIT);
+	if (speed > 0) {
+		FormatDebug(cdio_domain,"Attempting to set CD speed to %dx",speed);
+		cdda_speed_set(drv,speed);
+	} else {
+		FormatDebug(cdio_domain,"Leaving CD speed alone");
+	}
 
 	if (0 != cdio_cddap_open(drv)) {
 		cdio_cddap_close_no_free_cdio(drv);

From 5f8dac68226735fef868dcaf843e32ebfc5e3af5 Mon Sep 17 00:00:00 2001
From: Andrew Basterfield <abasterfield@gmail.com>
Date: Sun, 7 Oct 2018 19:17:51 +0100
Subject: [PATCH 2/3] Add some docs for CDParanoia extraction speed

---
 doc/user.rst | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/doc/user.rst b/doc/user.rst
index 872afe020..f6536da33 100644
--- a/doc/user.rst
+++ b/doc/user.rst
@@ -1056,6 +1056,8 @@ Plays audio CDs using libcdio. The URI has the form: "cdda://[DEVICE][/TRACK]".
      - Description
    * - **default_byte_order little_endian|big_endian**
      - If the CD drive does not specify a byte order, MPD assumes it is the CPU's native byte order. This setting allows overriding this.
+   * - **speed N**
+     - Request CDParanoia cap the extraction speed to Nx normal CD audio rotation speed, keeping the drive quiet.
 
 curl
 ~~~~

From 9c1bf9ac5fd76c81b52748408395c006f3dd8a48 Mon Sep 17 00:00:00 2001
From: Andrew Basterfield <abasterfield@gmail.com>
Date: Sun, 7 Oct 2018 19:21:38 +0100
Subject: [PATCH 3/3] Remove some extraneous leftover debugging

---
 src/input/plugins/CdioParanoiaInputPlugin.cxx | 2 --
 1 file changed, 2 deletions(-)

diff --git a/src/input/plugins/CdioParanoiaInputPlugin.cxx b/src/input/plugins/CdioParanoiaInputPlugin.cxx
index 221384df1..eeba659b8 100644
--- a/src/input/plugins/CdioParanoiaInputPlugin.cxx
+++ b/src/input/plugins/CdioParanoiaInputPlugin.cxx
@@ -214,8 +214,6 @@ input_cdio_open(const char *uri,
 	if (speed > 0) {
 		FormatDebug(cdio_domain,"Attempting to set CD speed to %dx",speed);
 		cdda_speed_set(drv,speed);
-	} else {
-		FormatDebug(cdio_domain,"Leaving CD speed alone");
 	}
 
 	if (0 != cdio_cddap_open(drv)) {