summaryrefslogtreecommitdiffstats
path: root/audio
Commit message (Collapse)AuthorAgeFilesLines
* mixer: fix volume initialization with --af=volumewm42015-12-111-0/+2
| | | | | | | | A manually added af_volume could lead to muted audio when switching to a new file. af_volume keeps the last volume set by AF_CONTROL_SET_VOLUME to return it with AF_CONTROL_GET_VOLUME, but the initial value is 0. So the mixer volume was forced to 0 when unintializing the filter chain and reading back the previously set volume.
* mixer: minor simplificationwm42015-12-111-4/+7
| | | | (Why is this code so complex?)
* ao: disambiguate default device list entrieswm42015-11-271-2/+6
| | | | | | | | | | | If there were many AO drivers without device selection, this added a "Default" entry for each AO. These entries were not distinguishable, as the device list feature is meant not to require to display the "raw" device name in GUIs. Disambiguate them by adding the driver name. If the AO is the first, the name will remain just "Default". (The condition checks "num > 1", because the very first entry is the dummy for AO autoselection.)
* af_lavrresample: fix build on Libavwm42015-11-261-1/+1
| | | | | | | Of course, only FFmpeg has av_clipd(), while Libav does not. (Nevermind that it doesn't do much more than the mpv MPCLAMP() macro. Supposedly, libavutil can provide optimized platform-specific versions for av_clip*, but of course nothing actually does for av_clipf() or av_clipd().)
* af_lavrresample: clamp float output to rangewm42015-11-251-0/+12
| | | | | | | libswresample doesn't do it - although it should, but the patch is stuck in limbo. Probably reduces problems with artifacts on downmixing in some cases.
* ao_alsa: filter audio device listwm42015-11-241-1/+15
| | | | | | | | Remove known useless device entries from the --audio-device list (and corresponding property). Do this because the list is supposed to be a high level list of devices the user can select. ALSA does not provide such a list (in an useable manner), and ao_alsa.c is still in the best position to improve the situation somewhat.
* ao_alsa: list bidirectional devices toowm42015-11-241-1/+1
| | | | | | | | | The ALSA doxygen says: IOID - input / output identification ("Input" or "Output"), NULL means both This bug was blatantly introduced with commit cf94fce4.
* ao_wasapi: get rid of Vistablob hackKevin Mitchell2015-11-244-51/+6
| | | | | This was required to work around XP linking issues and is no longer required.
* ao_wasapi: only report per-app volume in shared modeKevin Mitchell2015-11-191-1/+2
| | | | | otherwise we were incorrectly adjusting the hardware master volume in exclusive mode with softvol=auto
* ao_wasapi: work around DTS passthrough failurewm42015-11-191-1/+18
| | | | | | | | | | Apparently, some audio drivers do not support the DTS subtype, but passthrough works anyway if the AC3 subtype is set. Just retry with AC3 if the proper format doesn't work. The audio device which exposed this behavior reported itself as "M601d-A3/A3R (Intel(R) Display Audio)". xbmc/kodi even always passes DTS as AC3.
* ao_openal: fix sign of speaker angle in commentKevin Mitchell2015-11-181-1/+1
|
* ao_openal: fix virtual speaker positioningJustas LaviĊĦius2015-11-181-10/+10
| | | | | | Place speakers in standard positions equidistant from the listener. use standard coordinate system
* ao_openal: accommodate more sample formatsKevin Mitchell2015-11-171-7/+44
| | | | | | Try and and choose the closest sample format to the one requested. fixes #2494
* ao_openal: move uninit before initKevin Mitchell2015-11-171-12/+12
| | | | the next commit will use uninit within init
* af_lavrresample: simplify set_compensation usagewm42015-11-111-13/+12
| | | | | | | | | | | | | Just set the ratio directly by working around the intended semantics of the API function. The silly rounding stuff we had isn't needed anymore (and not entirely correct anyway). Note that since the compensation is virtually active forever, we need to reset if it's not needed. So always run this code to be sure to reset it. Also note that libswresample itself had a precision issue, until it was fixed in FFmpeg commit 351e625d.
* dec_audio: add missing includewm42015-11-081-0/+1
| | | | Was masked by FFmpeg's terrible headers, but failed with Libav.
* audio: interpolate audio timestampswm42015-11-081-2/+12
| | | | | | | | | | | | Deal with jittering Matroska crap timestamps. This reuses the mechanism that is needed for frames without PTS, and adds a heuristic to it. If the interpolated timestamp is less than 1ms away from the real one, it might be due to Matroska timestamp rounding (or other file formats with such rounding, or files remuxed from Matroska). While there actually isn't much of a need to do this (audio PTS jittering by such a low amount doesn't negatively influence much), it helps with identifying jitter from other sources.
* audio: move PTS setting out of the decoderwm42015-11-084-18/+16
| | | | | | | Instead of requiring the decoder to set the PTS directly on the dec_audio context (including handling absence of PTS etc.), transfer the packet PTS to the decoded audio frame. Marginally simpler, and gives more control to the generic code.
* chmap: remove MPlayer layoutswm42015-11-074-39/+0
| | | | Unused; last uses removed with the previous two commits.
* ao_jack: remove "alsa" std-channel-layout choicewm42015-11-071-5/+1
| | | | | Same deal as with previous commit. "waveext" is less arbitrary and at least supports 3/7 channels.
* ao_alsa: remove the last bits of legacy channel map fallbackwm42015-11-071-3/+1
| | | | | | | | Essentially we'd use something random, just because it's part of the srt of traditionally used ALSA channel mappings. But each driver can do its own things. This doesn't let me sleep at night, so remove it.
* audio: fix af_fmt_change_bytes() with spdif formatswm42015-11-071-1/+1
| | | | | | | | | This could accidentally change some spdif formats to AAC (because AAC is the first on the list and will match first). spdif formats are inherently uninterchangeable, so treat them as their own class of formats (like int vs. float). Might fix some issues with ao_wasapi.c.
* audio: do not require full audio chain reinit for speed changeswm42015-11-041-3/+0
| | | | | | | | | | | | | | | Actually, it didn't really require that before (most work was avoided), but some bits had to be run anyway. Separate the speed change into a light-weight function, which merely updates already created filters, and a heavy-weight one which messes with filter insertion. This also happens to fix the case where the filters would "forget" the current speed (force resampling, change speed, hit a volume control to force af_volume insertion - it will reset speed and desync). Since we now always run the light-weight function, remove the af_scaletempo verbose message that is printed on speed setting. Other than that, all setters are cheap.
* af_lavcac3enc: simplify/fix AVPacket handlingwm42015-11-041-16/+21
| | | | | | For some reason, the encoder didn't like that the AVPacket already had fields set. I'm not quite sure, but this might just be invalid API usage. Do it as it's recommended.
* ao_alsa: fix 7.1 over HDMIwm42015-11-041-0/+26
| | | | | | | | | | | | | | | | | We need to effectively swap the last channel pair. See commit 4e358a96 and 5a18c5ea for details. Doing this seems rather strange, as 7.1 just extends 5.1 with 2 new speakers, and 5.1 doesn't need this change. Going by the HDMI standard and the Intel HDA sources (cited in the referenced commits), it also looks like 7.1 should simply append two channels to 5.1 as well. But swapping them is apparently correct. This is also what XBMC does. (I didn't find any other applications doing 7.1 PCM using the ALSA channel map API. VLC seems to ignore the 7.1 case.) Testing reveals that at least the end result is correct. "Normal" ALSA 7.1 is unaffected by this, as it reports a different (and saner) channel layout.
* ao_alsa: map mp_chmaps back to ALSA in a different waywm42015-11-041-39/+54
| | | | | | | | | | | | | | | | Instead of constructing an ALSA channel map from mpv ones from scratch, try to find the original ALSA channel map again. Th result is that we need to convert channel maps only in one direction. If we need to map a mp_chmap to ALSA, we fetch the device's channel map list, convert each entry to mp_chmap, and find the first one which fits. This seems helpful for the following commit. For now, this only gets rid of mapping back the trivial MONO mapping, which alone would still be acceptable, but with other channel layout mogrifications it gets messy fast. While we need to do something awkward to keep our channel map reordering for VAR chmaps (which basically gives nicer output and possibly slightly better performance), this is still the better solution.
* ao_alsa: print more chmap info at debug verbositywm42015-11-041-9/+11
|
* Revert "af_lavrresample: don't drop sl/sr channels for 7.1 on ALSA"wm42015-11-041-28/+5
| | | | | | | | | | | This reverts commit 4e358a963604af8746a059d7388cb202be0f919d. Testing shows the channel pairs must indeed be swapped (details see commit message of the reverted commit). Making the downmix code move sl/sr to sdl/sdr is not an appropriate solution anymore, and it's better to fix the unusual channel layout in ao_alsa.c directly. (Not reverting the change in chmap.c; this is still correct.)
* af_lavrresample: don't drop sl/sr channels for 7.1 on ALSAwm42015-11-032-6/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ao_alsa: attempt to fix 7.1 over HDMI The last 2 channels of 7.1 (RLC/RRC in ALSA) were exported as sdl/sdr instead of sl/sr (I don't even know why I chose sdl/sdr, but SL/SR and RLC/RRC are different in the ALSA API). libsw/avresample do not move the sl/sr channels to sdl/sdr when rematrixing, so silence was sent for 2 channels. If my selection of sdl/sdr is essentially API abuse, there's no reason why they should do this differently. The mess here is really that ALSa doesn't map the HDMI layouts cleanly. Most ALSA drivers export 7.1 in a way compatible to our expectations, but Intel HDA/HDMI does not: mpv/ffmpeg: fl-fr-fc-lfe-bl-br-sl-sr ALSA/generic: FL FR FC LFE RL RR SL SR [1] ALSA/HDMI: FL FR LFE FC RL RR RLC RRC [2] The HDMI layout is layout 0x13 (going by CEA-861-B). The comment in the kernel code has to be correct too. The early standard defines only 1 other layout, which replaces RLC/RRC with FRC/FLC - this probably corresponds to what we call "7.1(wide)". So it appears when ALSA requests RLC/RRC, we should feed it sl/sr. To make it more complicated, Kodi/xbmc apparently also have to deal with ALSA being special, but instead of sending sl/sr to RLC/RRC, they swap the last two pairs of the layout, and send sl/sr to RL/RR and bl/br to RLC/RRC. Or I might have misunderstood their code. I don't have a 7.1-capable A/V receiver, so I can't test this. For now, go with the simpler solution, and wait until someone tests it. If the speakers end up swapped, a completely different solution will be needed. [1] https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/sound/core/pcm_lib.c?id=refs/tags/v4.3#n2434 [2] https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/sound/pci/hda/patch_hdmi.c?id=refs/tags/v4.3#n307
* ao_alsa: minor cleanupswm42015-11-031-34/+18
|
* ao_alsa: simplify dmix non-NA hackwm42015-11-031-58/+43
| | | | | There's really no need to do this deep in the chmap sslection code. This will setup the device further than before, but that doesn't matter.
* ao_alsa: move channel map setting code out of main init functionwm42015-11-031-104/+125
| | | | This grew way too large.
* ao_alsa: make failure of buffer parameter setting non-fatalwm42015-11-031-4/+12
| | | | | | | | | | | | | | | | | | | | These calls actually can leave the ALSA configuration space empty (how very useful), which is why snd_pcm_hw_params() can fail. An earlier change intended to make this non-fatal, but it didn't work for this reason. Backup the old parameters, so we can retry with the non-empty configuration space. (It has to be non-empty, because the previous setters didn't fail.) Note that the buffer settings are not very important to us. They're a leftover from MPlayer, which needed to write enough data to the audio device to not underrun while decoding and displaying a video frame. In mpv, most of these things happen asynchronously, _and_ there is a dedicated thread just for feeding the audio device, so we should be pretty imune even against extreme buffer settings. But I suppose it's still useful to prevent PulseAudio from making the buffer too large, so still keep this code.
* ao_alsa: disable resampling first thingwm42015-11-031-7/+7
| | | | | | Again, this could have bad access, is unlikely, and has no bad consequences. It's noteworthy that vlc and the ALSA PCM example both do this first, even if they set the sample rate later.
* ao_alsa: set access type before formatwm42015-11-031-11/+13
| | | | | | | | I'm worried that not restricting the access type before restricting the format will cause problems. While it's unlikely, it might prevent failures in some corner cases. Also, since we by default always use interleaved access (buggy ALSA plugins), this will have no effects at all.
* ao_alsa: handle channel count mismatch safeguard after chmap negotiationwm42015-11-031-12/+12
| | | | | | | | If the API doesn't list padded channel maps, but the final device channel map is padded, and if unpadded output is not possible (unlike in the somewhat similar dmix case), then we shouldn't apply the channel count mismatch fallback in the beginning. Do it after channel map negotiation instead.
* ao_alsa: apply non-NA fallback only if input is stereowm42015-11-031-0/+1
| | | | | | Doesn't matter much; effectively this prevents just log spam in some cases where the map is legitimately padded. Normally this is really only needed for the dmix ALSA case. (See git blame for details.)
* ao_alsa: treat SND_CHMAP_UNKNOWN as NA channel toowm42015-11-031-0/+1
| | | | | | Apparently required by nVidia HDMI. It should not be, and NA would definitely be more correct here, so this could be considered a driver bug. Maybe.
* ao_alsa: remove log message on pausingwm42015-11-031-1/+2
| | | | This was annoying.
* Replace deprecated av_free_packet() callswm42015-10-281-1/+1
| | | | | | av_free_packet() got finally deprecated. Use av_packet_unref() instead, which has almost the same semantics, has existed for a while, and is available in all FFmpeg and Libav versions we support.
* player: add audio drop/duplicate modewm42015-10-272-0/+10
| | | | Not very robust in the moment.
* ao_coreaudio_exclusive: check for maximum channel countwm42015-10-261-0/+6
| | | | | | Until recently, the channel layout code happened to catch this, but now an explicit check is needed. Otherwise, it'd try to pad the missing channels with NA in the channel map fallback code.
* ao_coreaudio_exclusive: fallback to stereo on unknown channel layoutswm42015-10-261-1/+10
| | | | | | | | | | | This is intended for the case when CoreAudio returns only unknown channel layouts, or no channel layout matches the number of channels the CoreAudio device forces. Assume that outputting stereo or mono to the first channels is safe, and that it's better than outputting nothing. It's notable that XBMC/kodi falls back to a static channel layout in this case. For some messed up reason, the layout it uses happens to match with the channel order in ALSA's/mpv's "7.1(alsa)" layout.
* ao_coreaudio_chmap: minor refactorwm42015-10-261-26/+22
| | | | | | Share some code between ca_init_chmap() and ca_get_active_chmap(), which also makes it look slightly nicer. No functional changes, other than the additional log message.
* ao_coreaudio_chmap: allow stereo as fallback; avoid mono fallbackwm42015-10-261-2/+5
| | | | | | | | | | | | | | | | If no channel layouts were determined (which can actually happen with some "strange" devices), the selection code was falling back to mono, because mono is always added as a fallback. This doesn't seem quite right. Allow a fallback to stereo too, if no channel layout could be retrieved at all. So we always assume that mono and stereo work, if no other layouts are available. (I still don't know what the CoreAudio stereo layout is supposed to do. It could be used to swap left and right channels. It could also be used to pad/move the channels, but I have never seen that. And it can be set to non-stereo channels, which breaks mpv. Whatever.)
* ao_coreaudio: fix another minor memory leakwm42015-10-261-1/+2
| | | | How stupid, even the cleanup gotos were already there.
* audio: bump maximum number of channels to 16wm42015-10-261-1/+1
| | | | | | | | | | | The main reason is that ao_coreaudio_exclusive needs this for some OSX devices. They want packed audio, and special-casing this in the coreaudio code would be too much of a pain. The maximum of channels we can support is 64 (because FFmpeg uses 64 bit masks for channel layouts), but since struct mp_audio can get pretty big (has static allocations of 2 pointers for each channel for planar mode), it's less wasteful to stay lower for now.
* audio: use AVFrames with more than 8 channels correctlywm42015-10-263-8/+15
| | | | | | | Requires messy dealing with the extended_ fields. Don't bother with af_lavfi and ao_lavc for now. There are probably no valid use-cases for these.
* af_lavrresample: make planarization pass work with >8 channelswm42015-10-261-4/+5
| | | | | | | | | | av_get_default_channel_layout() fails with channel counts larger than 8. The channel layout doesn't need to make sense, so pick an arbitrary fallback. libswresample also has options for setting the channel counts directly, but better not introduce new concepts in the code. Also, libavresample doesn't have these options.
* audio: improve mp_chmap_to_lavc_unchecked() unknown chmap behaviorwm42015-10-261-2/+10
| | | | | | | | | | | | | | | | | | | | | | | Change it so that it will always return a bitmask with the correct number of channels set if an unknown channel map is passed. This didn't work for channel counts larger than 8, as there are not any standard channel layouts defined with more than 8 channels (both in mpv and FFmpeg). Instead, it returned 0. This will help when raising the maximum allowed channel count in mpv. Some code in af_lavrresample relies on it, more or less. One change is that unknown channel maps won't result in lavc standard channel layouts anymore, just a set of random speakers. This should be fine, as the caller of mp_chmap_to_lavc_unchecked() should handle these cases. For mp_chmap_reorder_to_lavc() this is not so clear anymore, but should also be ok. For normal channel maps, simply dropping NA channels is still the correct and wanted behavior. Currently, the mpv maximum channel count is 8. This commit is preparation for raising this limit.
* audio: always log channel maps before determining final mapwm42015-10-265-17/+33
| | | | | Until now, this was done only in debug verbosity, while some AOs logged equivalent information in verbose mode. Clean this up.
* ao_coreaudio: fix potential UB in error caseswm42015-10-261-3/+2
| | | | | | | | | mNumberChannelDescriptions being 0 is pretty much an error, but if it can happen, then the code checking the chmap below will trigger UB, as chmap is not initialized at all. Also, simplify the code a little: we never change the number of channels, so this is just fine.
* ao_coreaudio_chmap: add more loggingwm42015-10-261-8/+10
|
* af: prevent endless loop when removing filters due to spdifwm42015-10-261-1/+2
| | | | | | | | | | | | | | | | | | | | | This code removes filters which can not take spdif inout. This was made so that PCM filters are transparently dropped in spdif mode. This entered an endless loop with: --af=lavcac3enc:::2 --audio-channels=5.1 The forced number of output channels is incompatible with spdif. It's trying to insert af_lavrresample as conversion filter to compensate for it. Of course this doesn't work, which triggers the PCM filter removal. Then it goes on normally - since the new state is exactly as before, it will try the same thing again, forever. Fix by reusing the retry counter, which is a very dumb but very effective measure against these cases of filter negotiation failure. We could try to be more clever (for example, if the removed filter is a conversion filter, we can be sure this won't work, and error out immediately). But better keep it simple and robust.
* ao_alsa: log format probing in verbose modewm42015-10-251-2/+1
| | | | | And also remove a redundant log message. (We can tell from the following probe or error message whether or not the format test is successful.)
* ao_coreaudio_exclusive: fix buildwm42015-10-211-2/+2
| | | | "Let's apply cosmetic last minute changes without testing them."
* ao_coreaudio: do not accept unknown channel layoutswm42015-10-211-1/+1
| | | | | | | | | | | | | | | Coreaudio gives us a channel map with all entries set to kAudioChannelLabel_Unknown. This is translated to a mpv channel map with all channels set to NA, which has special meaning: it's an "unknown" channel map, which acts as wildcard and can be converted from/to any channel layout. Not really what we want. I've got this with USB audio, playing stereo. The multichannel layout consisted of 2 unknown channels, while the stereo channel map was stereo (as expected). Note that channel maps with _some_ NA entries are not affected by this, and must still work.
* ao_coreaudio_exclusive: deal with devices return different channel countwm42015-10-213-1/+33
| | | | | | | | | If the device returns an unexpected number of channels instead