summaryrefslogtreecommitdiffstats
path: root/core
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'cache_new'wm42013-06-163-24/+22
|\
| * cache: use threads instead of fork()wm42013-06-161-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-162-12/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-11/+9
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* | audio/out: remove ao->outburst/buffersize fieldswm42013-06-163-5/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The core didn't use these fields, and use of them was inconsistent accross AOs. Some didn't use them at all. Some only set them; the values were completely unused by the core. Some made full use of them. Remove these fields. In places where they are still needed, make them private AO state. Remove the --abs option. It set the buffer size for ao_oss and ao_dsound (being ignored by all other AOs), and was already marked as obsolete. If it turns out that it's still needed for ao_oss or ao_dsound, their default buffer sizes could be adjusted, and if even that doesn't help, AO suboptions could be added in these cases.
* | core: add a spsc ringbuffer implementationStefano Pigozzi2013-06-163-0/+303
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently every single AO was implementing it's own ringbuffer, many times with slightly different semantics. This is an attempt to fix the problem. I stole some good ideas from ao_portaudio's ringbuffer and went from there. The main difference is this one stores wpos and rpos which are absolute positions in an "infinite" buffer. To find the actual position for writing / reading just apply modulo size. The producer only modifies wpos while the consumer only modifies rpos. This makes it pretty easy to reason about and make the operations thread safe by using barriers (thread safety is guaranteed only in the Single-Producer/Single- Consumer case). Also adapted ao_coreaudio to use this ringbuffer.
* | encode_lavc strings: use new option syntaxRudolf Polzer2013-06-161-19/+19
| |
* | mplayer: update window title if its properties changeJohn Hawthorn2013-06-161-10/+18
| | | | | | | | | | | | This allows having properties like time-pos in the window title update properly. There is a danger of this causing significant CPU usage, depending on the properties used and the window manager.
* | video/out: introduce VOCTRL_UPDATE_WINDOW_TITLEwm42013-06-151-0/+1
| | | | | | | | | | | | | | | | | | | | | | Instead of implicitly changing the window title on config(), do it as part of the new VOCTRL. At first I wanted to make all VOs use the VOCTRL argument directly, but on a second thought it appears vo_get_window_title() is much more useful for some (namely, if the window is created lazily on first config()). Not all VOs are changed. Wayland and OSX have to follow.
* | command: use more standard time format for clock propertywm42013-06-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | %k is not very standard. The manpage notes them as conforming to "Olson's timezone package", and it's not standard C89, C99 or POSIX. mingw doesn't provide it, and even some of the smaller Linux libcs don't have support. Use %H instead. This gives slightly different results, but I think this is ok. Difference in behavior between these summarized: %k: "single digits are preceded by a blank" %H: "range 00 to 23"
* | x11: enable screensaver when paused, rename/change --stop-xscreensaverwm42013-06-143-5/+6
| | | | | | | | | | | | | | | | | | | | | | Use the recently introduced screensaver VOCTRLs to control the screensaver in the X11 backend. This means the behavior when paused changes: the old code always kept the screensaver disabled, but now the screensaver is reenabled on pausing. Rename the --stop-xscreensaver option to --stop-screensaver and make it more generic. Now it affects all backends that respond to the screensaver VOCTRLs.
* | core: introduce separate VOCTRLs for screensaver stop/resumewm42013-06-141-8/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is slightly better because VOCTRL_RESUME/VOCTRL_PAUSE are usually needed by VOs to know whether video is actually being played (for whatever reason), and they wouldn't be passed to the backend's VOCTRL handler, like vo_x11_control(). Also try to make sure that these flags (both pause state and screensaver state) are set consistently in some corner cases. For example, it seems enabling video in the middle of playing a file while the player is paused would not set the paused flag. If codec initialization fails, destroy the VO instead of keeping it around to make sure the state is consistent. Framestepping is implemented by unpausing the player for the duration of a frame. Remove the special handling of VOCTRL_PAUSE/RESUME in these cases. It was most likely needed because these VOCTRLs used to be important for screen redrawing (blatant guess), which is now handled completely differently. The only potentially bad side-effect is that the screensaver will be disabled/reenabled for the duration of one frame.
* | support "-" as file name when encodingRudolf Polzer2013-06-131-7/+15
| | | | | | | | | | | | | | This workaround sucks. avio just does not support "-" - and ffmpeg's command line binaries work around it. FOUR TIMES. DIFFERENTLY. WHY DOESN'T AVIO DO THIS RIGHT TO BEGIN WITH?
* | options: remove --stereowm42013-06-131-6/+0
| | | | | | | | | | | | | | Whatever this was supposed to be originally, it doesn't have much value anymore. It just forced ad_mpg123 to upmix mono to stereo by default (the audio chain can do that). As an option, it was mostly useless and misleading, so get rid of it.
* | mplayer: save sub-visibility propertywm42013-06-131-1/+1
| |
* | mplayer: try to handle PTS forward jumpswm42013-06-131-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Raw MPEG streams can contain PTS discontinuities. While the playback core has obvious code for handling PTS going backward, PTS going forward was as far as I can see not handled. This can be an issue with DVD playback. This wasn't caught earlier, because DVD playback was just recently switched to demux_lavf, which implies -no-correct-pts mode. This mode doesn't use PTS in the same way as the normal playback mode, and as such was too primitive to be affected by this issue. Use the following heuristic to handle PTS forward jumps: if the PTS difference between two frames is higher than 10 seconds, consider it a reset. (Also, use MSGL_WARN for the PTS discontinuity warnings.) In this particular case, the MPEG stream was going from pts=304510857 to pts=8589959849 according to ffprobe (raw timestamps), which seems a bit strange. Note that this heuristic breaks if the source video has unusually high frame times. For example Rooster_Teeth_Podcast_191.m4a, an audio file with a slide show encoded as MJPEG video track.
* | options: fix compilation on Windowswm42013-06-111-0/+1
| | | | | | | | Closes github issue #107. (Hopefully.)
* | command: fix empty metadata casewm42013-06-111-2/+2
| | | | | | | | show_text "${metadata}" crashed if no metadata was set.
* | Option -omaxfps: limit fps when encodingRudolf Polzer2013-06-092-0/+2
|/ | | | | Lower-fps content is left alone (NOT aligned to this fps); higher fps content is decimated to this frame rate.
* core: make options.c compile standalonewm42013-06-084-59/+55
| | | | | This also removes the split between "mplayer" and "common" opts (common opts used to be shared between mencoder and mplayer).
* core: rename cfg-mplayer.h to options.cwm42013-06-082-2/+2
|
* core: merge defaultopts.c into cfg-mplayer.hwm42013-06-084-124/+110
| | | | | There isn't really any reason why this should be in a separate source file.
* command: replace some show_ commands with propertieswm42013-06-073-122/+126
| | | | | | | | | | | show_chapters, show_tracks, and show_playlist are killed and replaced with the properties chapter-list, track-list, and playlist. The code and the output of these stays the same, this is just moving a lot of code around and reducing the number of properties. The "old" commands will still be supported for a while (to avoid making everyone angry), so handle them with the legacy layer. Add something to suppress printing the legacy warnings for these commands.
* command: human readable output for metadata propertywm42013-06-071-0/+10
| | | | | | | Slightly better output when printing ${metadata}. Print each metadata item as "name: value", instead of the raw list. It's still not very great, though. The old format is still available through ${=metadata} for things which dare to use the broken slave mode.
* core: reset pause state by default when going to next filewm42013-06-071-0/+2
| | | | Apparently this behavior is more intuitive/better to users.
* m_option: allow setting empty listswm42013-06-071-2/+5
| | | | There's no reason why this should be forbidden.
* keycodes: fix copy paste errorStefano Pigozzi2013-06-051-3/+3
| | | | Makes 213ad5d behave has intended.
* command: add the current local time as a propertyJan-Marek Glogowski2013-06-041-0/+16
| | | | | | | | This adds a the property 'clock', which returns the current local time as the string hh:mm. Additionally the keybinding 'shift' + 'o' was added to displaying the clock as '[hh:mm]' .
* osx: improve Media Keys supportStefano Pigozzi2013-06-044-2/+23
| | | | | | | | | | | | | | | | | | | | | | | This commit addresses some issues with the users had with the previous implementation in commit c39efb9. Here's the changes: * Use Quartz Event Taps to remove Media Key events mpv handles from the global OS X queue. This prevents conflicts with iTunes. I did this on the main thread since it is mostly idling. It's the playloop thread that actually does all the work so there is no danger of blocking the event tap callback. * Introduce `--no-media-keys` switch so that users can disable all of mpv's media key handling at runtime (some prefer iTunes for example). * Use mpv's bindings so that users can customize what the media keys do via input.conf. Current bindings are: MK_PLAY cycle pause MK_PREV playlist_prev MK_NEXT playlist_next An additional benefit of this implementation is that it is completly handled by the `macosx_events` file instead of `macosx_application` making the project organization more straightforward.
* Merge branch 'sub_mess'wm42013-06-049-357/+209
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | This branch heavily refactors the subtitle code (both loading and rendering), and adds support for a few new formats through FFmpeg. We don't remove any of the old code yet. There are still some subtleties related to subreader.c to be resolved: code page detection & conversion, timing post-processing, UTF-16 subtitle support, support for the -subfps option. Also, SRT reading and loading ASS via libass should be turned into proper demuxers. (SRT is needed because Libav's is gravely broken, and we want ASS loading via libass to cover full libass format support. Both should be demuxers which are probed _before_ libavformat, so that all subtitles can be loaded through the demuxer infrastructure, and libavformat subtitles don't need to be treated in a special way.)
| * sub: always show subtitles on terminal with -no-videowm42013-06-041-2/+4
| | | | | | | | | | | | | | | | | | | | | | Until now, this happened only when the -no-ass option was used. This difference in behavior doesn't make much sense, so change it so that whether -no-ass is used or not doesn't matter. (-no-ass enables the OSD subtitle renderer, which has the terminal fallback, while the normal path is video only.) the changes in set_osd_subtitle() and reinit_video_chain() are for resetting the state correctly when switching between video/no-video.
| * core: add common function to initialize AVPacketwm42013-06-032-0/+22
| | | | | | | | | | | | | | | | | | | | Audio and video had their own (very similar) functions to initialize an AVPacket (ffmpeg's packet struct) from a demux_packet (mplayer's packet struct). Add a common function for these. Also use this function for sd_lavc_conv. This is actually a functional change, as some libavfilter subtitle demuxers add weird out-of-band stuff as side-data.
| * sub: pass subtitle packets directlywm42013-06-031-11/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | Before this, subtitle packets were returned as data ptr/len pairs, and mplayer.c got the rest (pts and duration) directly from the demuxer data structures. Then mplayer.c reassembled the packet data structure again. Pass packets directly instead. The mplayer.c side stays a bit awkward, because the (now by default unused) DVD path keeps getting in the way. In demux.c there's lots of weird stuff (3 functions that read packets, really?), but we want to keep the code equivalent for now to avoid hitting weird issues and corner cases.
| * sub: use libass even if -no-ass is usedwm42013-06-031-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The -no-ass option used to disable all use of libass completely. This doesn't work this way anymore, and the text subtitle path has an inherent dependency on libass. Currently -no-ass does 3 things: 1. Strip tags and formatting on display, and use a separate renderer for the result. (Which might be the terminal, or libass via OSD code.) 2. Not loading attached fonts from Matroska files. 3. Use subreader.c instead of libass for reading .ass files. 1. and 2. are ok and what the user (probably wants), but 3. doesn't really make sense anymore. subreader.c reads .ass files just fine, but then does some strange things to them (something about coalescing and re-adding newlines?), leading to even more broken display with -no-ass. Instead of fighting with subreader.c, just use libass as loader.
| * sub: turn subassconvert_ functions into sub converterswm42013-06-031-20/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This means subassconvert.c is split in sd_srt.c and sd_microdvd.c. Now this code is involved in the sub conversion chain like sd_movtext is. The invocation of the converter in sd_ass.c is removed. This requires some other changes to make the new sub converter code work with loading external subtitles. Until now, subtitles loaded via subreader.c was assumed to be in plaintext, or for some formats, in ASS (except in -no-ass mode). Then these were added to an ASS_Track. Change this so that subtitles are always in their original format (as far as decoders/converters for them are available), and turn every sub event read by subreader.c as packet to the dec_sub.c subtitle chain. This removes differences between external/demuxed and -ass/-no-ass code paths further.
| * sub: basic subtitle converterswm42013-06-031-7/+0
| | | | | | | | | | | | | | | | | | | | Add a basic infrastructure for subtitle converters. These converters work sort-of like decoders, except that they produce packets instead of subtitle bitmaps. They are put in front of actual decoders. Start with sd_movtext. 4 lines of code are blown up to a 55 lines file, but fortunately this is not going to be that bad for the following converters.
| * sub: refactorwm42013-06-012-33/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Make the sub decoder stuff independent from sh_sub (except for initialization of course). Sub decoders now access a struct sd only, instead of getting access to sh_sub. The glue code in dec_sub.c is similarily independent from osd. Some simplifications are made. For example, the switch_id stuff is unneeded: the frontend code just has to make sure to call osd_changed() any time subtitles are switched. This is also preparation for introducing subtitle converters. It's much cleaner to completely separate demuxer header/renderer glue/decoders for this purpose, especially since sub converters might completely change how demuxer headers have to be interpreted. Also pass data as demux_packets. Currently, this doesn't help much, but libavcodec converters might need scary stuff like packet side data, so it's perhaps better to go with passing packets.
| * core: add demux_sub pseudo demuxerwm42013-06-012-42/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Subtitle files are opened in mplayer.c, not using the demuxer infrastructure in general. Pretend that this is not the case (outside of the loading code) by opening a pseudo demuxer that does nothing. One advantage is that the initialization code is now the same, and there's no confusion about what the difference between track->stream, track->sh_sub and mpctx->sh_sub is supposed to be. This is a bit stupid, and it would be much better if there were proper subtitle demuxers (there are many in recent FFmpeg, but not Libav). So for now this is just a transition to a more proper architecture. Look at demux_sub like an artifical limb: it's ugly, but don't hate it - it helps you to get on with your life.
| * sub: various minor subtitle related changeswm42013-06-011-11/+10
| | | | | | | | Just pushing some code around.
| * sub: remove some global variableswm42013-05-305-19/+32