diff options
author | jstebbins <[email protected]> | 2009-07-09 16:36:17 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2009-07-09 16:36:17 +0000 |
commit | 766df9ffa24851ca6523311484c426c126eb6ee2 (patch) | |
tree | 87a7732e7c37e45cd9cdb5afe18561fe45f51726 /libhb/ports.c | |
parent | 68dc5bceabe811f180c525c2d1b2f19edf1bd6cd (diff) |
libhb: DVD drive region detection on linux
Read and log the region mask of the DVD drive.
We get the occasional linux user that has an unset region. Logging
the region will help isolate the problem more quickly.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2675 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/ports.c')
-rw-r--r-- | libhb/ports.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/libhb/ports.c b/libhb/ports.c index 6c6960633..7b18ce896 100644 --- a/libhb/ports.c +++ b/libhb/ports.c @@ -54,6 +54,16 @@ #include <netinet/in.h> #endif +#if defined( SYS_LINUX ) +#include <linux/cdrom.h> +#include <fcntl.h> +#include <sys/ioctl.h> +#elif defined( SYS_OPENBSD ) +#include <sys/dvdio.h> +#include <fcntl.h> +#include <sys/ioctl.h> +#endif + #include <stddef.h> #include "hb.h" @@ -82,6 +92,33 @@ int gettimeofday( struct timeval * tv, struct timezone * tz ) #endif */ +int hb_dvd_region(char *device, int *region_mask) +{ +#if defined( DVD_LU_SEND_RPC_STATE ) && defined( DVD_AUTH ) + struct stat st; + dvd_authinfo ai; + int fd, ret; + + fd = open( device, O_RDONLY ); + if ( fd < 0 ) + return -1; + if ( fstat( fd, &st ) < 0 ) + return -1; + if ( !( S_ISBLK( st.st_mode ) || S_ISCHR( st.st_mode ) ) ) + return -1; + + ai.type = DVD_LU_SEND_RPC_STATE; + ret = ioctl(fd, DVD_AUTH, &ai); + if ( ret < 0 ) + return ret; + + *region_mask = ai.lrpcs.region_mask; + return 0; +#else + return -1; +#endif +} + uint64_t hb_get_date() { struct timeval tv; |