From 162e0f5ad92116d1a4fb740d087da2a152686b73 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 1 Sep 2018 11:56:28 +0200 Subject: stream: remove BD/DVD/CDDA sector size alignment This was possibly needed by libdvdread, and/or old CD drivers on some system. It still works with on-filesystem DVD and BD test images, so this can go. --- stream/stream.c | 15 ++++----------- stream/stream.h | 2 -- stream/stream_bluray.c | 1 - stream/stream_cdda.c | 1 - stream/stream_dvdnav.c | 1 - 5 files changed, 4 insertions(+), 16 deletions(-) diff --git a/stream/stream.c b/stream/stream.c index 0c21682da9..fd2bd8c163 100644 --- a/stream/stream.c +++ b/stream/stream.c @@ -42,8 +42,7 @@ #include "options/m_option.h" #include "options/m_config.h" -// Includes additional padding in case sizes get rounded up by sector size. -#define TOTAL_BUFFER_SIZE (STREAM_MAX_BUFFER_SIZE + STREAM_MAX_SECTOR_SIZE) +#define TOTAL_BUFFER_SIZE STREAM_MAX_BUFFER_SIZE extern const stream_info_t stream_info_cdda; extern const stream_info_t stream_info_dvb; @@ -247,7 +246,7 @@ static int open_internal(const stream_info_t *sinfo, const char *url, int flags, } if (!s->read_chunk) - s->read_chunk = 4 * (s->sector_size ? s->sector_size : STREAM_BUFFER_SIZE); + s->read_chunk = 4 * STREAM_BUFFER_SIZE; assert(s->seekable == !!s->seek); @@ -344,8 +343,6 @@ static int stream_fill_buffer_by(stream_t *s, int64_t len) { len = MPMIN(len, s->read_chunk); len = MPMAX(len, STREAM_BUFFER_SIZE); - if (s->sector_size) - len = s->sector_size; len = stream_read_unbuffered(s, s->buffer, len); s->buf_pos = 0; s->buf_len = len; @@ -365,9 +362,9 @@ int stream_read_partial(stream_t *s, char *buf, int buf_size) assert(buf_size >= 0); if (s->buf_pos == s->buf_len && buf_size > 0) { s->buf_pos = s->buf_len = 0; - // Do a direct read, but only if there's no sector alignment requirement + // Do a direct read // Also, small reads will be more efficient with buffering & copying - if (!s->sector_size && buf_size >= STREAM_BUFFER_SIZE) + if (buf_size >= STREAM_BUFFER_SIZE) return stream_read_unbuffered(s, buf, buf_size); if (!stream_fill_buffer(s)) return 0; @@ -412,8 +409,6 @@ struct bstr stream_peek(stream_t *s, int len) // Fill rest of the buffer. while (buf_valid < len) { int chunk = MPMAX(len - buf_valid, STREAM_BUFFER_SIZE); - if (s->sector_size) - chunk = s->sector_size; assert(buf_valid + chunk <= TOTAL_BUFFER_SIZE); int read = stream_read_unbuffered(s, &s->buffer[buf_valid], chunk); if (read == 0) @@ -521,8 +516,6 @@ bool stream_seek(stream_t *s, int64_t pos) return s->seekable && s->seek(s, pos); int64_t newpos = pos; - if (s->sector_size) - newpos = (pos / s->sector_size) * s->sector_size; MP_TRACE(s, "Seek from %" PRId64 " to %" PRId64 " (with offset %d)\n", s->pos, pos, (int)(pos - newpos)); diff --git a/stream/stream.h b/stream/stream.h index c575db4a10..e6a352917a 100644 --- a/stream/stream.h +++ b/stream/stream.h @@ -29,7 +29,6 @@ #include "misc/bstr.h" #define STREAM_BUFFER_SIZE 2048 -#define STREAM_MAX_SECTOR_SIZE (8 * 1024) // Max buffer for initial probe. #define STREAM_MAX_BUFFER_SIZE (2 * 1024 * 1024) @@ -137,7 +136,6 @@ typedef struct stream { // Close void (*close)(struct stream *s); - int sector_size; // sector size (seek will be aligned on this size if non 0) int read_chunk; // maximum amount of data to read at once to limit latency unsigned int buf_pos, buf_len; int64_t pos; diff --git a/stream/stream_bluray.c b/stream/stream_bluray.c index 10562d6af4..41b96fe5db 100644 --- a/stream/stream_bluray.c +++ b/stream/stream_bluray.c @@ -354,7 +354,6 @@ static int bluray_stream_open_internal(stream_t *s) s->fill_buffer = bluray_stream_fill_buffer; s->close = bluray_stream_close; s->control = bluray_stream_control; - s->sector_size = BLURAY_SECTOR_SIZE; s->priv = b; MP_VERBOSE(s, "Blu-ray successfully opened.\n"); diff --git a/stream/stream_cdda.c b/stream/stream_cdda.c index e99db3eda1..dd8405a4a1 100644 --- a/stream/stream_cdda.c +++ b/stream/stream_cdda.c @@ -346,7 +346,6 @@ static int open_cdda(stream_t *st) priv->sector = priv->start_sector; st->priv = priv; - st->sector_size = CDIO_CD_FRAMESIZE_RAW; st->fill_buffer = fill_buffer; st->seek = seek; diff --git a/stream/stream_dvdnav.c b/stream/stream_dvdnav.c index 2aaccd5561..9a95446455 100644 --- a/stream/stream_dvdnav.c +++ b/stream/stream_dvdnav.c @@ -417,7 +417,6 @@ static int open_s_internal(stream_t *stream) if (p->opts->angle > 1) dvdnav_angle_change(priv->dvdnav, p->opts->angle); - stream->sector_size = 2048; stream->fill_buffer = fill_buffer; stream->control = control; stream->close = stream_dvdnav_close; -- cgit v1.2.3