summaryrefslogtreecommitdiffstats
path: root/audio
Commit message (Collapse)AuthorAgeFilesLines
* ffmpeg: update to handle deprecation of `av_init_packet`Philip Langdale2022-12-032-8/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This has been a long standing annoyance - ffmpeg is removing sizeof(AVPacket) from the API which means you cannot stack-allocate AVPacket anymore. However, that is something we take advantage of because we use short-lived AVPackets to bridge from native mpv packets in our main decoding paths. We don't think that switching these to `av_packet_alloc` is desirable, given the cost of heap allocation, so this change takes a different approach - allocating a single packet in the relevant context and reusing it over and over. That's fairly straight-forward, with the main caveat being that re-initialising the packet is unintuitive. There is no function that does exactly what we need (what `av_init_packet` did). The closest is `av_packet_unref`, which additionally frees buffers and side-data. However, we don't copy those things - we just assign them in from our own packet, so we have to explicitly clear the pointers before calling `av_packet_unref`. But at least we can make a wrapper function for that. The weirdest part of the change is the handling of the vtt subtitle conversion. This requires two packets, so I had to pre-allocate two in the context struct. That sounds excessive, but if allocating the primary packet is too expensive, then allocating the secondary one for vtt subtitles must also be too expensive. This change is not conditional as heap allocated AVPackets were available for years and years before the deprecation.
* ao_pipewire: log sample queueingThomas Weißschuh2022-11-281-0/+2
| | | | | | | This allows us to more easily see the datapath from mpv to pipewire. We know how often the callbacks are triggered, how big the buffers are and how much data mpv provides to pipewire.
* ao_pipewire: log version information and metadataThomas Weißschuh2022-11-131-0/+13
|
* ao_pipewire: reload ao on stream disconnectThomas Weißschuh2022-11-071-0/+5
| | | | | | | | This allows the core of mpv to know about issues in the AO. Otherwise playback will just freeze as no more data callbacks are sent by PipeWire. Also it allows mpv to try to reconnect the AO or find another, working AO.
* ao_pipewire: explicitly remove stream hookThomas Weißschuh2022-11-071-0/+2
| | | | | | We want to add more logic to the stream event handler. This logic should not be triggered during normal stream shutdown, so we remove the listener beforehand.
* ao_pipewire: log generic stream errorsThomas Weißschuh2022-11-071-0/+17
|
* Revert "ao/audiounit: include AVAudioSession buffer in latency calc"Aman Karmani2022-11-071-1/+1
| | | | This reverts commit 8b114e574abd08892612e21e784ea1872e1adf8c.
* ao_coreaudio: specify UTF-8 as text encoding for CFString conversionsrcombs2022-10-291-1/+1
| | | | | This matches our internal expectations, as well as fixes handling of non-ASCII device descriptions.
* ao_pipewire: compatibility for libpipewire 0.3.19Thomas Weißschuh2022-10-261-0/+6
|
* ao: promote ao_pipewireThomas Weißschuh2022-10-241-3/+3
| | | | | | The AO is feature-complete now. As PipeWire also provides compatibility with PulseAudio, ALSA and Jack we should put it before those for the autodetection to work.
* ao_pipewire: test for session to contain audio sinksThomas Weißschuh2022-10-241-0/+22
| | | | | | | | | | | | The pure presence of PipeWire does not mean that it is actually driving the audio session. For example it could only be meant for video. Currently there is no proper API to detect this (see [0]), so we check for the presence of audio sinks. As soon as a proper API exists, we should use that. [0] https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/1835
* ao_pipewire: init_boilerplate(): simplify errorhandlingThomas Weißschuh2022-10-241-7/+3
|
* audio/format: fix Type 'struct entry' has incompatible definitions in ↵Cœur2022-10-231-4/+4
| | | | | | different translation units `struct entry` already exists from <search.h>, so the one we declare in audio/format.c needs to be named differently
* ao_pipewire: allow specification of remote nameThomas Weißschuh2022-10-061-2/+10
|
* ao_pipewire: small cleanups and restructringThomas Weißschuh2022-10-061-7/+9
| | | | | | * Remove unneeded braces. * Don't use non-standard %m in printf. * Organize struct priv a bit.
* ao_pipewire: don't try to lock nonexistent loopThomas Weißschuh2022-09-281-2/+3
|
* ao_pipewire: use target.objectThomas Weißschuh2022-09-281-39/+2
| | | | | | | Specifying the id of the target node during stream connect is deprecated. Instead the property target.object should be used to link by target serial or name. Using the name allows us to drop a bunch of custom code.
* af_scaletempo2: fix crash when the number of channels increasesPeter DeLong2022-09-231-5/+4
| | | | | | | | | | | | | | | | When af_scaletempo2.c:process() detects a format change, it goes back through mp_scaletempo2_init() to reinitialize everything. However, mp_scaletempo2.input_buffer is not necessarily reallocated due to a check in af_scaletempo2_internals.c:resize_input_buffer(). This is a problem if the number of audio channels increases, since without reallocating, the buffer for the new channel(s) will at best point to NULL, and at worst uninitialized memory. Since resize_input_buffer() is only called from two places, pull size check out into mp_scaletempo2_fill_input_buffer(). This allows each caller to decide whether they want to resize or not. We could be smarter about when to reallocate, but that would add a lot of machinery for a case I don't expect to be hit often in practice.
* ao_audiounit: get the channel layout from the AU itselfrcombs2022-09-151-13/+77
| | | | | | | Fixes 5.1/7.1 output mapping on tvOS 16, and also makes the AC3-layout hack unnecessary. Also adds some diagnostic log messages.
* ao_pipewire: listen to hotplug eventsThomas Weißschuh2022-09-111-1/+100
|
* ao_pipewire: use proper hotplug init APIsThomas Weißschuh2022-09-111-8/+13
|
* ao_pipewire: create is_sink_node helperThomas Weißschuh2022-09-111-8/+16
|
* audio: list devices for all AOs with hotplug_initThomas Weißschuh2022-09-111-4/+7
| | | | | | | | | | | | | | Previously we would only call list_devs() on available AOs if an AO *did not* have a hotplug_init() callback or for the first one that *did* have it. This is problematic when multiple fully functional hotplug-capable AOs are available. The second one would not be able to contribute discovered devices. This problem prevents ao_pipewire from introducing full hotplug support with hotplug_init().
* audio: try to use playback AO as hotplug AO firstThomas Weißschuh2022-09-112-7/+23
| | | | | | | | | | | | | | | | | | | | | When a platform has multiple valid AOs that can provide hotplug events we should try to use the one that also provides playback. Concretely this will help when introducing hotplug support for ao_pipewire. Currently ao_pulse is probed by ao_hotplug_get_device_list() before ao_pipewire and on the common setups where both AOs could work pulse will be selected for hotplug handling. This means that hotplug_init() of ao_pipewire will never be called and list_devs() has to do its own initialization. But if ao_pulse is non-functional or not compiled-in suddenly ao_pipewire *must* implement hotplug_init() for hotplugging events to work for all. Also if the hotplug ao_pulse connects to a PulseAudio instance that is not emulated by the same PipeWire instance as the playback ao_pipewire the hotplug events are useless.
* ao_pipewire: handle AOCONTROL_UPDATE_MEDIA_ROLEThomas Weißschuh2022-09-101-2/+22
|
* audio: add AOCONTROL_UPDATE_MEDIA_ROLEThomas Weißschuh2022-09-101-0/+7
| | | | | | This is used to notify an AO about the type of media that is being played. Either a movie or music.
* ao_pipewire: fix indentThomas Weißschuh2022-09-101-7/+7
|
* ad_lavc: strip non-normalized floatsNiklas Haas2022-09-023-0/+35
| | | | | | | `opus` codec likes returning denormalized floats in some cases, causing wacky issues. Fixes #10290
* ao_pipewire: for_each_sink(): report errorsThomas Weißschuh2022-08-281-9/+32
|
* audio: fix lack of reinitialization on format change with pull AOsPhilip Langdale2022-08-231-0/+1
| | | | | | | | | | | | uau did some investigation and noticed that we do not send a wakeup event when we encounter end-of-stream in ao_read_data(), in contrast to the equivalent logic for push AOs in ao_play_data(). Inserting that wakeup fixes the original problem of lack of reinitialization on a format change without the problems we saw with the previous attempted fix. Fixes #10566
* ao_pipewire: make sure not to exceed the available bufferThomas Weißschuh2022-08-211-1/+1
| | | | | | | | | | The error description in #10545 could indicate that we are overflowing we are corrupting the buffer metadata ourselves through out-of-bound writes. This check is also present in pw-cat so it seems to be expected for b->requested to exceed the actual available buffer space. Potential fix for #10545
* ao_pipewire: restructure logic a bitThomas Weißschuh2022-08-171-4/+3
|
* ao_pipewire: only try to read requested dataThomas Weißschuh2022-08-171-0/+4
|
* ao_pipewire: report all available info about chunkThomas Weißschuh2022-08-171-1/+5
| | | | | This allows the audio server better to make sense of the data instead of having to use heuristics.
* ao_pipewire: tell audio server about number of queued samplesThomas Weißschuh2022-08-091-1/+2
|
* ao_pipewire: use mpv loggingThomas Weißschuh2022-08-041-1/+1
|
* af_rubberband: add new engine option in rubberband 3.0.0Christoph Heinrich2022-08-031-2/+15
|
* ao_pipewire: prevent deprecation warning for pw_stream_get_time()Thomas Weißschuh2022-07-081-1/+7
|
* ao_pipewire: pipewire uses linear volumeWim Taymans2022-07-081-3/+2
| | | | Don't use cube root volumes, pipewire uses linear volumes.
* ao_pipewire: don't access core after disconnectWim Taymans2022-07-081-1/+0
| | | | | | | | pw_core_disconnect frees the core, so accessing it afterward to destroy the context is not allowed. Instead, just destroy the context, the first thing it does is disconnect all cores for us.
* ao_pipewire: zero listenersWim Taymans2022-07-081-0/+2
| | | | | The listeners need to be cleared because removing them might invoke the removed handler, which could otherwise point to invalid memory.
* ao_pipewire: support ao-volume on non-stereo channel layoutsAlex B2022-07-081-9/+23
| | | | | | | | mpv only remembers volume for two channels. Always apply the same volume to all channels in case of non-stereo layout similarly to ao_pulse. Don't try to do anything smart when averaging volumes, normally they are equal anyway.
* audio/chmap: add mp_iterate_builtin_layoutsJan Ekström2022-06-152-0/+32
| | | | | Mostly useful for unit tests in order to access the channel layouts from chmap which have mapped channels.
* ad_lavc: switch to AVChannelLayout when availableJan Ekström2022-06-151-1/+18
|
* af_lavcac3enc: switch to AVChannelLayout when availableJan Ekström2022-06-141-3/+36
|
* af_lavcac3enc: refactor chmap adding into its own functionJan Ekström2022-06-141-7/+13
| | | | This simplifies ifdeffery with AVChannelLayouts.
* ao_lavc: switch to AVChannelLayout when availableJan Ekström2022-06-121-0/+6
|
* audio/aframe: switch to AVChannelLayout when availableJan Ekström2022-06-121-0/+32
|
* audio: add AVChannelLayout helpers to convert from/to mp_chmapJan Ekström2022-06-122-0/+83
| | | | | | | | | This is the new FFmpeg channel layout structure, which now combines channel count and layout into a single location. Only unspecified (channel count only) and native (channel layout mask based) layouts are currently supported for the initial move towards non-deprecated APIs.
* various: remove trailing whitespaceGuido Cella2022-05-144-6/+6
|
* various: fix typosCœur2022-04-251-1/+1
|
* ao_pipewire: Do not hold thread lock during loop stopThomas Weißschuh2022-03-311-3/+1
| | | | | | | Stopping the thread is done using pw_thread_loop_stop(), *which must be called without the lock held.* Fixes #10033
* ao_pipewire: fix resource lifetimesThomas Weißschuh2022-03-301-7/+21
| | | | | | | We have to destroy the core before destroying the loop. Also we have to lock the mainloop for operations on its objects. Fixes #10003
* ao_sndio: fix parentheses warningLaserEyess2022-03-111-3/+3
| | | | | No change in logic, but wrap the LT operator and the && in parentheses to silence the compiler warning.
* ao_pipewire: fix ao-volume handlingAlex B2022-02-111-3/+6
| | | | | | | | Pass channel volumes to `pw_stream_set_control` as array. This is correct calling conventions and prevents right channel muting every time ao-volume property is changed. Terminate `pw_stream_set_control` calls with 0.
* ao_pipewire: validate pod creationThomas Weißschuh2022-02-061-0/+6
| | | | | Our allocated buffers should be big enough, but add some errorhandling just in case.
* ao_pipewire: add support for device selectionThomas Weißschuh2022-02-061-14/+188
|
* ao_sndio: bugfix and small refactoring for #8314Andrew Krasavin2022-01-221-43/+44
| | | | | | | | Changes: * fixed hangups in the loop function and in some other cases * refactoring according to @michaelforney's recommendations in #8314 * a few minor and/or cosmetic changes * ability to build ao_sndio using meson
* ao_sndio: add this audio output againrim2022-01-222-0/+321
| | | | | | | | | Changes: - rewrite to use new internal MPV API; - code refactoring; - fix buffers size calculations; - buffer set to auto; - reset() - clean/reinit device only after errors;
* ao/pipewire: Add copyright headerPhilip Langdale2022-01-171-0/+21
| | | | | | | | | | Sometimes the most obvious things can be missed. Reflects authorship described in the original commit. * https://github.com/mpv-player/mpv/pull/7902 * https://github.com/Oschowa/mpv/commit/fddb143282fa74425a8a6f29c9566e51777759d0 * https://github.com/mpv-player/mpv/pull/9587
* ao_pipewire: Add PipeWire audio backendThomas Weißschuh2022-01-172-0/+400
| | | | | | | | | | | | | | | | | | | | | | | | | | The AO provides a way for mpv to directly submit audio to the PipeWire audio server. Doing this directly instead of going through the various compatibility layers provided by PipeWire has the following advantages: * It reduces complexity of going through the compatibility layers * It allows a richer integration between mpv and PipeWire (for example for metadata) * Some users report issues with the compatibility layers that to not occur with the native AO For now the AO is ordered after all the other relevant AOs, so it will most probably not be picked up by default. This is for the following reasons: * Currently it is not possible to detect if the PipeWire daemon that mpv connects to is actually driving the system audio. (https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/1835) * It gives the AO time to stabilize before it is used by everyone. Based-on-patch-by: Oschowa <oschowa@web.de> Based-on-patch-by: Andreas Kempf <aakempf@gmail.com> Helped-by: Ivan <etircopyhdot@gmail.com>
* af_lavcac3enc: fix some minor thingssfan52022-01-101-2/+3
| | | | mark an array as static, a typo and a missing free
* af_lavcac3enc: replace deprecated av_init_packet()sfan52022-01-101-11/+17
|
* af_lavcac3enc: fix memory leak on no-opNiklas Haas2021-12-141-16/+19
| | | | | | | | | Simply returning out of this function leaks avpkt, need to always "goto done". Rewrite the logic a bit to make it more clear what's going on (IMO). Fixes #9593
* ao_openal: enable AL_SOFT_direct_channels_remix extension by defaultIvan2021-11-291-3/+9
| | | | Prevent audio distortions caused by OpenAL's 3D effects.
* audio: stop corrupting audio on underreadsAman Karmani2021-11-201-1/+2
| | | | | | regression introduced in b74c09efbf7c6969fc053265f72cc0501b840ce1 Signed-off-by: Aman Karmani <aman@tmm1.net>
* ao_opensles: add guards for sample rate to useTom Yan2021-11-191-0/+2
| | | | | | Upstream "Wilhelm" (the Android OpenSLES implementation) supports only 8000 <= rate <= 192000. Make sure mpv resamples the audio when necessary.
* options: remove always true m_obj_list::allow_unknown_entriesEmil Velikov2021-11-151-1/+0
| | | | | | | Ever instance of m_obj_list is a constant and for all of them, the field is true. Just remove the field all together. Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
* ao_oss: define PATH_DEV_MIXER as it is an internal defineJan Ekström2021-11-101-0/+1
| | | | | | | | This fixes a mismatch between configure working and build time failing with Linux + OSSv4, enabling compilation on Debian based Linux systems with the oss4-dev package. Fixes #9378
* audio: replace deprecated av_mallocz_arraysfan52021-11-051-1/+1
|
* ao_audiotrack: change buffer sizing logicAman Karmani2021-10-211-2/+2
| | | | | | | | Previously number of channels was being ignored. The buffer will now be between 75ms and 150ms Signed-off-by: Aman Karmani <aman@tmm1.net>
* ao_audiotrack: allocate chunk buffer based on negotiated sizeAman Karmani2021-10-211-2/+3
| | | | Signed-off-by: Aman Karmani <aman@tmm1.net>
* ao_audiotrack: support delay up to 2s as normalAman Karmani2021-10-211-2/+2
| | | | | | Fixes issues streaming to echo speaker pair from firetv devices. Signed-off-by: Aman Karmani <aman@tmm1.net>
* ao_audiotrack: set device_buffer based on underlying buffer size when availableAman Karmani2021-10-211-0/+10
| | | | Signed-off-by: Aman Karmani <aman@tmm1.net>
*