summaryrefslogtreecommitdiffstats
path: root/audio
Commit message (Collapse)AuthorAgeFilesLines
* build: add preliminary LGPL modewm42017-09-211-2/+2
| | | | | | | See "Copyright" file for caveats. This changes the remaining "almost LGPL" files to LGPL, because we think that the conditions the author set for these was finally fulfilled.
* audio: make libaf derived code optionalwm42017-09-214-3/+9
| | | | | | | | | | | | | | | This code could not be relicensed. The intention was to write new filter code (which could handle both audio and video), but that's a bit of work. Write some code that can do audio conversion (resampling, downmixing, etc.) without the old audio filter chain code in order to speed up the LGPL relicensing. If you build with --disable-libaf, nothing in audio/filter/* is compiled in. It breaks a few features, such as --volume, --af, pitch correction on speed changes, replaygain. Most likely this adds some bugs, even if --disable-libaf is not used. (How the fuck does EOF notification work again anyway?)
* audio: move libswresample wrapper out of audio filter codewm42017-09-219-461/+773
| | | | | | | | | Move it from af_lavrresample.c to a new aconverter.c file, which is independent from the filter chain code. It also doesn't use mp_audio, and thus has no GPL dependencies. Preparation for later commits. Not particularly well tested, so have fun.
* audio_buffer: remove dependency on mp_audiowm42017-09-213-125/+112
| | | | | | | | | Just reimplement it in some way, as mp_audio is GPL-only. Actually I wanted to get rid of audio_buffer.c completely (and instead have a list of mp_aframes), but to do so would require rewriting some more player core audio code. So to get this LGPL relicensing over quickly, just do some extra work.
* audio: fix spdif modewm42017-08-231-2/+2
| | | | | Not sure how this was not caught before. It crashed when trying to use spdif mode.
* ao_rsound: allow setting the hostwm42017-08-211-0/+3
| | | | | | | | Completely untested (rsound dev libs unavailable on my system). Trivial enough that it's very likely that it'll just work. No port selection, but could be added by parsing it as part of the device name. Should fix #4714.
* audio: fix uninitialized data accesswm42017-08-181-0/+1
| | | | | | dst was not supposed to be initialized, the mp_audio_ setters (which initialize dst's fields) assume it is -> shit happens. Regression from recent changes. Was probably harmless.
* audio: fix build on Libavwm42017-08-161-0/+1
| | | | Sigh...
* audio: introduce a new type to hold audio frameswm42017-08-1611-67/+591
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is pretty pointless, but I believe it allows us to claim that the new code is not affected by the copyright of the old code. This is needed, because the original mp_audio struct was written by someone who has disagreed with LGPL relicensing (it was called af_data at the time, and was defined in af.h). The "GPL'ed" struct contents that surive are pretty trivial: just the data pointer, and some metadata like the format, samplerate, etc. - but at least in this case, any new code would be extremely similar anyway, and I'm not really sure whether it's OK to claim different copyright. So what we do is we just use AVFrame (which of course is LGPL with 100% certainty), and add some accessors around it to adapt it to mpv conventions. Also, this gets rid of some annoying conventions of mp_audio, like the struct fields that require using an accessor to write to them anyway. For the most part, this change is only dumb replacements of mp_audio related functions and fields. One minor actual change is that you can't allocate the new type on the stack anymore. Some code still uses mp_audio. All audio filter code will be deleted, so it makes no sense to convert this code. (Audio filters which are LGPL and which we keep will have to be ported to a new filter infrastructure anyway.) player/audio.c uses it because it interacts with the old filter code. push.c has some complex use of mp_audio and mp_audio_buffer, but this and pull.c will most likely be rewritten to do something else.
* af_lavrresample: don't call swr_set_compensation() unless necessarywm42017-08-121-5/+9
| | | | | | | | | | | | | | This was _always_ called, even if the resampling was static, or the filter was inserted for format conversion only. This should have been fine, as I expected the function not to enable resampling when the compensation is unset, and the source/target rates are the same. But this is not the case, and it always enables resampling. So explicitly avoid the call. If we have already called it successfully, it's better not do avoid it (to overwrite the previous compensation value), but it will also be cheap/no-op then. Probably fixes #4716.
* ao_wasapi: remove old commentKevin Mitchell2017-08-071-1/+1
|
* ao_wasapi: reorganize wasapi.hKevin Mitchell2017-08-072-12/+8
| | | | | Remove dead declarations. Move macro only used in wasapi_utils.c closer to use. Rearrange declaration order.
* ao_wasapi: deduplicate wasapi sample format selectionKevin Mitchell2017-08-071-49/+40
|
* ao_wasapi: clean up find_formats logicKevin Mitchell2017-08-071-75/+45
| | | | | There were too many functions within functions, too much going on in if clauses and duplicated code. Fix it.
* ao_wasapi: return bool instead of HRESULT from thread_initKevin Mitchell2017-08-073-38/+48
| | | | | | | | Any bad HRESULTs should have been printed already and lots of failure modes don't have an HRESULT leading to awkward hr = E_FAIL business. This also checks the exit status of GetBufferSize in the align hack. A final fatal message is added if either of the retry hacks fail.
* ao_oss: fix a dumb calculationwm42017-07-211-2/+3
| | | | | | | period_size used the wrong unit, and even if the unit had been correct, was assigned the wrong value. Probably fixes #4642.
* Replace remaining avcodec_close() callswm42017-07-162-8/+2
| | | | | | | | This API isn't deprecated (yet?), but it's still inferior and harder to use than avcodec_free_context(). Leave the call only in 1 case in af_lavcac3enc.c, where we apparently seriously close and reopen the encoder for whatever reason.
* ao_wasapi: remove redundant / outdated commentKevin Mitchell2017-07-101-1/+0
| | | | | Where this was moved from, it made slightly more sense. Here what the comment is trying to say is already pretty obvious from the code.
* ao_waspi: use switch for handling fix_format errorsKevin Mitchell2017-07-101-5/+8
|
* ao_wasapi: don't repeat format negotiation on align hackKevin Mitchell2017-07-101-4/+7
| | | | | Even if it did return a different result, the bufferFrameCount from the align hack would be wrong anyway.
* ao_wasapi: fix leak on align hackKevin Mitchell2017-07-101-1/+1
|
* ad_spdif: minor cleanupswm42017-07-101-3/+5
| | | | | | | | Use avcodec_free_context() unstead of random other calls. Actually it was already used in the second case, but calling avcodec_close() is redundant. Don't crash if allocating a codec context fails.
* audio/out: fix comment typoKevin Mitchell2017-07-091-1/+1
|
* ao_wasapi: enable packed 24 bit outputKevin Mitchell2017-07-091-1/+1
|
* audio/out: correct copy length in ao_read_data_convertedKevin Mitchell2017-07-091-6/+7
| | | | | | | | | | | | | Previously, the entire convert_buffer was being copied to the desination without regard to the fact that it may be packed and therefore smaller. The allocated conversion buffer was also way to big bytes * (channels * samples) ** 2 instead of bytes * channels * samples
* ao_wasapi: reorder channels and samplerates to speed up searchKevin Mitchell2017-07-091-4/+4
| | | | | | | This shouldn't affect which are chosen, but it should speed up the search by putting more common configurations earlier so that a working sample format and sample rates can be found sooner obviating the need to search them for each iteration of the outer loops.
* ao_wasapi: minor cosmetic fixesKevin Mitchell2017-07-091-3/+3
|
* ao_wasapi: try correct initial formatKevin Mitchell2017-07-091-1/+4
| | | | | | | | | The loop to select the native wasapi_format for the incoming audio was not breaking correctly when it found the most desirable format. It therefore executed completely leaving the least desirable format (u8) as the choice. fixes #4582
* audio: drop AF_FORMAT_S24wm42017-07-073-44/+2
| | | | | | | | | | | This is the last sample format that was only in mpv and not in FFmpeg (except the spdif special formats). It was a huge pain, even if the removed code in af_lavrresample is pretty small after all. Note that this drops S24 from the ao_coreaudio AOs too. I'm not sure about the impact, but I expect it doesn't matter. af_fmt_change_bytes() was unused as well, so remove that too.
* ao_pcm: drop AF_FORMAT_S24 usagewm42017-07-071-1/+0
| | | | | | | I'd actually be somewhat interested in supporting this, as it could help testing the S24 conversion code. But then again it's only a pain, there's no immediate need, and it would require new options to make ao_pcm.c select this output format at all.
* ao_oss: drop AF_FORMAT_S24 usagewm42017-07-071-7/+0
| | | | Can't test / don't care.
* ao_sndio: drop AF_FORMAT_S24 usagewm42017-07-071-3/+0
| | | | | | I can't test it, so I'm dropping it without replacement. If anyone is interested in readding support, it would be done like the ao_alsa.c change.
* ao_wasapi_utils: be slightly more clever when converting channel mapwm42017-07-071-0/+5
|
* ao_wasapi: drop use of AF_FORMAT_S24wm42017-07-073-117/+133
| | | | | | | | | | | Do conversion directly, using the infrastructure that was added before. This also rewrites part of format negotation, I guess. I couldn't test the format that was used for S24 - my hardware does not report support for it. So I commented it, as it could be buggy. Testing this with the wasapi_formats[] entry for 24/24 uncommented would be appreciated.
* ao_alsa: drop use of AF_FORMAT_S24wm42017-07-071-21/+56
| | | | | | | | | | | | | Instead of the infrastructure added in the previous commit to do the conversion within the AO. If this is used, and snd_pcm_status_get_avail() returns more frames than snd_pcm_write*() actually accepts, you will get some nice audio corruption. Also, this mutates the data passed via play(), which is rather fishy, but sort of doesn't matter for now. Surely this will cause unintended bugs and WTFs.
* audio/out: add helper code to do 24 bit conversion in AOwm42017-07-073-0/+129
| | | | | | | | | | | | | | | | | | | | | | | | | I plan to remove the S24 sample formats in mpv. It seems like we should still support this _somehow_ in AOs though. So the idea is to convert the data to more obscure representations (that would not be useful for filtering etc. anyway) within the AO. This commit adds helper to enable this. ao_convert_fmt is meant to provide mechanisms for this, rather than a generic audio format description (as the latter leads only to overly generic misery). The conversion also supports only cases which we think will be needed at all. The main advantage of this approach is that we get S24 out of sight, and that we could support other crazy formats (like S20). The main disadvantage is that usually S32 will be selected (if both S32 and S24 are available), and there's no user control to force S24. That doesn't really matter though, and at worst makes testing harder or will lead to unpleasant arguments with audiophiles (they'd be wrong anyway). ao_convert_fmt.pad_lsb is ignored, although if we ever find a case in which playing S32 with data in the LSBs breaks when playing it as padded 24 bit format. (For example, WAVEFORMATEXTENSIBLE recommends setting the unused bits to 0 if wValidBitsPerSample implies LSB padding.)
* ad_lavc, vd_lavc, sd_lavc: consistently use avcodec_free_context()wm42017-07-061-7/+1
| | | | | Instead of various ad-hoc ways to achieve the same thing. (The API was added only later.)
* ao_coreaudio: insane hack for passing through AC3 as float PCMwm42017-06-301-5/+65
| | | | | This uses the same hack as Kodi uses, and I suspect MPlayer/ancient mpv also did this (but didn't research that).
* ao_wasapi: UWP wrapper hack supportwm42017-06-292-7/+40
| | | | | | | | | | | UWP does not support the whole IMMDevice API. Instead, you need to use a new API (available starting from Windows 8), which is in addition not in MinGW, and extremely unpleasant to use. The wasapiuwp2.dll wrapper is a small custom MSVC DLL, which does this instead, and returns a normal IAudioClient. Before this, ao_wasapi did not initialize on UWP.
* Universal Windows Plaform (UWP) supportPedro Pombeiro2017-06-291-0/+4
| | | | | | | | libmpv only. Some things are still missing. Heavily reworked. Signed-off-by: wm4 <wm4@nowhere>
* ao_wasapi: do not use deprecated wchar functionsPedro Pombeiro2017-06-292-2/+2
| | | | These break on UWP. Based on a patch by Pedro Pombeiro.
* Avoid calling close(-1)wm42017-06-291-2/+5
| | | | | | | | | | While this is perfectly OK on Unix, it causes annoying valgrind warnings, and might be otherwise confusing to others. On Windows, the runtime can actually abort the process if this is called. push.c part taken from a patch by Pedro Pombeiro.
* ao_wasapi: remove subtly duplicated codewm42017-06-281-7/+6
| | | | Seems like this can be slightly simplified.
* ao_wasapi: remove duplicate code for creating IAudioClientwm42017-06-281-34/+24
| | | | | | | | | | | | The code accounting for the terrible AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED semantics (which MSDN claims can happen "starting with Windows 7" - so probably on Windows 10 too) duplicated the call for creating the IAudioClient. That's not great, so get rid of it. Let wasapi_thread_init() handle this. It has a retry loop anyway. This redoes device lookup and format negotiation, but potential failures due to race conditions (what if the driver decides to change behavior) shouldn't be worse than before.
* audio/out/pull: detect and log underflowswm42017-06-281-0/+20
| | | | Mostly for debugging, I guess.
* audio/out: require AO drivers to report period size and correct bufferwm42017-06-259-4/+39
| | | | | | | | | | | | | | | | Before this change, AOs could have internal alignment, and play() would not consume the trailing data if the size passed to it is not aligned. Change this to require AOs to report their alignment (via period_size), and make sure to always send aligned data. The buffer reported by get_space() now always has to be correct and reliable. If play() does not consume all data provided (which is bounded by get_space()), an error is printed. This is preparation for potential further AO changes. I casually checked alsa/lavc/null/pcm, the other AOs might or might not work.
* ao_openal: change license to LGPLwm42017-06-241-7/+7
| | | | All authors have agreed.
* chmap: remove misleading "downmix" channel layout namewm42017-06-241-1/+0
| | | | | | | | I'm not even sure when/if FFmpeg produces those. It's just confusing. If you really need this, you can still use dl-dr. I expect that most use is unintentional. Probably fixes #4545.
* ao_pulse: reorder format choiceNiklas Haas2017-06-231-2/+2
| | | | | | | | | | | | Right now, the current order pretty much means that pulse defaults to S16 for arbitrary unsupported formats, but fallback to float would make more sense since it's the easiest to convert everything to without requiring dithering, and PA will probably just internally convert things to float anyway. Also move S32 above S16, which essentially means format_maps is sorted by preference. (Although ao_pulse currently ignores this and always picks the first as a fallback)
* build: simplify OSS checks and remove changes by "bugmen0t"wm42017-06-221-6/+3
| | | | | | | | | | | | | | | | | | The user bugmen0t was apparently a shared github account with publicly available login. Thus, we can't get LGPL relicensing permission from the people who used this account. To relicense successfully, we have to remove all their changes. This commit should remove 20d1fc13, f26fb009, defbe48d. It also should remove whatever test fragments were copied from the ancient configure, as well as some configure logic (potentially that device path stuff). I think this change still preserves the most important use-cases of OSS: BSDs, and the Linux OSS emulation (the latter for testing only). According to an OSS user, the 4front checks were probably broken anyway. The SunAudio stuff was probably for (Open)Solaris, which is dead. ao_oss.c itself will remain GPL, and still contains bugmen0t changes.
* audio/format: change license to LGPLwm42017-06-202-23/+14
| | | | | | | | | | | | | | | | | | | | | | | | | Although the origins lie somewhere in libaf, which was written by "anders" and who explicitly disagreed with the LGPL relicensing, we can change the license of these files, because all code was written by "alex", who agreed with the relicensing. The only things that remain from anders' code is the AF_FORMAT_ and af_ prefixes (see e.g. 66f4e563). It was alex who redid this file and added the format identifiers we have today (507121f7). It's also nice to see that alex actually claimed copyright on format.c (221a599f). In commit efb50cab even the bitmask concept (which anders introduced with his early af_format.c code) was removed, and essentially all lines and symbols by anders were dropped. To put it into perspective: the original af_format code was for converting actual sample data and relied on OSS sample format identifiers, mpv's format.c/h provides its own sample formats, but does not do any data conversion. Remove an now inaccurate comment from format.c (it somehow even survived the typo that was present in the original commit). Also remove most of the format.c include statements - most of them are technically anders' code. We keep limits.h though.
* dec_audio, ad_lavc: change license to LGPLwm42017-06-144-22/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | All relevant authors of the current code have agreed. As always, there are the usual historical artifacts that could be mentioned. For example, there used to be a large number of decoders by various authors who were not asked, but whose code was all 100% removed. (Mostly due to FFmpeg providing all codecs.) One point of contention is that Nick Kurshev might have refactored the old audio decoder code in 2001. Basically, there are hints that it might have been done by him, such as Arpi's commit message stating that the code was imported from MPlayerXP (Nick's fork), or all the files having his name in the "maintainer" field. On the other hand, the murky history of ad.h weakens this - it could be that Arpi started this work, and Nick took it (and possibly finished it). In any case, Nick could not be reached, so there is no agreement for LGPL relicensing from him. We're changing the license anyway, and assume that his change in itself is not copyrightable. He only moved code, and in addition used the equivalent video decoder framework (done by Arpi, who agreed) as template. For example, ad_functions_s was basically vd_functions_s, which the signature of the decode callback changed to the same as audio_decode(). ad_functions_s also had a comment that said it interfaces with "video decoder drivers" (I'm fixing this comment in this commit). I verified that no additional code was added that is copyright-relevant, still in today's code, and not copied from the existing code at the time (either from the previous audio decoder code or the video framework code). What apparently matters here is that none of the old code was not written by Nick, and the authors of the old code have given his agreement, and (probably) that Nick didn't add actual new code (none that would have survived), that was not trivially based on the old one (i.e. no new copyrightable "work"). A copyright expert told me that this kind of change can be considered not relevant for copyright, so here we go. Rewriting this would end with the same code anyway, and the naming conventions can't be copyrighted.
* encode_lavc: move from GPL 2+ to LGPL 2.1+.Rudolf Polzer2017-06-131-7/+8
|
* af, vf: improvements to libavfilter bridgewm42017-05-312-1/+8
| | | | | | Add the "lavfi-" prefix (details see manpage additons). Tag the filter name as "(lavfi)" in the verbose filter list output.
* ad_spdif: change license to LGPLwm42017-05-211-7/+7
| | | | | All authors have agreed. (Even the main author, if you wonder about the entry in the Copyright file.)
* ao_pcm: change license to LGPLwm42017-05-201-7/+7
| | | | | | | | | | | | | | | | | | | | | All relevant authors have agreed to the relicensing. Problem cases: eca47b1a5edae: someone else gets credited for the "idea" of this change, but it doesn't seem like it was a patch (otherwise reimar would have said "patch"). Also, the associated code got essentially removed again anyway. (The option parsing was rewritten fully.) ffb529e4eb2a9: anonymous/unknown author, but the code was fully removed anyway. The struct was removed, and the modern code does explicit read/write calls. 40789473d215b: author was not contacted, but this code was removed anyway. The magic number (0x7ffff000) is still in the new code, but I don't think that is copyright relevant. c750b8ab2d3c8: the message was entirely removed.
* audio/out: change license of some core files to LGPLwm42017-05-204-28/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | All contributors of the current code have agreed. ao.c requires a