diff options
author | wm4 <wm4@nowhere> | 2019-11-07 15:54:34 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2019-11-07 22:53:13 +0100 |
commit | e5a9b792ecf08ddbcf3b674de3a00f7a919d1858 (patch) | |
tree | ead751b12d006d13f138867324b62dda62b8e77b /stream/stream_smb.c | |
parent | ca75fedaf4dea19986159f1caa5ab9ebc202f9d4 (diff) | |
download | mpv-e5a9b792ecf08ddbcf3b674de3a00f7a919d1858.tar.bz2 mpv-e5a9b792ecf08ddbcf3b674de3a00f7a919d1858.tar.xz |
stream: replace STREAM_CTRL_GET_SIZE with a proper entrypoint
This is overlay convoluted as a stream control, and important enough to
warrant "first class" functionality.
Diffstat (limited to 'stream/stream_smb.c')
-rw-r--r-- | stream/stream_smb.c | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/stream/stream_smb.c b/stream/stream_smb.c index bc1c00a8ef..a87150a838 100644 --- a/stream/stream_smb.c +++ b/stream/stream_smb.c @@ -46,22 +46,13 @@ static void smb_auth_fn(const char *server, const char *share, workgroup[wgmaxlen - 1] = '\0'; } -static int control(stream_t *s, int cmd, void *arg) { +static int64_t get_size(stream_t *s) { struct priv *p = s->priv; - switch(cmd) { - case STREAM_CTRL_GET_SIZE: { - pthread_mutex_lock(&smb_lock); - off_t size = smbc_lseek(p->fd,0,SEEK_END); - smbc_lseek(p->fd,s->pos,SEEK_SET); - pthread_mutex_unlock(&smb_lock); - if(size != (off_t)-1) { - *(int64_t *)arg = size; - return 1; - } - } - break; - } - return STREAM_UNSUPPORTED; + pthread_mutex_lock(&smb_lock); + off_t size = smbc_lseek(p->fd,0,SEEK_END); + smbc_lseek(p->fd,s->pos,SEEK_SET); + pthread_mutex_unlock(&smb_lock); + return size; } static int seek(stream_t *s,int64_t newpos) { @@ -149,7 +140,7 @@ static int open_f (stream_t *stream) stream->fill_buffer = fill_buffer; stream->write_buffer = write_buffer; stream->close = close_f; - stream->control = control; + stream->get_size = get_size; stream->read_chunk = 128 * 1024; stream->streaming = true; |