summaryrefslogtreecommitdiffstats
path: root/audio
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* audio: fix assertion failure on audio decodingwm42015-01-141-2/+2
| | | | | | | There are several cases in which a decoder may need several packets to produce some output audio. Commit 5e25a3d2 broke this. Fixes #1471.
* af_convert24: use refcounted frameswm42015-01-131-8/+13
| | | | | This requires allocating a fully new frame. 32->24 could be in-place, but this is not possible for 24->32.
* audio/filters: use refcounted frames for some in-place filterswm42015-01-133-7/+31
| | | | | These are also quite simple, but require requesting write access to the frames. The error handling (for OOM) is a bit annoying.
* audio/filters: use refcounted frames for some simple filterswm42015-01-134-10/+18
| | | | These are read-only, and very trivial to convert.
* af_volume: use refcounted frameswm42015-01-131-8/+15
|
* audio: use refcounted frames in the filter chainwm42015-01-133-77/+227
| | | | | | | | | | | | | | | | | | | The goal is switching the whole audio chain to using refcounted frames. This brings the architecture closer to FFmpeg, enables better integration with libavfilter, will reduce useless copying somewhat, and will probably allow better timestamp tracking. For now, every filter goes through a semi-awful wrapper in af_do_filter(), though. This will be fixed step by step, and the wrapper should eventually be removed. Another thing that will have to be done is improving the timestamp handling and avoiding extra copies for the AO. Some of the new code is rather similar to the video filter code (the core filter code basically just has types replaced). Such code duplication is normally very unwanted, but in this case there's probably no other choice. On the other hand, this code is pretty simple (even if somewhat tricky). Maybe there will be unified filter code in the future, but this is still far away.
* audio: add some utility functions for refcounted frameswm42015-01-132-10/+64
| | | | Used in the following commits.
* audio/filter: remove unused af_calc_filter_multiplier()wm42015-01-136-31/+2
| | | | | | | | | | | | The purpose of this function was to filter only as much audio input as needed to produce a certain amount of audio output. This could (in theory) avoid excessive buffering when e.g. changing playback speed with resampling. Use of this was already removed in commit 5fd8a1e0. No problems were experienced, so let's assume this feature is practically worthless. (Though it's possible that it was quite useful over a decade ago, or in some cornercases with evil files.)
* ao_pulse: exit AO if stream failswm42015-01-111-1/+5
| | | | | | This can for example reproduced by killing the pulseaudio server. If this happens, just try to reload the AO, instead of breaking everything forever.
* ao_alsa: fix dtshd passthroughwm42015-01-091-2/+6
| | | | | | | We must not try to remap channels with this. Whethever ALSA gives us, and whatever we do with it, the result will probably be nonsense. Untested, as I don't have the required hardware.
* ao: remove coreaudio_exclusive from autoprobing listwm42015-01-071-2/+2
| | | | Apparently this was a mistake.
* ao_pulse: disable latency calculation hacks by defaultwm42015-01-071-1/+0
| | | | | | | | | | | | | | This used to be required to workaround PulseAudio bugs. Even later, when the bugs were (partially?) fixed in PulseAudio, I had the feeling the hacks gave better behavior. On the other hand, I couldn't actually reproduce any bad behavior without the hacks lately. On top of this, it seems our hacks sometimes perform much worse than PulseAudio's native implementation (see #1430). So disable the hacks by default, but still leave the code and the option in case it still helps somewhere. Also, being able to blame PulseAudio's code by using its native API is much easier than trying to debug our own (mplayer2-derived) hacks.
* win32: request UTF-16 API variants, Vista+ APIs, and COM C macroswm42015-01-075-13/+1
| | | | | Put the Vista+ (_WIN32_WINNT) and the COM C (COBJMACROS) defines into the build system, instead of defining them over and over in the code.
* player: print used number of threads in verbose modewm42015-01-051-1/+1
| | | | Also, don't use av_log() for mpv output.
* af_volume: dump applied replaygain in verbose modewm42015-01-041-1/+5
|
* ao/wasapi: style/code formatting tweaksKevin Mitchell2015-01-023-64/+63
|
* ao/wasapi: improve exclusive mode format searchKevin Mitchell2015-01-021-46/+36
| | | | fixes #1376
* ao/wasapi: revamp set_waveformatexKevin Mitchell2015-01-021-27/+43
| | | | | | | | * bits instead of bytes * add valid_bits argument * just pass in the mp_chmap and get the number and wavext channel map from that * indicate valid bits in waveformat_to_str * make appropriate accomodations in try_format
* ao/wasapi: add CO_E_NOTINITIALIZED to explain_errKevin Mitchell2015-01-021-0/+1
| | | | someone on irc reported seeing this error
* ao_portaudio: remove this audio outputwm42014-12-292-280/+0
| | | | | It's just completely useless. We have good native support for all 3 desktop platforms, and ao_sdl or ao_openal as fallbacks.
* ao_alsa: print channel map if setting it failswm42014-12-291-1/+2
| | | | | | | | | | This message is printed when the audio device advertised a channel map, but couldn't set it - which is probably a dmix bug (we'll never know, ALSA doesn't take bug reports). Print the requested map, so that the user (maybe) can make a connection when seeing the message and the actually used channel map, which might be less confusing. Or at least less useless.
* ao: add debug log with the detected channel mapsStefano Pigozzi2014-12-291-0/+6
| | | | This could be helpful with bug reports.
* chmap_sel: add multichannel fallback heuristicStefano Pigozzi2014-12-294-0/+123
| | | | | | | | | | | | Instead of just failing during channel map selection, try to select a close layout that makes most sense and upmix/downmix to that instead of failing AO initialization. The heuristic is rather simple, and uses the following steps: 1) If mono is required