summaryrefslogtreecommitdiffstats
path: root/audio
Commit message (Collapse)AuthorAgeFilesLines
* af_bs2b: fix option default valuewm42015-03-221-1/+2
| | | | | | | | | --af=bs2b:help abort()ed because the default value of the "profile" option is not represented by any choice. Fix it by adding an "unset" choice. (It's a bit odd because there's already a "default" choice, which is not default, but I don't care enough about this filter.) Fixes #1712.
* player: better handling of video with no timestampswm42015-03-201-0/+3
| | | | | | | | | | | Trying to handle such video is almost worthless, but it was requested by at least 2 users. If there are no timestamps, enable byte seeking by setting ts_resets_possible. Use the video FPS (wherever it comes from) and the audio samplerate for timing. The latter was already done by making the first packet emit DTS=0; remove this again and do it "properly" in a higher level.
* af_lavfi: handle seekingwm42015-03-171-1/+27
| | | | | | | | To handle seeking correctly, we need to flush the filter. libavfilter does not support flushing, so we destroy and recreate it. We also need to handle resume-after-EOF, because the mpv audio code sends an EOF before and after seeking (the latter happens because the player drains the filter chain in a generic way, which "causes" EOF).
* ao: slightly extend debug messageswm42015-03-161-1/+4
| | | | | This function already got uglified with debug printing; might as well go all the way.
* audio: fix off by one error in channel map selection codewm42015-03-151-2/+2
| | | | | | | The consequence was that some AOs (like ao_jack) could not output 8 channels. Fixes #1688.
* ao: align audio buffer sizewm42015-03-131-0/+3
| | | | Might or might not matter.
* audio: fix spdif packet size unitwm42015-03-102-9/+9
| | | | | | | | | | | In commit 5f8b060e I blindly assumed that the packet sizes were in pseudo-samples, but they were actually in bytes. Oops. (The effect was that cutting the audio was a bit less precise than it can be.) Also remove the packet size from ad_spdif.c; it didn't actually use it, and simply takes what the spdif "muxer" returns.
* audio: fix spdif DTS packet sizewm42015-03-101-0/+1
| | | | Broken in one of the previous commits.
* ad_spdif: move frame sizes to a general functionwm42015-03-103-7/+16
| | | | | | Needed for the next commit. This commit should probably be reverted as soon as we're working with full audio frames internally, instead of "flat" FIFOs.
* ao_coreaudio_exclusive: port to pull API, fix latency calculationswm42015-03-101-78/+37
| | | | | | | | | | | | | | Instead of maintaining a private ring buffer, use the generic support for audio APIs with pull callbacks (internally called AO pull API). This also fixes latency calculations: instead of just returning the ringbuffer status, the audio playback state is calculated better and includes interpolation. The main reason this wasn't done earlier was mid-stream format switching. The pull API can now handle it (in a way) by destroying and recreating the AO. This is a bit brutal, but quite simple. It's untested in this new AO, though. Some details might not be right, like how ot restores the old format when reloading.
* ao_coreaudio: move some helpers to utilswm42015-03-103-16/+20
| | | | Needed by ao_coreaudio_exclusive.c in the next commit.
* ao_coreaudio_exclusive: rip out pseudo volume controlwm42015-03-101-40/+1
| | | | | | | | | | | | | | | | | This could mute a digital passthrough stream by writing zeros. All other volume values did nothing. The comment about MPlayer dying hasn't been true in mpv for quite a while. It's even possible that it's fixed in upstream MPlayer. mpv will print a scary error message when trying to change volume with spdif, and continue normally. If we really want to mute by writing zeros, we should do it in a separate filter. But I'm not overly fascinated by this approach; is it even guaranteed receivers will not be confused by a stream of zeros? The main reason to remove this is that it's in the way of further cleanups.
* audio: refuse to change playback speed with spdifwm42015-03-071-1/+1
| | | | | | | | | | | | Handle the failure gracefully, instead of exploding and disabling audio. Just set the speed back to 1.0. Also remove the AF_DETACH from af_scaletempo. This actually created a dangling pointer in af_add(), a tricky consequence of af_add() reconfiguring the filter chain and the newly added filter using AF_DETACH. Fortunately the AF_DETACH is not needed (and probably never worked - it comes from MPlayer times, and MPlayer also disables audio when trying to change speed with spdif).
* af_scaletempo: minor simplificationwm42015-03-061-15/+6
|
* af_scaletempo: restore confusing mplayer behaviorwm42015-03-061-3/+9
| | | | | | | | | This matters only when setting obscure scaletempo suboptions. See #1653. (But what we really should do is figuring out how to do this in a sane way.)
* ad_spdif: remove per-packet messagewm42015-03-041-1/+0
| | | | It was annoying and didn't ever help with anything.
* audio: change playback speed directly in resamplerwm42015-03-023-90/+73
| | | | | | | | | | | | | Although the libraries we use for resampling (libavresample and libswresample) do not support changing sampelrate on the fly, this makes it easier to make sure no audio buffers are implicitly dropped. In fact, this commit adds additional code to drain the resampler explicitly. Changing speed twice without feeding audio in-between made it crash with libavresample inc ertain cases (libswresample is fine). This is probably a libavresample bug. Hopefully this will be fixed, and also I attempted to workaround the situation that crashes it. (It seems to point in direction of random memory corruption, though.)
* audio: accept 1.0 and 2.0 as aliases for mono and stereowm42015-02-261-0/+2
|
* ao/wasapi: move resume to audio threadKevin Mitchell2015-02-233-24/+38
| | | | | | | | | | | | | | This echanges the two events hForceFeed/hFeedDone for hResume. This like the last commit makes things more deterministic. Importantly, the forcefeed is only done if there is not already a full buffer yet to be played by the device. This should fix some of the problems with exclusive mode. This commit also removes the necessity to have a proxy to the AudioClient object in the main thread. fixes #1529
* ao_wasapi: move reset into audio threadKevin Mitchell2015-02-232-9/+37
| | | | | | | | | This makes things a bit more deterministic. It ensures that the audio thread isn't doing anything between IAudioClient_Stop(), IAudioClient_Reset() and setting the sample_count to 0. Buffer overfilling on resume is still a problem in exclusive mode (see next commit).
* ao: fix null dereferenceStefano Pigozzi2015-02-141-0/+2
|
* ao_coreaudio: add support for hotplug notificationsStefano Pigozzi2015-02-143-23/+96
| | | | | | | | | | This commit adds notifications for hot plugging of devices. It also extends the old behaviour of the `audio-out-detected-device` property which is now backed by the hotplugging code. This allows clients to be notified when the actual audio output device changes. Maybe hotplugging should be supported for ao_coreaudio_exclusive too, but it's device selection code is a bit fragile.
* ao_pulse: listen for hotplug eventswm42015-02-121-7/+41
| | | | | | | | | | | | | | | This requires jumping through multiple hoops on fire. Since the PulseAudio API is virtually undocumented, I'm not sure if this is correct either. We only react to sink events, and only to the NEW/REMOVE events. CHANGE events are ignored, because PulseAudio fires them far too often - even if the system is completely idle! If pa_sink_info.name can change, we're in trouble. pa_sink_info.description is not so important, but it'd also be a bit un-nice if it can change, and we don't update it. The weird way how the actual AO and the hotplug context share the same struct (ao) comes in handy here, although context_success_cb() still had to be duplicated from success_cb() - the unused argument has a different type.
* audio: add device change notification for hotpluggingwm42015-02-123-25/+120
| | | | | | | | | | | | | | | | | | | | | | | | | | | Not very important for the command line player; but GUI applications will want to know about this. This only adds the internal API; support for specific audio outputs comes later. This reuses the ao struct as context for the hotplug event listener, similar to how the "old" device listing API did. This is probably a bit unclean and confusing. One argument got reusing it is that otherwise rewriting parts of ao_pulse would be required (because the PulseAudio API requires so damn much boilerplate). Another is that --ao-defaults is applied to the hotplug dummy ao struct, which automatically applies such defaults even to the hotplug context. Notification works through the property observation mechanism in the client API. The notification chain is a bit complicated: the AO notifies the player, which in turn notifies the clients, which in turn will actually retrieve the device list. (It still has the advantage that it's slightly cleaner, since the AO stuff doesn't need to know about client API issues.) The weird handling of atomic flags in ao.c is because we still don't require real atomics from the compiler. Otherwise we'd just use atomic bitwise operations.
* ao: set correct client name when listing deviceswm42015-02-121-4/+3
| | | | | | | | | | This is a small oversight. The client name (as set on command line options or, more importantly, the client API) was not set when listing devices e.g. via the "audio-device-list" property. Might or might not fix #1578. Also adjust the log level for an unrelated message.
* af_rubberband: actually fix deadlockMartin Herkt2015-02-121-1/+1
| | | | 371e5d0 missed this one
* af_rubberband: fix filter error deadlockwm42015-02-121-2/+2
| | | | | | | | | | | | rubberband_available() can return a negative value, which we assigned to a size_t variable, leading to the frame allocation to fail. This could spam "Error filtering frame.". (That it spams this instead of exiting should probably also be considered a bug.) At least in the realtime mode and in our case, a negative return value should not have any different meaning from a 0 return value, in particular because we call rubberband_get_samples_required() or set the "final" parameter for rubberband_process() to continue/stop processing.
* af_rubberband: change defaultsMartin Herkt2015-02-121-9/+6
| | | | | | | | | After some testing, I am fairly convinced that these defaults sound better than the previous settings. This also eliminates some issue with random crackling and noise. Also remove the `stretch` option since it has no effect in realtime mode.
* af_rubberband: fix breakagewm42015-02-111-1/+3
| | | | | | | | | The previous commit on this filter accidentally removed the RubberBandOptionProcessRealTime option. Without it, the lib prints a warning and passes the audio through. Also add the RubberBandOptionSmoothingOn option back. Though for some reason the output sounds still very wrong.
* af_rubberband: make all librubberband options configurablewm42015-02-111-4/+43
| | | | | | | librubberband exports a big load of options. Normally, the default settings (whether they're librubberband defaults or our defaults) should be sufficient, but since I'm not so sure about this, making it configurable allows others to figure it out for me.
* af_rubberband: attempt to fix audio position calculationwm42015-02-111-4/+17
| | | | | | | | | | | The problem here is that librubberband can buffer an arbitrary amount of data, but at the same time doesn't provide a way to query how much data is buffered. So we keep track of this manually, assuming that librubberband tries to reach the requested time ratio for input and output (which is probably true). The disadvantage is that rounding errors could accumulate over time. (Maybe it should try to round towards keeping the time ratio.)
* af_rubberband: always calculate and set delaywm42015-02-111-12/+11
| | | | Basically, add an if and reindent the block instead of exiting early.
* af: account for queued frames in audio position calculationwm42015-02-111-0/+2
| | | | af_rubberband exposed this issue.
* af_rubberband: improve EOF handlingwm42015-02-111-5/+11
| | | | | | In theory it could happen that draining on EOF happens incrementally, and then the unconditional reset could have dropped the remaining buffered audio.
* audio: fix pool allocationwm42015-02-111-1/+2
| | | | | It reallocated the pool on every request, making the pool completely useless. Oops.
* af_rubberband: pitch correction with librubberbandwm42015-02-112-0/+173
| | | | | | | | | If "--af=rubberband" is used, librubberband will be used to speed up or slow down audio with pitch correction. This still has some problems: the audio delay is not calculated correctly, so the audio position jitters around by a few milliseconds. This will probably ruin video timing.
* af_scaletempo: allow changing speed at runtime without reinitwm42015-02-101-18/+21
| | | | | | | | | | | | | | | | Staring at the code a bit, it turns out that changing speed without losing state is quite easy. The initialization code is big and complicated, but most of it is specific only to the configured audio format, not the speed. Refactor the code so that changing speed at runtime could work. (It's not actually used yet - the player code still does a complete reinit. This will be fixed in the next commit.) The "if (s->speed_tempo == s->speed_pitch)" looks a bit strange, but does the same thing as the code did before: speed can be changed only if exactly one flag is set. If both are set or none, speed can't be changed.
* af_scaletempo: drop detaching or skipping init on speed=1wm42015-02-101-7/+5
| | | | | | | | | | | | | | | | | | This code skipped initialization if no speed/pitch change was to be applied. It also didn't force conversion of the audio to a supported format, which is probably the most important case in context of compatibility. With this change applied, af_scaletempo will always force format conversion. To make the change less disruptive, make the filter detach if unconvertable formats are used. Some users use spdif and also have "af=scaletempo" in their config, so better not completely break this. In the case the filter was added with the "speed=both" suboption, the filter also detached itself in this case; but it's an obscure case, so I don't care about that.
* ao_coreaudio: fix small memory leakStefano Pigozzi2015-02-031-0/+4
|
* ao_coreaudio: use device UID instead of ID for selectionStefano Pigozzi2015-02-034-19/+46
| | | | | | | | | | Previously we let the user use the audio device ID, but this is not persistent and can change when plugging in new devices. That of course made it quite worthless for storing it as a user setting for GUIs, or for user scripts. In theory getting the kAudioDevicePropertyDeviceUID can fail but it doesn't on any of my devices, so I'm leaving the error reporting quite high and see if someone complains.
* command: add property returning detected audio deviceStefano Pigozzi2015-02-034-0/+11
| | | | | This can be useful to adjust some other audio related properties at runtime depending on the audio device being used.
* ao_null: add emulation for certain broken behaviorwm42015-01-301-1/+12
| | | | | I'm not sure how common this behavior possibly is; well whatever. This option will allow reproducing such behavior, and help debugging it.
* ao_pulse: plug a memory leakBen Boeckel2015-01-251-0/+3
|
* ao_wasapi: fix try_format logic in shared modeJames Ross-Gowan2015-01-231-2/+1
| | | | | | | | | | | | | | | | | The MSDN documentation for IsFormatSupported says a return code of AUDCLNT_E_UNSUPPORTED_FORMAT means the function "succeeded but the specified format is not supported in exclusive mode." This seems to imply that the format is supported in shared mode, and that's what the old code assumed, however try_format would incorrectly return success with some drivers. The remarks section of the documentation contradicts that assumption. It says that in shared mode, if the audio engine does not support the caller-specified format or any similar format, ppClosestMatch is set to NULL and the function returns AUDCLNT_E_UNSUPPORTED_FORMAT. This is the same as in exclusive mode, so treat AUDCLNT_E_UNSUPPORTED_FORMAT the same regardless of opt_exclusive. In shared mode, the format selection code will fall back to the mix format, which should always be supported.
* ao_alsa: reinitialize if device got brokenwm42015-01-211-0/+3
| | | | | | | | | Apparently, physically disconnecting the audio device (consider USB audio) breaks the ALSA device handle forever. It will signal ENODEV. Fortunately, it's easy for us to handle this, and we can just use existing mechanisms that will make the playback core close and reopen the AO. Whether the immediate reopening will actually succeeds really is ALSA's problem, though.
* ao_coreaudio: reset possibly random errno valuewm42015-01-201-1/+2
| | | | | | | | | | In general, you need to check errno when using strtol(), but as far as I know, strtol() won't reset errno on success. This has to be done manually. The code could have failed sporadically if strtol() succeeded, and errno was already set to one of the checked values. (This strtol() still isn't fully error checked, but I don't know if it's intentional, e.g. for parsing a numeric prefix only.)
* ao: never autoselect ao_nullwm42015-01-201-1/+2
| | | | | | | | | Before this commit, ao_null was used as last fallback. This doesn't make too much sense. Why would you decode audio just to discard it? Let audio initialization fail instead. This also handles the weird but possible corner-case that ao_null might fail initializing, in which case e.g. ao_pcm could be autoselected. (This happened once, and had to be fixed manually.)
* ao: refactor --audio-device selection codewm42015-01-201-85/+73
| | | | | | | | | | | | | | This removes the slightly duplicated code for picking the required AO driver if --audio-device forces one. Now --audio-device reuses the same code as --ao for this. As a consequence, ao_alloc_pb() and ao_create() can be merged into ao_init(). Although the ao_init() argument list, which is already pretty big, grows by one, it's better than having all these similar sounding functions around. Actually, I just wanted to do the change the following commit will do, but I found this code was more of a mess than it had to be.
* af: remove old filter compatibility hackwm42015-01-152-42/+1
|
* audio/filter: switch remaining filters to refcountingwm42015-01-154-44/+58
| | | | | All of these filters are very similar in frame management, and copy data to a new frame during filtering.
* audio/filter: switch remaining in-place filters to refcountingwm42015-01-159-127/+134
| | | | | | | | | | | | | | | | | | Adds about 7 lines of boilerplate per filter. This could be avoided by providing a different entrypoint (something like af->filter_inplace), which would basically mirror the old interface exactly for this kind of filter. But I feel like it would just be a hack to support all those old, useless filters better. (The ideal solution would be using a language that can do closures to provide a compat. wrapper, but whatever.) af_bs2b has terribly repetitious code for setting up filter functions for each format (most of them useless, in addition to bs2b being useless), so I did something terrible with macros. af_sinesuppress had commented code for float filtering (maybe it was broken; it has been commented every since it was added in 2006). Remove this code.
* af: verify filter input formatswm42015-01-151-1/+4
| | | | | | | | | | | Just to make sure all filters get the correct format. Together wih the check in af_add_output_frame(), this asserts that af->prev->fmt_out == af->fmt_in This also requires setting the "in" pseudo-filter (s->first) formats correctly. Before this commit, the fmt_in/fmt_out fields weren't used for this filter.
* ao_alsa: fix a small memory leakwm42015-01-141-0/+2
|
* af_lavcac3enc: use refcounted frameswm42015-01-141-89/+95
|
* af_lavfi: use refcounted frameswm42015-01-141-44/+57
|
* audio/filter: actually set fmt_in/fmt_out fieldswm42015-01-141-0/+2
|
* af_scaletempo: use refcounted frameswm42015-01-141-11/+23
|
* af_lavrresample: use refcounted frameswm42015-01-141-23/+46
|
* audio: add missing declarationwm42015-01-141-0/+1
|
* ao_pcm: add append modewm42015-01-141-1/+3
| | | | | Pretty useful for debugging, although a bit useless or possibly misleading too (see comments in the manpage).
* audio: fix initial audio PTSwm42015-01-141-24/+25
| | | | | | | | | | Commit 5e25a3d2 broke handling of the initial frame (the one decoded with initial_audio_decode()). It didn't update the pts_offset field, leading to a shift in timestamps by one audio frame. Fix by calling the actual decode function in a single place. This requires slightly more changes than what would be necessary to fix the bug, but it also somewhat simplifies the data flow.
*