summaryrefslogtreecommitdiffstats
path: root/stream/cache.c
Commit message (Collapse)AuthorAgeFilesLines
* stream: remove old chapter handling codewm42014-03-251-1/+0
| | | | | | | | Stream-level chapters (like DVD etc.) did potentially not have timestamps for each chapter, so STREAM_CTRL_SEEK_TO_CHAPTER and STREAM_CTRL_GET_CURRENT_CHAPTER were needed to navigate chapters. We've switched everything to use timestamps and that seems to work, so we can simplify the code and remove this old mechanism.
* command: set 'media-title' property for bluray disc with meta-dataxylosper2014-03-131-7/+7
|
* cache: cache DVD volume IDwm42014-02-231-0/+13
| | | | | Since this might be queried every frame or so, it's important not to stall the cache by doing a synchronous stream_control().
* cache: refuse to seek outside of cache boundarieswm42014-01-311-4/+18
| | | | | | | | | | | | | | | | | Note that this still happens in the stream level, so we can't have nice highlevel behavior restricting seeking. Instead, if a seek leads to the demuxer requesting data outside of the cached range, the seek will simply fail. This might confuse the demuxer, and the resulting behavior is not necessarily useful. Note that this also doesn't try to skip data on a forward seek. This would just freeze the stream with slow unseekable streams. One nice thing is that stream.h has a separate function for merely skipping data (separate from seeking forward), which is pretty useful in this case: we want skipping of data to work, even if we reject seeking forward by skipping data as too expensive. This probably is or will be useful for demux_mkv.c.
* cache: remove debug codewm42014-01-171-1/+0
| | | | | | This was accidentally committed. <rcombs> `mp_sleep_us(100000);` <-- are you drunk?
* cache: reduce message spamwm42014-01-161-7/+16
| | | | Output only 1 message every 5 seconds at most.
* stream: mp_msg conversionswm42013-12-211-22/+21
| | | | We also drop some slave mode stuff from stream_vcd.
* Split mpvcore/ into common/, misc/, bstr/wm42013-12-171-2/+2
|
* Replace mp_tmsg, mp_dbg -> mp_msg, remove mp_gtext(), remove set_osd_tmsgwm42013-12-161-2/+2
| | | | | | | | | The tmsg stuff was for the internal gettext() based translation system, which nobody ever attempted to use and thus was removed. mp_gtext() and set_osd_tmsg() were also for this. mp_dbg was once enabled in debug mode only, but since we have log level for enabling debug messages, it seems utterly useless.
* cache: add a way to explicitly resume cachewm42013-12-141-0/+4
|
* cache: try harder on EOFwm42013-12-141-5/+11
| | | | | | | | | | | | | EOF is a special case. Normally, the reader will block until the cache thread has new data. Obviously we don't want to do this on EOF, because we'd potentially block forever. On the other hand, EOF will put the cache thread into a waiting state, so if EOF recovers, this will happen at a "later" point. This is bad if there is some kind of external event that ends the EOF condition. In this case, a steram_read() call would still return EOF. Make it so that the reader waits at least for one iteration of the cache trying to rad a new block. Also adjust some debug messages to not print file positions in hex.
* Add prelimimary (basic, possibly broken) dvdnav supportwm42013-12-121-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | This readds a more or less completely new dvdnav implementation, though it's based on the code from before commit 41fbcee. Note that this is rather basic, and might be broken or not quite usable in many cases. Most importantly, navigation highlights are not correctly implemented. This would require changes in the FFmpeg dvdsub decoder (to apply a different internal CLUT), so supporting it is not really possible right now. And in fact, I don't think I ever want to support it, because it's a very small gain for a lot of work. Instead, mpv will display fake highlights, which are an approximate bounding box around the real highlights. Some things like mouse input or switching audio/subtitles stream using the dvdnav VM are not supported. Might be quite fragile on transitions: if dvdnav initiates a transition, and doesn't give us enough mpeg data to initialize video playback, the player will just quit. This is added only because some users seem to want it. I don't intend to make mpv a good DVD player, so the very basic minimum will have to do. How about you just convert your DVD to proper video files?
* stream: split out pthread helper functionwm42013-11-171-26/+3
| | | | Also split the function itself into 3.
* core: move contents to mpvcore (2/2)Stefano Pigozzi2013-08-061-2/+2
| | | | Followup commit. Fixes all the files references.
* cache: fix time check for printing warningwm42013-07-201-1/+1
| | | | | This actually waited 2 seconds, because CACHE_WAIT_TIME happened to be 0.5.
* w32: silence some warningsJames Ross-Gowan2013-07-131-1/+1
|
* cache: fix compilation without posix timersStefano Pigozzi2013-07-081-0/+1
| | | | | | This is a regression caused by 854303a. This commit removed the include of `sys/time.h` which was included in `cache.c` through a chain of recurvive includes.
* core: update metadata during playback, allow streams to export metadatawm42013-07-021-1/+22
| | | | | | | STREAM_CTRL_GET_METADATA will be used to poll for streamcast metadata. Also add DEMUXER_CTRL_UPDATE_INFO, which could in theory be used by demux_lavf.c. (Unfortunately, libavformat is too crappy to read metadata mid-stream for mp3 or ogg, so we don't implement it.)
* cache: fix per-block metadata memory leakwm42013-07-021-0/+1
|
* cache: cache number of chapterswm42013-06-241-0/+10
| | | | | | | | | Querying this caused the cache to block and wait. Some parts of the frontend (like progress bar) call this very often, so cache performance was ruined in these cases. Also print a message in -v mode when the cache is blocked for a STREAM_CTRL. This should make debugging similar issues easier.
* cache: fix stream_pts cachingwm42013-06-181-20/+20
| | | | | | | | | | | | | | | | | | | | | | | | Or rather, keep hacking it until it somehow works. The problem here was that trying to avoid calling STREAM_CTRL_GET_CURRENT_TIME too often didn't really work, so the cache sometimes returned incorrect times. Also try to avoid the situation that looking up the time with an advanced read position doesn't really work, as well as when trying to look it up when EOF or cache end has been reached. In that case we have read_filepos == max_filepos, which is "outside" of the cache, but querying the time is still valid. Should also fix the issue that demuxing streams with demux_lavf and if STREAM_CTRL_GET_CURRENT_TIME is not supported messed up the reported playback position. This stuff is still not sane, but the way the player tries to fix the playback time and how the DVD/BD stream inputs return the current time based on the current byte position isn't sane to begin with. So, let's leave it at bad hacks. The two changes that touch s->eof are unrelated and basically of cosmetic nature (separate commit would be too noisy.)
* cache: actually use time instead of retry count for slow cache warningwm42013-06-181-9/+11
| | | | | There's actually no reason to maintain a retry count, and this is more robust against spurious wakeups.
* cache: fix build on OSX (again)wm42013-06-161-0/+7
| | | | | | | | | | | | | OSX doesn't support the POSIX API we were using. We check for _POSIX_TIMERS. 0 or -1 means unsupported. See: http://pubs.opengroup.org/onlinepubs/009696699/functions/clock_getres.html http://pubs.opengroup.org/onlinepubs/009696699/basedefs/unistd.h.html The workaround of using gettimeofday() is suggested by Apple: https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man3/pthread_cond_timedwait.3.html Thanks to AStorm for providing help here.
* cache: fix compilation on Libavwm42013-06-161-1/+8
| | | | Appears Libav doesn't have av_clip64(). So implement our own.
* cache: use correct header for clock_gettimewm42013-06-161-0/+1
| | | | Fixes compilation on OSX.
* cache: attempt to improve slow cache warningwm42013-06-161-26/+35
| | | | | Still sucks. The old cache behavior (before removing the fork code) wasn't great either, though.
* cache: report more precise stream timewm42013-06-161-9/+39
| | | | | | | | | | | | | | | | | | | | | | | | DVD and bluray packet streams carry (essentially) random timestamps, which don't start at 0, can wrap, etc. libdvdread and libbluray provide a linear timestamp additionally. This timestamp can be retrieved with STREAM_CTRL_GET_CURRENT_TIME. The problem is that this timestamp is bound to the current raw file position, and the stream cache can be ahead of playback by an arbitrary amount. This is a big problem for the user, because the displayed playback time and actual time don't match (depending on cache size), and relative seeking is broken completely. Attempt to fix this by saving the linear timestamp all N bytes (where N = BYTE_META_CHUNK_SIZE = 16 KB). This is a rather crappy hack, but also very effective. A proper solution would probably try to offset the playback time with the packet PTS, but that would require at least knowing how the PTS can wrap (e.g. how many bits is the PTS comprised of, and what are the maximum and reset values). Another solution would be putting the cache between libdvdread and the filesystem/DVD device, but that can't be done currently. (Also isn't that the operating system's responsibility?)
* cache: use threads instead of fork()wm42013-06-161-526/+383
| | | | | | | | | | | | | | | | | | | Basically rewrite all the code supporting the cache (i.e. anything other than the ringbuffer logic). The underlying design is untouched. Note that the old cache2.c (on which this code is based) already had a threading implementation. This was mostly unused on Linux, and had some problems, such as using shared volatile variables for communication and uninterruptible timeouts, instead of using locks for synchronization. This commit does use proper locking, while still retaining the way the old cache worked. It's basically a big refactor. Simplify the code too. Since we don't need to copy stream ctrl args anymore (we're always guaranteed a shared address space now), lots of annoying code just goes away. Likewise, we don't need to care about sector sizes. The cache uses the high-level stream API to read from other streams, and sector sizes are handled transparently.
* cache: make the stream cache a proper stream that wraps other streamswm42013-06-161-237/+117
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before this commit, the cache was franken-hacked on top of the stream API. You had to use special functions (like cache_stream_fill_buffer() instead of stream_fill_buffer()), which would access the stream in a cached manner. The whole idea about the previous design was that the cache runs in a thread or in a forked process, while the cache awa functions made sure the stream instance looked consistent to the user. If you used the normal functions instead of the special ones while the cache was running, you were out of luck. Make it a bit more reasonable by turning the cache into a stream on its own. This makes it behave exactly like a normal stream. The stream callbacks call into the original (uncached) stream to do work. No special cache functions or redirections are needed. The only different thing about cache streams is that they are created by special functions, instead of being part of the auto_open_streams[] array. To make things simpler, remove the threading implementation, which was messed into the code. The threading code could perhaps be kept, but I don't really want to have to worry about this special case. A proper threaded implementation will be added later. Remove the cache enabling code from stream_radio.c. Since enabling the cache involves replacing the old stream with a new one, the code as-is can't be kept. It would be easily possible to enable the cache by requesting a cache size (which is also much simpler). But nobody uses stream_radio.c and I can't even test this thing, and the cache is probably not really important for it either.
* core: use STREAM_CTRL instead of accessing stream_dvd internalswm42013-06-091-0/+10
| | | | | | | | | | | | Some code in mplayer.c did stuff like accessing (dvd_priv_t *)st->priv. Do this indirectly by introducing STREAM_CTRL_GET_DVD_INFO. This is extremely specific to DVD, so it's not worth abstracting this further. This is a preparation for turning the cache into an actual stream, which simply wraps the cached stream. There are other streams which are accessed in the way DVD was, at least TV/radio/DVB. We assume these can't be used with the cache. The code doesn't look thread-safe or fork aware.
* stream: rename cache2.c to cache.cwm42013-06-091-0/+804
I never found cache1.c (whatever it was named, if it ever existed). cache2.h will be deleted later, so don't go through the trouble of renaming it.