X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Faccess%2Fmmap.c;h=2c7dfbfc3544cb931e1eb32af33893f85cfb2c25;hb=9b9551a087bea36a5f03542a588c66f31c2f6ecc;hp=8a36040aad316eb673e62d5e9efda5c65f322080;hpb=80b7a3f139cd4c213c74b9ee1c238b594663ffb4;p=vlc diff --git a/modules/access/mmap.c b/modules/access/mmap.c index 8a36040aad..2c7dfbfc35 100644 --- a/modules/access/mmap.c +++ b/modules/access/mmap.c @@ -27,12 +27,11 @@ #include #include #include -#include +#include #include #include -#include #include #include #include @@ -58,12 +57,17 @@ vlc_module_begin () set_capability ("access", 52) add_shortcut ("file") set_callbacks (Open, Close) +#ifdef __APPLE__ + add_bool ("file-mmap", true, NULL, + FILE_MMAP_TEXT, FILE_MMAP_LONGTEXT, true) +#else add_bool ("file-mmap", false, NULL, FILE_MMAP_TEXT, FILE_MMAP_LONGTEXT, true) +#endif vlc_module_end () static block_t *Block (access_t *); -static int Seek (access_t *, int64_t); +static int Seek (access_t *, uint64_t); static int Control (access_t *, int, va_list); struct access_sys_t @@ -79,23 +83,18 @@ static int Open (vlc_object_t *p_this) { access_t *p_access = (access_t *)p_this; access_sys_t *p_sys; - const char *path = p_access->psz_path; + const char *path = p_access->psz_filepath; int fd; assert ((INT64_C(1) << 63) == ((off_t)(INT64_C(1) << 63))); - if (!var_CreateGetBool (p_this, "file-mmap")) + if (!var_InheritBool (p_this, "file-mmap")) return VLC_EGENERIC; /* disabled */ STANDARD_BLOCK_ACCESS_INIT; - if (!strcmp (p_access->psz_path, "-")) - fd = dup (0); - else - { - msg_Dbg (p_access, "opening file %s", path); - fd = utf8_open (path, O_RDONLY | O_NOCTTY, 0666); - } + msg_Dbg (p_access, "opening file %s", path); + fd = vlc_open (path, O_RDONLY | O_NOCTTY); if (fd == -1) { @@ -185,7 +184,7 @@ static block_t *Block (access_t *p_access) p_access->info.i_update |= INPUT_UPDATE_SIZE; } - if ((uint64_t)p_access->info.i_pos >= (uint64_t)p_access->info.i_size) + if (p_access->info.i_pos >= p_access->info.i_size) { /* We are at end of file */ p_access->info.b_eof = true; @@ -194,7 +193,7 @@ static block_t *Block (access_t *p_access) } #ifdef MMAP_DEBUG - int64_t dbgpos = lseek (p_sys->fd, 0, SEEK_CUR); + uint64_t dbgpos = lseek (p_sys->fd, 0, SEEK_CUR); if (dbgpos != p_access->info.i_pos) msg_Err (p_access, "position: 0x%016"PRIx64" instead of 0x%016"PRIx64, p_access->info.i_pos, dbgpos); @@ -266,7 +265,7 @@ fatal: } -static int Seek (access_t *p_access, int64_t i_pos) +static int Seek (access_t *p_access, uint64_t i_pos) { #ifdef MMAP_DEBUG lseek (p_access->p_sys->fd, i_pos, SEEK_SET); @@ -286,13 +285,13 @@ static int Control (access_t *p_access, int query, va_list args) case ACCESS_CAN_FASTSEEK: case ACCESS_CAN_PAUSE: case ACCESS_CAN_CONTROL_PACE: - *((bool *)va_arg (args, bool *)) = true; + *va_arg(args, bool *) = true; return VLC_SUCCESS; case ACCESS_GET_PTS_DELAY: { - int delay_ms = var_CreateGetInteger (p_access, "file-caching"); - *((int64_t *)va_arg (args, int64_t *)) = delay_ms * INT64_C (1000); + int64_t delay_ms = var_CreateGetInteger (p_access, "file-caching"); + *va_arg(args, int64_t *) = delay_ms * INT64_C (1000); return VLC_SUCCESS; }