summaryrefslogtreecommitdiffstats
path: root/audio
Commit message (Collapse)AuthorAgeFilesLines
* audio/filter: remove reentrancy flagwm42015-09-205-22/+1
| | | | | | | | | | This flag was used by some filters and made sure none of these filters were inserted twice. This triggers only if the user explicitly tries to add multiple filters (and not e.g. due to auto-insertion), so at best this warned the user from doing something potentially pointless. At worst, it blocked some (mildly) legitimate use-cases. Get rid of it. Also see #2322.
* af_lavfi: implement af-metadata propertywm42015-09-113-0/+37
| | | | | | | Works like vf-metadata. Unfortunately requires some code duplication (even though it's not much). Fixes #2311.
* af: use generic statuc codeswm42015-09-111-7/+7
| | | | | | | The reason MPlayer traditionally duplicated them all over the place is that it wanted every component to be a self-contained library (e.g. audio filters were in "libaf"). But this is not necessarily helpful, and this change makes the following commit a bit simpler.
* ao_lavc: minor simplificationwm42015-09-111-2/+2
|
* ao_alsa: use sample format determination codeKevin Mitchell2015-09-101-12/+10
|
* ao_alsa: add double to sample format listKevin Mitchell2015-09-101-0/+1
|
* ao_alsa: put spdif formats into find_alsa_formatKevin Mitchell2015-09-101-9/+9
|
* audio/format: revise af_format_conversion_scoreKevin Mitchell2015-09-101-8/+13
| | | | | | | | | | | | | | | | | | | * (de)planarize -1 * pad 1 byte -8 * truncate 1 byte -1024 * float -> int 1048576 * (8 - dst_bytes) * int -> float -512 Now the score is negative if and only if the conversion is lossy (e.g. previously s24 -> float was given a negative (lossy) score), However, int->float is still considered bad (s16->float is worse than than s16->s32). This penalizes any loss of precision more than performance / bandwidth hits. For example, previously s24->s16p was considered equal to s24->u8. Finally, we penalize padding more than (de)planarizing as this will increase the output size for example with ao_lavc.
* ao_oss: use new sample format determination codewm42015-09-101-1/+2
|
* ao_lavc: use new sample format determination codewm42015-09-103-24/+16
| | | | | | | This is just a refactor, which makes it use the previously introduced function, and allows us to make af_format_conversion_score() private. (We drop 2 unlikely warning messages too... who cares.)
* audio/format: add function for determining sample conversion candidateswm42015-09-102-0/+32
|
* audio/format: fix interlaved vs. non-interleaved conversionswm42015-09-101-1/+1
| | | | | | | | | | This mixed up the returned score for some interleaved/non-interleaved comparisons. Changing interleaving subtracted 1 point, while extending sample size by 1 byte also subtracted 1 point. (This scoring system is not ideal - it'd be much cleaner to do a 3-way sample format comparison instead, and sort the formats according to the comparison instead of the score.)
* audio/format: actually prefer float over double sample formatwm42015-09-101-1/+1
| | | | | ...for int->float conversions. This code accidentally inverted the condition.
* af_lavrresample: remove unnecessary indirectionswm42015-09-081-35/+30
| | | | | | | Not sure why struct af_resample_opts even exists. It seems useful to group the fields set by user options. But storing the current format conversion parameters doesn't seem very elegant, and having a separate instance in the "ctx" field isn't helpful either.
* af_lavrresample: add normalize suboptionwm42015-09-081-1/+6
|
* af_lavrresample: add missing include statementwm42015-09-041-0/+1
| | | | | | Apparently, this broke compilation with Libav under some circumstances. Looking at it again, it shouldn't have, but this change doesn't hurt anyway.
* audio/filter: remove af_bs2b toowm42015-09-042-171/+0
| | | | | | | Some users still use this filter, so the filter was going to be kept. But I overlooked that libavfilter provides this filter. Remove the redundant wrapper from mpv. Something like --af=lavfi=bs2b should work and give exactly the same results.
* audio/filter: remove some useless filterswm42015-09-0319-3942/+0
| | | | | | | | | | | | | | | | | | | | | | | | All of these filters are considered not useful anymore by us. Some have replacements in libavfilter (useable through af_lavfi). af_center, af_extrastereo, af_karaoke, af_sinesuppress, af_sub, af_surround, af_sweep: pretty simple and useless filters which probably nobody ever wants. af_ladspa: has a replacement in libavfilter. af_hrtf: the algorithm doesn't work properly on most sources, and the implementation was buggy and complicated. (The filter was inherited from MPlayer; but even in mpv times we had to apply fixes that fixed major issues with added noise.) There is a ladspa filter if you still want to use it. af_export: I'm not even sure what this is supposed to do. Possibly it was meant for GUIs rendering audio visualizations, but it couldn't really work well. For example, the size of the audio depended on the samplerate (fixed number of samples only), and it couldn't retrieve the complete audio, only fragments. If this is really needed for GUIs, mpv should add native visualization, or a proper API for it.
* ao_alsa: fix minor memory leakwm42015-08-251-8/+11
| | | | | | | So snd_device_name_get_hint() return values do in fact have to be freed. Also, change listing semantics slightly: if io==NULL, skip the entry, instead of assuming it's an output device.
* audio: remove unused legacy libavutil headerwm42015-08-073-3/+0
| | | | It was never used, but is a leftover from old times.
* audio: remove af_dummywm42015-08-012-63/+0
| | | | Was used internally once; has no function anymore.
* win32: revert wchar_t changeswm42015-08-014-14/+13
| | | | | | | | | | | Revert "win32: more wchar_t -> WCHAR replacements" Revert "win32: replace wchar_t with WCHAR" Doing a "partial" port of this makes no sense anymore from my perspective. Revert the changes, as they're confusing without context, maintenance, and progress. These changes were a bit premature anyway, and might actually cause other issues (locale neutrality etc. as it was pointed out).
* win32: more wchar_t -> WCHAR replacementswm42015-07-303-9/+9
| | | | | | | | | | | | | This was essentially missing from commit 0b52ac8a. Since L"..." string literals have the type wchar_t[], we can't use them for UTF-16 strings. Use C11 u"..." string literals instead. These have the type char16_t[], but we simply assume char16_t is the same underlying type as WCHAR. In practice, they're both unsigned short. For this reason use -std=c11 on Windows. Since Windows is a "special" environment (we require either MinGW or Cygwin), we don't need to worry too much about compiler compatibility.
* win32: replace wchar_t with WCHARwm42015-07-293-4/+5
| | | | | | | | | | | | | WCHAR is more portable. While at least MinGW, Cygwin, and MSVC actually use 16 bit wchar_t, Midipix will have 32 bit wchar_t. In that context, using WCHAR instead is more portable. This affects only non-MinGW parts, so not all uses of wchar_t need to be changed. For example, terminal-win.c won't be used on Midipix at all. (Most of io.c won't either, so the search & replace here is more than necessary, but also not harmful.) (Midipix is not useable yet, so this is just preparation.)
* audio: fix restoring volumeshdown2015-07-271-1/+1
| | | | | Was broken by 68bbab0e42e141896545f1f6e9699bcad2d685f8, which changed the number of fields to scan, but not the expected return value.
* af_lavrresample: always reinit resampler on filter reinitwm42015-07-191-18/+1
| | | | | | | | This was a minor optimization to potentially avoid resampler reconfiguration when the filter is reinitialized. But filter reinitialization is a rare event, and the case when no reconfiguration is needed is even rarer. As such, this is an unnecessary micro- optimization and only adds potential for bugs.
* af_lavrresample: don't unnecessarily print remix messagewm42015-07-191-8/+8
| | | | | | | | | This message bloats verbose log output if e.g. audio speed is frequently readjusted, such as when syncing audio to video. So don't print the message if only speed is changed. (This case requires reconfiguration, but can't change the input/output channel maps.) Also do not print the message if no remixing is done at all.
* af: fix behavior with pathologic filter chainswm42015-07-071-0/+2
| | | | | | | | Some filter chains require a huge number of auto-inserted conversion filters. There is an overly stupid safeguard against infinite filter insertions, which counts the number of conversion filters inserted. This triggered accidentally in this case. Fix by resetting this counter after a non-conversion filter was successfully configured.
* ao_coreaudio: fix device latency, share the codewm42015-07-064-23/+25
| | | | | | | | | ao_coreaudio (using AudioUnit) accounted only for part of the latency - move the code in ao_coreaudio_exclusive to utils, and use that for the AudioUnit code. (There's still the question why CoreAudio and AudioUnit require you to jump through hoops this much, but apparently that's how it is.)
* ao_coreaudio_exclusive: continue even if setting physical format failswm42015-07-062-2/+4
| | | | | Makes it work with (apparently) crappy drivers, which refuse to set the physical format in some cases.
* ao_coreaudio_exclusive: fix some verbose outputwm42015-07-041-2/+2
|
* ao: don't pass along AO arguments when redirectingwm42015-07-031-1/+1
| | | | Only causes problems.
* ao_coreaudio: add exclusive suboptionwm42015-07-031-2/+4
|
* ao_coreaudio_exclusive: support PCMwm42015-07-031-15/+35
| | | | | | | | | | | | | | | | | | Until now, this was for AC3 only. For PCM, we used AudioUnit in ao_coreaudio, and the only reason ao_coreaudio_exclusive exists is that there is no other way to passthrough AC3. PCM support is actually rather simple. The most complicated issue is that modern OS X versions actually do not support copying through the data; instead everything must go through float. So we have to deal with virtual and physical format being different, which causes some complications. This possibly also doesn't support some other things correctly. For one, if the device allows non-interleaved output only, we will probably fail. (I couldn't test it, so I don't even know what is required. Supporting it would probably be rather simple, and we already do it with AudioUnit.)
* ao_coraudio: reject all non-PCM formatswm42015-07-031-1/+1
| | | | | Currently this is equivalent. On the other hand, all audio code should reject formats that is not in a category known to it.
* ao_coreaudio_utils: reduce spamwm42015-07-031-1/+0
|
* ao_coreaudio_utils: fix format back-mappingwm42015-07-031-5/+7
| | | | | | | | | | | Mapping of spdif formats was imperfect. Since the first format on the list is somehow AAC, it was returned first, which is confusing, because CoreAudio calls all spdif formats AC3. Since the spdif formats have some rather arbitrary, reverse mapping the formats didn"t actually work either. Fix by explicitly ignoring these when spdif is used. Also, don't forget to set the samplerate in ca_asbd_to_mpformat(), or it will work only in some cases.
* ao_coreaudio_exclusive: do not set ao->bpswm42015-07-031-3/+0
| | | | | This field is basically deprecated or for convenience only, and this code doesn't need it.
* ao_coreaudio_exclusive: dump all latency info in verbose modewm42015-07-031-1/+4
|
* ao_coreaudio_exclusive: factor format selectionwm42015-07-031-35/+44
|
* ao_coreaudio_exclusive: separate out stream selectionwm42015-07-031-61/+76
|
* af_lavrresample: log actual channel layout conversionswm42015-06-301-3/+6
| | | | | With all the reordering etc. that can go on in this filter, it's useful to see what upmix/downmix it's actually performing.
* ao_coreaudio: restore physical format if it can't be set exactlywm42015-06-302-2/+14
| | | | | | | | May help with (supposedly) bad drivers, which can put the device into some sort of broken state when trying to set a different physical format. When the previous format is restored, it apparently recovers. This might make the change-physical-format suboption more robust.
* ao_coreaudio: support native mono outputwm42015-06-291-0/+2
| | | | | | | We can be pretty sure that AudioUnit will remix for us. Before this commit, we usually upmixed to stereo, because the stereo and multichannel layouts were the only whitelisted ones.
* ao_coreaudio: log hotplug events explicitlywm42015-06-291-3/+6
|
* ao_wasapi: fix regressionwm42015-06-271-1/+1
| | | | This probably fixes the regression introduced with commit 6147bcce.
* chmap_sel: add a mechanism for preferred conversionswm42015-06-271-9/+39
| | | | | And use it for the mono case. This is slightly more formal and will make it easier to add more such cases.
* chmap_sel: remove outdated incomplete commentwm42015-06-271-3/+0
|
* audio: fix format function consistency issueswm42015-06-2620-86/+83
| | | | | | | | | | | Replace all the check macros with function calls. Give them all the same case and naming schema. Drop af_fmt2bits(). Only af_fmt2bps() survives as af_fmt_to_bytes(). Introduce af_fmt_is_pcm(), and use it in situations that used !AF_FORMAT_IS_SPECIAL. Nobody really knew what a "special" format was. It simply meant "not PCM".
* audio: replace format name tablewm42015-06-263-52/+23
| | | | Having a big switch() is simpler.
* audio: remove bitmask format definition messwm42015-06-262-92/+80
| | | | | | | | | | Audio formats used a semi-clever schema to encode the properties of the PCM encoding as bitfields into the format integer value. The af_fmt_change_bits() implementation becomes a bit weird, but it's an improvement to the rest of the code. (I've always disliked it, so why not get rid of it.)
* ao_coreaudio_utils: use a macrowm42015-06-261-1/+1
| | | | | This is actually the last line of code outside of format.c/h which still tries to fiddle with the format bitfields.
* ao_sndio: fix commentwm42015-06-261-2/+1
| | | | | | So whoever (nobody?) would want to deal with this broken and obscure AO for an obscure audio API could add support for some more channel layouts.
* ao_coreaudio: support non-interleaved outputwm42015-06-262-5/+12
| | | | | This saves us the trouble of interleaving the audio data for no reason.
* ao_coreaudio: explicitly skip input streamswm42015-06-262-4/+22
| | | | | | | This may or may not fix some issues with the format switching code. Actually, it seems somewhat unlikely, but then checking the stream type isn't incorrect either, and is probably something the API user should always be doing.
* ao_coreaudio_utils: compare full AudioStreamBasicDescriptionwm42015-06-251-1/+3
| | | | | | Originally, this was written for comparing the sample format only, but ca_change_physical_format_sync() actually expects that the full format is compared. (For all other uses it doesn't matter.)
* audio: output human-readable channel layouts toowm42015-06-254-10/+30
| | | | | This gets you the "logical" channel layout, instead of the exact thing we're sending to the AO. (Tired of the cryptic shit ALSA gives me.)
* audio: fix channel map fallback selection (again)wm42015-06-251-36/+61
| | | | | | | | | | | | | | | | | | | | The speaker replacement nonsense sometimes made blatantly incorrect decisions. In this case, it prefered a 7.1(rear) upmix over outputting 5.1(side) as 5.1, which makes no sense at all. This happened because 5.1 and 7.1(rear) appeared equivalent to the final selection, as both of them lose the sl-sr channels. The old code was too stupid to select the one with the lower number of channels as well. Redo this. There's really no reason why there should be a separate final decision, so move the speaker replacement logic into the mp_chmap_is_better() function. Improve some other details. For example, we never should compare the plain number of channels for deciding upmix/downmix, because due to NA channels this is essentially meaningless. Remove the NA channels when doing this comparison. Also, explicitly handle exact matches. Conceptually this is not necessary, but it avoids that we have to needlessly shuffle audio data around.
* ao: standardize channel layout name in debug output furtherwm42015-06-251-0/+2
|
* af: move af_from_dB() function to af_volume.cwm42015-06-233-22/+11
| | | | | And also simplify it (it certainly had the most awkward API you could think of for such a simple function).
* af_volume: add a replaygain fallback optionwm42015-06-231-0/+5
|
* af_lavrresample: free and reallocate resample context on reconfigwm42015-06-221-30/+35
| | | | | | | | This avoids keeping "bad" state from previous reconfig calls, such as the internal_sample_format option (which is set only on the first reconfig call). There's no advantage to keeping the resample contexts around anyway.
* af_lavrresample: fix commentwm42015-06-221-4/+4
| | | | | mp_format is not a libavresample input format here, and the comment was more confusing than it helped.
* af: restore detaching of PCM filters when using spdifwm42015-06-223-1/+14
| | | | | | Basically, af_fix_format_conversion() behaves stupid you insert a conversion filter that won't work, and adding back the conversion test function is the simplest fix to it.
* af_lavrresample: don't flush in uninitialized statewm42015-06-221-1/+2
| | | | libswresample verbosely complains.
* ao_alsa: fix a log messagewm42015-06-211-4/+5
| | | | | | | | | | | | | | | | | So apparently, this essentially happens when the kernel driver doesn't implement write accesses in the channel map control. Which doesn't necessarily mean that the channel map is unsupported, or that there is a bug - it's just lazyness and a consequence of the terrible ALSA kernel API for the channel mapping stuff. In these cases, the channel count implicitly selects the channel map, and snd_pcm_set_chmap() always fails with ENXIO. I'm actually not sure what happens if dmix is on top of e.g. HDMI, which actually lets you change the channel mapping. I'm also not sure why commit d20e24e5d1614354e9c8195ed0b11fe089c489e4 (alsa-lib git repository) does not take care of this.
* demux: merge extradata fieldswm42015-06-211-5/+1
| | | | | | | MPlayer traditionally had completely separate sh_ structs for audio/video/subs, without a good way to share fields. This meant that fields shared across all these headers had to be duplicated. This commit deduplicates essentially the last remaining duplicated fields.
* demux: rename sh_stream.format to sh_stream.codec_tagwm42015-06-211-1/+1
| | | | | Why not. "format" sounds too misleading for the actual importance and meaning of this field.
* Various spelling fixesMarcin Kurczewski2015-06-188-13/+13
| | | |</