mirror of https://github.com/mpv-player/mpv
stream_file: activate cache with files on network file systems
Detected 'protocols' are AFP, nfs, smb and webdav. This can be extended on request. This is currently only implemented for BSD systems (using fstatfs). This addresses issue #558 on the above platforms.
This commit is contained in:
parent
5fcf4b46f7
commit
689646962e
|
@ -34,6 +34,11 @@
|
|||
#include "options/m_option.h"
|
||||
#include "options/path.h"
|
||||
|
||||
#if HAVE_BSD_FSTATFS
|
||||
#include <sys/param.h>
|
||||
#include <sys/mount.h>
|
||||
#endif
|
||||
|
||||
struct priv {
|
||||
int fd;
|
||||
bool close;
|
||||
|
@ -108,6 +113,26 @@ char *mp_file_url_to_filename(void *talloc_ctx, bstr url)
|
|||
return filename;
|
||||
}
|
||||
|
||||
#if HAVE_BSD_FSTATFS
|
||||
static bool check_stream_network(stream_t *stream)
|
||||
{
|
||||
struct statfs fs;
|
||||
const char *stypes[] = { "afpfs", "nfs", "smbfs", "webdav", NULL };
|
||||
struct priv *priv = stream->priv;
|
||||
if (fstatfs(priv->fd, &fs) == 0)
|
||||
for (int i=0; stypes[i]; i++)
|
||||
if (strcmp(stypes[i], fs.f_fstypename) == 0)
|
||||
return true;
|
||||
return false;
|
||||
|
||||
}
|
||||
#else
|
||||
static bool check_stream_network(stream_t *stream)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int open_f(stream_t *stream, int mode)
|
||||
{
|
||||
int fd;
|
||||
|
@ -195,6 +220,9 @@ static int open_f(stream_t *stream, int mode)
|
|||
stream->read_chunk = 64 * 1024;
|
||||
stream->close = s_close;
|
||||
|
||||
if (check_stream_network(stream))
|
||||
stream->streaming = true;
|
||||
|
||||
return STREAM_OK;
|
||||
}
|
||||
|
||||
|
|
5
wscript
5
wscript
|
@ -196,6 +196,11 @@ iconv support use --disable-iconv.",
|
|||
'name': 'setmode',
|
||||
'desc': 'setmode()',
|
||||
'func': check_statement('io.h', 'setmode(0, 0)')
|
||||
}, {
|
||||
'name': 'bsd-fstatfs',
|
||||
'desc': "BSD's fstatfs()",
|
||||
'func': check_statement(['sys/param.h', 'sys/mount.h'],
|
||||
'struct statfs fs; fstatfs(0, &fs)')
|
||||
}, {
|
||||
'name': 'sys-sysinfo-h',
|
||||
'desc': 'sys/sysinfo.h',
|
||||
|
|
Loading…
Reference in New Issue