Commit Graph

967 Commits

Author SHA1 Message Date
Marcin Kurczewski f43017bfe9 Update license headers
Signed-off-by: wm4 <wm4@nowhere>
2015-04-13 12:10:01 +02:00
wm4 ab2a27ae01 af_lavrresample: minor simplification
The in/out pointers usually have not much meaning outside of
AF_CONTROL_REINIT. Also remove the redundant casts.
2015-04-12 18:07:05 +02:00
wm4 f8a98fc133 af_lavrresample: allow resetting output sample format
It must be allowed to set format==0.
2015-04-12 18:07:05 +02:00
wm4 e466a735a3 audio/filter: fully renegotiate audio formats on every reconfig
It could happen that a lavrresample filter would keep its old output
format when the decoder changed its output format. This simply happened
because the output format was never reset.

Normally, this was not an issue, because lavrresample filters only
inserted for format conversion were removed on format changes. But if
--no-audio-pitch-correction is set and playback speed is changed, then
there is a "permanent" lavrresample filter in the filter chain, which
shows this behavior.

Fix by explicitly resetting output formats for all filters which support
it.

Note: this can crash with libswresample in some cases. I'm not sure if
this is mpv's fault or libswresample's, but since it works with
libavresample, I'm going to assume it's not our's.
2015-04-12 18:06:23 +02:00
wm4 77869e5914 ao_coreaudio: fix inverted condition
And also use the correct type for the printf call below.
2015-04-10 13:51:13 +02:00
wm4 36ae8a6cab audio: automatically deatch filters if spdif prevents their use
Fixes #1743 and partially #1780.
2015-04-07 21:38:39 +02:00
wm4 579c4dac34 audio: change a detail about filter insertion
The af_add() function has a problem: if the inserted filter returns
AF_DETACH during init, the function will have a dangling pointer. Until
now this was avoided by making sure none of the used filters actually
return AF_DETACH, but it's getting infeasible.

Solve this by requiring passing an unique label to af_add(), which is
then used instead of the pointer.
2015-04-07 21:24:22 +02:00
wm4 e98ab5e596 ao_alsa: change log output
Silence the usually user-visible warning about unsupported channel maps.
This might be an ALSA bug, but ALSA will never fix this behavior anyway.
(Or maybe it's a feature.)

Log some other information that might be useful.
2015-04-07 18:11:27 +02:00
wm4 5574820f13 ao_coreaudio: do not error if retrieving info for verbose mode fails
The message log level shouldn't get to decide whether something fails
or not. So replace the fatal error check on the verbose output code
path with a warning.
2015-04-07 12:23:24 +02:00
Kevin Mitchell 642f84f922 ao/wasapi: use atomic state variable instead of different events
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
2015-04-04 16:31:14 -07:00
Kevin Mitchell fe60cff03b ao/wasapi: reorder priv members 2015-04-04 16:31:14 -07:00
Kevin Mitchell bf3e0bc1da ao_wasapi: code formatting and alignment 2015-04-03 15:40:01 -07:00
Kevin Mitchell 46b9df9f9e audio: make all format query shortcuts macros
af_fmt_is_float and af_fmt_is_planar were previously inconsistent with
AF_FORAMT_IS_SPECIAL/AF_FORMAT_IS_IEC61937
2015-04-03 15:40:01 -07:00
Kevin Mitchell 07671ac57b ao_wasapi: passthrough rework
* 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
2015-04-03 15:39:51 -07:00
wm4 bf69edb1c2 af_lavrresample: always normalize (libswresample is stupid)
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.
2015-04-02 00:42:54 +02:00
wm4 f5603cba23 af: remove unused functions 2015-04-01 21:39:40 +02:00
Kevin Mitchell 4987c1906d ao_wasapi: abstract HRESULT_to_str 2015-04-01 02:30:19 -07:00
wm4 d4e31166b7 mixer: per-app volume and private volume conflict
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.
2015-04-01 01:15:59 +02:00
wm4 ab3a64ee4c ao_coreaudio: do not signal per-app volume
CoreAudio doesn't seem to have this concept. The volume is reset the
next time audio is opened.
2015-04-01 01:10:23 +02:00
wm4 62030e1090 mixer: handle prevention of unneeded af_volume insertion differently
Just so that this special-case is out of the common volume path.
2015-04-01 01:08:48 +02:00
wm4 502f9a1450 mixer: cleanup volume logic slightly 2015-04-01 00:22:47 +02:00
wm4 1d2b81b550 mixer: add more debug output
For remote-debugging volume rstore problems.
2015-04-01 00:20:07 +02:00
Kevin Mitchell e408dd20c7 ao_wasapi: remove redundant casts 2015-03-31 14:13:58 -07:00
Kevin Mitchell b6c28dd26b ao_wasapi: simplify hotplug
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.
2015-03-31 13:43:32 -07:00
Kevin Mitchell ea00fe0eeb ao_wasapi: fix device listing
remove depricated and convoluted validation. refer instead to the
--audio-device option.
2015-03-31 12:28:41 -07:00
Kevin Mitchell a6bf38bcad ao/wasapi: add ao hotplug
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.
2015-03-31 02:02:54 -07:00
wm4 ebef5da074 ad_lavc: disable AC3 DRC by default 2015-03-30 19:44:52 +02:00
wm4 b561ec99ff ao_alsa: add an option to ignore ALSA channel map negotiation
This was requested, more or less.
2015-03-28 23:53:49 +01:00
Kevin Mitchell 36d1b28849 ao/wasapi: use built in KSDATAFORMATs
Rather than defining them ourselves. Thanks to rossy for figuring out
the headers.
2015-03-27 16:14:31 -07:00
Kevin Mitchell 81da34549f ao/wasapi: add missing "if" braces 2015-03-26 05:52:34 -07:00
Kevin Mitchell 41c10c3ec2 ao/wasapi: rewrite format search
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.
2015-03-26 05:33:57 -07:00
Dmitrij D. Czarkoff 58e0292a9f ao_sndio: open device in blocking mode, don't inflate buffer artificially
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.
2015-03-26 00:09:15 +01:00
wm4 e07d1b397c mixer: fix how volume is restored with per-app system mixers
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.
2015-03-24 22:21:59 +01:00
wm4 b7325b2f64 ao_pulse: drop video role; fixes random muting
The details are described in #1173.

This "features" causes problems to users so often, it's better to remove
it.

Fixes #1173.
2015-03-24 22:07:14 +01:00
wm4 d5318e5e09 audio: remove internal libmpg123 wrapper
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.
2015-03-24 16:04:44 +01:00
wm4 7205e75079 af_bs2b: fix option default value
--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.
2015-03-22 13:28:20 +01:00
wm4 fe0c37b007 player: better handling of video with no timestamps
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.
2015-03-20 22:08:12 +01:00
wm4 775a02aab5 af_lavfi: handle seeking
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).
2015-03-17 22:31:05 +01:00
wm4 420e657a0b ao: slightly extend debug messages
This function already got uglified with debug printing; might as well go
all the way.
2015-03-16 20:29:52 +01:00
wm4 c4f4b09014 audio: fix off by one error in channel map selection code
The consequence was that some AOs (like ao_jack) could not output 8
channels.

Fixes #1688.
2015-03-15 17:07:06 +01:00
wm4 67b41f533e ao: align audio buffer size
Might or might not matter.
2015-03-13 20:49:22 +01:00
wm4 eb482140d9 audio: fix spdif packet size unit
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.
2015-03-10 17:11:38 +01:00
wm4 69c61a882d audio: fix spdif DTS packet size
Broken in one of the previous commits.
2015-03-10 15:33:01 +01:00
wm4 5f8b060ec2 ad_spdif: move frame sizes to a general function
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.
2015-03-10 15:12:52 +01:00
wm4 2f5e31cf47 ao_coreaudio_exclusive: port to pull API, fix latency calculations
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.
2015-03-10 10:37:05 +01:00
wm4 fa75a7b6d7 ao_coreaudio: move some helpers to utils
Needed by ao_coreaudio_exclusive.c in the next commit.
2015-03-10 10:13:23 +01:00
wm4 ee14da2988 ao_coreaudio_exclusive: rip out pseudo volume control
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.
2015-03-10 10:08:15 +01:00
wm4 89db92398e audio: refuse to change playback speed with spdif
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).
2015-03-07 20:34:05 +01:00
wm4 ddbecd09b0 af_scaletempo: minor simplification 2015-03-06 21:51:18 +01:00
wm4 c30d5f79b5 af_scaletempo: restore confusing mplayer behavior
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.)
2015-03-06 21:48:41 +01:00