summaryrefslogtreecommitdiffstats
path: root/audio
Commit message (Collapse)AuthorAgeFilesLines
* timer: teach it about nanosecondsKacper Michajłow2023-09-291-1/+1
| | | | | Those changes will alow to change vsync base to more precise time base. In general there is no reason to truncate values returned by system.
* ao_audiotrack: convert to nanosecondsKacper Michajłow2023-09-291-14/+14
|
* audio/chmap: support up to 64 channelsKacper Michajłow2023-09-291-1/+1
| | | | This fixes AAC 22.2 playback
* wasapi: clamp number of output channels to 8Kacper Michajłow2023-09-291-1/+13
| | | | | | This is the most supported in standard layout, if we request more it tends to fallback to stereo instead. Also channels mask is 32-bit and it can get truncated.
* chmap: add more channel layouts up to 22.2Kacper Michajłow2023-09-294-1/+30
|
* audio/chmap: link string buffer size to MP_NUM_CHANNELSKacper Michajłow2023-09-292-3/+6
|
* af_scaletempo2: raise max playback rate to 8.0llyyr2023-09-271-1/+1
| | | | | | 4.0 was too low and copied from Chromium defaults when the filter was initially written, there's no good reason for it to be so low, so double it.
* options: remove a few options marked with .deprecation_messageDudemanguy2023-09-211-3/+0
| | | | | | | | | | | A bit different from the OPT_REPLACED/OPT_REMOVED ones in that the options still possibly do something but they have a deprecation message. Most of these are old and have no real usage. The only potentially controversial ones are the removal of --oaffset and --ovoffset which were deprecated years ago and seemingly have no real replacement. There's a cryptic message about --audio-delay but who knows. The less encoding mode code we have, the better so just chuck it.
* af_scaletempo2: fix missing variable init, remove redundant initferreum2023-09-201-1/+1
|
* af_scaletempo2: truncate final packet to expected lengthferreum2023-09-201-0/+14
| | | | | | | | | | Avoid generating too much audio after EOF. Note: This often has no effect, because less audio is produced than required. Usually this comes to effect with the userspeed filter at high speed (4x) and going back to 1x speed to remove the filter.
* af_scaletempo2: fix processing of final packetferreum2023-09-203-16/+64
| | | | | | | | | | | | After the final input packet, the filter padded with silence to allow one more iteration. That was not enough to process the final frames. Continue padding the end of `input_buffer` with silence until the final frames have been processed. Implementation: Instead of padding when adding final samples, pad before running WSOLA iteration. Count number of added silent frames and remaining input frames for time keeping.
* af_scaletempo2: calculate latency by center of search blockferreum2023-09-202-6/+6
| | | | | | | | | | | | | | | | | | | | | This changes the emitted pts values from the start of the search block to the center of the search block. Change initial `output_time` accordingly. Initial `search_block_index` is irrelevant, because it's overwritten before the first iteration. Using the `output_time` removes the rounding of `search_block_index`, which also fixes the <20 microsecond gaps in timestamps between output packets. Rationale: The variance in audio position was in the range `0..search-interval`. With this change, the range is (- search-interval / 2)..(search-interval / 2)` which ensures lower maximum offset.
* af_scaletempo2: restore exact audio sync on return to 1x speedferreum2023-09-201-1/+9
| | | | | | | | | Target block can be anywhere in the previous search-block, varying by `search-interval` while the filter is active. This resulted in constant audio offset when returning to 1x playback speed. - Move the search block to the target block to sync up exactly. - Drop old frames to minimize input_buffer usage.
* af_scaletempo2: fix speed change latency and pts spikesferreum2023-09-203-42/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The internal time update function involved multiple problems: - Time was updated after WSOLA iteration. The means speed was updated one iteration later than it could be. - The update functions caused spikes of too many or too few samples advanced, leading to audio glitches on speed changes. - The inconsistent updates made it very difficult to produce gapless audio packets. - The `output_time` update function involved complicated feedback: `search_block_index` influenced how many frames from `input_buffer` are retained, which influenced how much `output_time` is changed, which influenced `search_block_index`. With these changes: - Time is updated before WSOLA iterations. Speed changes are effective instantly. - There are no spikes in playback speed during speed changes. - No significant gaps are introduced in output packets. - The time update function becomes (function calls omitted for brevity) output_time += ola_hop_size * playback_rate Functions received a `playback_rate` parameter to check how many samples are needed before iteration. Internal state is only updated when the iteration is actually run, so the speed is allowed to change until enough data is received.
* af_scaletempo2: fix audio artifact on initial WSOLA iterationferreum2023-09-202-7/+20
| | | | | | | | | The first WSOLA iteration overlapped audio with whatever was in the `wsola_output` buffer. This was either silence (if not run before), or old frames (if switching to 1x and back to a different speed). Track the state of the output buffer and memcpy the whole window for the first iteration instead.
* af_scaletempo2: fix audio offset when playing back at 1x speedferreum2023-09-201-9/+13
| | | | | `read_input_buffer` needs to respect the `target_block_index`, otherwise the audio resumes at the wrong position.
* af_scaletempo2: fix inconsistent search block position after initferreum2023-09-201-2/+3
| | | | | | | | | `output_time` is used to set the center of the search block. Init of both `search_block_index` and `output_time` with 0 caused inconsistent search block movement for the first iterations. Initialize with `search_block_center_offset` for consistency with initial `search_block_index`.
* af_scaletempo2: move latency calculation to internal functionferreum2023-09-203-3/+9
|
* af_scaletempo2: fix missing dereference when processing final packetferreum2023-09-201-1/+1
| | | | | Missing dereference was not noticed because assigning 0 to pointer is allowed.
* af_scaletempo2: fix audio-video de-sync caused by speed changesferreum2023-09-201-8/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes #12028 There was an additional issue that audio was always delayed by half the configured search-interval. This was caused by the `out` buffer length not being included in the delay calculation. Notes: - Every WSOLA iteration advances the input buffer by _some amount_, and produces data in the output buffer always of size `ola_hop_size`. - `mp_scaletempo2_fill_buffer` is always called with `ola_hop_size` - Thus, the rendered frames are always cleared immediately after processing, and `num_complete_frames` is 0 in the delay calculation. - The factors contributing to delay are: - the pending samples in the input buffer according to the search block position, and - the pending rendered samples in the output buffer (always empty in practice). The frame_delay code looked like that of the rubberband filter, which might not work for scaletempo2. Sometimes a different amount of input audio was consumed by scaletempo2 than expected. It may have been caused by speed changes being a more dynamic process in scaletempo2. This can be seen by where `playback_rate` is used in `run_one_wsola_iteration`: `playback_rate` is only referenced after the iteration, when updating the time and removing old data from buffers. In scaletempo2, the playback speed is applied by changing the amount the search block is moved. That apparently averages out correctly at constant playback speed, but when the speed changes, the error in this assumption probably spikes. This error accumulated across all speed changes because of the persistent `frame_delay` value. With the removal of the persistent `frame_delay`, there should be no way for the audio to drift off. By deriving the delay from filter buffer positions, and the buffers are filled only as much as needed, the delay always stays within buffer bounds.
* Revert "ao/pulse: implement period_size"sfan52023-08-201-1/+0
| | | | | | | This is why you don't merge three year old contributions without checking that they're even applicable anymore. This reverts commit 5a94c86029a2d0e5452c07a7c12d2a6981f607df.
* ao/pulse: implement period_sizeNicolas F2023-08-201-0/+1
| | | | | | | | The idea behind period_size is that it's the minimum amount of data that your audio subsystem wants to fetch. For PulseAudio, this is given by the minreq buffer attribute, which is in bytes for all channels. Hence the divisions.
* ao/jack: set device_buffer to JACK buffer sizeNicolas F2023-08-201-0/+2
| | | | | | | | | | | | | This change sets the device_buffer member of the ao struct for the JACK ao to whatever value we read during init. While JACK allows changing the audio buffer size on-the-fly (you can do this for example through DBus), having it somehow reconfigure the entire audio buffer logic of mpv that depends on device_buffer in some way when that happens only leads to audio dropout and weird code. device_buffer's role is mostly for prebuffer from what I understand, which means that simply setting it to its current value in the init function is fine.
* ao_oss: add "spdif" passthrough support for high bitrate codecs (e.g. Dolby ↵rim2023-08-201-5/+5
| | | | | | | | | | | | | | | | Atmos, DTS-HD, etc.) over HDMI In addition to the patch, appropriate additions to the mpv.conf file will of course be needed for this to work. For example on my system: audio-device=oss//dev/dsp4 audio-spdif=ac3,dts,dts-hd,eac3,truehd This has been tested using recent FreeBSD-13.1-stable, using external surround processors (both a Trinnov Altitude 16 and an LG OLED that supports Dolby Atmos, and connected with HDMI to an NVidia RTX 2070). Author and tester: David G Lawrence <dg1007@dglawrence.com>
* audio: drain ao before setting pauseDudemanguy2023-08-112-2/+7
| | | | | | | | | There's an edge cause with gapless audio and pausing. Since, gapless audio works by sending an EOF immediately, it's possible to pause on the next file before audio actually finishes playing and thus the sound gets cut off. The fix is to simply just always do an ao_drain if the ao is about to set a pause on EOF and we still have audio playing. Fixes #8898.
* ao_audiotrack: enable pcm-float by defaultsfan52023-08-081-0/+3
| | | | Since recent commits this should work 100% as well as s16.
* ao_audiotrack: support more channel layoutssfan52023-08-081-25/+39
|
* ao_audiotrack: support media rolesfan52023-08-081-1/+5
| | | | maybe this is good for something, who knows
* ao_audiotrack: don't ignore ao_read_data return valuesfan52023-08-081-2/+1
| | | | | | | | The difference this makes is that the OS API will notice when we underrun (as opposed to being fed silence). Other AOs mostly seem to not do this because they've committed to filling a buffer of a certain size no matter what, but I have not observed any ill effects for AudioTrack in my testing.
* ao_audiotrack: allow byte buffer data transfer for float samplessfan52023-08-081-12/+15
|
* ao_audiotrack: align buffer size to sample sizesfan52023-08-081-2/+8
| | | | | | This looks like a pretty bad bug but only became a problem with the last commit that allows rates like 22.5kHz to pass through directly instead of being resampled.
* ao_audiotrack: do not needlessly resamplesfan52023-08-081-1/+1
| | | | | Resampling when the driver says it isn't outputting more than a certain rate anyway makes sense, the inverse does not.
* ao_audiotrack: fix broken exception checkssfan52023-08-081-3/+3
| | | | | The exception always has to be checked and cleared even if we can already see that no valid value was returned.
* ao_audiotrack: remove unused writeV23sfan52023-08-081-2/+0
| | | | | The piece of code where it would make sense to use this never runs with API 21 or newer, so calling it there would be useless.
* ad_spdif: fix this not working at allsfan52023-08-071-4/+7
| | | | | fixes 4c3ed843dc8bde419d8c08565159a83cee9e3b9b closes #12102
* 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/