0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 12:02:23 +02:00

stream_dvd, cache: hack seeking with --cache + dvd:// back into working

This was broken at some unknown point (even before the recent cache
changes). There are several problems:
- stream_dvd returning a random stream position, confusing the cache
  layer (cached data and stream data lost their 1:1 corrospondence by
  position)
- this also confused the mechanism added with commit a9671524, which
  basically triggered random seeking (although this was not the only
  problem)
- demux_lavf requesting seeks in the stream layer, which resulted in
  seeks in the cache or the real stream

Fix this by completely removing byte-based seeking from stream_dvd. This
already works fine for stream_dvdnav and stream_bluray. Now all these
streams do time-based seeks, and pretend to be infinite streams of data,
and the rest of the player simply doesn't care about the stream byte
positions.
This commit is contained in:
wm4 2014-04-09 23:11:57 +02:00
parent d6086fa9ec
commit 24f1878e95
3 changed files with 3 additions and 41 deletions

View File

@ -130,6 +130,8 @@ static int64_t mp_seek(void *opaque, int64_t pos, int whence)
struct demuxer *demuxer = opaque;
struct stream *stream = demuxer->stream;
int64_t current_pos;
if (stream_manages_timeline(stream))
return -1;
MP_DBG(demuxer, "mp_seek(%p, %"PRId64", %d)\n",
stream, pos, whence);
if (whence == SEEK_CUR)

View File

@ -233,7 +233,7 @@ static bool cache_fill(struct priv *s)
cache_drop_contents(s);
}
if (stream_tell(s->stream) != s->max_filepos) {
if (stream_tell(s->stream) != s->max_filepos && s->seekable) {
MP_VERBOSE(s, "Seeking underlying stream: %"PRId64" -> %"PRId64"\n",
stream_tell(s->stream), s->max_filepos);
stream_seek(s->stream, s->max_filepos);

View File

@ -305,38 +305,6 @@ read_next:
return d->cur_pack-1;
}
static void dvd_seek(stream_t *stream, dvd_priv_t *d, int pos)
{
d->packs_left=-1;
d->cur_pack=pos;
// check if we stay in current cell (speedup things, and avoid angle skip)
if(d->cur_pack>d->cell_last_pack ||
d->cur_pack<d->cur_pgc->cell_playback[ d->cur_cell ].first_sector) {
// ok, cell change, find the right cell!
cell_playback_t *cell;
for(d->cur_cell=0; d->cur_cell < d->cur_pgc->nr_of_cells; d->cur_cell++) {
cell = &(d->cur_pgc->cell_playback[d->cur_cell]);
if(cell->block_type == BLOCK_TYPE_ANGLE_BLOCK && cell->block_mode != BLOCK_MODE_FIRST_CELL)
continue;
d->cell_last_pack=cell->last_sector;
if(d->cur_pack<cell->first_sector) {
d->cur_pack=cell->first_sector;
break;
}
if(d->cur_pack<=d->cell_last_pack) break; // ok, we find it! :)
}
}
MP_VERBOSE(stream, "DVD Seek! lba=0x%X cell=%d packs: 0x%X-0x%X \n",
d->cur_pack,d->cur_cell,d->cur_pgc->cell_playback[ d->cur_cell ].first_sector,d->cell_last_pack);
// if we're in interleaved multi-angle cell, find the right angle chain!
// (read Navi block, and use the seamless angle jump table)
d->angle_seek=1;
}
static int fill_buffer(stream_t *s, char *buf, int len)
{
int64_t pos;
@ -345,16 +313,9 @@ static int fill_buffer(stream_t *s, char *buf, int len)
pos = dvd_read_sector(s, s->priv, buf);
if (pos < 0)
return -1;
// dvd_read_sector() sometimes internally skips disk-level blocks
s->pos = 2048*(pos - 1);
return 2048; // full sector
}
static int seek(stream_t *s, int64_t newpos) {
dvd_seek(s, s->priv,newpos/2048);
return 1;
}
static void stream_dvd_close(stream_t *s) {
dvd_priv_t *d = s->priv;
ifoClose(d->vts_file);
@ -976,7 +937,6 @@ static int open_s(stream_t *stream, int mode)
stream->sector_size = 2048;
stream->flags = MP_STREAM_SEEK;
stream->fill_buffer = fill_buffer;
stream->seek = seek;
stream->control = control;
stream->close = stream_dvd_close;
stream->start_pos = (int64_t)d->cur_pack*2048;