diff options
author | wm4 <wm4@nowhere> | 2018-10-02 19:57:01 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2019-09-19 20:37:04 +0200 |
commit | c91e659f88450bee3937bdef4338903c508cbba2 (patch) | |
tree | c4ded0e89bf343ad2c98d06822a38a91251737a4 /stream/stream.h | |
parent | ca142be7e8c42d8fbc21935ee3f3db2b6d2f457c (diff) | |
download | mpv-c91e659f88450bee3937bdef4338903c508cbba2.tar.bz2 mpv-c91e659f88450bee3937bdef4338903c508cbba2.tar.xz |
stream: redo buffer handling and allow arbitrary size for stream_peek()
struct stream used to include the stream buffer, including peek buffer,
inline in the struct. It could not be resized, which means the maximum
peek size was set in stone. This meant demux_lavf.c could peek only so
much data.
Change it to use a dynamic buffer. Because it's possible, keep the
inline buffer for default buffer sizes (which are basically always used
outside of file opening). It's unknown whether it really helps with
anything. Probably not.
This is also the fallback plan in case we need something like the old
stream cache in order to deal with mp4 + unseekable http: the code can
now be easily changed to use any buffer size.
Diffstat (limited to 'stream/stream.h')
-rw-r--r-- | stream/stream.h | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/stream/stream.h b/stream/stream.h index c423d70096..8bd8ecfc01 100644 --- a/stream/stream.h +++ b/stream/stream.h @@ -30,10 +30,6 @@ #define STREAM_BUFFER_SIZE 2048 -// Max buffer for initial probe. -#define STREAM_MAX_BUFFER_SIZE (2 * 1024 * 1024) - - // stream->mode #define STREAM_READ 0 #define STREAM_WRITE 1 @@ -123,8 +119,10 @@ typedef struct stream { // added to this. The user can reset this as needed. uint64_t total_unbuffered_read_bytes; - // Includes additional padding in case sizes get rounded up by sector size. - unsigned char buffer[]; + uint8_t *buffer; + + int buffer_alloc; + uint8_t buffer_inline[STREAM_BUFFER_SIZE]; } stream_t; int stream_fill_buffer(stream_t *s); |