summaryrefslogtreecommitdiffstats
path: root/audio
Commit message (Collapse)AuthorAgeFilesLines
* ao_pipewire: set media role during init()Thomas Weißschuh2023-07-311-1/+1
| | | | | | wireplumber uses the media role when the node is first created. To have the property available at this point reliably we need to set it directly when creating the stream/node.
* audio: add AO_INIT_MEDIA_ROLE_MUSICThomas Weißschuh2023-07-311-0/+2
| | | | This allows the AO to set the media role directly during init().
* ao_sndio: use sio_flush() to improve controls responsivenessAlexandre Ratchov2023-07-301-0/+5
| | | | Use sio_flush() instead of sio_stop() to improve controls responsiveness.
* Revert "audio: add AOCONTROL_UPDATE_MEDIA_ROLE"Thomas Weißschuh2023-07-301-7/+0
| | | | | | | The only user of these APIs was ao_pipewire and the logic there got converted so drop the now dead code. This reverts commit 3167a77aa38b3700c9a4459fa5fe2f65eef080a8.
* Revert "ao_pipewire: handle AOCONTROL_UPDATE_MEDIA_ROLE"Thomas Weißschuh2023-07-301-22/+2
| | | | | | | | | | As the role property is interpreted by wireplumber it can only be evaluated when creating the stream. The current, dynamic mechanism is racy so revert it. See: #11253 Fixes: #12041 This reverts commit 535cd6f3130a179890505535b1cb06998a9cb07f.
* ad_spdif: fix segfault due to early deallocationsfan52023-07-271-7/+9
| | | | | | | | The avpkt was created once on decoder init but destroyed each time the filter was destroyed, this obviously can't work. Move the packet alloc to the filter init function instead. fixes: 4574dd5dc6ff75b1fc693afceec59fbcd51ccd4c
* ao_pipewire: for_each_sink: properly check termination conditionThomas Weißschuh2023-07-231-4/+15
| | | | | | | | | | | | | | | Doing a pw_thread_loop_wait() without checking conditions is invalid. The thread loop could be signalled for other reasons and in this case the wait needs to continue. PipeWire added such additional signaling in commit 33be898130f0 ("thread-loop: signal when started"). This meant that for_each_sink would return before the callbacks have fired and session_has_sink() would incorrectly return "false", failing the initialization of ao_pipewire. Fixes #11995
* ao_pipewire: use native buffersize by defaultThomas Weißschuh2023-07-221-1/+1
| | | | | | | Instead of trying to guess the correct number in mpv let the pipewire server choose. Fixes #9992
* osdep: move cfstr<->cstr conversions to a new apple_utils.c filercombs2023-06-252-20/+1
|
* ad_lavc: check for allocation failureNRK2023-06-221-0/+1
| | | | Fixes: https://github.com/mpv-player/mpv/issues/11792
* ao_pipewire: bump dependency to 0.3.48Thomas Weißschuh2023-06-211-12/+0
| | | | | | | | Now that Debian 12 is release bump the minium required version to what is provided in Ubuntu Jammy (22.04). The same as has been done for the wayland dependencies. Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
* ao_wasapi: use client name instead of hardcoded stringKacper Michajłow2023-06-211-7/+11
|
* ao_wasapi: remove infinite loop hack in AOCONTROL_UPDATE_STREAM_TITLEKacper Michajłow2023-06-211-13/+21
| | | | | | | | | | | | | | | | Instead of brute forcing the name until it is set, without any error checking and expecting it would start to work, fallback to client name if initial request fails. Fixes player going into infinite loop with very long title names. The API rejects unreasonably long names, which make sense. As for alleged "weird race condition in the IAudioSessionControl itself" I cannot comment. It works on my end and even if it fails, it is not a critical error or even something that we should care about... and obviously not hang the whole player for that. Fixes: #11803
* ao_oss: return actual OSS playing staterim2023-05-111-11/+2
| | | | fix: https://github.com/mpv-player/mpv/issues/10640
* ao_pipewire: let sound server determine latencyThomas Weißschuh2023-04-231-3/+7
| | | | Fixes #11467
* ao_pipewire: give sound server more flexibility for buffersThomas Weißschuh2023-04-231-1/+2
|
* ao_pipewire: use realtime scheduling for data threadThomas Weißschuh2023-03-051-1/+4
| | | | | | | | | | | By making the data thread realtime it is able to serve requests faster and more reliable reducing crackling in certain situations. As the mpv callbacks that are running on the data thread are all non-blocking and very short this should be safe. The same mechanism is also used by pw-cat and the alsa plugin shipped by pipewire.
* options: remove explicit initialization of integers to 0Christoph Heinrich2023-02-211-1/+0
|
* options: transition commands from OPT_FLAG to OPT_BOOLChristoph Heinrich2023-02-212-0/+2
|
* options: transition options from OPT_FLAG to OPT_BOOLChristoph Heinrich2023-02-2113-46/+42
| | | | | | c78482045444c488bb7948305d583a55d17cd236 introduced a bool option type as a replacement for the flag type, but didn't actually transition and remove the flag type because it would have been too much mundane work.
* various: drop unused #include "config.h"Thomas Weißschuh2023-02-2012-15/+0
| | | | | | Most sources don't need config.h. The inclusion only leads to lots of unneeded recompilation if the configuration is changed.
* ao_pipewire: drop unused #include "generated/version.h"Thomas Weißschuh2023-02-201-1/+0
|
* ao_pipewire: fix removal of zeroed hooks on old pipewireThomas Weißschuh2023-02-151-0/+5
| | | | | | | | | | Older versions of pipewire segfault when calling spa_hook_remove() on hooks that are zeroed. Add a backfill for the logic added by pipewire 0.3.57. Being able to remove zeroed hooks makes errorhandling much easier. See #11309
* ao_pipewire: allow usage of global volume controlThomas Weißschuh2023-02-111-5/+29
| | | | | | | | | | | | | PipeWire supports a global volume control for streams that works on top of the per-channel volumes. As mpv only supports a single volume with ao-volume it can make sense to use the single global volume from PipeWire for it. This allows the user to also specify per-channel volumes and not have mpv trample over them. This mode is not the default as pulseaudio does not support this global volume control and all tooling controlling PipeWire via pipewire-pulse (like pavucontrol) will not be able to see this channel.
* ao_pipewire: report linking errors from init()Thomas Weißschuh2023-02-031-0/+45
|
* ao_pipewire: add support for exclusive modeThomas Weißschuh2023-02-031-0/+3
|
* ao_pipewire: move stream flags to dedicated variableThomas Weißschuh2023-02-031-6/+6
|
* ao_pipewire: adjust message level based on probingThomas Weißschuh2023-02-031-2/+3
| | | | | | | Use the ao->probing property to upgrade the status message when the AO is explicitly selected. Suggested-by: uau on #mpv-devel
* ao_pipewire: remove unneeded gotoThomas Weißschuh2023-02-031-2/+2
|
* ao_pipewire: replace opencoded talloc()Thomas Weißschuh2023-02-031-1/+1
|
* ao_pipewire: print stream states as stringThomas Weißschuh2023-02-031-1/+2
|
* ao_pipewire: remove unnecessary empty linesThomas Weißschuh2023-02-031-3/+0
|
* ao_pipewire: remove opencoded spa_zero()Thomas Weißschuh2023-02-031-1/+1
|
* ao_pipewire: remove some unnecessary linebreaksThomas Weißschuh2023-02-031-7/+2
|
* ao_pipewire: reduce message level of unsuccessful connectionThomas Weißschuh2023-02-031-2/+2
| | | | | | | As ao_pipewire is probed first if a user does not have PipeWire running they will see a scary warning message even if another AO afterwards is probed fine. Tone down the error message so as not to confuse users.
* ao_pipewire: remove unnecessary bracesThomas Weißschuh2023-02-031-4/+2
|
* ao_lavc: remove unused codeKacper Michajłow2023-02-021-10/+0
|
* ao_pipewire: align thread name with general conventionsThomas Weißschuh2023-01-251-1/+1
|
* audio: simplify implementation of property ao-volumeThomas Weißschuh2023-01-259-74/+38
| | | | | | | | | | | | | | ao-volume is represented in the code with a `struct ao_control_vol_t` which contains volumes for two channels, left and right. However the code implementing this property in command.c never treats these values individually. They are always averaged together. On the other hand the code in the AOs handling these values also has to handle the case where *not* exactly two channels are handled. So let's remove the `struct ao_control_vol_t` and replace it with a simple float. This makes the semantics clear to AO authors and allows us to drop some code from the AOs and command.c.
* ao: remove trailing NULL element from driver arrayThomas Weißschuh2023-01-161-4/+3
|
* audio: fix crash during uninit on ao_lavcDudemanguy2023-01-131-10/+12
| | | | | The buffer state can be null when using --ao=lavc, so just check it first. Fixes #10175.
* various: replace abort() with MP_ASSERT_UNREACHABLE() where appropriatesfan52023-01-123-4/+5
| | | | | | | | In debug mode the macro causes an assertion failure. In release mode it works differently and tells the compiler that it can assume the codepath will never execute. For this reason I was conversative in replacing it, e.g. in mpv-internal code that exhausts all valid values of an enum or when a condition is clear from directly preceding code.
* various: replace if + abort() with MP_HANDLE_OOM()sfan52023-01-123-8/+4
| | | | | MP_HANDLE_OOM also aborts but calls assert() first, which will result in an useful message if compiled in debug mode.
* ao_audiotrack: replace malloc with tallocsfan52023-01-121-6/+1
|
* {video,audio}: adjust unsafe strncpy usagessfan52023-01-121-1/+1
|
* ao_coreaudio: use AudioUnitReset as ao_driver.reset to prevent long restartLi Chang2023-01-021-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | [motivation] Seeking on MacOS appears to be lagged when users connect to wireless audio output (airpods for example). This commit attempts to fix mpv-player/mpv#10270 [observation] 1. When using other media player (VLC to be exact) simultaneously, the lagging on seek disappear. We could guess that the AudioDevice is on some sort of "warm-up" state. See mpv-player/mpv#9243 for detailed description. 2. `AudioOutputUnitStart` takes significant longer time after each seek or pause/play when using wireless output devices compares to wired devices. [rationale] After investigate codes in ao_coreaudio.c, it appears that the the `stop` function was used as `ao_driver.reset` function. Therefore every seek and pause would call `AudioOutputUnitStop`. It turns out that `ao_driver.reset` function is used in `ao_reset`. And `ao_reset` function is used to clean up the state of current `ao` so I think `AudioUnitReset` is more proper than `AudioOutputUnitStop` under this semantics. Since ao_coreaudio use pull base mechanism, audio playback behaviors upon pause/seek could be handled by callback function (streaming silence when paused) so there is no need to stop AudioUnit when resetting. Therefore using `AudioUnitReset` as `ao_driver.reset` looks proper. Additionally, after using proper reset, the AudioUnit that represents hardware I/O devices doesn't need to be restart everytime seek/pause actions happen. Restarting wireless devices simply takes longer in MacOS which is the root cause of lagging observed by users when they seek or pause/play media. [method] Use `AudioUnitReset` for ao_driver.reset.
* audio: reset pull AO at end of fileThomas Weißschuh2022-12-221-1/+1
| | | | | | | | | | When a pull AO reaches reaches EOF then ao_read_data() will set p->playing = false. Because the ao is marked as not playing ao_set_pause(true) will not reset the AO. This keeps the output stream unintentionally open. Fixes #9835
* Revert "ao_pipewire: deactivate stream at end of playback"Philip Langdale2022-12-191-14/+0
| | | | This reverts commit b5373079f20aeeba8ac80e773f3cc05692dbb51f.
* ao_pipewire: deactivate stream at end of playbackThomas Weißschuh2022-12-181-0/+14
| | | | | | | By explictly shutting down the stream pipewire can deactivate the used hardware, saving CPU and power. Fixes #9835
* ao_pipewire: clean up when hotplug_init failsThomas Weißschuh2022-12-121-1/+2
|
* ao_pipewire: destroy context on connection failureThomas Weißschuh2022-12-121-0/+1
|
* ao_pipewire: free properties on failureThomas Weißschuh2022-12-121-2/+4
|
* ao_coreaudio: use device's nominal sample rate for latency propertiesrcombs2022-12-101-1/+9
| | | | | | Fixes sync issues when using high-latency devices at non-native sample rates Closes #10984
* 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
|