Commit Graph

34823 Commits

Author SHA1 Message Date
eng 74487b8430 af_ladspa: code cleanup
Cleanup based on results from cppcheck-1.59
Reduce the scope of several variables
Fix memory leak
2013-05-12 21:24:56 +02:00
wm4 3b1956608d audio: print channel map additionally to channel count on terminal 2013-05-12 21:24:56 +02:00
wm4 bc03eb0295 ao_alsa: map to exact channel layout
This allows supporting 5 channel audio (which can be eother 5.0 or 4.1).

Fallback doesn't work yet. It will do nonsense if the channel layout
doesn't match perfectly, even though it's similar.
2013-05-12 21:24:56 +02:00
wm4 7828048d65 ao_alsa: move format lookup into separate function 2013-05-12 21:24:56 +02:00
wm4 c6076b5de5 ao_alsa: more reformat 2013-05-12 21:24:56 +02:00
wm4 9afad5180c af: print filter chain info on error
The filter chain was only visible with -v. Always print it if the filter
chain could not be configured.
2013-05-12 21:24:56 +02:00
wm4 d2e5b50041 ao_alsa: cosmetics, macro-fy error reporting
Add a CHECK_ALSA_ERROR macro to report ALSA errors. This is similar to
what vo_vdpau does. This removes lots of boiler plate, it almost gives
me the feeling the ao_alsa initialization code is now readable. This
change is squashed with the reformatting, because both changes are
just as noisy and useless.
2013-05-12 21:24:55 +02:00
wm4 7f0f33fc8f ao_alsa: uncrustify 2013-05-12 21:24:55 +02:00
wm4 30dd18eac1 uncrustify: add some instructions 2013-05-12 21:24:55 +02:00
wm4 8bd6bf14bb audio: remove useless audio channels from AO, unless requested 2013-05-12 21:24:55 +02:00
wm4 1c601e84ff ad_lavc: force channel layout pass-through with demux_rawaudio
Using demux_rawaudio and the --rawaudio-channels option is useful for
testing channel map stuff. The libavcodec PCM decoder normalizes the
channel map to ffmpeg order, though. Prevent this by forcing the
original channel map when using the mp-pcm pseudo decoder entry (used by
demux_rawaudio and stream/tv.c only).
2013-05-12 21:24:55 +02:00
wm4 ade08d676f ao_coreaudio: switch to WAVEEXT channel order
This used ALSA order, which was not correct. Most likely this has been
wrong since forever.
2013-05-12 21:24:55 +02:00
wm4 bf014677ce ao_pulse: try to set correct channel layout
Like most other AOs, ao_pulse set the channel count only, always using a
default layout. Try to set the exact layout.

For this, we need a big lookup table to map waveex/lavc/mpv speaker
position to PulseAudio's, since PA_CHANNEL_POSITION_ is apparently not
compatible to waveext, and I haven't seen any API functions that would
help mapping them.

Completely untested. (Let's leave that to someone else...)
2013-05-12 21:24:55 +02:00
wm4 4b5cee4617 core: use channel map on demuxer level too
This helps passing the channel layout correctly from decoder to audio
filter chain. (Because that part "reuses" the demuxer level codec
parameters, which is very disgusting.)

Note that ffmpeg stuff already passed the channel layout via
mp_copy_lav_codec_headers(). So other than easier dealing with the
demuxer/decoder parameters mess, there's no real advantage to doing
this.

Make the --channels option accept a channel map. Since simple numbers
map to standard layouts with the given number of channels, this is
downwards compatible. Likewise for demux_rawaudio.
2013-05-12 21:24:55 +02:00
wm4 586b75ad08 reorder_ch: remove old channel reorder functions
This is done in af_lavrresample now, and as part of format negotiation.

Also remove the remaining reorder_channel calls. They were redundant
and did nothing.
2013-05-12 21:24:55 +02:00
wm4 408b7eecee audio: let libavresample do channel reordering 2013-05-12 21:24:55 +02:00
wm4 b20026c29b af_lavrresample: context is always allocated here 2013-05-12 21:24:55 +02:00
wm4 aea2328906 audio/out: switch to channel map
This actually breaks audio for 5/6/8 channels. There's no reordering
done yet. The actual reordering will be done inside of af_lavrresample
and has to be made part of the format negotiation.
2013-05-12 21:24:54 +02:00
wm4 37325f2796 af_pan: set unknown channel layout for output 2013-05-12 21:24:54 +02:00
wm4 7971bb87cb af: use mp_chmap for mp_audio, include channel map in format negotiation
Now af_lavrresample pretends to reorder the channels, although it
doesn't yet, and nothing sets non-standard layouts either.
2013-05-12 21:24:54 +02:00
wm4 f7a427676c audio: add some setters for mp_audio, and require filters to use them
mp_audio has some redundant fields. Setters like mp_audio_set_format()
initialize these properly.

Also move the mp_audio struct to a the file audio.c.

We can remove a mysterious line of code from af.c:

    in.format |= af_bits2fmt(in.bps * 8);

I'm not sure if this was ever actually needed, or if it was some kind of
"make it work" quick-fix that works against the way things were supposed
to work. All filters etc. now set the format correctly, so if there ever
was a need for this code, it's definitely gone.
2013-05-12 21:24:54 +02:00
wm4 0042735d7a audio: add channel map API
Unused, will be used in the following commits.

Let chmap.h define the number of maximum channels, because that is most
convenient.
2013-05-12 21:24:54 +02:00
wm4 1e37d35970 audio/filter: remove unused AF_CONTROLs
Was unused, has never been used.
2013-05-12 20:55:50 +02:00
wm4 071a8f50b9 options: add option to prevent decoder audio downmixing
Also rename --a52drc to --ad-lavc-ac3drc, and add --ad-lavc-o.
2013-04-13 04:21:30 +02:00
wm4 0d939a6847 af: fix negotiation endless loop
Yeah... ok.

Can be reproduced by having AF_CONTROL_CHANNELS not really set the
correct channel map.
2013-04-13 04:21:29 +02:00
wm4 fd6302631a af: streamline format negotiation
Add dummy input and output filters to remove special cases in the format
negotiation code (af_fix_format_conversion() etc.). The output of the
filter chain is now negotiated in exactly the same way as normal
filters.

Negotiate setting the sample rate in the same way as other audio
parameters. As a side effect, the resampler is inserted at the start of
the filter chain instead of the end, but that shouldn't matter much,
especially since conversion and channel mixing are conflated into the
same filter (due to libavresample's API).
2013-04-13 04:21:29 +02:00
wm4 d2c20f4cfb manpage: update af_lavrresample entry
Reflects the changes over the last few commits.
2013-04-13 04:21:29 +02:00
wm4 ff6342a311 af_lavrresample: add no-detach suboption
Normally, af_lavrresample detaches itself immediately if the input and
output audio parameters are the same. no-detach prevents this.
2013-04-13 04:21:29 +02:00
wm4 abd5e8a2e7 options: remove --af-adv
Anything this option did has been removed in the preceding 3 commits.
Note that even though these options sounded like a good idea (like
setting accuracy vs. speed tradeoffs), they were not really properly
implemented.
2013-04-13 04:21:29 +02:00
wm4 08eecf070e af: remove accuracy option
All this option did was deciding whether the resample filter was to be
insert at the beginning or end of the filter chain. Always do what the
option set for accuracy did. I doubt it makes much of a difference.
libavresample does most things in just one go anyway, so it won't
matter.
2013-04-13 04:21:28 +02:00
wm4 f9a6b1c3f8 af: remove force option
Dangerous and misleading. If it turns out that this is actually needed
to make certain setups work right, it should be added back in a better
way (in a way it doesn't cause random crashes).
2013-04-13 04:21:28 +02:00
wm4 bc268b313e audio: remove float processing option
The only thing this option did was changing the behavior of af_volume.
The option decided what sample format af_volume would use, but only if
the sample format was not already float. If the option was set, it would
default to float, otherwise to S16.

Remove use of the option and all associated code, and make af_volume
always use float (unless a af_volume specific sub-option is set).

Silence maximum value tracking. This message is printed when the filter
is destroyed, and it's slightly annoying. Was enabled due to enabling
float by default.
2013-04-13 04:21:28 +02:00
wm4 41aefce730 audio: switch to libavcodec channel order, use libavresample for mixing
Switch the internal channel order to libavcodec's. If the channel number
mismatches at some point, use libavresample for up- or downmixing.
Remove the old af_pan automatic downmixing.

The libavcodec channel order should be equivalent to WAVEFORMATEX order,
at least nowadays. reorder_ch.h assumes that WAVEFORMATEX and libavcodec
might be different, but all defined channels have the same mappings.

Remove the downmixing with af_pan as well as the channel conversion with
af_channels from af.c, and prefer af_lavrresample for this. The
automatic downmixing behavior should be the same as before (if the
--channels option is set to 2, which is the default, the audio output
is forced to 2 channels, and libavresample does all downmixing).

Note that mpv still can't do channel layouts. It will pick the default
channel layout according to the channel count. This will be fixed later
by passing down the channel layout as well.

af_hrtf depends on the order of the input channels, so reorder to ALSA
(for which this code was written). This is better than changing the
filter code, which is more risky.

ao_pulse can accept waveext order directly, so set that as channel
mapping.
2013-04-13 04:21:28 +02:00
wm4 f54909d4df ao_alsa: reorder channels from internal to alsa order
Currently, internal and alsa order are exactly the same, so this will do
absolutely nothing.
2013-04-13 04:21:28 +02:00
wm4 e4da671820 af: simplification
If format negotiation fails, and additional filters are inserted to fix
this, don't try to reinitialize the filter immediately. Instead, correct
the audio format, and let the caller retry.

Add a retry counter to af_reinit() to ensure that misbehaving filters
can't put the format negotiation into an endless loop.
2013-04-13 04:21:28 +02:00
wm4 8a53b3f523 af: factor channel filter insertion
Do this just like it has been done for the format filter.
2013-04-13 04:21:27 +02:00
wm4 c866583e1e af: use af_lavrresample for format conversions, if possible
Refactor to remove the duplicated format filter insertion code. Allow
other format converting filters to be inserted on format mismatches.
af_info.test_conversion checks whether conversion between two formats
would work with the given filter; do this to avoid having to insert
multiple conversion filters at once and such things. (Although this
isn't ideal: what if we want to avoid af_format for some conversions?
What if we want to split af_format in endian-swapping filters etc.?)

Prefer af_lavrresample for conversions that it supports natively,
otherwise let af_format handle the full conversion.
2013-04-13 04:21:27 +02:00
wm4 5a958921a7 af: remove automatically inserted filters on full reinit
Make sure automatically inserted filters are removed on full reinit
(they are re-added later if they are really needed). Automatically
inserted filters were never explicitly removed, instead, it was
expected that redundant conversion filters detach themselves. This
didn't work if there were several chained format conversion filters,
e.g. s16le->floatle->s16le, which could result from repeated filter
insertion and removal. (format filters detach only if input format and
output format are the same.)

Further, the dummy filter (which exists only because af.c can't handle
an empty filter chain for some reason) could introduce bad conversions
due to how the format negotiation works. Change the code so that the
dummy filter never takes part on format negotiation. (It would be better
to fix format negotiation, but that would be much more complicated and
would involving fixing all filters.)

Simplify af_reinit() and remove the start audio filter parameter. This
means format negotiation and filter initialization is run more often,
but should be harmless.
2013-04-13 04:21:27 +02:00
wm4 0a136ece5a af_lavrresample: allow other ffmpeg sample formats for input/output
The format was locked to s16. Extend it to accept all other ffmpeg
sample formats, and even allow different in- and output formats. The
generic filter code will still insert af_format on format mismatches,
though.
2013-04-13 04:21:27 +02:00
wm4 fc24ab9298 audio/filter: replace pointless memcpys with assignments
The change in af_scaletempo actually fixes a memory leak. af->data
contained a pointer to an allocated buffer, which was overwritten
during format negotiation. Set the format explicitly instead.
2013-04-13 04:21:27 +02:00
wm4 8bf759e888 af: uncrustify 2013-04-13 04:21:27 +02:00
Stefano Pigozzi cb0b0d99a4 ad_lavc: use fmt-conversion to map sample formats 2013-04-13 04:21:27 +02:00
wm4 203b57d863 demux: simplify chapter appending code
This pre-allocation looked tricky and awkward. Use MP_TARRAY_APPEND(),
which makes the code simpler. This even keeps the pre-allocation.
2013-04-12 14:38:22 +02:00
wm4 6f28c061b4 demux: always sort chapters
The condition that checked whether the chapters are out of order and
should be sorted was inverted. This likely wasn't noticed in testing,
because even if the chapters are unsorted, if the last two chapters
were sorted, the rest got sorted too.

Instead of doing this silly check, always sort the chapters after
demuxer initialization. Also make sure the sort order is stable in case
chapter start times are the same (original_index check).
2013-04-12 14:38:04 +02:00
wm4 a5916f5d1d core: remove dead --vsync leftovers 2013-04-12 14:36:26 +02:00
wm4 90e57fc266 command: fix deref before NULL check
Was accidentally broken in the last global variable removal round.
2013-04-12 14:34:46 +02:00
Stefano Pigozzi ed48c657ee ao_jack: fix deprecation warning
jack_port_get_total_latency is deprecated: use the "new" API based on
jack_port_get_latency_range instead.
2013-04-12 00:10:39 +02:00
wm4 37a424ed10 mplayer: remove unnecessary variable 2013-04-10 21:32:46 +02:00
wm4 9df2260506 core: add --reset-on-next-file option
This option can be used to selectively reset settings when playing the
next file in the playlist (i.e. restore mplayer and mplayer2 behavior).

Might remove this option again should it turn out that nobody uses it.
2013-04-10 21:32:46 +02:00
wm4 62daa08d3b mplayer: keep volume persistent, even when using --volume
Consider:

    mpv --volume 10 file1.mkv file2.mkv

Before this commit, the volume was reset to 10 when playing file2.mkv.
This was inconsistent to most other options. E.g. --brightness is a
rather similar case.

In general, settings should never be reset when playing the next file,
unless the option was explicitly marked file-local. This commit
corrects the behavior of the --volume and --mute options.

File local --volume still works as expected:

    mpv --{ --volume 10 file1.mkv file2.mkv --}

This sets the volume always to 10 on playback start.

Move the m_config_leave_file_local() call down so that the mixer code
in uninit_player() can set the option volume and mute variables without
overwriting the global option values.

Another subtle issue is that we don't want to set volume if there's no
need to, which is why the user_set_volume/mute fields are introduced.
This is important because setting the volume might change the system
volume depending on other options.
2013-04-10 21:29:04 +02:00