summaryrefslogtreecommitdiffstats
path: root/mplayer.c
Commit message (Collapse)AuthorAgeFilesLines
* win32: core: wake up more often to poll for inputUoti Urpala2012-04-261-2/+13
| | | | | | | | | MSWindows does not have properly working support for detecting events on file descriptors. As a result the current mplayer2 code does not support waking up when new input events occur. Make the central playloop wake up more often to poll for events; otherwise response would be a lot laggier than on better operating systems during pause or other cases where the process would not otherwise wake up.
* core: change initial sync with --delay, video stream switchUoti Urpala2012-04-231-1/+2
| | | | | | | | | | | | | Make A/V sync at the start of playback with nonzero --delay behave the same way as it does when seeking to the beginning later, meaning video plays from the start and audio is truncated or padded with silence to match timing. This was already the default behavior in case the streams in the file started at different times, but not if the mismatch was due to --delay. Trigger similar audio synchronization when switching to a new video stream. Previously, switching a video stream on after playing for some time in audio-only mode was buggy and caused initial desync equal to the duration of prior audio-only playback.
* core: uninitialize VO and AO when no track playsUoti Urpala2012-04-231-10/+9
| | | | | | | | | | | | Uninitialize video and audio outputs when switching to a file without a corresponding track (audio-only file / file with no sound), or when entering --idle mode. Switching track choice to "off" during playback already did this. It could be useful to have a mode where the video window stays open even when no video plays, but implementing that properly would require more than just leaving the window on screen like the code did before this commit.
* audio: fix unmute-at-end logicUoti Urpala2012-04-111-3/+3
| | | | | | | | | | | | The player tried to disable mute before exiting, so that if mute is emulated by setting volume to 0 and the volume setting is a system-global one, we don't leave it at 0. However, the logic doing this at process exit was flawed, as volume settings are handled by audio output instances and the audio output that set the mute state may have been closed earlier. Trying to write reliably working logic that restores volume at exit only would be tricky, so change the code to always unmute an audio driver before closing it and restore mute status if one is opened again later.
* audio: restore volume setting after AO reinit if neededUoti Urpala2012-04-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | MPlayer volume control was originally implemented with the assumption that it controls a system-wide volume setting which keeps its value even if a process closes and reopens the audio device. However, this is not actually true for --softvol mode or some audio output APIs that only consider volume as a per-client setting for software mixing. This could have annoying results, as the volume would be reset to a default value if the AO was closed and reopened, for example whem moving to a new file or crossing ordered chapter boundaries. Add code to set the previous volume again after audio reinitialization if the current audio chain is known to behave this way (softvol active or the AO driver is known to not keep persistent volume externally). This also avoids an inconsistency with the mute flag. The frontend assumed the mute status is persistent across file changes, but it could be similarly lost. The audio drivers that are assumed to not keep persistent volume are: coreaudio, dsound, esd, nas, openal, sdl. None of these changes have been tested. I'm guessing that ESD and NAS do per-connection non-persistent volume settings. Partially based on code by wm4.
* audio: keep volume level internally (not only in AO)Uoti Urpala2012-04-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Current volume was always queried from the the audio output driver (or filter in case of --softvol). The only case where it was stored on mixer level was that when turning off mute, volume was set to the value it had before mute was activated. Change the mixer code to always store the current target volume internally. It still checks for significant changes from external sources and resets the internal value in that case. The main functionality changes are: Volume will now be kept separately from mute status. Increasing or decreasing volume will now change it relative to the original value before mute, even if mute is implemented by setting AO level volume to 0. Volume changes no longer automatically disable mute. The exception is relative changes up (like the volume increase key in default keybindings); that's the only case which still disables mute. Keeping the value internally avoids problems with granularity of possible volume values supported by AO. Increase/decrease keys could work unsymmetrically, or when specifying a smaller than default --volstep, even fail completely. In one case occurring in practice, if the AO only supports changing volume in steps of about 2 and rounds down the requested volume, then volume down key would decrease by 4 but volume up would increase by 2 (previous volume plus or minus the default change of 3, rounded down to a multiple of 2). Now, the internal value will keep full precision.
* build: remove OS/2 supportUoti Urpala2012-04-061-1/+1
|
* input: stop trying to read terminal input on EOFUoti Urpala2012-04-061-2/+3
| | | | | | | | | | | | Stop trying to read terminal input if a read attempt returns EOF. The most important case where this matters is when someone runs the player with stdin redirected from /dev/null and without specifying --no-consolecontrols. This used to cause 100% CPU load while paused, as select() would continuously trigger on stdin (the need for --no-consolecontrols was not apparent to people with older mplayer versions, as input reading was less efficient and latencies like hardcoded sleeps kept CPU use well below 100%). Now this will only cause a "Dead key input" error message.
* core: in VO flip timing, recheck time after OSD drawUoti Urpala2012-04-051-0/+1
| | | | | | | | Make the code read current real time again after drawing OSD. This ensures time taken in OSD drawing is properly deducted from the duration of the following sleep. The main practical effect is to avoid the A-V field on the status line staying at a value a couple of milliseconds above 0 (depending on VO).
* core: fix problems in video EOF detectionUoti Urpala2012-04-051-14/+15
| | | | | | | | | Fix a missing check that could sometimes result in video frames being shown after specified end pts (end of timeline segment or --endpos). Fix mistaken video EOF detection after aspect change in video stream, when there is no current valid visible frame but the next frame is already buffered in VO.
* ao_pulse, core: make pulse thread wake up core for more dataUoti Urpala2012-03-261-2/+1
| | | | | | | | | | | | | | | For ao_pulse, the current latency is not a good indicator of how soon the AO requires new data to avoid underflow. Add an internal pipe that can be used to wake up the input loop from select(), and make the pulseaudio main loop (which runs in a separate thread) use this mechanism when pulse requests more data. The wakeup signal currently contains no information about the reason for the wakup, but audio buffers are always filled when the event loop wakes up. Also, request a latency of 1 second from the Pulseaudio server. The default is normally significantly higher. We don't need low latency, while higher latency helps prevent underflows reduces need for wakeups.
* timeline: subs: keep subtitle tracks in source timeUoti Urpala2012-03-251-30/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Timeline handling converted the pts values from demuxed subtitles to timeline scale. Change the code to do most subtitle handling in original subtitle source pts, and instead convert current playback timeline pts to those units when deciding which subtitle to show. The main functionality changes are that now demuxed subtitles which overlap chapter boundaries are handled correctly (at least for libass subtitles), and external subtitles are assumed to use same pts scale as current source (this needs improvements later). Before, a video subtitle that had a duration continuing past the end of the chapter would continue to be shown for the original duration, even if the chapter ended and playback switched to a position in the source where the subtitle shouldn't exist. Now, the subtitle will correctly end. Before, external subtitle files were interpreted as specifying pts values in timeline scale. Now, they're interpreted as specifying pts values in source file time scale, for _every_ source file. This is probably more likely to be what the user wants for the "main" source file in case there is one, but almost certainly not quite right for multiple source files where the same subs could be shown over different scenes. If the user wants them to match some main source file, it's probably still better to have incorrect extra subs for video from some files than to have every subtitle appearing at the wrong time. The new code makes it easier to change the interpretation of the subtitle times, and some configurability should be added in the future.
* core: improve sub and audio start after timeline part switchUoti Urpala2012-03-201-15/+21
| | | | | | | | | | | | | | | | | | | | | | | When switching to a timeline part from another file, decoders were reinitialized after doing the demuxer-level seek. This is necessary for audio because some decoders read from the demuxer stream during initialization and the previous stream position before seek could have been at EOF. However, this initialization sequence could lose first subtitles or first part of audio. The problem for subtitles was that the seek itself or audio initialization could already have buffered subtitle packets from the new position, and the way subtitles are reinitialized flushes packet buffers. Thus early subtitles could be lost (even if they were demuxed - unfortunately demuxers may not know about still active subtitles earlier in the file, but that's another issue). Fix this by moving subtitle and video reinitialization before the demuxer seek; they don't have the problems which prevent that for audio. Audio initialization can already decode and buffer some output. However, the seek_reset() call done last would then throw away this buffered output. Work around this by adding an extra flag to seek_reset().
* options: move mixer.h options to structUoti Urpala2012-03-201-0/+3
|
* core: restructure main play loop, continue audio after videoUoti Urpala2012-03-191-283/+246
| | | | | | | | | | | Restructure parts of the code in the main play loop. The main functionality difference is that if a video track ends first, now audio will continue to be played until it ends too. Now the process also wakes up less often if there's no need to update video or audio. This will reduce unnecessary wakeups especially when paused, but may make handling of input events laggier when fd-based notifications are not supported (like most input on Windows).
* terminal output: if audio/video pts is missing, show "???"Uoti Urpala2012-03-161-13/+26
| | | | | | Change the terminal status line to show "???" instead of a huge negative number if audio or video pts is missing (there was a partial workaround for audio before, but not video or A-V difference).
* core: remove old EDL mode (--edl option)Uoti Urpala2012-03-091-73/+5
| | | | | | | | | | | | | | | Remove the old EDL implementation that was activated with the --edl option. It is mostly redundant and inferior compared to the newer demux_edl support, though currently there's no support for using the same EDL files with the new implementation and the mute functionality of the old implementation is not supported. The main reason to remove the old implementation at this point is that the mute functionality would conflict with following audio volume handling changes, and working on the old code would be a wasted effort in the long run as at some point it would be removed anyway. The --edlout functionality is kept for now, even though after this commit there is no code that could directly read its output.
* windows support: unicode filenameswm42012-03-091-9/+10
| | | | | | | | | | | | | | | | | | | Windows uses a legacy codepage for char* / runtime functions accepting char *. Using UTF-8 as the codepage with setlocale() is explicitly forbidden. Work this around by overriding the MSVCRT functions with wrapper macros, that assume UTF-8 and use "proper" API calls like _wopen etc. to deal with unicode filenames. All code that uses standard functions that take or return filenames must now include osdep/io.h. stat() can't be overridden, because MinGW-w64 itself defines "stat" as a macro. Change code to use use mp_stat() instead. This is not perfectly clean, but still somewhat sane, and much better than littering the rest of the mplayer code with MinGW specific hacks. It's also a bit fragile, but that's actually little different from the previous situation. Also, MinGW is unlikely to ever include a nice way of dealing with this.
* windows support: remove _UWIN definewm42012-03-011-1/+0
| | | | | | | The _UWIN define causes the mingw headers not to declare deprecated (on Windows) function names such as open and mkdir. But the code uses these. I have no idea why this used to work (if it even did), but the original reason why it was defined seems to have vanished.
* osd: erase terminal OSD line with mp_msg() instead of printf()Uoti Urpala2012-02-251-1/+1
| | | | | | | | The terminal OSD line was written with mp_msg(MSGT_CPLAYER, ...) but erased with printf(). This meant that disabling MSGT_CPLAYER messages would prevent the terminal line from being printed, but a line (probably unrelated) would still be cleared. Change the clearing code to use mp_msg(MSGT_CPLAYER, ...) too.
* vd_ffmpeg: fix flushing of buffered framesUoti Urpala2012-02-031-2/+12
| | | | | | | | | The vd_ffmpeg decode() function returned without doing anything if the input packet had size 0. This meant that flushing buffered frames at EOF did not work. Remove this test. Have the core code skip such packets coming from the file being played instead (Libav treats 0-sized packets as flush signals anyway, so better assume such packets do not represent real frames with any codec).
* build: switch to libavutil bswap.h and intreadwrite.hUoti Urpala2012-02-011-3/+2
| | | | | | | | | | | | Remove the private bswap and intreadwrite.h implementations and use libavutil headers instead. Originally these headers weren't publicly installed by libavutil at all. That already changed in 2010, but the pure C bswap version in installed headers was very inefficient. That was recently (2011-12) improved and now using the public bswap version probably shouldn't cause noticeable performance problems, at least if using a new enough compiler.
* core: print pause status message only once on consolewm42012-01-101-31/+55
| | | | | | | | | | | Since the recent OSD redraw changes, every GUI expose event causes the message "===== PAUSE =====" to be printed on console. This was a bit annoying, so change it so that it is only printed once when going into paused mode. It's also printed again if the cache status changes (when playing URLs), or when the status line is printed during pause mode (when you seek while paused). This also removes some minor code duplication.
* osd: always display pause icon when frame steppingwm42012-01-091-0/+3
| | | | | | | When the OSD was enabled and the player was paused by executing the frame_step command, the OSD still displayed the icon indicating playback. Fix this and always set the proper icon when the pause state is changed.
* cleanup: remove left over access_mpcontext.h (from GUI)Uoti Urpala2012-01-091-31/+0
| | | | | | access_mpcontext.h and the declared functions in mplayer.c were only used by the now deleted internal GUI. Remove the unused header and functions.
* ad_ffmpeg: pass packet side data from libavformatUoti Urpala2012-01-081-1/+1
| | | | | Pass avpacket->side_data when using a libavcodec audio decoder together with libavformat demuxer (this was already done for video).
* configure, build: remove --disable-libav supportUoti Urpala2011-12-111-4/+0
| | | | | Remove support for building the player without libavcodec and libavformat. These libraries are now always required.
* core: minor hrseek tweak (affects vo_vdpau deint frames)Uoti Urpala2011-12-061-3/+2
| | | | | | Remove no longer necessary tests from hrseek code. As a result each field of vo_vdpau framerate-doubling deinterlace modes is now considered as a possible seek target.
* core, vo: new window refresh logic, add slow-video OSD redrawUoti Urpala2011-12-061-6/+9
| | | | | | | | | | | | | | | | | | | | Remove code refreshing window contents after events such as resize from vo_vdpau, vo_gl and vo_xv. Instead have them simply set a flag indicating that a refresh is needed, and have the player core perform that refresh by doing an OSD redraw. Also add support for updating the OSD contents over existing frames during slow-but-not-paused playback. The VOs now also request a refresh if parameters affecting the picture change (equalizer settings, colormatrix, VDPAU deinterlacing setting). Even previously the picture was typically redrawn with the new settings while paused because new OSD messages associated with setting changes triggered a redraw, but this did not happen if OSD was turned off. A minor imperfection is that now window system events can trigger a single one-frame step forward when using vo_xv after pausing so that vo_xv does not yet have a copy of the current image. This could be fixed but I think it's not important enough to bother.
* core, vo: modify OSD redraw architecture, support EOSDUoti Urpala2011-12-061-1/+18
| | | | | | | | | | | | | | | | Previously the core sent VFCTRL_REDRAW_OSD to change OSD contents over the current frame. Change this to VFCTRL_REDRAW_FRAME followed by normal EOSD and OSD drawing calls, then vo_flip_page(). The new version supports changing EOSD contents for libass-rendered subtitles and simplifies the redraw support code needed per VO. vo_xv doesn't support EOSD changes because it relies on vf_ass to render EOSD contents earlier in the filter chain. vo_xv logic is additionally simplified because the previous commit removed the need to track the status of current and next images separately (now each frame is guaranteed to become "visible" soon after we receive it as "next", with no VO code running in the interval between).
* vo: do final frame draw only near page flipUoti Urpala2011-12-061-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Separate passing a new frame to VOs using the new API into two steps. The first, vo_draw_image(), happens after a new frame is available from the filter chain. In constrast to old behavior, now the frame is not actually rendered yet at this point (though possible slice draw calls can already reach the VO before). The second step, vo_new_frame_imminent(), happens when we're close enough to the display time of the new frame that we'll commit to flipping it as the next action and will not change the OSD over the previous frame any more. This new behavior fixes a previous problem with vo_vdpau and vo_gl in the situation where the player is paused after decoding a new frame but before flipping it; previously changing OSD in that state would switch to the new frame as a side effect. It would also allow an easy way to fix extra output files produced with something like "--vo=png --frames=1" with precise seeking, but this is not done yet. The code now relies on a new mp_image from the filter chain staying valid even after the vf_vo put_image() call providing it returns. In other words decoders/filters must not deallocate or otherwise invalidate their output frame between passing it forward and returning from the decode/filter call.
* Merge branch 'screenshot' (early part)Uoti Urpala2011-11-251-1/+6
|\
| * core: add infrastructure to get screenshots from VOswm42011-11-251-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a VO command (VOCTRL_SCREENSHOT) which requests a screenshot directly from the VO. If VO support is available, screenshots will be taken instantly (no more 1 or 2 frames delay). Taking screenshots when hardware decoding is in use will also work (vdpau). Additionally, the screenshots will now use the same colorspace as the video display. Change the central MPContext to be allocated with talloc so that it can be used as a talloc parent context. This commit does not yet implement the functionality for any VO (added in subsequent commits). The old screenshot video filter is not needed anymore if VO support is present, and in that case will not be used even if it is present in the filter chain. If VO support is not available then the filter is used like before. Note that the filter still has some of the old problems, such as delaying the screenshot by at least 1 frame.
* | options, core/hrseek: add --hr-seek-demuxer-offsetUoti Urpala2011-11-141-0/+2
| | | | | | | | | | | | | | | | | | | | | | Some demuxers do not accurately seek to a keyframe before a given time but instead start too late. This means that precise seeks cannot work either. Most notably the libavformat mpeg demuxer exhibits this behavior depending on the file being played (with the internal mpeg demuxer precise seeks don't work at all). Add new option --hr-seek-demuxer-offset which can be used as a workaround with such demuxers. The value of the option is subtracted from the seek target position given to the demuxer when doing a precise seek.
* | core/hrseek: support precise seeks in audio-only caseUoti Urpala2011-11-141-4/+18
|/ | | | | | | Before, precise seeking only worked if there was a video stream; in the audio-only case playback always started from the demuxer seek position. Add code to cut away samples from the demuxer seek position to the seek target position.
* core, demux: fix --identify chapter output with ordered chapterswm42011-10-251-15/+50
| | | | | | | | | | | | | | | Information about individual chapters was printed during demuxer opening phase, and total chapter count (ID_CHAPTERS) was printed according to mpctx->demuxer->num_chapters. When playing a file with ordered chapters, this meant that chapter information about every source file was printed individually (even though only the chapters from the first file would be used for playback) and the total chapter count could be wrong. Remove the printing of chapter information from the demuxer layer and print the chapter information and count actually used for playback in core print_file_properties(). Also somewhat simplify the internal chapters API and remove possible inconsistencies.
* libmenu: remove OSD menu functionality (--menu)Uoti Urpala2011-10-251-63/+0
| | | | | | | | | | Something like the OSD menu functionality could be useful. However the current implementation has several problems and would require a relatively large amount of work to get into good shape. As far as I know there are few users of the existing functionality. Nobody is working on the existing code and keeping it compiling at all while changing other code would require extra work. So delete the menu code and some related code elsewhere that's used by nothing else.
* terminal output: show libav version numbers in verbose modeUoti Urpala2011-10-011-0/+1
|
* core: fix --sstepUoti Urpala2011-09-041-1/+1
| | | | | The --step option had broken at some point. Probably nobody uses it, but it was easy to fix.
* cosmetics: mplayer.c: minor tweaksUoti Urpala2011-09-041-21/+8
|
* options: move libass-related options to structUoti Urpala2011-09-031-3/+3
|
* core: remove bad workaround for files without FPS setUoti Urpala2011-08-251-7/+2
| | | | | | | | | | | | | Commit dde8b753e4 merged an mplayer1 change (r31328) that set correct_pts to true if FPS was not set (on the assumption that correct-pts mode could provide proper timing without FPS). As the merge commit noted this change was somewhat questionable, as the option shouldn't really change after things have already been initialized. After recent changes it can cause an outright crash (assert in ds_get_packet2() from 9c7c4e5b7d fails). Remove the hack. Also only print a warning about not having FPS if correct_pts is not set (in correct_pts mode not having FPS shouldn't be a real problem, as everything is based on timestamps anyway).
* core, demux, vd_ffmpeg: pass side data from demux_lavf to vd_ffmpegUoti Urpala2011-08-201-13/+13
| | | | | | | | | | | | Pass the libavformat packet side_data field from demux_lavf to vd_ffmpeg. Libavcodec/libavformat use this field for palette data, and passing it is required for the playback of some paletted video codecs. The implementation works by giving vd_ffmpeg a copy of the struct demux_packet used to store the video packet (from which it can access the avpacket field). The definition of struct demux_packet is moved to new file demux_packet.h so that vd_ffmpeg.c can use it without including all of demuxer.h.
* dvdnav: fix crash caused by missing line from 58834653c0Uoti Urpala2011-08-101-0/+1
| | | | | | The committed version of 58834653c0 ("dvdnav: make mp_dvdnav_save_smpi() more robust") was somehow missing one line which caused a crash with dvdnav. Add it back.
* core: allocate OSD text buffers dynamicallyharklu2011-08-091-14/+12
| | | | | | | The OSD text buffers (mp_osd_msg_t.text and osd_state.text) used to be static arrays, with the buffer sizes spread all over the code as magic constants. Make the buffers dynamically allocated and remove the arbitrary length limits.
*