summaryrefslogtreecommitdiffstats
path: root/audio
Commit message (Collapse)AuthorAgeFilesLines
* ao_pulse: fix typo in error messagewm42014-09-081-1/+1
| | | | Closes #1076.
* audio/out: fix active waiting during pause againwm42014-09-061-1/+2
| | | | | This was fixed in commit 8432eaefa, and commit 39609fc1 of course broke it again. This was pretty stupid.
* audio/out/push: redo audio waitingwm42014-09-061-45/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | Improve the logic how the audio thread decides how to wait until the AO is ready for new data. The previous commit makes some of this easier, although it turned out that it wasn't required, and we still can handle AOs with bad get_space implementation (although the new code prints an error message, and it might fail in obscure situations). The new code is pretty similar to the old one, and the main thing that changes is that complicated conditions are tweaked. AO waiting is now used better (mainly instead of max>0, r>0 is used). Whether to wakeup is reevaluated every time, instead of somehow doing the wrong thing and compensating for it with a flag. This fixes the specific situation when the device buffer is full, and we don't want to buffer more data. In the old code, this wasn't handled correctly: the AO went to sleep forever, because it prevented proper wakeup by the AO driver, and as consequence never asked the core for new data. Commit 4fa3ffeb was a hack-fix against this, and now that we have a proper solution, this hack is removed as well. Also make the refill threshold consistent and always use 1/4 of the buffer. (The threshold is used for situations when an AO doesn't support proper waiting or chunked processing.) This commit will probably cause a bunch of regressions again.
* audio/out: always round get_space on period sizewm42014-09-064-4/+6
| | | | | | | | | | | Round get_space() results in the same way play() rounds the input size. Some audio APIs do this for various reasons. This affects only "push" based AOs. Some of these need no change, because they either do it already right (like ao_openal), or they seem not to have any such requirements (like ao_pulse). Needed for the following commit.
* ao_sndio: fix a commentwm42014-09-061-2/+2
| | | | | Whether this code was written with the correct assumptions in mind, I don't know.
* ao_pcm: minor simplificationwm42014-09-061-1/+1
|
* ao_oss: minor simplificationwm42014-09-061-3/+1
| | | | Equivalent code.
* audio/out: remove old thingswm42014-09-0611-31/+27
| | | | | | | | Remove the unnecessary indirection through ao fields. Also fix the inverted result of AOCONTROL_HAS_TEMP_VOLUME. Hopefully the change is equivalent. But actually, it looks like the old code did it wrong.
* audio/out: make EOF handling properly event-basedwm42014-09-054-6/+52
| | | | | | | | | | | | | | | | | With --gapless-audio=no, changing from one file to the next apparently made it hang, until the player was woken up by unrelated events like input. The reason was that the AO doesn't notify the player of EOF properly. the played was querying ao_eof_reached(), and then just went to sleep, without anything waking it up. Make it event-based: the AO wakes up the playloop if the EOF state changes. We could have fixed this in a simpler way by synchronously draining the AO in these cases. But I think proper event handling is preferable. Fixes: #1069 CC: @mpv-player/stable (perhaps)
* af_hrtf: request required samplerate, instead of erroring outwm42014-09-051-8/+1
| | | | | | | | It seems hrtf works in 48khz only - and if that wasn't the input, the filter just exited with an error. Make it request the 48khz instead. The player will insert a resampling filter. Not sure why it wasn't done like this in the first place.
* af_hrtf: cosmetics: reindent misaligned code blockwm42014-09-051-8/+8
|
* audio: make buffer size configurablewm42014-09-053-6/+5
| | | | Really only for testing.
* audio/out: prevent burning CPU when seeking while pausedwm42014-08-311-1/+2
| | | | | | | | | The audio/video sync code in player/audio.c calls ao_reset() each time audio decoding is entered, but the player is paused, and there would be more than 1 sample to skip to make audio start match with video start. This caused a wakeup feedback loop with push.c. CC: @mpv-player/stable
* Move compat/ and bstr/ directory contents somewhere elsewm42014-08-2910-11/+8
| | | | | | | | | 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.
* coreaudio_device: fix overwriting of user inputStefano Pigozzi2014-08-251-9/+8
| | | | Fixes #1030
* ao_dsound: raise default buffer size to 200ms, make it configurablewm42014-08-221-3/+5
|
* audio: limit on low (and not high) buffer sizewm42014-08-211-1/+1
| | | | | | | The original intention was probably to avoid unnecessarily high numbers of wakeups. Change it to wait at most 25% of buffer time instead of 75% until refilling. Might help with the dsound problems in issue #1024, but I don't know if success is guaranteed.
* af_lavrresample: minor cosmeticswm42014-08-171-4/+2
|
* af_lavcac3enc: lower minimum channel number to 3wm42014-08-121-1/+1
| | | | It seems only stereo PCM should be passed through.
* af_lavcac3enc: change default bitrate to 640wm42014-08-121-1/+2
| | | | | | | No reason to use less. Since the name "default" is misleading now, replace it with "auto" (still recognize the old name).
* ao_dsound: reduce default buffer sizewm42014-08-081-1/+1
| | | | | | Reduce from 1000ms to 100ms. Since there is an audio thread updating AOs quickly enough now, requesting such a large buffer size makes no sense anymore.
* Improve setting AVOptionswm42014-08-023-23/+12
| | | | | | | | Use OPT_KEYVALUELIST() for all places where AVOptions are directly set from mpv command line options. This allows escaping values, better diagnostics (also no more "pal"), and somehow reduces code size. Remove the old crappy option parser (av_opts.c).
* ao_alsa: disable use of non-interleaved formats by defaultwm42014-07-301-0/+6
| | | | | | | | Some ALSA plugins take non-interleaved audio, but treat it as interleaved, which results in various funny bugs. Users keep hitting this issue, and it just doesn't seem worth the trouble. CC: @mpv-player/stable
* audio: ignore (some) decoding errors on initializationwm42014-07-291-0/+1
| | | | | | | | | | | | It probably happens relatively often that the first packet (or even the first N packets) of a stream will fail to decode, but decoding will eventually succeed at a later point. Before commit 261506e3, this was handled by an explicit retry loop (although this was also for other purposes), but with then was changed to abort on the first error. This makes it impossible to decode some audio streams. Change this so that errors are ignored for the first 50 packets, which should make it equivalent to the old code.
* audio: change playback restart and resyncingwm42014-07-285-31/+40
| | | | | | | | | | | | | | | | | | | | | This commit makes audio decoding non-blocking. If e.g. the network is too slow the playloop will just go to sleep, instead of blocking until enough data is available. For video, this was already done with commit 7083f88c. For audio, it's unfortunately much more complicated, because the audio decoder was used in a blocking manner. Large changes are required to get around this. The whole playback restart mechanism must be turned into a statemachine, especially since it has close interactions with video restart. Lots of video code is thus also changed. (For the record, I don't think switching this code to threads would make this conceptually easier: the code would still have to deal with external input while blocked, so these in-between states do get visible [and thus need to be handled] anyway. On the other hand, it certainly should be possible to modularize this code a bit better.) This will probably cause a bunch of regressions.
* ao_pulse: allow disabling timing bug workaroundswm42014-07-261-3/+38
| | | | | | | | | | | | | | | | Add an option that enables using native PulseAudio auto-updated timing information, instead of the manual calculations added in mplayer2 times. You can use --ao=pulse:no-latency-hacks to enable the new code. The code is almost the same as the code that was removed with commit de435ed5, but I didn't readd some bits I didn't understand. Likewise, the option will disable the code added with that commit. In my tests this seemed to work well, though the A/V sync display looks funny when seeking. The default is still the old behavior. See issue #959.
* ao_pulse: remove hacks for ancient PulseAudio versionswm42014-07-261-21/+0
| | | | | | | | | | | This was needed by very old (0.9) versions only. Get rid of it. Unfortunately, I can't cross-check with the original bug report, since the bug URL leads to this: Internal Server Error TracError: IOError: [Errno 2] No such file or directory: '/home/lennart/svn/trac/pulseaudio/VERSION'
* ao_null: never fail at initializationwm42014-07-261-1/+1
| | | | | | | | | ao_null is used to stop autoprobing (if all AOs before fail to init). After it come things like ao_pcm, which should never be automatically selected. Remove a certain theoretically possible failure case, and force "some" fallback.
* audio/out: fix initialization failure with win32wm42014-07-261-2/+1
| | | | | | | mp_make_wakeup_pipe() always fails on win32. If this call fails on Linux (and e.g. ao_alsa is used), this will probably burn CPU since poll() won't work on the invalid file descriptor, but whatever, the failure case is obscure enough.
* audio, client API: check mp_make_wakeup_pipe() return valuewm42014-07-251-5/+7
| | | | Could fail e.g. due to FD exhaustion.
* audio: fix timestampswm42014-07-243-2/+1
| | | | | | | | | Accidentally broken in b6af44d3. For ad_lavc (and in general), the PTS was not updated correctly when filtering only parts of audio frames, and for ad_mpg123 and ad_spdif the PTS was additionally offset by the frame size. This could lead to incorrect time display, and possibly broken A/V sync.
* audio: adjust format change codewm42014-07-241-8/+9
| | | | | | Execute the format change based on whether we logically detected EOF (after filters), instead of when the decode buffer was drained. It's slightly cleaner. (The requirement of len>0 existed before.)
* audio: fix race condition in EOF codewm42014-07-242-3/+3
| | | | | | | | | | Don't return an EOF code if there's still buffered data. Also, don't call demux_stream_eof() in the playloop. There's probably nothing wrong with it, but it's cleaner not to use it. Also give AD_EOF its own value, so that a decoding error doesn't drain audio by causing an EOF condition.
* audio: cosmeticswm42014-07-241-9/+5
| | | | | | | Move a function call, which does not change semantics. Write the extra buffer sample count in a more straight-forward way; the old code was not meaningful in any way (anymore).
* audio: remove unnecessary codewm42014-07-241-3/+0
| | | | | | | | It's true that the decoder can successfully decode, but return no data (for various reasons). We don't need to handle this specially, though. We just let the decoder decode some more data. This doesn't increase the danger of an endless loop either, because audio_decode() already calls this function until enough is decoded.
* 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_pulse: fix potential compilation problemwm42014-07-221-2/+2
| | | | | | It seems at least on some platforms (OSX 10.9), the POSIX wait() function becomes visible, and conflicts with this unrelated function. Just rename it.
* audio: move initial decode to generic codewm42014-07-216-239/+127
| | | | | | | | | | | | This commit mainly moves the initial decoding of data (done to probe the audio format) to generic code. This will make it easier to make audio decoding non-blocking in a later commit. This commit also changes how decoders return data: instead of having them write the data into a prepared buffer, they return a reference to an internal buffer (by setting dec_audio.decoded). This makes it significantly easier to handle audio format changes, since the decoders don't really need to care anymore.
* ad_lavc: drop questionable fallback codewm42014-07-211-6/+0
| | | | | | | | | | | If the decoder didn't set a samplerate, it was initialized from the container samplerate. This probably didn't make much sense, because it's passed to the decoder on initialization (so it could definitely use it). It's an artifact from commit 66a9eb57 (which removed some Matroska-specific non- sense), and I've never seen it actually happen since it was made into a warning. Just get rid of it.
* audio: remove unused metadata fieldwm42014-07-214-6/+0
| | | | | This was used for replaygain at some point, until replaygain info was passed through explicitly.
* audio: use symbolic constants instead of magic integerswm42014-07-205-12/+18
| | | | Similar to commit 26468743.
* 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
|
* Remove some mp_msg calls with no trailing \nwm42014-07-131-6/+6
| | | | | | | The final goal is all mp_msg calls produce complete lines. We want this because otherwise, race conditions could corrupt the terminal output, and it's inconvenient for the client API too. This commit works towards this goal. There's still code that has this not fixed yet, though.
* audio: don't wait for draining if pausedwm42014-07-134-15/+16
| | | | | | | | | | | | | Logic for this was missing from pull.c. For push.c it was missing if the driver didn't support it. But even if the driver supported it (such as with ao_alsa), strange behavior was observed by users. See issue #933. Always check explicitly whether the AO is in paused mode, and if so, don't drain. Possibly fixes #933. CC: @mpv-player/stable
* build: include <strings.h> for strcasecmp()wm42014-07-101-0/+1
| | | | | | | It happens to work without strings.h on glibc or with _GNU_SOURCE, but the POSIX standard requires including <strings.h>. Hopefully fixes OSX build.
* build: deal with endian messwm42014-07-101-1/+1
| | | | | | | | | | | | | | | | | | | | There is no standard mechanism for detecting endianess. Doing it at compile time in a portable way is probably hard. Doing it properly with a configure check is probably hard too. Using the endian definitions in <sys/types.h> (usually includes <endian.h>, which is not available everywhere) works under circumstances, but the previous commit broke it on OSX. Ideally all code should be endian dependent, but that is not possible due to the dependencies (such as FFmpeg, some video output APIs, some audio output APIs). Create a header osdep/endian.h, which contains various fallbacks. Note that the last fallback uses libavutil; however, it's not clear whether AV_HAVE_BIGENDIAN is a public symbol, or whether including <libavutil/bswap.h> really makes it visible. And in fact we don't want to pollute the namespace with libavutil definitions either. Thus it's only the last fallback.
* ao_null: disable latency emulationwm42014-07-071-1/+0
| | | | | | | | | Doesn't work quite right, and will pause for the latency duration after seeking. Some users use --ao=null to disable audio (even though they should probably use --no-audio), and this use-case is broken by this issue too. CC: @mpv-player/stable
* ao_pulse: set icon nameatomnuker2014-07-051-0/+2
| | | | Will replace the generic XDG video icon inherited from media role.
* ao_coreaudio: report hardware latency to ao_read_dataStefano Pigozzi2014-07-032-3/+43
| | | | | Commit a6a4cd2c88 added reporting of playout latency, this commit also adds support for reporting hardware and constant audio unit latency.
* ao_coreaudio: report latency more correctlyStefano Pigozzi2014-07-021-1/+19
| | | | | | | | | | Previous code was completly wrong. This still doesn't report the device latency, but we report the buffer latency (as before the AO refactoring) and the AudioUnit's latency (this is a new 'feature'). Apparently we can also report the device actual latency and we should also calculate the actual sample rate of the audio device instead of using the nominal sample rate, but I'll leave this for a later commit.
* ao_coreaudio: move channel mapping away from utilsStefano Pigozzi2014-07-023-126/+128
| | | | | Channel mapping functions are only used in the AUHAL based coreaudio, so move them there.
* ao_coreaudio: use mpv's internal pull APIStefano Pigozzi2014-07-021-82/+9
|
* ao_coreaudio: remove useless commentsStefano Pigozzi2014-07-021-5/+3
|
* ao_coreaudio: rename init_lpcm -> init_audiounitStefano Pigozzi2014-07-021-6/+9
|
* ao_coreaudio: fill asbd with an helper functionStefano Pigozzi2014-07-024-39/+29
|
* ao_coreaudio: split control to helper functionsStefano Pigozzi2014-07-021-23/+30
|
* ao_coreaudio: move device related functions to the new AOStefano Pigozzi2014-07-023-277/+255
|
* ao_coreaudio: remove useless call to print_asbdStefano Pigozzi2014-07-022-4/+0
|
* ao_coreaudio: move spdif code to a new AOStefano Pigozzi2014-07-025-433/+595
| | | | | | | | | | | | | | | | The mplayer1/2/mpv CoreAudio audio output historically contained both usage of AUHAL APIs (these go through the CoreAudio audio server) and the Device based APIs (used only for output of compressed formats in exclusive mode). The latter is a very unwieldy and low level API and pretty much forces us to write a lot of code for little workr. Also with the widespread of HDMI, the actual need for outputting compressed audio directly to the device is getting lower (it was very useful with S/PDIF for bandwidth constraints not allowing a number if channels transmitted in LPCM). Considering how invasive it is (uses hog/exclusive mode), the new AO (`ao_coreaudio_device`) is not going to be autoprobed but the user will have to select it.
* Audit and replace all ctype.h useswm42014-07-012-3/+2
| | | | | | | | | | | | | | | | Something like "char *s = ...; isdigit(s[0]);" triggers undefined behavior, because char can be signed, and thus s[0] can be a negative value. The is*() functions require unsigned char _or_ EOF. EOF is a special value outside of unsigned char range, thus the argument to the is*() functions can't be a char. This undefined behavior can actually trigger crashes if the implementation of these functions e.g. uses lookup tables, which are then indexed with out-of-range values. Replace all <ctype.h> uses with our own custom mp_is*() functions added with misc/ctype.h. As a bonus, these functions are locale-independent. (Although currently, we _require_ C locale for other reasons.)
* af_volume: fix calculations including replay-gainMohammad Alsaleh2014-06-281-2/+2
| | | | | | | | | | | | | rgain is not an additive value. It's a multiplier/gain. Previous behaviour produced negative level values in some cases (when rgain < 1.0) which caused volume to be louder when its value was lowered. CC: @mpv-player/stable Signed-off-by: Mohammad Alsaleh <CE.Mohammad.AlSaleh@gmail.com> Signed-off-by: wm4 <wm4@nowhere>
* ao_pcm: fix message stringsAmos Onn2014-06-151-2/+2
| | | | Signed-off-by: wm4 <wm4@nowhere>
* encode: get rid of the recursion that led to a deadlock.Rudolf Polzer