summaryrefslogtreecommitdiffstats
path: root/audio
Commit message (Collapse)AuthorAgeFilesLines
* ao_wasapi: fix includeswm42013-12-181-3/+2
| | | | Broken due to recent header renaming. Untested.
* ad_lavc: work around deprecation warningwm42013-12-181-1/+4
| | | | | | | | | | request_channels has been deprecated for years (request_channel_layout is the replacement), but it appears it's still needed despite the deprecation at least on older libavcodec versions. So still set request_channels, but to it with the avoption API, which hides the deprecation warning. This should also prevent mpv getting trashed when libavcodec happens to bump its major version.
* Reduce recursive config.h inclusions in headerswm42013-12-184-4/+4
| | | | | | In my opinion, config.h inclusions should be kept to a minimum. MPlayer code really liked including config.h everywhere, though, even in often used header files. Try to reduce this.
* Remove the _ macrowm42013-12-181-0/+2
| | | | | This was a gettext-style macro to mark strings that should be translated.
* Split mpvcore/ into common/, misc/, bstr/wm42013-12-1744-60/+60
|
* Merge mp_talloc.h into ta/ta_talloc.hwm42013-12-171-1/+1
|
* Move options/config related files from mpvcore/ to options/wm42013-12-1725-28/+28
| | | | | | | | | Since m_option.h and options.h are extremely often included, a lot of files have to be changed. Moving path.c/h to options/ is a bit questionable, but since this is mainly about access to config files (which are also handled in options/), it's probably ok.
* Move mpvcore/input/ to input/wm42013-12-171-1/+1
|
* Replace mp_tmsg, mp_dbg -> mp_msg, remove mp_gtext(), remove set_osd_tmsgwm42013-12-167-23/+23
| | | | | | | | | 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.
* ao_wasapi: Fix mistaken behavior on uninitDiogo Franco (Kovensky)2013-12-081-2/+2
| | | | | The parameter, when true, tells whether uninit should block for flushing the buffers, not whether it should quit immediately without flushing.
* ao_wasapi: handle AOPLAY_FINAL_CHUNKDiogo Franco (Kovensky)2013-12-081-2/+6
| | | | | Used for writing down all samples to the audio driver, even if it's not a full chunk; needed at EOF on weird files.
* ao_wasapi: Reduce the buffer size to a sane valueDiogo Franco (Kovensky)2013-12-081-1/+1
| | | | | | | The previous RING_BUFFER_COUNT value, 64, would have ao_wasapi buffer 64 frames of audio in the ring buffer; a delay of 1280ms, which is clearly overkill for everything. A value of 8 buffers 8 frames for a total of 160ms.
* ao_wasapi: fix audio buffering delay calculationDiogo Franco (Kovensky)2013-12-081-1/+1
| | | | | | | | When get_space was converted to returning samples instead of bytes, a unit type mismatch in get_delay's calculation returned bogus values. Fix by converting get_space's value back to bytes. Fixes playback with ao_wasapi when reaching EOF, or seeking past it.
* mixer: remove comment about af_pan doing downmixingwm42013-12-071-3/+1
| | | | We don't do that anymore.
* audio: flush remaining data from the filter chain on EOFwm42013-12-052-3/+7
| | | | | | | | | | | | | | | | | This can be reproduced with: mpv short.wav -af 'lavfi="aecho=0.8:0.9:5000|6800:0.3|0.25"' An audio file that is just 1-2 seconds long should play for 8-9 seconds, which audible echo towards the end. The code assumes that when playing with AF_FILTER_FLAG_EOF, the filter will either produce output, or has all remaining data flushed. I'm not really sure whether this really works if there are multiple filters with EOF handling in the chain. To handle it correctly, af_lavfi should retry filtering if 1. EOF flag is set, 2. there were input samples, and 3. no output samples were produced. But currently it seems to work well enough anyway.
* audio/filter: change filter callback signaturewm42013-12-0528-152/+152
| | | | | | | | | The new signature is actually closer to how it actually works, and someone who is not familiar to the API and how it works might make fewer fatal mistakes with the new signature than the old one. Pretty weird. Do this to sneak in a flags parameter, which will later be used to flush remaining data of at least vf_lavfi.
* ad_lavc: handle decoder EAGAIN only if there was an input packetwm42013-12-041-3/+3
| | | | | Otherwise, it'd probably get stuck if the decoder still returns EAGAIN at EOF on e.g. a shortened data stream.
* af: remove af->setup fieldwm42013-12-043-9/+7
| | | | Used to be used by filters that didn't use the option parser.
* af: remove legacy option parsing hackswm42013-12-042-10/+2
|
* af_pan: change options, use option parserwm42013-12-041-42/+38
| | | | Similar to af_channels etc...
* af_ladspa: change options, use option parserwm42013-12-041-158/+103
|
* af_delay: change option parsing, fix bugs, use option parserwm42013-12-041-27/+36
| | | | Similar situation to af_channels.
* af_channels: use "unknown" channel layoutswm42013-12-041-2/+4
| | | | | | | | | This will make af_channels output a channel layout that is compatible with any destination layout. Not sure if that's a good idea though, since the way the AO choses a layout is perhaps less predictable. On the other hand, using the old MPlayer standard layouts doesn't make much sense either. We'll see whether this improves or breaks someone's use case.
* af_channels: change options, fix bugs, use option parserwm42013-12-041-65/+45
| | | | | | | Apparently this stopped working after some planar changes (broken format negotiation). Radically change option parsing in an incompatible way. Suggest alternatives to this filter, since it barely has any importance anymore.
* af_sweep: use option parserwm42013-12-041-16/+7
|
* af_surround: use option parserwm42013-12-041-24/+8
|
* af_sub: use option parserwm42013-12-041-36/+9
|
* af_sinesuppress: use option parserwm42013-12-041-24/+8
|
* af_hrtf: use option parserwm42013-12-041-34/+23
|
* af_extrastereo: use option parserwm42013-12-041-22/+8
|
* af_export: use option parserwm42013-12-041-48/+16
| | | | Probably requires the user to quote the shared buffer filename.
* af_equalizer: use option parserwm42013-12-041-26/+17
|
* af_drc: use option parserwm42013-12-041-35/+18
|
* af_center: use option parserwm42013-12-041-27/+8
|
* af: returning NULL on filtering means errorwm42013-12-041-2/+4
| | | | | | This code used to be ok, until the assert() was added. Simplify the loop statement, since the other NULL check for data doesn't make sense anymore.
* ad_lavc: expose an option to enable threadingwm42013-12-041-0/+3
|
* ad_lavc: deal with arbitrary decoder delaywm42013-12-041-16/+24
| | | | | | | | | | | | | | | | | | | | Normally, audio decoder don't have a decoder delay, so the code was fine. But FFmpeg supports multithreaded decoding for some audio codecs, which introduces such a delay. The delay means that we won't get decoded audio for the first few packets, and that we need to do something to get the trailing audio still buffered in the decoder when reaching EOF. Two changes are needed to deal with the delay: - If EOF is reached, pass a "flush" packet to the decoder to return the buffered audio. Such a flush packet is automatically setup when calling mp_set_av_packet() with a NULL packet. - Use the PTS returned by the decoder, instead of the packet's. This is important to get correct timestamps for decoded audio. Ignoring this would result into offsetting the audio playback time by the decoder delay. Note that we can still use the timestamp of the first packet to get the timestamp for the start of the audio.
* av_common: add timebase parameter to mp_set_av_packet()wm42013-12-042-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | If the timebase is set, it's used for converting the packet timestamps. Otherwise, the previous method of reinterpret-casting the mpv style double timestamps to libavcodec style int64_t timestamps is used. Also replace the kind of awkward mp_get_av_frame_pkt_ts() function by mp_pts_from_av(), which simply converts timestamps in a way the old function did. (Plus it takes a timebase parameter, similar to the addition to mp_set_av_packet().) Note that this should not change anything yet. The code in ad_lavc.c and vd_lavc.c passes NULL for the timebase parameters. We could set AVCodecContext.pkt_timebase and use that if we want to give libavcodec "proper" timestamps. This could be important for ad_lavc.c: some codecs (opus, probably mp3 and aac too) have weird requirements about doing decoding preroll on the container level, and thus require adjusting the audio start timestamps in some cases. libavcodec doesn't tell us how much was skipped, so we either get shifted timestamps (by the length of the skipped data), or we give it proper timestamps. (Note: libavcodec interprets or changes timestamps only if pkt_timebase is set, which by default it is not.) This would require selecting a timebase though, so I feel uncomfortable with the idea. At least this change paves the way, and will allow some testing.
* ao_oss: when falling back from unknown prefer larger formatbugmen0t2013-12-041-0/+16
|
* ao_oss: add 24bit formatsbugmen0t2013-12-041-0/+12
|
* options: add options that set defaults for af/vf/ao/vowm42013-12-013-1/+4
| | | | | | | | There are some use cases for this. For example, you can use it to set defaults of automatically inserted filters (like af_lavrresample). It's also useful if you have a non-trivial VO configuration, and want to use --vo to quickly change between the drivers without repeating the whole configuration in the --vo argument.
* Use O_CLOEXEC when creating FDswm42013-11-301-1/+3
| | | | | | | | | | | | | | This is needed so that new processes (created with fork+exec) don't inherit open files, which can be important for a number of reasons. Since O_CLOEXEC is relatively new (POSIX.1-2008, before that Linux specific), we #define it to 0 in io.h to prevent compilation errors on older/crappy systems. At least this is the plan. input.c creates a pipe. For that, add a mp_set_cloexec() function (which is based on Weston's code in vo_wayland.c, but more correct). We could use pipe2() instead, but that is Linux specific. Technically, we have a race condition, but it won't matter.
* ao_oss: add 6.1 and 7.1 speaker placement from FreeBSDbugmen0t2013-11-301-1/+15
|
* ao_oss: SNDCTL_DSP_CHANNELS takes int, not uint8_twm42013-11-301-2/+3
| | | | | | | This caused weird issue, probably caused by setting up the wrong number of channels, or similar. See github issue #383. Patch by bugmen0t on github.
* ao_alsa: remove unneeded checkswm42013-11-301-19/+11
| | | | | If initialization succeeds, p->alsa should always be set. Additional checks are not needed, and also this wasn't even done consistently.
* ao_alsa: enable "plug" for non-interleaved float formats toowm42013-11-301-2/+1
| | | | | | I have no idea what this code does, but it seems logical it should be active for all float formats, not just for float with interleaved access.
* ao_alsa: disable ALSA resampling by default againwm42013-11-291-0/+9
| | | | | | | | | | | | | | | | | | | | | This partially reverts commit 7d152965. It turns out that at least some ALSA drivers (at least snd-hda-intel) report incorrect audio delay with non-native sample rates, even if the sample rate is only very slightly different from the native one. For example, 48000Hz is fine on my hda-intel system, while both 8000Hz and 47999Hz lead to a delay off by 40ms (according to mpv's A/V difference display), which suggests that something in ALSA is calculating the delay using the wrong sample rate. As an additional problem, with ALSA resampling enabled, using 48001Hz/float/2ch fails, while 49000Hz/float/2ch or 48001Hz/s16/2ch work. With resampling disabled, all these cases work obviously, because our own resampler doesn't just refuse any of these formats. Since some people want to use the ALSA resampler (because it's highly configurable, supports multiple backends, etc.), we still allow enabling ALSA resampling with an ao_alsa suboption.
* ao_coreaudio: simplify ch label to speaker id conversionStefano Pigozzi2013-11-271-23/+37
| | | | | | | | Previous code was using the values of the AudioChannelLabel enum directly to create the channel bitmap. While this was quite smart it was pretty unreadable and fragile (what if Apple changes the values of those enums?). Change it to use a 'dumb' conversion table.
* af_lavi: actually free the filter graph on uninitwm42013-11-271-5/+1
| | | | | | | This was a memory leak. Also remove the AF_CONTROL_COMMAND_LINE code, which was inactive. (It's never called if the new option parser is used.)
* Move some code from player to audio/video reset functionswm42013-11-271-2/+6
|
* cosmetics: rename video/audio reset functionswm42013-11-275-7/+7
| | | | | | | | | | These used the suffix _resync_stream, which is a bit misleading. Nothing gets "resynchronized", they really just reset state. (Some audio decoders actually used to "resync" by reading packets for resuming playback, but that's not the case anymore.) Also move the function in dec_video.c to the top of the file.
* ao_coreaudio: map channel labels needed for 8ch layoutsStefano Pigozzi2013-11-271-4/+30
| | | | | | The code stopped at kAudioChannelLabel_TopBackRight and missed mapping for 5 more channel labels. These are in a completely different order that the mpv ones so they must be mapped manually.
* audio: better rejection of invalid formatswm42013-11-274-20/+28
| | | | | | | | | This includes the case when lavc decodes audio with more than 8 channels, which our audio chain currently does not support. the changes in ad_lavc.c are just simplifications. The code tried to avoid overriding global parameters if it found something invalid, but that is not needed anymore.
* ao_alsa: do not forcibly disable ALSA resamplingMartin Herkt2013-11-261-6/+0
| | | | | | | | Resampling with non-ancient ALSA setups works fine, so there is no need to keep this around. Furthermore, as of writing, the default builtin resampler used by many ALSA setups (taken from libspeex) actually has higher quality than the default resampling modes of avresample and swresample.
* ad_lavc: increase number of packets for initial decodewm42013-11-261-2/+5
| | | | | | | | | | | Apparently just 5 packets is not enough for the initial audio decode (which is needed to find the format). The old code (before the recent refactor) appeared to use 5 packets, but there were apparently other code paths which in the end amounted to more than 5 packets being read. The sample that failed (see github issue #368) needed 9 packets. Fixes #368.
* ao_rsound: fix option typeswm42013-11-231-2/+2
| | | | | | These are option values, and the option code expects char*. Not actually tested.
* demux: remove gsh field from sh_audio/sh_video/sh_subwm42013-11-231-6/+7
| | | | | | | | | This used to be needed to access the generic stream header from the specific headers, which in turn was needed because the decoders had access only to the specific headers. This is not the case anymore, so this can finally be removed again. Also move the "format" field from the specific headers to sh_stream.
* audio: remove ad_driver.preinitwm42013-11-236-34/+13
| | | | | This never had any real use. Get rid of dec_audio.initialized too, as it's redundant.
* audio: don't write decoded audio format to sh_audiowm42013-11-235-47/+42
| | | | | | | | sh_audio is supposed to contain file headers, not whatever was decoded. Fix this, and write the decoded format to separate fields in the decoder context, the dec_audio.decoded field. (Note that this field is really only needed to communicate the audio format from decoder driver to the generic code, so no other code accesses it.)
* audio: move decoder context from sh_audio into new structwm42013-11-236-191/+219
| | | | | | | | | Move all state that basically changes during decoding or is needed in order to manage decoding itself into a new struct (dec_audio). sh_audio (defined in stheader.h) is supposed to be the audio stream header. This should reflect the file headers for the stream. Putting the decoder context there is strange design, to say the least.
* ao_null: fix simulated buffer sizewm42013-11-191-1/+1
| | | | | The size accidentally defaulted to 200 seconds instead of 200 milliseconds, which had fatal consequences when trying to use it.
* audio/filter: rename af_tools.c to tools.cwm42013-11-181-0/+0
| | | | This always bothered me.
* audio: drop buffered filter data when seekingwm42013-11-184-0/+25
| | | | | This could lead to (barely) audible artifacts with --af=scaletempo and modified playback speed.
* audio/filter: remove unneeded AF_CONTROLs, convert to enumwm42013-11-1815-247/+73
| | | | | | | | The AF control commands used an elaborate and unnecessary organization for the command constants. Get rid of all that and convert the definitions to a simple enum. Also remove the control commands that were not really needed, because they were not used outside of the filters that implemented them.
* af: cleanup documentation commentswm42013-11-183-139/+22
| | | | | | And by "cleanup", I mean "remove". Actually, only remove the parts that are redundant and doxygen noise. Move useful parts to the comment above the function's implementation in the C source file.
* audio: use the decoder buffer's format, not sh_audiowm42013-11-181-2/+2
| | | | | | | | | | | | | | | | | | When the decoder detects a format change, it overwrites the values stored in sh_audio (this affects the members sample_format, samplerate, channels). In the case when the old audio data still needs to be played/filtered, the audio format as identified by sh_audio and the format used for the decoder buffer can mismatch. In particular, they will mismatch in the very unlikely but possible case the audio chain is reinitialized while old data is draining during a format change. Or in other words, sh_audio might contain the new format, while the audio chain is still configured to use the old format. Currently, the audio code (player/audio.c and init_audio_filters) access sh_audio to get the current format. This is in theory incorrect for the reasons mentioned above. Use the decoder buffer's format instead, which should be correct at any point.
* audio: fix mid-stream audio reconfigurationwm42013-11-183-1/+12
| | | | | | | | | | | | | | | | | | | | | Commit 22b3f522 not only redid major aspects of audio decoding, but also attempted to fix audio format change handling. Before that commit, data that was already decoded but not yet filtered was thrown away on a format change. After that commit, data was supposed to finish playing before rebuilding filters and so on. It was still buggy, though: the decoder buffer was initialized to the new format too early, triggering an assertion failure. Move the reinit call below filtering to fix this. ad_mpg123.c needs to be adjusted so that it doesn't decode new data before the format change is actually executed. Add some more assertions to af_play() (audio filtering) to make sure input data and configured format don't mismatch. This will also catch filters which don't set the format on their output data correctly. Regression due to planar_audio branch.
* af_lavrresample: set cutoff as double, not intwm42013-11-171-1/+1
| | | | Regression introduced with commit a89549e8.
* ao_