MythTV master
mythcdrom-darwin.cpp
Go to the documentation of this file.
1#include <cerrno>
2#include <sys/fcntl.h>
3#include <unistd.h> // for close definition
4
5#include <IOKit/storage/IOCDMediaBSDClient.h>
6#include <IOKit/storage/IODVDMediaBSDClient.h>
7
8#include "mythcdrom.h"
9#include "mythcdrom-darwin.h"
10#include "mythlogging.h"
11
12#define LOC QString("MythCDROMDarwin:")
13
15{
16public:
17 MythCDROMDarwin(QObject* par, const QString& DevicePath,
18 bool SuperMount, bool AllowEject):
19 MythCDROM(par, DevicePath, SuperMount, AllowEject) {};
20
21 void setDeviceSpeed(const char *device, int speed) override; // MythMediaDevice
22};
23
24MythCDROM *GetMythCDROMDarwin(QObject* par, const QString& devicePath,
25 bool SuperMount, bool AllowEject)
26{
27 return new MythCDROMDarwin(par, devicePath, SuperMount, AllowEject);
28}
29
30void MythCDROMDarwin::setDeviceSpeed(const char *device, int speed)
31{
32 int fd;
33 QString raw = device;
34 uint16_t spd = speed;
35
36
37 fd = open(raw.toLocal8Bit().constData(), O_RDONLY | O_NONBLOCK);
38 if (fd == -1)
39 {
40 LOG(VB_MEDIA, LOG_ERR, LOC +
41 "setDeviceSpeed() can't open drive " + raw);
42 return;
43 }
44
45 if (ioctl(fd, DKIOCCDSETSPEED, &spd) == -1 &&
46 ioctl(fd, DKIOCDVDSETSPEED, &spd) == -1)
47 {
48 LOG(VB_MEDIA, LOG_ERR, LOC + "setDeviceSpeed() failed: " + ENO);
49 close(fd);
50 return;
51 }
52
53 LOG(VB_MEDIA, LOG_INFO, LOC + "setDeviceSpeed() - CD/DVD speed now " +
54 QString::number(spd));
55
56 close(fd);
57}
void setDeviceSpeed(const char *device, int speed) override
MythCDROMDarwin(QObject *par, const QString &DevicePath, bool SuperMount, bool AllowEject)
#define O_NONBLOCK
Definition: compat.h:292
#define close
Definition: compat.h:39
unsigned short uint16_t
Definition: iso6937tables.h:3
#define LOC
MythCDROM * GetMythCDROMDarwin(QObject *par, const QString &devicePath, bool SuperMount, bool AllowEject)
#define ENO
This can be appended to the LOG args with "+".
Definition: mythlogging.h:74
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39