summaryrefslogtreecommitdiffstats
path: root/stream/stream_file.c
diff options
context:
space:
mode:
authorDiogo Franco (Kovensky) <diogomfranco@gmail.com>2015-04-25 18:28:17 +0900
committerDiogo Franco (Kovensky) <diogomfranco@gmail.com>2015-04-25 18:28:17 +0900
commit5f1d6b6e5ae515abfb77c78c44d21ee21beb0fc3 (patch)
tree6b757d37d296709dfd5955ef9d4d41426cd47da6 /stream/stream_file.c
parentd64ff3aa51b49451348383a6ff6de7697a52dc62 (diff)
parent983d24e3b9ce9c9c7755279138c14170e85fbf37 (diff)
downloadmpv-5f1d6b6e5ae515abfb77c78c44d21ee21beb0fc3.tar.bz2
mpv-5f1d6b6e5ae515abfb77c78c44d21ee21beb0fc3.tar.xz
Merge branch 'master' into release/0.9
* master: (87 commits) manpage: move --autosync description player: add --window-scale option player: flush decoder even if cover art is decoded player: don't show A/V desync message in non-sense situations w32_common: add more rounded-down frame rates w32_common: use the current monitor's refresh rate dxva2: fix broken build with gcc 5.1 terminal: printf() is not signal-safe man: fix PDF build DOCS/mplayer-changes: Eleborate on joystick input osc: add nil check for element.eventresponder mp_image: remove some unused interlacing flags vf_vapoursynth: update _FieldBased semantics options: remove unneeded hack from command line parser manpage: document ff-index sub-property demux_mkv: limit timestamp fixing to 1ms max demux_mkv: attempt to fix rounded timestamps demux_mkv: move global options to the demuxer demux_mkv: better seeking after video end lua: add utils.format_json() function ...
Diffstat (limited to 'stream/stream_file.c')
-rw-r--r--stream/stream_file.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/stream/stream_file.c b/stream/stream_file.c
index 01e983fa31..d0da8629bc 100644
--- a/stream/stream_file.c
+++ b/stream/stream_file.c
@@ -155,12 +155,11 @@ char *mp_file_get_path(void *talloc_ctx, bstr url)
}
#if HAVE_BSD_FSTATFS
-static bool check_stream_network(stream_t *stream)
+static bool check_stream_network(int fd)
{
struct statfs fs;
const char *stypes[] = { "afpfs", "nfs", "smbfs", "webdav", NULL };
- struct priv *priv = stream->priv;
- if (fstatfs(priv->fd, &fs) == 0)
+ if (fstatfs(fd, &fs) == 0)
for (int i=0; stypes[i]; i++)
if (strcmp(stypes[i], fs.f_fstypename) == 0)
return true;
@@ -168,7 +167,7 @@ static bool check_stream_network(stream_t *stream)
}
#elif HAVE_LINUX_FSTATFS
-static bool check_stream_network(stream_t *stream)
+static bool check_stream_network(int fd)
{
struct statfs fs;
const uint32_t stypes[] = {
@@ -181,8 +180,7 @@ static bool check_stream_network(stream_t *stream)
0xBEEFDEAD /*SNFS*/, 0xBACBACBC /*VMHGFS*/, 0x7461636f /*OCFS2*/,
0
};
- struct priv *priv = stream->priv;
- if (fstatfs(priv->fd, &fs) == 0) {
+ if (fstatfs(fd, &fs) == 0) {
for (int i=0; stypes[i]; i++) {
if (stypes[i] == fs.f_type)
return true;
@@ -192,7 +190,7 @@ static bool check_stream_network(stream_t *stream)
}
#elif defined(_WIN32)
-static bool check_stream_network(stream_t *stream)
+static bool check_stream_network(int fd)
{
NTSTATUS (NTAPI *pNtQueryVolumeInformationFile)(HANDLE,
PIO_STATUS_BLOCK, PVOID, ULONG, FS_INFORMATION_CLASS) = NULL;
@@ -208,8 +206,7 @@ static bool check_stream_network(stream_t *stream)
if (!pNtQueryVolumeInformationFile)
return false;
- struct priv *priv = stream->priv;
- HANDLE h = (HANDLE)_get_osfhandle(priv->fd);
+ HANDLE h = (HANDLE)_get_osfhandle(fd);
if (h == INVALID_HANDLE_VALUE)
return false;
@@ -224,7 +221,7 @@ static bool check_stream_network(stream_t *stream)
(info.Characteristics & FILE_REMOTE_DEVICE);
}
#else
-static bool check_stream_network(stream_t *stream)
+static bool check_stream_network(int fd)
{
return false;
}
@@ -238,6 +235,7 @@ static int open_f(stream_t *stream)
.fd = -1
};
stream->priv = priv;
+ stream->type = STREAMTYPE_FILE;
bool write = stream->mode == STREAM_WRITE;
int m = O_CLOEXEC | (write ? O_RDWR | O_CREAT | O_TRUNC : O_RDONLY);
@@ -278,9 +276,9 @@ static int open_f(stream_t *stream)
struct stat st;
if (fstat(fd, &st) == 0) {
if (S_ISDIR(st.st_mode)) {
- MP_ERR(stream, "File is a directory: '%s'\n", filename);
- close(fd);
- return STREAM_ERROR;
+ stream->type = STREAMTYPE_DIR;
+ stream->allow_caching = false;
+ MP_INFO(stream, "This is a directory - adding to playlist.\n");
}
#ifndef __MINGW32__
if (S_ISREG(st.st_mode)) {
@@ -302,7 +300,6 @@ static int open_f(stream_t *stream)
stream->seekable = true;
}
- stream->type = STREAMTYPE_FILE;
stream->fast_skip = true;
stream->fill_buffer = fill_buffer;
stream->write_buffer = write_buffer;
@@ -310,7 +307,7 @@ static int open_f(stream_t *stream)
stream->read_chunk = 64 * 1024;
stream->close = s_close;
- if (check_stream_network(stream))
+ if (check_stream_network(fd))
stream->streaming = true;
return STREAM_OK;