summaryrefslogtreecommitdiffstats
path: root/audio
Commit message (Collapse)AuthorAgeFilesLines
* af_fmt2bits: change to af_fmt2bps (bytes/sample) where appropriateMarcoen Hirschberg2014-05-2811-20/+26
| | | | | | 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.
* audio: rename i_bps to 'bitrate' to avoid confusionMarcoen Hirschberg2014-05-283-6/+6
| | | | Since i_bps now contains bits/sec, rename it to reflect this change.
* audio: change values from bytes-per-second to bits-per-secondMarcoen Hirschberg2014-05-282-8/+10
| | | | | | | The i_bps members of the sh_audio and dev_video structs are mostly used for displaying the average audio and video bitrates. Keeping them in bits-per-second avoids truncating them to bytes-per-second and changing them back lateron.
* atomics: switch to C11 stdatomic.hwm42014-05-214-35/+24
| | | | | | | | | | | | | | | | | | | | | | | | | 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 wrapperwm42014-05-181-1/+1
| | | | | | 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 commitwm42014-05-111-9/+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 loopwm42014-05-111-2/+7
| | | | | | | | | | | | | 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 readablewm42014-05-111-7/+3
| | | | | 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-statswm42014-05-111-1/+5
|
* ao_coreaudio: skip unknown channel labelsStefano Pigozzi2014-05-101-0/+2
| | | | | | | | | | | | | 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 codeStefano Pigozzi2014-05-101-15/+0
| | | | | 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 waveextStefano Pigozzi2014-05-101-4/+5
| | | | | | 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 conditionStefano Pigozzi2014-05-101-1/+1
|
* ao_coreaudio: print an error when channel mapping failsStefano Pigozzi2014-05-101-1/+5
|
* ao_coreaudio: use description-based channel layoutsStefano Pigozzi2014-05-103-89/+54
| | | | | | | | | | | | 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 functionStefano Pigozzi2014-05-101-7/+7
| | | | | Apparently passing the struct by value somehow messed with the value of some fields.
* chmap_sel: add channel replacement for sl/sr <-> sdl/sdrStefano Pigozzi2014-05-101-16/+21
| | | | | 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 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.
* mixer: don't restore volume with different --softvol-max settingswm42014-05-061-8/+11
| | | | | | | | | | | 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 timewm42014-05-041-3/+2
| | | | | | | | | 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 optionwm42014-05-041-5/+8
| | | | It's in seconds, but the code used it as sample count.
* options: remove deprecated --identifyMartin Herkt2014-05-041-3/+0
| | | | | | | 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 modeStefano Pigozzi2014-04-241-5/+27
| | | | | 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 layoutsStefano Pigozzi2014-04-231-0/+5
| | | | This can be useful for debugging purposes.
* audio: minor simplification in wait codewm42014-04-231-2/+1
|
* audio: preallocate audio buffers on resizewm42014-04-181-2/+7
| | | | | | 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 handlingwm42014-04-173-5/+11
| | | | | | | | | | | | | | | | | | 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 conditionwm42014-04-171-1/+16
| | | | | | | | | | | | 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 conditionwm42014-04-171-0/+5
| | | | | | 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 problemswm42014-04-171-3/+19
| | | | | 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 optionwm42014-04-171-5/+6
| | | | | | | | | | | | | | | | | | | | | | | 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 checkwm42014-04-171-4/+0
| | | | It did nothing; the real check is in push.c.
* af_lavcac3enc: detach on any passthrough format, not just ac3wm42014-04-161-1/+1
|
* audio: wake up the core when audio buffer is running low (2)wm42014-04-151-2/+9
| | | | | | | | | | | | | | 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()wm42014-04-151-2/+2
| | | | | | | | | 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 lowwm42014-04-152-15/+61
| | | | | | | | | | | | | | | | | 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 tabswm42014-04-1321-524/+524
| | | | | | | | | | | 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-uninitializedKevin Mitchell2014-04-131-1/+1
|
* af_lavfi: fix graph parse deprecation warningKevin Mitchell2014-04-131-1/+1
|
* encode: add a missing \n to a log callwm42014-04-101-1/+1
|
* demux: move metadata-based replaygain decoding out of af_volumeAlessandro Ghedini2014-04-041-80/+9
|
* af_volume: use replaygain side dataAlessandro Ghedini2014-04-041-7/+19
|
* af: add replaygain_data field to af_stream and af_instanceAlessandro Ghedini2014-04-044-0/+6
| | | | Closes #664
* ao_wasapi: make code shorterwm42014-03-301-65/+36
| | | | | | | | | 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 replaygainwm42014-03-271-2/+3
| | | | | | | | 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 APIwm42014-03-161-3/+3
|
* 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
|
* ad_lavc: use new AVFrame APIwm42014-03-161-2/+4
| | | | | | | 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 checkswm42014-03-161-1/+1
| | | | | This is all not needed anymore. In particular, remove all configure switches except --enable-libavfilter.
* Remove some more unneeded version checkswm42014-03-161-13/+3
| | | | | All of these check against things that happened before the latest supported FFmpeg/Libav release.
* ad_lavc: remove deprecated downmixing by channel countwm42014-03-161-4/+0
| | | | | Downmixing by channel layout now hopefully works with all supported libavcodec versions.
* ao_dsound: remove duplicated codewm42014-03-161-17/+6
|
* af_lavrresample: remove avresample_set_channel_mapping() fallbackswm42014-03-166-135/+0
| | | | | | | This function is now always available. Also remove includes of reorder_ch.h from some AOs (these are just old relicts).
* options: fix off-by-1 error in option help outputwm42014-03-151-1/+1
|
* ao: print (estimated) device buffer size on init in verbose modewm42014-03-141-1/+3
|
* af_volume: don't print missing replaygain tags as errorwm42014-03-141-1/+1
| | | | There's no reason to. Audio files often lack them.
* af_volume: add detach optionwm42014-03-141-0/+4
| | | | | | Maybe this should be default. On the other hand, this filter does something even if the volume is neutral: it clips samples against the allowed range, should the decoder or a previous filter output garbage.
* af_volume: separate softvol volume control from replaygain levelwm42014-03-141-5/+8
| | | | | | | | | Currently, both replaygain adjustment and user volume control (if softvol is enabled) share the same variable. Sharing the variable would cause especially if --volume is used; then the replaygain volume would always be overwritten. Now both gain values are simple added right before doing filtering.
* af_volume: remove double-negated suboptionwm42014-03-141-3/+3
| | | | | You had to use "no-replaygain-noclip" to set this option. Rename it, so that only one negation is needed.
* af_volume: add support for replaygain pre-amp and clipping preventionAlessandro Ghedini2014-03-131-11/+74
|
* af_volume: add replaygain supportAlessandro Ghedini2014-03-131-0/+22
| | | | | | | | | This adds the options replaygain-track and replaygain-album. If either is set, the replaygain track or album gain will be automatically read from the track metadata and the volume adjusted accordingly. This only supports reading REPLAYGAIN_(TRACK|ALBUM)_GAIN tags. Other formats like LAME's info header would probably require support from libav.
* af: add metadata field to af_stream and af_instanceAlessandro Ghedini2014-03-134-0/+7
| | | | | | This allows to propagate metadata information to audio filters. Closes #632
* af_lavfi: beat it into working with Libavwm42014-03-131-23/+39
| | | | | | | | | | | | | | | | | | | The main incompatibility was that Libav didn't have av_opt_set_int_list. But since that function is excessively ugly and idiotic (look how it handles types), I'm not missing it much. Use an aformat filter instead to handle the functionality that was indirectly provided by it. This is similar to how vf_lavfi works. The other incompatibility was channel handling. Libav consistently uses channel layouts only, why ffmpeg still requires messing with channel counts to some degree. Get rid of most channel count uses (and hope channel layouts are "exact" enough). Only in one case FFmpeg fails with a runtime check if we feed it AVFrames with channel count unset. Another issue were AVFrame accessor functions. FFmpeg introduced these for ABI compatibility with Libav. I refuse to use them, and it's not my problem if FFmpeg doesn't manage to provide a stable ABI for fields provided both by FFmpeg and Libav.
* ao_wasapi: Use the character set conversion functions from io.hDiogo Franco (Kovensky)2014-03-112-37/+19
| | | | | ...rather than rolling out our own. The only possible advantage is that the "custom" ones didn't use talloc.
* ao_wasapi: Implement AOCONTROL_UPDATE_STREAM_TITLEDiogo Franco (Kovensky)2014-03-113-34/+89
|
* ao_wasapi: Implement per-application mixingDiogo Franco (Kovensky)2014-03-113-16/+95
| | | | | | | | | | | | | The volume controls in mpv now affect the session's volume (the application's volume in the mixer). Since we do not request a non-persistent session, the volume and mute status persist acr