aboutsummaryrefslogtreecommitdiff
path: root/backends/audiocd/linux
diff options
context:
space:
mode:
authorMatthew Hoops2015-10-01 19:12:37 -0400
committerJohannes Schickel2016-03-13 13:57:05 +0100
commit442f91c622075c026c1c2295d72d7f4b7e06b665 (patch)
tree36a1df2eb228e7b6721e29aca782fd885afdd11c /backends/audiocd/linux
parent1626fbd633ff5e39ee5551b6e839def62ef9b599 (diff)
downloadscummvm-rg350-442f91c622075c026c1c2295d72d7f4b7e06b665.tar.gz
scummvm-rg350-442f91c622075c026c1c2295d72d7f4b7e06b665.tar.bz2
scummvm-rg350-442f91c622075c026c1c2295d72d7f4b7e06b665.zip
BACKENDS: Add support for opening a CD on Linux by path or drive
Diffstat (limited to 'backends/audiocd/linux')
-rw-r--r--backends/audiocd/linux/linux-audiocd.cpp20
1 files changed, 20 insertions, 0 deletions
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;