From 24f1878e95020b8cb62a6f17301b1ec2209fa109 Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 9 Apr 2014 23:11:57 +0200 Subject: 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. --- stream/cache.c | 2 +- stream/stream_dvd.c | 40 ---------------------------------------- 2 files changed, 1 insertion(+), 41 deletions(-) (limited to 'stream') diff --git a/stream/cache.c b/stream/cache.c index 6f52609082..a377d4c96a 100644 --- a/stream/cache.c +++ b/stream/cache.c @@ -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); diff --git a/stream/stream_dvd.c b/stream/stream_dvd.c index 3d6e3b3cb2..5014c90d9a 100644 --- a/stream/stream_dvd.c +++ b/stream/stream_dvd.c @@ -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_packcur_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_packfirst_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; -- cgit v1.2.3