summaryrefslogtreecommitdiffstats
path: root/audio/out/ao_lavc.c
Commit message (Collapse)AuthorAgeFilesLines
* ao_lavc: fix warning: ISO C forbids forward references to 'enum' typesnanahi2024-03-191-0/+1
|
* ALL: use new mp_thread abstractionKacper Michajłow2023-11-051-3/+3
|
* options: remove a few options marked with .deprecation_messageDudemanguy2023-09-211-3/+0
| | | | | | | | | | | A bit different from the OPT_REPLACED/OPT_REMOVED ones in that the options still possibly do something but they have a deprecation message. Most of these are old and have no real usage. The only potentially controversial ones are the removal of --oaffset and --ovoffset which were deprecated years ago and seemingly have no real replacement. There's a cryptic message about --audio-delay but who knows. The less encoding mode code we have, the better so just chuck it.
* ao_lavc: remove unused codeKacper Michajłow2023-02-021-10/+0
|
* various: replace if + abort() with MP_HANDLE_OOM()sfan52023-01-121-2/+1
| | | | | MP_HANDLE_OOM also aborts but calls assert() first, which will result in an useful message if compiled in debug mode.
* ao_lavc: switch to AVChannelLayout when availableJan Ekström2022-06-121-0/+6
|
* ao_lavc: slightly simplify filter usewm42020-09-031-12/+12
| | | | | | Create a central function which pumps data through the filter. This also might fix bogus use of the filter API on flushing. (The filter is just used for convenience, but I guess the overall result is still simpler.)
* audio: fix inefficient behavior with ao_alsa, remove period_size fieldwm42020-08-291-1/+0
| | | | | | | | | | | | | | | | | | | | It is now the AO's responsibility to handle period size alignment. The ao->period_size alignment field is unused as of the recent audio refactor commit. Remove it. It turns out that ao_alsa shows extremely inefficient behavior as a consequence of the removal of period size aligned writes in the mentioned refactor commit. This is because it could get into a state where it repeatedly wrote single samples (as small as 1 sample), and starved the rest of the player as a consequence. Too bad. Explicitly align the size in ao_alsa. Other AOs, which need this, should do the same. One reason why it broke so badly with ao_alsa was that it retried the write() even if all reported space could be written. So stop doing that too. Retry the write only if we somehow wrote less. I'm not sure about ao_pulse.
* audio: refactor how data is passed to AOwm42020-08-291-99/+73
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This replaces the two buffers (ao_chain.ao_buffer in the core, and buffer_state.buffers in the AO) with a single queue. Instead of having a byte based buffer, the queue is simply a list of audio frames, as output by the decoder. This should make dataflow simpler and reduce copying. It also attempts to simplify fill_audio_out_buffers(), the function I always hated most, because it's full of subtle and buggy logic. Unfortunately, I got assaulted by corner cases, dumb features (attempt at seamless looping, really?), and other crap, so it got pretty complicated again. fill_audio_out_buffers() is still full of subtle and buggy logic. Maybe it got worse. On the other hand, maybe there really is some progress. Who knows. Originally, the data flow parts was meant to be in f_output_chain, but due to tricky interactions with the playloop code, it's now in the dummy filter in audio.c. At least this improves the way the audio PTS is passed to the encoder in encoding mode. Now it attempts to pass frames directly, along with the pts, which should minimize timestamp problems. But to be honest, encoder mode is one big kludge that shouldn't exist in this way. This commit should be considered pre-alpha code. There are lots of bugs still hiding.
* ao/lavc: add channels and channel_layout to AVFrameekisu2020-08-071-0/+2
| | | | | | FFmpeg expects those fields to be set on the AVFrame when encoding audio, not doing so will cause the avcodec_send_frame call to return EINVAL (at least in recent builds).
* audio: redo internal AO APIwm42020-06-011-24/+33
| | | | | | | | | | | | | | | | | | | | | | | | | This affects "pull" AOs only: ao_alsa, ao_pulse, ao_openal, ao_pcm, ao_lavc. There are changes to the other AOs too, but that's only about renaming ao_driver.resume to ao_driver.start. ao_openal is broken because I didn't manage to fix it, so it exits with an error message. If you want it, why don't _you_ put effort into it? I see no reason to waste my own precious lifetime over this (I realize the irony). ao_alsa loses the poll() mechanism, but it was mostly broken and didn't really do what it was supposed to. There doesn't seem to be anything in the ALSA API to watch the playback status without polling (unless you want to use raw UNIX signals). No idea if ao_pulse is correct, or whether it's subtly broken now. There is no documentation, so I can't tell what is correct, without reverse engineering the whole project. I recommend using ALSA. This was supposed to be just a simple fix, but somehow it expanded scope like a train wreck. Very high chance of regressions, but probably only for the AOs listed above. The rest you can figure out from reading the diff.
* audio: remove ao_driver.drainwm42020-05-271-6/+0
| | | | | | | | | | The recent change to the common code removed all calls to ->drain. It's currently emulated via a timed sleep and polling ao_eof_reached(). That is actually fallback code for AOs which lacked draining. I could just readd the drain call, but it was a bad idea anyway. My plan to handle this better is to require the AO to signal a underrun, even if AOPLAY_FINAL_CHUNK is not set. Also reinstate not possibly waiting for ao_lavc.c. ao_pcm.c did not have anything to handle this; whatever.
* encode: fix occasional init crash due to initialization order issueswm42020-03-221-1/+0
| | | | | | | | Looks like the recent change to this actually made it crash whenever audio happened to be initialized first, due to not setting the mux_stream field before the on_ready callback. Mess a way around this. Also remove a stray unused variable from ao_lavc.c.
* encode: add some shit that does some shitwm42020-03-221-3/+6
| | | | | | | | ????????????? Makes no sense, can endless loop, but whatever. Part of #7524.
* encode: restore audio muxer timebase usewm42020-03-221-0/+3
| | | | | | Seems to crash hard if an error happens somewhere at init. Who cares. Part of #7524.
* ao_lavc: don't spam underrun warningswm42020-03-131-0/+1
| | | | | Like ao_pcm, this is (conceptually) in perpetual underrun, as long as dumping is fast enough.
* Replace uses of FFMIN/MAX with MPMIN/MAXwm42019-10-311-2/+2
| | | | And remove libavutil includes where possible.
* encode: get rid of the output packet queuewm42018-05-031-1/+9
| | | | | | | | | | | | Until recently, ao_lavc and vo_lavc started encoding whenever the core happened to send them data. Since audio and video are not initialized at the same time, and the muxer was not necessarily opened when the first encoder started to produce data, the resulting packets were put into a queue. As soon as the muxer was opened, the queue was flushed. Change this to make the core wait with sending data until all encoders are initialized. This has the advantage that we don't need to queue up the packets.
* encode: remove old timestamp handlingwm42018-05-031-46/+6
| | | | | This effectively makes --ocopyts the default. The --ocopyts option itself is also removed, because it's redundant.
* encode: rewrite half of itwm42018-04-291-185/+55
| | | | | | | | | | | | | The main change is that we wait with opening the muxer ("writing headers") until we have data from all streams. This fixes race conditions at init due to broken assumptions in the old code. This also changes a lot of other stuff. I found and fixed a few API violations (often things for which better mechanisms were invented, and the old ones are not valid anymore). I try to get away from the public mutex and shared fields in encode_lavc_context. For now it's still needed for some timestamp-related fields, but most are gone. It also removes some bad code duplication between audio and video paths.
* encode: cosmeticswm42018-04-201-25/+29
| | | | Mostly whitespace changes; some semantic preserving transformations.
* audio: fix annyoing af_get_best_sample_formats() definitionwm42018-01-251-1/+1
| | | | | | | | | | | | | | | | The af_get_best_sample_formats() function had an argument of int[AF_FORMAT_COUNT], which is slightly incorrect, because it's 0 terminated and should in theory have AF_FORMAT_COUNT+1 entries. It won't actually write this many formats (since some formats are fundamentally incompatible), but it still feels annoying and incorrect. So fix it, and require that callers pass an AF_FORMAT_COUNT+1 array. Note that the array size has no meaning in C function arguments (just another issue with C static arrays being weird and stupid), so get rid of it completely. Not changing the af_lavcac3enc use, since that is rewritten in another branch anyway.
* audio/out: require AO drivers to report period size and correct bufferwm42017-06-251-1/+3
| | | | | | | | | | | | | | | | Before this change, AOs could have internal alignment, and play() would not consume the trailing data if the size passed to it is not aligned. Change this to require AOs to report their alignment (via period_size), and make sure to always send aligned data. The buffer reported by get_space() now always has to be correct and reliable. If play() does not consume all data provided (which is bounded by get_space()), an error is printed. This is preparation for potential further AO changes. I casually checked alsa/lavc/null/pcm, the other AOs might or might not work.
* encode_lavc: move from GPL 2+ to LGPL 2.1+.Rudolf Polzer2017-06-131-7/+8
|
* Remove compatibility thingswm42016-12-071-23/+0
| | | | | | Possible with bumped FFmpeg/Libav. These are just the simple cases.
* audio: use --audio-channels=auto behavior, except on ALSAwm42016-08-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | 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.
* ao_lavc, vo_lavc: Migrate to new encoding API.Rudolf Polzer2016-06-271-76/+121
| | | | | Also marked some places for possible later refactoring, as they became quite similar in this commit.
* encode_lavc: Migrate to codecpar API.Rudolf Polzer2016-04-111-41/+41
|
* ao_lavc: use new af_select_best_samplerate functionKevin Mitchell2016-03-171-0/+5
| | | | | | | | 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
* mpv_talloc.h: rename from talloc.hDmitrij D. Czarkoff2016-01-111-1/+1
| | | | This change helps avoiding conflict with talloc.h from libtalloc.
* audio: use AVFrames with more than 8 channels correctlywm42015-10-261-0/+3
| | | | | | | 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.
* ao_lavc: minor simplificationwm42015-09-111-2/+2
|
* ao_lavc: use new sample format determination codewm42015-09-101-20/+15
| | | | | | | 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.)
* audio: remove unused legacy libavutil headerwm42015-08-071-1/+0
| | | | It was never used, but is a leftover from old times.
* audio: fix format function consistency issueswm42015-06-261-3/+3
| | | | | | | | | | | 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".
* Update license headersMarcin Kurczewski2015-04-131-4/+3
| | | | Signed-off-by: wm4 <wm4@nowhere>
* audio: make all format query shortcuts macrosKevin Mitchell2015-04-031-2/+2
| | | | | af_fmt_is_float and af_fmt_is_planar were previously inconsistent with AF_FORAMT_IS_SPECIAL/AF_FORMAT_IS_IEC61937
* ao_lavc: fix setting up AVFrame pointerswm42014-11-211-3/+4
| | | | | | 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.
* ao_lavc: fix dangling pointerswm42014-11-211-1/+1
| | | | Found by Coverity.
* ao_lavc, vo_lavc: Fix crashes in case of multiple init attempts.Rudolf Polzer2014-11-121-0/+8
| | | | | | | | | | | | 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.
* Move compat/ and bstr/ directory contents somewhere elsewm42014-08-291-1/+0
| | | | | | | | | 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.
* encode: deal even more with codec->time_base deprecation.Rudolf Polzer2014-07-231-6/+5
| | | | I assume this works too with Libav 10 and FFmpeg d3e51b41.
* ao_lavc: Fix design of audio pts handling.Rudolf Polzer2014-07-161-2/+5
| | | | | | | | | 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).
* ao_lavc: Add a missing newline for the log.Rudolf Polzer2014-07-161-1/+1
|
* ao_lavc: Fix advancing of audio pts.Rudolf Polzer2014-07-161-1/+1
|
* encode: get rid of the recursion that led to a deadlock.Rudolf Polzer2014-06-121-23/+28
| | | | | Instead, the recursive call has been flattened away by instead overwriting a parameter and continuing.
* af_fmt2bits: change to af_fmt2bps (bytes/sample) where appropriateMarcoen Hirschberg2014-05-281-1/+1
| | | | | | 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.
* encode: fix PTS unit mismatchwm42014-05-101-5/+5
| | | | | | 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.
* encode: add a missing \n to a log callwm42014-04-101-1/+1
|
* ao_lavc: set AVFrame.formatwm42014-03-161-0/+1
| | | | | Seems kind of wrong that this wasn't done, although it didn't have any bad consequences.
* encode: use new AVFrame APIwm42014-03-161-5/+3
|
* audio/out: make draining a separate operationwm42014-03-091-1/+7
| | | | | | | | | | | | 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.
* encode: add lockingwm42014-03-091-4/+19
| | | | | | | | | | 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.
* audio/out: make ao struct opaquewm42014-03-091-0/+1
| | | | | | 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.
* encode: don't access ao->ptswm42014-03-071-1/+4
| | | | | | | | | | 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.
* audio/fmt-conversion.c: remove unknown audio format messageswm42013-12-211-0/+5
| | | | Same deal as with video/fmt-conversion.c.
* Split mpvcore/ into common/, misc/, bstr/wm42013-12-171-3/+3
|
* Move options/config related files from mpvcore/ to options/wm42013-12-171-1/+1
| | | | | | | | | 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.
* ao_lavc: use af_format_conversion_score()wm42013-11-161-26/+29
| | | | | | | | | | 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.
* ao_lavc: write the final audio chunks from uninit()Rudolf Polzer2013-11-161-7/+10
| | | | | | | | | 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.
* ao_lavc: fix crash with interleaved audio outputs.Rudolf Polzer2013-11-161-2/+4
|
* ao_lavc: support non-interleaved audiowm42013-11-131-193/+42
|
* Merge branch 'planar_audio'wm42013-11-121-10/+12
|\ | | | | | | | | Conflicts: audio/out/ao_lavc.c
| * audio/out: prepare for non-interleaved audiowm42013-11-121-11/+12
| | | | | | | | | | | | |