BACKENDS: Add support for opening a CD on Linux by path or drive

This commit is contained in:
Matthew Hoops 2015-10-01 19:12:37 -04:00 committed by Johannes Schickel
parent 1626fbd633
commit 442f91c622

View File

@ -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;