summaryrefslogtreecommitdiffstats
path: root/audio
Commit message (Collapse)AuthorAgeFilesLines
* ao_null: add untimed sub-optionwm42013-11-131-2/+18
|
* ao_null: support pausing properlywm42013-11-131-4/+14
| | | | | | ao_null should simulate a "perfect" AO, but framestepping behaved quite badly with it. Framstepping usually exposes problems with AOs dropping their buffers on pause, and that's what happened here.
* ao_lavc: support non-interleaved audiowm42013-11-133-232/+42
|
* Merge branch 'planar_audio'wm42013-11-1259-1406/+1460
|\ | | | | | | | | Conflicts: audio/out/ao_lavc.c
| * audio: add support for using non-interleaved audio from decoders directlywm42013-11-127-480/+316
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Most libavcodec decoders output non-interleaved audio. Add direct support for this, and remove the hack that repacked non-interleaved audio back to packed audio. Remove the minlen argument from the decoder callback. Instead of forcing every decoder to have its own decode loop to fill the buffer until minlen is reached, leave this to the caller. So if a decoder doesn't return enough data, it's simply called again. (In future, I even want to change it so that decoders don't read packets directly, but instead the caller has to pass packets to the decoders. This fits well with this change, because now the decoder callback typically decodes at most one packet.) ad_mpg123.c receives some heavy refactoring. The main problem is that it wanted to handle format changes when there was no data in the decode output buffer yet. This sounds reasonable, but actually it would write data into a buffer prepared for old data, since the caller doesn't know about the format change yet. (I.e. the best place for a format change would be _after_ writing the last sample to the output buffer.) It's possible that this code was not perfectly sane before this commit, and perhaps lost one frame of data after a format change, but I didn't confirm this. Trying to fix this, I ended up rewriting the decoding and also the probing.
| * ad_mpg123: reduce ifdefferywm42013-11-121-47/+2
| | | | | | | | Drop support for anything before 1.14.0.
| * dec_audio: fix behavior on format changeswm42013-11-121-3/+1
| | | | | | | | | | Decoder overwrites parameters in sh_audio, but we still have old audio in the old format to filter.
| * mp_audio: use av_malloc (cargo cult for libav*)wm42013-11-122-3/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | libav* is generally freaking horrible, and might do bad things if the data pointer passed to it are not aligned. One way to be sure that the alignment is correct is allocating all pointers using av_malloc(). It's possible that this is not needed at all, though. For now it might be better to keep this, since the mp_audio code is intended to replace another buffer in dec_audio.c, which is currently av_malloc() allocated. The original reason why this uses av_malloc() is apparently because libavcodec used to directly encode into mplayer buffers, which is not the case anymore, and thus (probably) doesn't make sense anymore. (The commit subject uses the word "cargo cult", after all.)
| * ao_jack: switch from interleaved to planar audioWilliam Light2013-11-121-95/+92
| |
| * ao_jack: refactoring, also fix "no-connect" optionWilliam Light2013-11-121-57/+97
| |
| * af_lavcac3enc: use planar formatswm42013-11-121-134/+82
| | | | | | | | | | | | | | | | | | | | | | Remove the awkward planarization. It had to be done because the AC3 encoder requires planar formats, but now we support them natively. Try to simplify buffer management with mp_audio_buffer. Improve checking for buffer overflows and out of bound writes. In theory, these shouldn't happen due to AC3 fixed frame sizes, but being paranoid is better.
| * af_lavcac3enc: simplify format negotiationwm42013-11-121-28/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | The format negotiation is the same, except don't confusingly copy the input format into af->data, just to overwrite it later. af->data should alwass contain the output format, and the existing code was just a very misguided use of the af_test_output() helper function. Just set af->data to the output format immediately, and modify the input format properly. Also, if format negotiation fails (and needs another iteration), don't initialize the libavcodec encoder.
| * audio/filter: fix mul/delay scale and valueswm42013-11-1228-55/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | Before this commit, the af_instance->mul/delay values were in bytes. Using bytes is confusing for non-interleaved audio, so switch mul to samples, and delay to seconds. For delay, seconds are more intuitive than bytes or samples, because it's used for the latency calculation. We also might want to replace the delay mechanism with real PTS tracking inside the filter chain some time in the future, and PTS will also require time-adjustments to be done in seconds. For most filters, we just remove the redundant mul=1 initialization. (Setting this used to be required, but not anymore.)
| * ao_openal: support non-interleaved outputwm42013-11-121-18/+11
| | | | | | | | | | | | Since ao_openal simulates multi-channel audio by placing a bunch of mono-sources in 3D space, non-interleaved audio is a perfect match for it. We just have to remove the interleaving code.
| * ao_alsa: support non-interleaved audiowm42013-11-121-25/+23
| | | | | | | | | | | | | | | | ALSA supports non-interleaved audio natively using a separate API function for writing audio. (Though you have to tell it about this on initialization.) ALSA doesn't have separate sample formats for this, so just pretend to negotiate the interleaved format, and assume that all non-interleaved formats have an interleaved companion format.
| * ao_null: support non-interleaved audiowm42013-11-121-17/+20
| | | | | | | | Simply change internals from using byte counts to sample counts.
| * audio: switch output to mp_audio_bufferwm42013-11-124-47/+32
| | | | | | | | | | | | Replace the code that used a single buffer with mp_audio_buffer. This also enables non-interleaved output operation, although it's still disabled, and no AO supports it yet.
| * audio: add mp_audio_bufferwm42013-11-122-0/+196
| | | | | | | | | | | | Implementation wise, this could be much improved, such as using a ringbuffer that doesn't require copying data all the time. This is why we don't use mp_audio directly instead of mp_audio_buffer.
| * audio/out: prepare for non-interleaved audiowm42013-11-1217-85/+92
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This comes with two internal AO API changes: 1. ao_driver.play now can take non-interleaved audio. For this purpose, the data pointer is changed to void **data, where data[0] corresponds to the pointer in the old API. Also, the len argument as well as the return value are now in samples, not bytes. "Sample" in this context means the unit of the smallest possible audio frame, i.e. sample_size * channels. 2. ao_driver.get_space now returns samples instead of bytes. (Similar to the play function.) Change all AOs to use the new API. The AO API as exposed to the rest of the player still uses the old API. It's emulated in ao.c. This is purely to split the commits changing all AOs and the commits adding actual support for outputting N-I audio.
| * af: don't require filters to allocate af_instance->data, redo bufferswm42013-11-1227-211/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | Allocate af_instance->data in generic code before filter initialization. Every filter needs af->data (since it contains the output configuration), so there's no reason why every filter should allocate and free it. Remove RESIZE_LOCAL_BUFFER(), and replace it with mp_audio_realloc_min(). Interestingly, most code becomes simpler, because the new function takes the size in samples, and not in bytes. There are larger change in af_scaletempo.c and af_lavcac3enc.c, because these had copied and modified versions of the RESIZE_LOCAL_BUFFER macro/function.
| * af_lavfi: add support for non-interleaved audiowm42013-11-121-30/+24
| |
| * af_volume: add support for non-interleaved audiowm42013-11-121-16/+25
| |
| * af_lavrresample: add support for non-interleaved audiowm42013-11-121-27/+45
| |
| * audio/out: reject non-interleaved formatswm42013-11-1213-1/+25
| | | | | | | | | | | | | | | | | | | | No AO can handle these, so it would be a problem if they get added later, and non-interleaved formats get accepted erroneously. Let them gracefully fall back to other formats. Most AOs actually would fall back, but to an unrelated formats. This is covered by this commit too, and if possible they should pick the interleaved variant if a non-interleaved format is requested.
| * audio/filter: prepare filter chain for non-interleaved audiowm42013-11-1228-177/+332
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Based on earlier work by Stefano Pigozzi. There are 2 changes: 1. Instead of mp_audio.audio, mp_audio.planes[0] must be used. 2. mp_audio.len used to contain the size of the audio in bytes. Now mp_audio.samples must be used. (Where 1 sample is the smallest unit of audio that covers all channels.) Also, some filters need changes to reject non-interleaved formats properly. Nothing uses the non-interleaved features yet, but this is needed so that things don't just break when doing so.
| * audio/format: add non-interleaved audio formatswm42013-11-123-2/+75
| |
* | demux_mkv: support some raw PCM variantswm42013-11-111-23/+11
| | | | | | | | | | | | | | | | | | | | This affects 64 bit floats and big endian integer PCM variants (basically crap nobody uses). Possibly not all MS-muxed files work, but I couldn't get or produce any samples. Remove a bunch of format tags that are not needed anymore. Most of these were used by demux_mov, which is long gone. Repurpose/abuse 'twos' as mpv-internal tag for dealing with the PCM variants mentioned above.
* | ao_lavc: remove audio offset hack to ease supporting planar audio.Rudolf Polzer2013-11-111-66/+11
|/ | | | | | | | Now to shift audio pts when outputting to e.g. avi, you need an explicit facility to insert/remove initial samples, to avoid initial regions of the video to be sped up/slowed down. One such facility is the delay filter in libavfilter.
* ao: add ao_play_silence, use for ao_alsa and ao_osswm42013-11-106-13/+31
| | | | | Also add a corresponding function to audio/format.c, which fills an audio block with silence.
* af: don't skip filtering if there's no more audiowm42013-11-102-3/+5
| | | | | | | | | | | | | | My main problem with this is that the output format will be incorrect. (This doesn't matter right, because there are no samples output.) This assumes all audio filters can deal with len==0 passed in for filtering (though I wouldn't see why not). A filter can still signal an error by returning NULL. af_lavrresample has to be fixed, since resampling 0 samples makes libavresample fail and return a negative error code. (Even though it's not documented to return an error code!)
* ad_spdif: change API usage so that it works on Libavwm42013-11-101-3/+9
| | | | | | | | | | | Apparently we were using FFmpeg-specific APIs. I have no idea whether this code is correct on both FFmpeg and Libav (no examples, bad doxygen... why do they even complaint aht people are using their APIs incorrectly?), but it appears to work on FFmpeg. That was also the case before commit ebc4ccb though, where it used internal libavformat symbols. Untested on Libav, Travis will tell us.
* player: set PulseAudio stream title to window titlewm42013-11-102-0/+15
| | | | | | | Set the PulseAudio stream title, just like the VO window title is set. Refactor update_vo_window_title() so that we can use it for AOs too. The ao_pulse.c bit is stolen from MPlayer.
* af_volume: use only one volume setting for all channelswm42013-11-092-34/+22
| | | | | | | | In theory, af_volume could use separate volume levels for each channel. But this was never used anywhere. MPlayer implemented something similar before (svn r36498), but kept the old path for some reason.
* ao_alsa: use correct magic spdif flagswm42013-11-091-14/+11
| | | | | I accidentally copied the AES4/ORIGFS constants from the ALSA headers, instead of the AES3/FS ones. The difference is probably important.
* Remove sh_audio->samplesizewm42013-11-093-8/+3
| | | | | | | | | This member was redundant. sh_audio->sample_format indicates the sample size already. The TV code is a bit strange: the redundant sample size was part of the internal TV interface. Assume it's really redundant and not something else. The PCM decoder ignores the sample size anyway.
* af_scaletempo: uncrustifywm42013-11-091-404/+388
| | | | | | | | | Also do some cosmetic changes, like merging definition and initialization of local variables. Remove an annoying debug mp_msg() from af_open(). It just printed the command line parameters; if this is really needed, it could be added to af.c instead (similar as to what vf.c does).
* af_lavrresample: reconfigure libavresample only on successful initwm42013-11-091-7/+6
| | | | | If filter initialization fails anyway, we don't need to reconfigure libavresample.
* af_lavrresample: move libavresample setup to separate functionwm42013-11-091-90/+98
| | | | | | | Helps with readability. Also remove the ctx_opt_set_* helper macros and use av_opt_set_* directly (I think these macros were used because the lines ended up too long, but this commit removes two indentation levels, giving more space).
* af_convert24: fix complicated and incorrect format negotiationwm42013-11-091-9/+4
| | | | | The conversion works for native endian only. The correct check lists supported format combination explicitly, but is also much simpler.
* af_surround: fix format negotiationwm42013-11-091-12/+9
| | | | This did strange things; perhaps caused by the channel layout changes.
* af: allow filters to return AF_OK, even if format doesn't matchwm42013-11-091-0/+2
| | | | | | | This should allow to make format negotiation much simpler, since it takes the responsibility to compare actual input and accepted input formats from the filters. It's also backwards compatible. Filters which have expensive initialization still can use the old method.
* ao: print requested audio format on initwm42013-11-093-6/+4
| | | | Also remove the rather bad/incomplete log calls from ao_alsa and ao_oss.
* ao_alsa: add magic spdif parameterswm42013-11-091-1/+25
| | | | | | | | | | | | | | I have no idea what these do, but apparently they are needed to inform ALSA about spdif configuration. First, replace the literal constant "6" for the AES0 parameter with the symbolic constants from the ALSA headers (the final value is the same). Second, copy paste some funky looking parameter setup from VLC's alsa output for setting the AES1, AES2, AES3 parameters. (The code is actually not literally copy-pasted, but does exactly the same.) My small but non-zero hope is that this could make DTS-HD work, or at least work into that direction. I can't test spdif stuff though, and for DTS-HD not even opening the ALSA device succeeds on my system.
* ao_alsa: redo the way parameters are added in the spdif casewm42013-11-091-38/+24
| | | | | | | | | | | Using spdif with alsa requires adding magic parameters to the device name, and the existing code tried to deal with the situation when the user wanted to add parameters too. Rewrite this code, in particular remove the duplicated parameter string as preparation for the next commit. The new code is a bit stricter, e.g. it doesn't skip spaces before and after '{' and '}'. (Just don't add spaces.)
* ad_spdif: fix libavformat API usagewm42013-11-091-107/+76
| | | | | | | This accessed tons of private libavformat symbols all over the place. Don't do this and convert all code to proper public APIs. As a consequence, the code becomes shorter and cleaner (many things the code tried are done by libavformat APIs).
* af: always remove auto-inserted filters, improve error messagewm42013-11-091-4/+3
| | | | | | | | | | It's probably better if all auto-inserted filters are removed when doing an af_add operation. If they're really needed, they will be automatically re-added. Fix the error message. It used to be for an actual internal error, but now it happens when format negotiation fails, e.g. when trying to use spdif and real audio filters.
* audio: don't let ao_lavc access frontend internals, change gapless audiowm42013-11-083-35/+33
| | | | | | | | | | | | | | | | | | | | | | | ao_lavc.c accesses ao->buffer, which I consider internal. The access was done in ao_lavc.c/uninit(), which tried to get the left-over audio in order to write the last (possibly partial) audio frame. The play() function didn't accept partial frames, because the AOPLAY_FINAL_CHUNK flag was not correctly set, and handling it otherwise would require an internal FIFO. Fix this by making sure that with gapless audio (used with encoding), the AOPLAY_FINAL_CHUNK is set only once, instead when each file ends. Basically, move the hack in ao_lavc's uninit to uninit_player. One thing can not be entirely correctly handled: if gapless audio is active, we don't know really whether the AO is closed because the file ended playing (i.e. we want to send the buffered remainder of the audio to the AO), or whether the user is quitting the player. (The stop_play flag is overwritten, fixing that is perhaps not worth it.) Handle this by adding additional code to drain the AO and the buffers when playback is quit (see play_current_file() change). Test case: mpv avdevice://lavfi:sine=441 avdevice://lavfi:sine=441 -length 0.2267 -gapless-audio
* audio: stop "unsupported sample format" spamwm42013-11-071-6/+1
| | | | | | | It spams these in verbose mode. It's caused by format negotiation code in af.c. It's for the mpv format to ffmpeg-format case, and that one is very uninteresting. (The ffmpeg supported audio formats are practically never extended.)
* audio: fix bogus audio format comparisonwm42013-11-071-1/+1
|
* af: remove a pointless macrowm42013-11-072-28/+16
| | | | | The code should be equivalent; a compatibility macro definition is left. (It should be mass-replaced later.)
* audio/format: convert format macros to enum, drop NE suffixwm42013-11-072-95/+96
| | | | | | | | | | Turn the sample format definitions into an enum. (The format bits are still macros.) The native endian versions of the new definitions don't have a NE suffix anymore, although there are still compatibility defines since too much code uses the NE variants. Rename the format bits for special formats to help to distinguish them from the actual definitions, e.g. AF_FORMAT_AC3 to AF_FORMAT_S_AC3.
* audio: replace af_fmt2str_short -> af_fmt_to_strwm42013-11-0713-34/+22
| | | | Also, remove all af_fmt2str usages.
* audio/format: reformatwm42013-11-072-58/+56
|
* ao_oss: fix previous ao_oss commitwm42013-11-061-1/+0
| | | | | Basically I introduced an inverted condition, and the line removed was inactive before commit ce72aaa.
* ao_oss: hide warningwm42013-11-061-2/+2
|