summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2020-06-10 11:15:48 +0200
committerwm4 <wm4@nowhere>2020-06-10 11:25:10 +0200
commitf3864638404284b7d3a54d22412ab9e81d0a6787 (patch)
tree96c64b6328d17f3b339bd40c61c17cec66c7cbb4
parentd5de79d10f895aaa8f65340adf949d28bc09b2d7 (diff)
downloadmpv-f3864638404284b7d3a54d22412ab9e81d0a6787.tar.bz2
mpv-f3864638404284b7d3a54d22412ab9e81d0a6787.tar.xz
build: change/simplify optical disc device detection
So this had a long list of OS specific device files for CD and DVD physical devices. If we ever migrate to a new build system, this will be a PITA for rather questionable usefulness. For example, Linux does provide /dev/sr0, but it also creates /dev/cdrom and /dev/dvd symlinks. For Windows, it's sort of ridiculous to hardcode D: (well, might still work). Get rid of this stuff, hardcode a single device name on Unix, keep D: on Windows. In general, this probably requires runtime detection in theory, so it's not much of a sin to move these from the build system to the code, even if we don't make use of determining the device at runtime yet. This should not invite to add new ifdeffery to add device files for other Unix variants. Rather, if anyone wants to extend this, I'd argue they should add proper runtime detection of the device. Or, even better, create an appropriate symlink on their systems.
-rw-r--r--stream/stream_cdda.c8
-rw-r--r--stream/stream_dvdnav.c7
-rw-r--r--waftools/detections/devices.py31
3 files changed, 12 insertions, 34 deletions
diff --git a/stream/stream_cdda.c b/stream/stream_cdda.c
index b00bb22539..4c959736d7 100644
--- a/stream/stream_cdda.c
+++ b/stream/stream_cdda.c
@@ -292,12 +292,16 @@ static int open_cdda(stream_t *st)
&global_device);
talloc_steal(st, global_device);
+#if defined(_WIN32)
+ p->device = "D:";
+#else
+ p->device = "/dev/cdrom";
+#endif
+
if (st->path[0]) {
p->device = st->path;
} else if (global_device && global_device[0]) {
p->device = global_device;
- } else {
- p->device = DEFAULT_CDROM_DEVICE;
}
#if defined(__NetBSD__)
diff --git a/stream/stream_dvdnav.c b/stream/stream_dvdnav.c
index d858c51aca..56aaaa90af 100644
--- a/stream/stream_dvdnav.c
+++ b/stream/stream_dvdnav.c
@@ -562,10 +562,15 @@ static int open_s_internal(stream_t *stream)
{
struct priv *priv, *p;
priv = p = stream->priv;
- char *filename;
p->opts = mp_get_config_group(stream, stream->global, &dvd_conf);
+ char *filename = "/dev/dvd";
+
+#if defined(_WIN32)
+ filename = "D:";
+#endif
+
if (p->device && p->device[0])
filename = p->device;
else if (p->opts->device && p->opts->device[0])
diff --git a/waftools/detections/devices.py b/waftools/detections/devices.py
deleted file mode 100644
index 42c4c28171..0000000000
--- a/waftools/detections/devices.py
+++ /dev/null
@@ -1,31 +0,0 @@
-__cdrom_devices_map__ = {
- 'win32': 'D:',
- 'cygwin': 'D:',
- 'darwin': '/dev/disk1',
- 'freebsd': '/dev/cd0',
- 'openbsd': '/dev/rcd0c',
- 'linux': '/dev/sr0',
- 'default': '/dev/cdrom'
-}
-
-__dvd_devices_map__ = {
- 'win32': 'D:',
- 'cygwin': 'D:',
- 'darwin': '/dev/rdiskN',
- 'freebsd': '/dev/cd0',
- 'openbsd': '/dev/rcd0c',
- 'linux': '/dev/sr0',
- 'default': '/dev/dvd'
-}
-
-def __default_cdrom_device__(ctx):
- default = __cdrom_devices_map__['default']
- return __cdrom_devices_map__.get(ctx.env.DEST_OS, default)
-
-def __default_dvd_device__(ctx):
- default = __dvd_devices_map__['default']
- return __dvd_devices_map__.get(ctx.env.DEST_OS, default)
-
-def configure(ctx):
- ctx.define('DEFAULT_DVD_DEVICE', __default_dvd_device__(ctx))
- ctx.define('DEFAULT_CDROM_DEVICE', __default_cdrom_device__(ctx))