aboutsummaryrefslogtreecommitdiffhomepage
path: root/audio
Commit message (Collapse)AuthorAge
* atomics: switch to C11 stdatomic.hGravatar wm42014-05-21
| | | | | | | | | | | | | | | | | | | | | | | | | In my opinion, we shouldn't use atomics at all, but ok. This switches the mpv code to use C11 stdatomic.h, and for compilers that don't support stdatomic.h yet, we emulate the subset used by mpv using the builtins commonly provided by gcc and clang. This supersedes an earlier similar attempt by Kovensky. That attempt unfortunately relied on a big copypasted freebsd header (which also depended on much more highly compiler-specific functionality, defined reserved symbols, etc.), so it had to be NIH'ed. Some issues: - C11 says default initialization of atomics "produces a valid state", but it's not sure whether the stored value is really 0. But we rely on this. - I'm pretty sure our use of the __atomic... builtins is/was incorrect. We don't use atomic load/store intrinsics, and access stuff directly. - Our wrapper actually does stricter typechecking than the stdatomic.h implementation by gcc 4.9. We make the atomic types incompatible with normal types by wrapping them into structs. (The FreeBSD wrapper does the same.) - I couldn't test on MinGW.
* threads: use mpv time for mpthread_cond_timedwait wrapperGravatar wm42014-05-18
| | | | | | Use the time as returned by mp_time_us() for mpthread_cond_timedwait(), instead of calculating the struct timespec value based on a timeout. This (probably) makes it easier to wait for a specific deadline.
* audio/out: fix previous commitGravatar wm42014-05-11
| | | | | | | | | This didn't quite work. The main issue was that get_space tries to be clever to reduce overall buffering, so it will cause the playloop to decode and queue only as much audio as is needed to refill the AO in reasonable time. Also, even if ignoring the problem, the logic of the previous commit was slightly broken. (This required a few retries, because I couldn't reproduce the issue on my own machine.)
* audio/out: avoid wakeup feedback loopGravatar wm42014-05-11
| | | | | | | | | | | | | When the audio buffer went low, but could not be refilled yet, it could happen that the AO playback thread and the decode thread could enter a wakeup feedback loop, causing up to 100% CPU usage doing nothing. This happened because the decoder thread would wake up the AO thread when writing 0 bytes of newly decoded data, and the AO thread in reaction wakes up the decoder thread after writing 0 bytes to the AO buffer. Fix this by waking up the decoder thread only if data was actually played or queued. (This will still cause some redundant wakeups, but will eventually settle down, reducing CPU usage close to ideal.)
* mixer: make code more readableGravatar wm42014-05-11
| | | | | You wouldn't have guessed that the bottom-most "level[i] = 0.f;" line was actually required. It even confused cppcheck.
* audio/out: more debugging info for --dump-statsGravatar wm42014-05-11
|
* ao_coreaudio: skip unknown channel labelsGravatar Stefano Pigozzi2014-05-10
| | | | | | | | | | | | | I don't think this is really a very good idea because it is conceptually incorrect but other prominent multimedia programs use this approach (VLC and xbmc), and it seems to make the conversion more robust in certain cases. For example it has been reported, that configuring a receiver that can output 7.1 to output 5.1, will make CoreAudio report 8 channel descriptions, and the last 2 descriptions will be tagged kAudioChannelLabel_Unknown. Fixes #737
* ao_coreaudio: remove useless codeGravatar Stefano Pigozzi2014-05-10
| | | | | This code doesn't actually makes much of a difference, and the AudioUnit mostly wants layout tags anyway.
* ao_coreaudio: don't fallback to full waveextGravatar Stefano Pigozzi2014-05-10
| | | | | | The code was falling back to the full waveext chmap_sel when less than 2 channels were detected. This new code is slightly more correct since it only fills the chmap_sel with the stereo or mono chmap in the fallback case.
* ao_coreaudio: cosmetic change of loop ending conditionGravatar Stefano Pigozzi2014-05-10
|
* ao_coreaudio: print an error when channel mapping failsGravatar Stefano Pigozzi2014-05-10
|
* ao_coreaudio: use description-based channel layoutsGravatar Stefano Pigozzi2014-05-10
| | | | | | | | | | | | CoreAudio supports 3 kinds of layouts: bitmap based, tag based, and speaker description based (using either channel labels or positional data). Previously we tried to convert everything to bitmap based channel layouts, but it turns out description based ones are the most generic and there are built-in CoreAudio APIs to perform the conversion in this direction. Moreover description based layouts support waveext extensions (like SDL and SDR), and are easier to map to mp_chmaps.
* ao_coreaudio: pass layout by reference to logging functionGravatar Stefano Pigozzi2014-05-10
| | | | | Apparently passing the struct by value somehow messed with the value of some fields.
* chmap_sel: add channel replacement for sl/sr <-> sdl/sdrGravatar Stefano Pigozzi2014-05-10
| | | | | This can be use useful for the 7.1 rear layout. In particular it looks like OS X likes to use sdl/sdr as opposed to sl/sr.
* encode: fix PTS unit mismatchGravatar wm42014-05-10
| | | | | | 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.
* mixer: don't restore volume with different --softvol-max settingsGravatar wm42014-05-06
| | | | | | | | | | | Changing --softvol-max and then resuming would change the volume level on resume to something different than the original volume. This is because the user volume setting is always between 0-100, and 100 corresponds to --softvol-max gain. Avoid that changing -softvol-max and resuming an older file could lead to a too loud volume level by refusing to restore if --softvol-max changed.
* audio: fix the exact value that is used for the wait timeGravatar wm42014-05-04
| | | | | | | | | The comment says that it wakes up the main thread if 50% has been played, but in reality the value was 0.74/2 => 37.5%. Correct this. This probably changes little, because it's a very fuzzy heuristic in the first place. Also move down the min_wait calculation to where it's actually used.
* ao_null: fix unit mismatch with latency optionGravatar wm42014-05-04
| | | | It's in seconds, but the code used it as sample count.
* options: remove deprecated --identifyGravatar Martin Herkt2014-05-04
| | | | | | | Also remove MSGL_SMODE and friends. Note: The indent in options.rst was added to work around a bug in ReportLab that causes the PDF manual build to fail.
* ao_coreaudio: log even more info in verbose modeGravatar Stefano Pigozzi2014-04-24
| | | | | This logs more info that can be used for debugging purposes, in particular it prints all the AudioChannelDescription in the descriptions array.
* ao_coreaudio: add verbose output of detected channel layoutsGravatar Stefano Pigozzi2014-04-23
| | | | This can be useful for debugging purposes.
* audio: minor simplification in wait codeGravatar wm42014-04-23
|
* audio: preallocate audio buffers on resizeGravatar wm42014-04-18
| | | | | | This avoids too many realloc() calls if the caller is appending to an audo buffer. This case is actually quite noticeable when using something that buffers a large amount of audio.
* player: unrangle one aspect of audio EOF handlingGravatar wm42014-04-17
| | | | | | | | | | | | | | | | | | For some reason, the buffered_audio variable was used to "cache" the ao_get_delay() result. But I can't really see any reason why this should be done, and it just seems to complicate everything. One reason might be that the value should be checked only if the AO buffers have been recently filled (as otherwise the delay could go low and trigger an accidental EOF condition), but this didn't work anyway, since buffered_audio is set from ao_get_delay() anyway at a later point if it was unset. And in both cases, the value is used _after_ filling the audio buffers anyway. Simplify it. Also, move the audio EOF condition to a separate function. (Note that ao_eof_reached() probably could/should whether the last ao_play() call had AOPLAY_FINAL_CHUNK set to avoid accidental EOF on underflows, but for now let's keep the code equivalent.)
* audio: add hack against broken pulseaudio EOF conditionGravatar wm42014-04-17
| | | | | | | | | | | | This was reported with PulseAudio 2.1. Apparently it still has problems with reporting the correct delay. Since ao_pulse.c still has our custom get_delay implementation, there's a possibility that this is our fault, but this seems unlikely, because it's full of workarounds for issues like this. It's also possible that this problem doesn't exist on PulseAudio 5.0 anymore (I didn't explicitly retest it). The check is general and works for all push based AOs. For pull based AOs, this can't happen as pull.c implements all the logic correctly.
* audio: explicitly document audio EOF conditionGravatar wm42014-04-17
| | | | | | This should probably be an AO function, but since the playloop still has some strange stuff (using the buffered_audio variable instead of calling ao_get_delay() directly), just leave it and make it more explicit.
* ao_null: add simulated device latency, simulate EOF problemsGravatar wm42014-04-17
| | | | | This EOF problems happen at least with PulseAudio, but since it's hard to reproduce, let ao_null optionally simulate it.
* player: add a --dump-stats optionGravatar wm42014-04-17
| | | | | | | | | | | | | | | | | | | | | | | This collects statistics and other things. The option dumps raw data into a file. A script to visualize this data is included too. Litter some of the player code with calls that generate these statistics. In general, this will be helpful to debug timing dependent issues, such as A/V sync problems. Normally, one could argue that this is the task of a real profiler, but then we'd have a hard time to include extra information like audio/video PTS differences. We could also just hardcode all statistics collection and processing in the player code, but then we'd end up with something like mplayer's status line, which was cluttered and required a centralized approach (i.e. getting the data to the status line; so it was all in mplayer.c). Some players can visualize such statistics on OSD, but that sounds even more complicated. So the approach added with this commit sounds sensible. The stats-conv.py script is rather primitive at the moment and its output is semi-ugly. It uses matplotlib, so it could probably be extended to do a lot, so it's not a dead-end.
* ao: remove redundant get_delay checkGravatar wm42014-04-17
| | | | It did nothing; the real check is in push.c.
* af_lavcac3enc: detach on any passthrough format, not just ac3Gravatar wm42014-04-16
|
* audio: wake up the core when audio buffer is running low (2)Gravatar wm42014-04-15
| | | | | | | | | | | | | | Same change as in e2184fcb, but this time for pull based AOs. This is slightly controversial, because it will make a fast syscall from e.g. ao_jack. And according to JackAudio developers, syscalls are evil and will destroy realtime operation. But I don't think this is an issue at all. Still avoid locking a mutex. I'm not sure what jackaudio does in the worst case - but if they set the jackaudio thread (and only this thread) to realtime, we might run into deadlock situations due to priority inversion and such. I'm not quite sure whether this can happen, but I'll readily follow the cargo cult if it makes hack happy.
* ao_pulse: use ao_need_data()Gravatar wm42014-04-15
| | | | | | | | | I'm not quite sure why ao_pulse needs this. It was broken when a thread to fill audio buffers was added to AO - the pulseaudio callback was waking up the playback thread, not the audio thread. But nobody noticed, so it can't be very important. In any case, this change makes it wake up the audio thread instead (which in turn wakes up the playback thread if needed).
* audio: wake up the core when audio buffer is running lowGravatar wm42014-04-15
| | | | | | | | | | | | | | | | | And also add a function ao_need_data(), which AO drivers can call if their audio buffer runs low. This change intends to make it easier for the playback thread: instead of making the playback thread calculate a timeout at which the audio buffer should be refilled, make the push.c audio thread wakeup the core instead. ao_need_data() is going to be used by ao_pulse, and we need to workaround a stupid situation with pulseaudio causing a deadlock because its callback still holds the internal pulseaudio lock. For AOs that don't call ao_need_data(), the deadline is calculated by the buffer fill status and latency, as before.
* Kill all tabsGravatar wm42014-04-13
| | | | | | | | | | | I hate tabs. This replaces all tabs in all source files with spaces. The only exception is old-makefile. The replacement was made by running the GNU coreutils "expand" command on every file. Since the replacement was automatic, it's possible that some formatting was destroyed (but perhaps only if it was assuming that the end of a tab does not correspond to aligning the end to multiples of 8 spaces).
* af_volume: fix clang -Wsometimes-uninitializedGravatar Kevin Mitchell2014-04-13
|
* af_lavfi: fix graph parse deprecation warningGravatar Kevin Mitchell2014-04-13
|
* encode: add a missing \n to a log callGravatar wm42014-04-10
|
* demux: move metadata-based replaygain decoding out of af_volumeGravatar Alessandro Ghedini2014-04-04
|
* af_volume: use replaygain side dataGravatar Alessandro Ghedini2014-04-04
|
* af: add replaygain_data field to af_stream and af_instanceGravatar Alessandro Ghedini2014-04-04
| | | | Closes #664
* ao_wasapi: make code shorterGravatar wm42014-03-30
| | | | | | | | | Also fix a format string mistake in a log call using it. I wonder if this code shouldn't use FormatMessage, but it looks kind of involved [1], so: no, thanks. [1] http://support.microsoft.com/kb/256348/en-us
* af_volume: fix replaygainGravatar wm42014-03-27
| | | | | | | | This was accidentally broken in commit b72ba3f7. I somehow made the wild assumption that replaygain adjusted the volume relative to 0% instead of 100%. The detach suboption was similarly broken.
* af_lavcac3enc: use new AVFrame APIGravatar wm42014-03-16
|
* ao_lavc: set AVFrame.formatGravatar wm42014-03-16
| | | | | Seems kind of wrong that this wasn't done, although it didn't have any bad consequences.
* encode: use new AVFrame APIGravatar wm42014-03-16
|
* ad_lavc: use new AVFrame APIGravatar wm42014-03-16
| | | | | | | Set refcounted_frames, because in some versions of libavcodec mixing the new AVFrame API and non-refcounted decoding could cause memory corruption. Likewise, it's probably still required to unref a frame before calling the decoder.
* build: simplify libavfilter configure checksGravatar wm42014-03-16
| | | | | This is all not needed anymore. In particular, remove all configure switches except --enable-libavfilter.
* Remove some more unneeded version checksGravatar wm42014-03-16
| | | | | All of these check against things that happened before the latest supported FFmpeg/Libav release.
* ad_lavc: remove deprecated downmixing by channel countGravatar wm42014-03-16
| | | | | Downmixing by channel layout now hopefully works with all supported libavcodec versions.
* ao_dsound: remove duplicated codeGravatar wm42014-03-16
|