From 442f91c622075c026c1c2295d72d7f4b7e06b665 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Thu, 1 Oct 2015 19:12:37 -0400 Subject: BACKENDS: Add support for opening a CD on Linux by path or drive --- backends/audiocd/linux/linux-audiocd.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'backends/audiocd/linux') diff --git a/backends/audiocd/linux/linux-audiocd.cpp b/backends/audiocd/linux/linux-audiocd.cpp index 917546cfa5..fe3ae1e58b 100644 --- a/backends/audiocd/linux/linux-audiocd.cpp +++ b/backends/audiocd/linux/linux-audiocd.cpp @@ -256,6 +256,9 @@ public: void closeCD(); void playCD(int track, int numLoops, int startFrame, int duration); +protected: + bool openCD(const Common::String &drive); + private: struct Device { Device(const Common::String &n, dev_t d) : name(n), device(d) {} @@ -320,6 +323,23 @@ bool LinuxAudioCDManager::openCD(int drive) { return true; } +bool LinuxAudioCDManager::openCD(const Common::String &drive) { + DeviceList devices; + if (!tryAddDrive(devices, drive) && !tryAddPath(devices, drive)) + return false; + + _fd = open(devices[0].name.c_str(), O_RDONLY | O_NONBLOCK, 0); + if (_fd < 0) + return false; + + if (!loadTOC()) { + closeCD(); + return false; + } + + return true; +} + void LinuxAudioCDManager::closeCD() { if (_fd < 0) return; -- cgit v1.2.3