Commit Graph

62 Commits

Author SHA1 Message Date
wm4 3eceac2eab Remove compatibility things
Possible with bumped FFmpeg/Libav.

These are just the simple cases.
2016-12-07 19:53:11 +01:00
wm4 0b144eac39 audio: use --audio-channels=auto behavior, except on ALSA
This commit adds an --audio-channel=auto-safe mode, and makes it the
default. This mode behaves like "auto" with most AOs, except with
ao_alsa. The intention is to allow multichannel output by default on
sane APIs. ALSA is not sane as in it's so low level that it will e.g.
configure any layout over HDMI, even if the connected A/V receiver does
not support it. The HDMI fuckup is of course not ALSA's fault, but other
audio APIs normally isolate applications from dealing with this and
require the user to globally configure the correct output layout.

This will help with other AOs too. ao_lavc (encoding) is changed to the
new semantics as well, because it used to force stereo (perhaps because
encoding mode is supposed to produce safe files for crap devices?).
Exclusive mode output on Windows might need to be adjusted accordingly,
as it grants the same kind of low level access as ALSA (requires more
research).

In addition to the things mentioned above, the --audio-channels option
is extended to accept a set of channel layouts. This is supposed to be
the correct way to configure mpv ALSA multichannel output. You need to
put a list of channel layouts that your A/V receiver supports.
2016-08-04 20:49:20 +02:00
Rudolf Polzer acb74236ac ao_lavc, vo_lavc: Migrate to new encoding API.
Also marked some places for possible later refactoring, as they became
quite similar in this commit.
2016-06-27 08:33:12 -04:00
Rudolf Polzer 160497b8ff encode_lavc: Migrate to codecpar API. 2016-04-11 14:57:20 -04:00
Kevin Mitchell e26462599b ao_lavc: use new af_select_best_samplerate function
This is particularly useful for opus which allows only a fairly restrictive set
of samplerates. If the codec doesn't provide a list of samplerates, just
continue to try the requsted one and hope for the best.

fixes #2957
2016-03-17 02:31:05 -07:00
Dmitrij D. Czarkoff ea442fa047 mpv_talloc.h: rename from talloc.h
This change helps avoiding conflict with talloc.h from libtalloc.
2016-01-11 21:05:55 +01:00
wm4 48c2e9d67d audio: use AVFrames with more than 8 channels correctly
Requires messy dealing with the extended_ fields.

Don't bother with af_lavfi and ao_lavc for now. There are probably no
valid use-cases for these.
2015-10-26 15:54:00 +01:00
wm4 e76f503fff ao_lavc: minor simplification 2015-09-11 09:01:49 +02:00
wm4 e721660e6d ao_lavc: use new sample format determination code
This is just a refactor, which makes it use the previously introduced
function, and allows us to make af_format_conversion_score() private.

(We drop 2 unlikely warning messages too... who cares.)
2015-09-10 23:38:42 +02:00
wm4 dd5c87e1d7 audio: remove unused legacy libavutil header
It was never used, but is a leftover from old times.
2015-08-07 02:41:39 +02:00
wm4 6147bcce35 audio: fix format function consistency issues
Replace all the check macros with function calls. Give them all the
same case and naming schema.

Drop af_fmt2bits(). Only af_fmt2bps() survives as af_fmt_to_bytes().

Introduce af_fmt_is_pcm(), and use it in situations that used
!AF_FORMAT_IS_SPECIAL. Nobody really knew what a "special" format
was. It simply meant "not PCM".
2015-06-26 23:06:37 +02:00
Marcin Kurczewski f43017bfe9 Update license headers
Signed-off-by: wm4 <wm4@nowhere>
2015-04-13 12:10:01 +02: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
wm4 c6c46f5aa7 ao_lavc: fix setting up AVFrame pointers
The caller set up the "start" pointer array using the number of planes,
the encode() function used the number of channels. This copied
uninitialized values for packed formats, which makes Coverity warn.
2014-11-21 10:09:25 +01:00
wm4 459f3aa4f9 ao_lavc: fix dangling pointers
Found by Coverity.
2014-11-21 03:50:52 +01:00
Rudolf Polzer 4f63a812de ao_lavc, vo_lavc: Fix crashes in case of multiple init attempts.
When initialization failed, vo_lavc may cause an irrecoverable state in
the ffmpeg-related structs. Therefore, we reject additional
initialization attempts at least until we know a better way to clean up
the mess.

ao_lavc currently cannot be initialized more than once, yet it's good to
do consistent changes there as well.

Also, clean up uninit-after-failure handling to be less spammy.
2014-11-12 12:16:07 +01:00
wm4 68ff8a0484 Move compat/ and bstr/ directory contents somewhere else
bstr.c doesn't really deserve its own directory, and compat had just
a few files, most of which may as well be in osdep. There isn't really
any justification for these extra directories, so get rid of them.

The compat/libav.h was empty - just delete it. We changed our approach
to API compatibility, and will likely not need it anymore.
2014-08-29 12:31:52 +02:00
Rudolf Polzer c19ec6f6f6 encode: deal even more with codec->time_base deprecation.
I assume this works too with Libav 10 and FFmpeg d3e51b41.
2014-07-23 16:09:44 +02:00
Rudolf Polzer 073b2becfe ao_lavc: Fix design of audio pts handling.
There was confusion about what should go into audio pts calculation and
what not (mainly due to the audio push thread). This has been fixed by
using the playing - not written - audio pts (which properly takes into
account the ao's buffer), and incrementing the samples count only by the
amount of samples actually taken from the buffer (unfortunately this
now forces us to keep the lock too long for my taste).
2014-07-16 16:18:34 +02:00
Rudolf Polzer e257cbfdbb ao_lavc: Add a missing newline for the log. 2014-07-16 16:18:34 +02:00
Rudolf Polzer 2a985716cd ao_lavc: Fix advancing of audio pts. 2014-07-16 16:18:34 +02:00
Rudolf Polzer ee2e91dce1 encode: get rid of the recursion that led to a deadlock.
Instead, the recursive call has been flattened away by instead
overwriting a parameter and continuing.
2014-06-12 11:42:00 +02:00
Marcoen Hirschberg 31a10f7c38 af_fmt2bits: change to af_fmt2bps (bytes/sample) where appropriate
In most places where af_fmt2bits is called to get the bits/sample, the
result is immediately converted to bytes/sample. Avoid this by getting
bytes/sample directly by introducing af_fmt2bps.
2014-05-28 21:38:00 +02:00
wm4 fc385baf02 encode: fix PTS unit mismatch
This used MP_NOPTS_VALUE to compare with ffmpeg-style int64_t PTS
values. This probably happened to work, because both constants use the
same value.
2014-05-10 10:44:16 +02:00
wm4 856d2c2491 encode: add a missing \n to a log call 2014-04-10 23:58:12 +02:00
wm4 05e3a5a2b4 ao_lavc: set AVFrame.format
Seems kind of wrong that this wasn't done, although it didn't have any
bad consequences.
2014-03-16 13:19:29 +01:00
wm4 62c88a52c4 encode: use new AVFrame API 2014-03-16 13:19:29 +01:00
wm4 e16c91d07a audio/out: make draining a separate operation
Until now, this was always conflated with uninit. This was ugly, and
also many AOs emulated this manually (or just ignored it). Make draining
an explicit operation, so AOs which support it can provide it, and for
all others generic code will emulate it.

For ao_wasapi, we keep it simple and basically disable the internal
draining implementation (maybe it should be restored later).

Tested on Linux only.
2014-03-09 01:27:41 +01:00
wm4 5ffd6a9e9b encode: add locking
Since the AO will run in a thread, and there's lots of shared state with
encoding, we have to add locking.

One case this doesn't handle correctly are the encode_lavc_available()
calls in ao_lavc.c and vo_lavc.c. They don't do much (and usually only
to protect against doing --ao=lavc with normal playback), and changing
it would be a bit messy. So just leave them.
2014-03-09 00:19:35 +01:00
wm4 41f2b26d11 audio/out: make ao struct opaque
We want to move the AO to its own thread. There's no technical reason
for making the ao struct opaque to do this. But it helps us sleep at
night, because we can control access to shared state better.
2014-03-09 00:19:31 +01:00
wm4 74b7001500 encode: don't access ao->pts
This field will be moved out of the ao struct. The encoding code was
basically using an invalid way of accessing this field.

Since the AO will be moved into its own thread too and will do its own
buffering, the AO and the playback core might not even agree which
sample a PTS timestamp belongs to. Add some extrapolation code to handle
this case.
2014-03-07 15:23:03 +01:00
wm4 60c06fec1e audio/fmt-conversion.c: remove unknown audio format messages
Same deal as with video/fmt-conversion.c.
2013-12-21 20:50:12 +01:00
wm4 0112143fda Split mpvcore/ into common/, misc/, bstr/ 2013-12-17 02:39:45 +01:00
wm4 eb15151705 Move options/config related files from mpvcore/ to options/
Since m_option.h and options.h are extremely often included, a lot of
files have to be changed.

Moving path.c/h to options/ is a bit questionable, but since this is
mainly about access to config files (which are also handled in
options/), it's probably ok.
2013-12-17 02:07:57 +01:00
wm4 ca455e65a3 ao_lavc: use af_format_conversion_score()
This should allow it to select better fallback formats, instead of
picking the first encoder sample format if ao->format is not equal to
any of the encoder sample formats.

Not sure what is supposed to happen if the encoder provides no
compatible sample format (or no sample format list at all), but in this
case ao_lavc.c still fails gracefully.
2013-11-16 21:46:17 +01:00
Rudolf Polzer 6391453fab ao_lavc: write the final audio chunks from uninit()
These must be written even if there was no "final frame", e.g. due to
the player being exited with "q".

Although the issue is mostly of theoretical nature, as most audio codecs
don't need the final encoding calls with NULL data. Maybe will be more
relevant in the future.
2013-11-16 18:50:07 +01:00
Rudolf Polzer 0d4628a7fd ao_lavc: fix crash with interleaved audio outputs. 2013-11-16 14:10:00 +01:00
wm4 933fbf7333 ao_lavc: support non-interleaved audio 2013-11-13 20:10:17 +01:00
wm4 e4bbb1d348 Merge branch 'planar_audio'
Conflicts:
	audio/out/ao_lavc.c
2013-11-12 23:42:04 +01:00
wm4 380fc765e4 audio/out: prepare for non-interleaved audio
This comes with two internal AO API changes:

1. ao_driver.play now can take non-interleaved audio. For this purpose,
the data pointer is changed to void **data, where data[0] corresponds to
the pointer in the old API. Also, the len argument as well as the return
value are now in samples, not bytes. "Sample" in this context means the
unit of the smallest possible audio frame, i.e. sample_size * channels.

2. ao_driver.get_space now returns samples instead of bytes. (Similar to
the play function.)

Change all AOs to use the new API.

The AO API as exposed to the rest of the player still uses the old API.
It's emulated in ao.c. This is purely to split the commits changing all
AOs and the commits adding actual support for outputting N-I audio.
2013-11-12 23:27:51 +01:00
wm4 bf60281ffb audio/out: reject non-interleaved formats
No AO can handle these, so it would be a problem if they get added
later, and non-interleaved formats get accepted erroneously. Let them
gracefully fall back to other formats.

Most AOs actually would fall back, but to an unrelated formats. This is
covered by this commit too, and if possible they should pick the
interleaved variant if a non-interleaved format is requested.
2013-11-12 23:16:31 +01:00
Rudolf Polzer 149ab3afa2 ao_lavc: remove audio offset hack to ease supporting planar audio.
Now to shift audio pts when outputting to e.g. avi, you need an explicit
facility to insert/remove initial samples, to avoid initial regions of
the video to be sped up/slowed down.

One such facility is the delay filter in libavfilter.
2013-11-11 13:04:13 +01:00
wm4 8125252399 audio: don't let ao_lavc access frontend internals, change gapless audio
ao_lavc.c accesses ao->buffer, which I consider internal. The access was
done in ao_lavc.c/uninit(), which tried to get the left-over audio in
order to write the last (possibly partial) audio frame. The play()
function didn't accept partial frames, because the AOPLAY_FINAL_CHUNK
flag was not correctly set, and handling it otherwise would require an
internal FIFO.

Fix this by making sure that with gapless audio (used with encoding),
the AOPLAY_FINAL_CHUNK is set only once, instead when each file ends.
Basically, move the hack in ao_lavc's uninit to uninit_player.

One thing can not be entirely correctly handled: if gapless audio is
active, we don't know really whether the AO is closed because the file
ended playing (i.e. we want to send the buffered remainder of the audio
to the AO), or whether the user is quitting the player. (The stop_play
flag is overwritten, fixing that is perhaps not worth it.) Handle this
by adding additional code to drain the AO and the buffers when playback
is quit (see play_current_file() change).

Test case: mpv avdevice://lavfi:sine=441 avdevice://lavfi:sine=441 -length 0.2267  -gapless-audio
2013-11-08 20:00:58 +01:00
wm4 d58d4ec93c audio/out: remove useless info struct and redundant fields 2013-10-23 19:30:02 +02:00
wm4 edd36a3afc audio/out: do some mp_msg conversions
Use the new MP_ macros for some AOs instead of mp_msg.

Not all AOs are converted, and some only partially. In some cases, some
additional cosmetic changes are made.
2013-08-22 23:12:35 +02:00
Stefano Pigozzi 406241005e core: move contents to mpvcore (2/2)
Followup commit. Fixes all the files references.
2013-08-06 22:52:31 +02:00
wm4 f32a90a839 audio/out: remove options argument from init()
Same as with VOs in the previous commit.
2013-07-22 22:58:09 +02:00
wm4 4d3a2c7e0d audio/out: remove ao->outburst/buffersize fields
The core didn't use these fields, and use of them was inconsistent
accross AOs. Some didn't use them at all. Some only set them; the values
were completely unused by the core. Some made full use of them.

Remove these fields. In places where they are still needed, make them
private AO state.

Remove the --abs option. It set the buffer size for ao_oss and ao_dsound
(being ignored by all other AOs), and was already marked as obsolete. If
it turns out that it's still needed for ao_oss or ao_dsound, their
default buffer sizes could be adjusted, and if even that doesn't help,
AO suboptions could be added in these cases.
2013-06-16 19:36:56 +02:00
wm4 f88193091b audio/out: don't require AOs to set ao->bps
Some still do, because they use the value in other places of the init
function. ao_portaudio is tricky and reads ao->bps in the stream
thread, which might be started on initialization (not sure about that,
but better safe than sorry).
2013-06-16 19:32:18 +02:00
Rudolf Polzer dcd36c79c7 encode_lavc strings: use new option syntax 2013-06-16 17:14:47 +02:00