summaryrefslogtreecommitdiffstats
path: root/audio
Commit message (Collapse)AuthorAgeFilesLines
* ao/wasapi: use atomic state variable instead of different eventsKevin Mitchell2015-04-044-65/+78
| | | | | | | | | Unfortunately, because we have proxy objects (pAudioVolumeProxy, pEndpointVolumeProxy, pSessionControlProxy) it looks like we still have to use MsgWaitForMultipleObjects and watch for and dispatch pending messages: https://msdn.microsoft.com/en-us/library/windows/desktop/ms680112%28v=vs.85%29.aspx
* ao/wasapi: reorder priv membersKevin Mitchell2015-04-041-12/+14
|
* ao_wasapi: code formatting and alignmentKevin Mitchell2015-04-032-24/+23
|
* audio: make all format query shortcuts macrosKevin Mitchell2015-04-039-25/+15
| | | | | af_fmt_is_float and af_fmt_is_planar were previously inconsistent with AF_FORAMT_IS_SPECIAL/AF_FORMAT_IS_IEC61937
* ao_wasapi: passthrough reworkKevin Mitchell2015-04-032-161/+152
| | | | | | | | | | | | | | | * unify passthrough and pcm exclusive mode format setting/testing * set passthrough format parameters correctly * support all of mpv's existing passthrough formats * automatically test passthrough with exclusive mode and enable exclusive if it succeeds, even if it was not explictly requested. this obviates the need for --ao=wasapi,wasapi=exclusive * if passthrough fails (such as the device doesn't support the format), fallback to either exclusive pcm or shared mode depending on what the user specified. Right now this isn't very useful as it still fails due to the decoder path remainin stuck on spdif. fixes #1742
* af_lavrresample: always normalize (libswresample is stupid)wm42015-04-021-0/+4
| | | | | | | | | | libswresample doesn't normalize when remixing to a float format. This will cause clipping due to float samples being out of the allowed range. Fortunately this extremely bad default can be changed. This does not happen with libavresample: it normalizes by default. Fixes #1752.
* af: remove unused functionswm42015-04-012-34/+0
|
* ao_wasapi: abstract HRESULT_to_strKevin Mitchell2015-04-014-79/+67
|
* mixer: per-app volume and private volume conflictwm42015-04-011-1/+3
| | | | | | Per-app volume would change the volume across all instances of the same application, while a private volume control (HAS_PER_APP_VOLUME) obviously should influence only one instance/audio stream only.
* ao_coreaudio: do not signal per-app volumewm42015-04-011-2/+0
| | | | | CoreAudio doesn't seem to have this concept. The volume is reset the next time audio is opened.
* mixer: handle prevention of unneeded af_volume insertion differentlywm42015-04-011-2/+3
| | | | Just so that this special-case is out of the common volume path.
* mixer: cleanup volume logic slightlywm42015-04-011-12/+11
|
* mixer: add more debug outputwm42015-04-011-3/+16
| | | | For remote-debugging volume rstore problems.
* ao_wasapi: remove redundant castsKevin Mitchell2015-03-313-42/+37
|
* ao_wasapi: simplify hotplugKevin Mitchell2015-03-313-55/+22
| | | | | | | | | Take advantage of the fact that list_devs is called with a hotplug_inited ao. Also eliminate unnecessary nested function abstraction of hotplug_(un)init and list_devs. However, keep list_devs in ao_wasapi_utils.c since it uses the private functions get_device_id, get_device_name and exposing these would require including headers for IMMDevice in ao_wasapi_utils.h.
* ao_wasapi: fix device listingKevin Mitchell2015-03-313-92/+29
| | | | | remove depricated and convoluted validation. refer instead to the --audio-device option.
* ao/wasapi: add ao hotplugKevin Mitchell2015-03-315-64/+118
| | | | | | | Create a second copy of the change_notify structure for the hotplug ao. change_notify->is_hotplug distinguishes the hotplug version from the regular one monitoring the currently playing ao. Also make the change notification less verbose now that there might be two of them around.
* ad_lavc: disable AC3 DRC by defaultwm42015-03-301-2/+2
|
* ao_alsa: add an option to ignore ALSA channel map negotiationwm42015-03-281-2/+6
| | | | This was requested, more or less.
* ao/wasapi: use built in KSDATAFORMATsKevin Mitchell2015-03-271-13/+8
| | | | | Rather than defining them ourselves. Thanks to rossy for figuring out the headers.
* ao/wasapi: add missing "if" bracesKevin Mitchell2015-03-262-35/+33
|
* ao/wasapi: rewrite format searchKevin Mitchell2015-03-262-182/+300
| | | | | | | More clearly separate the exclusive and shared mode format discovery. Make the exclusive mode search more systematic in particular about channel maps (i.e., use chmap_sel). Assume that the same sample format / sample rates work for all channels to narrow the search space.
* ao_sndio: open device in blocking mode, don't inflate buffer artificiallyDmitrij D. Czarkoff2015-03-261-20/+2
| | | | | | The code actually uses blocking mode, so opening sound device in non-blocking mode results in choppy sound. Also, inflating the buffer isn't necessary in blocking mode, so the function may simply return without doing anything.
* mixer: fix how volume is restored with per-app system mixerswm42015-03-241-3/+6
| | | | | | | | | | This broke with PulseAudio: when changing some audio filters (like for playback speed), mixer_reinit_audio() was called - and it overwrote the volume with whatever mpv thought the volume was before. If the volume was changed externally before and while mpv was running, this would reset the volume to the old value. Fixes #1335.
* ao_pulse: drop video role; fixes random mutingwm42015-03-241-1/+0
| | | | | | | | | The details are described in #1173. This "features" causes problems to users so often, it's better to remove it. Fixes #1173.
* audio: remove internal libmpg123 wrapperwm42015-03-242-309/+0
| | | | | | | We've been prefering the libavcodec mp3 decoder for half a year now. There is likely no benefit at all for using the libmpg123 one. It's just a maintenance burden, and tricks users into thinking it's a required dependency.
* 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