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.
This commit is contained in:
wm4 2018-09-01 11:56:28 +02:00
parent a9d83eac40
commit 162e0f5ad9
5 changed files with 4 additions and 16 deletions

View File

@ -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));

View File

@ -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;

View File

@ -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");

View File

@ -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;

View File

@ -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;