summaryrefslogtreecommitdiffstats
path: root/audio/out/ao_oss.c
Commit message (Collapse)AuthorAgeFilesLines
* various: use thread safe mp_strerror()nanahi9 days1-2/+3
|
* ao_oss: add "spdif" passthrough support for high bitrate codecs (e.g. Dolby ↵rim2023-08-201-5/+5
| | | | | | | | | | | | | | | | Atmos, DTS-HD, etc.) over HDMI In addition to the patch, appropriate additions to the mpv.conf file will of course be needed for this to work. For example on my system: audio-device=oss//dev/dsp4 audio-spdif=ac3,dts,dts-hd,eac3,truehd This has been tested using recent FreeBSD-13.1-stable, using external surround processors (both a Trinnov Altitude 16 and an LG OLED that supports Dolby Atmos, and connected with HDMI to an NVidia RTX 2070). Author and tester: David G Lawrence <dg1007@dglawrence.com>
* ao_oss: return actual OSS playing staterim2023-05-111-11/+2
| | | | fix: https://github.com/mpv-player/mpv/issues/10640
* options: transition commands from OPT_FLAG to OPT_BOOLChristoph Heinrich2023-02-211-0/+1
|
* options: transition options from OPT_FLAG to OPT_BOOLChristoph Heinrich2023-02-211-1/+0
| | | | | | c78482045444c488bb7948305d583a55d17cd236 introduced a bool option type as a replacement for the flag type, but didn't actually transition and remove the flag type because it would have been too much mundane work.
* various: drop unused #include "config.h"Thomas Weißschuh2023-02-201-1/+0
| | | | | | Most sources don't need config.h. The inclusion only leads to lots of unneeded recompilation if the configuration is changed.
* audio: simplify implementation of property ao-volumeThomas Weißschuh2023-01-251-4/+3
| | | | | | | | | | | | | | ao-volume is represented in the code with a `struct ao_control_vol_t` which contains volumes for two channels, left and right. However the code implementing this property in command.c never treats these values individually. They are always averaged together. On the other hand the code in the AOs handling these values also has to handle the case where *not* exactly two channels are handled. So let's remove the `struct ao_control_vol_t` and replace it with a simple float. This makes the semantics clear to AO authors and allows us to drop some code from the AOs and command.c.
* {video,audio}: adjust unsafe strncpy usagessfan52023-01-121-1/+1
|
* ao_oss: define PATH_DEV_MIXER as it is an internal defineJan Ekström2021-11-101-0/+1
| | | | | | | | This fixes a mismatch between configure working and build time failing with Linux + OSSv4, enabling compilation on Debian based Linux systems with the oss4-dev package. Fixes #9378
* ao_oss: add this audio output againrim2021-03-151-0/+410
| | | | | | | | | | | Changes: - code refactored; - mixer options removed; - new mpv sound API used; - add sound devices detect (mpv --audio-device=help will show all available devices); - only OSSv4 supported now; Tested on FreeBSD 12.2 amd64.
* ao_oss: remove this audio outputwm42020-03-281-657/+0
| | | | | | | | | | Ancient Linux audio output. Apparently it survived until now, because some BSDs (but not all) had use of this. But these should work with ao_sdl or ao_openal too (that's why these AOs exist after all). ao_oss itself has the problem that it's virtually unmaintainable from my point of view due to all the subtle (or non-subtle) difference. Look at the ifdef mess and the multiple code paths (that shouldn't exist) in the removed source code.
* options: change option macros and all option declarationswm42020-03-181-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Change all OPT_* macros such that they don't define the entire m_option initializer, and instead expand only to a part of it, which sets certain fields. This requires changing almost every option declaration, because they all use these macros. A declaration now always starts with {"name", ... followed by designated initializers only (possibly wrapped in macros). The OPT_* macros now initialize the .offset and .type fields only, sometimes also .priv and others. I think this change makes the option macros less tricky. The old code had to stuff everything into macro arguments (and attempted to allow setting arbitrary fields by letting the user pass designated initializers in the vararg parts). Some of this was made messy due to C99 and C11 not allowing 0-sized varargs with ',' removal. It's also possible that this change is pointless, other than cosmetic preferences. Not too happy about some things. For example, the OPT_CHOICE() indentation I applied looks a bit ugly. Much of this change was done with regex search&replace, but some places required manual editing. In particular, code in "obscure" areas (which I didn't include in compilation) might be broken now. In wayland_common.c the author of some option declarations confused the flags parameter with the default value (though the default value was also properly set below). I fixed this with this change.
* audio/out: rip out old unused app/softvolume reportingwm42019-10-111-4/+0
| | | | | | | | | | | This was all dead code. Commit 995c47da9a (over 3 years ago) removed all uses of the controls. It would be nice if AOs could apply a linear gain volume, that only affects the AO's audio stream for low-latency volume adjust and muting. AOCONTROL_HAS_SOFT_VOLUME was supposed to signal this, but to use it, we'd have to thoroughly check whether it really uses the expected semantics, so there's really nothing useful left in this old code.
* options: add M_OPT_FILE to some more options that take filesPhilip Sequeira2019-09-271-1/+1
|
* ao_oss: Fallback to stereo when the device does not support >2 channelsLeonardo Taccari2019-09-211-6/+10
| | | | | | | | ioctl(..., SNDCTL_DSP_CHANNELS, &nchannels) for not supported nchannels does not return an error and instead set nchannels to the default value. Instead of failing with no audio, fallback to stereo.
* 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.
* Fix undefined preprocessor behaviorwm42018-01-181-1/+5
| | | | | | | | | | | This commit eliminates the following clang warning: warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined] Going by the clang commit message, this seems to be explicitly specified as UB by the standard, and they added this warning because MSVC apparently results in different behavior. Whatever, we can just avoid the warning with some small changes.
* Add checks for HAVE_GPL to various GPL-only source fileswm42017-10-101-0/+4
| | | | | | | | This should actually cover all of them, if you take into account that some unchanged GPL source files include header files with such checks. Also this was done already for the libaf derived code. This is only for "safety" and to avoid misunderstandings.
* ao_oss: fix a dumb calculationwm42017-07-211-2/+3
| | | | | | | period_size used the wrong unit, and even if the unit had been correct, was assigned the wrong value. Probably fixes #4642.
* ao_oss: drop AF_FORMAT_S24 usagewm42017-07-071-7/+0
| | | | Can't test / don't care.
* audio/out: require AO drivers to report period size and correct bufferwm42017-06-251-1/+2
| | | | | | | | | | | | | | | | 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.
* build: simplify OSS checks and remove changes by "bugmen0t"wm42017-06-221-6/+3
| | | | | | | | | | | | | | | | | | The user bugmen0t was apparently a shared github account with publicly available login. Thus, we can't get LGPL relicensing permission from the people who used this account. To relicense successfully, we have to remove all their changes. This commit should remove 20d1fc13, f26fb009, defbe48d. It also should remove whatever test fragments were copied from the ancient configure, as well as some configure logic (potentially that device path stuff). I think this change still preserves the most important use-cases of OSS: BSDs, and the Linux OSS emulation (the latter for testing only). According to an OSS user, the 4front checks were probably broken anyway. The SunAudio stuff was probably for (Open)Solaris, which is dead. ao_oss.c itself will remain GPL, and still contains bugmen0t changes.
* options: remove remaining deprecated audio device selection optionswm42017-04-231-4/+0
|
* ao_oss: fix mixer channel messageKevin Mitchell2017-02-081-1/+1
|
* ao_oss: use --audio-device if --oss-device isn't set.Kevin Mitchell2017-02-081-6/+10
| | | | | | | | | | | | | | Fall back on PATH_DEV_DSP if nothing is set. This mirrors the behaviour of --audio-device / --alsa-device. There doesn't appear to be a general way to list devices with oss, so --audio-device=help doesn't list oss devices except for the default one if the file exists. Previously --audio-device was ignored entirely by ao_oss. fixes #4122
* options: remove deprecated sub-option handling for --vo and --aowm42016-11-251-1/+1
| | | | | | | | Long planned. Leads to some sanity. There still are some rather gross things. Especially g_groups is ugly, and a hack that can hopefully be removed. (There is a plan for it, but whether it's implemented depends on how much energy is left.)
* audio/out: deprecate device sub-optionswm42016-09-051-1/+1
| | | | | We have --audio-device, which can force the device. Also add something describing to this extent to the manpage.
* options: deprecate suboptions for the remaining AO/VOswm42016-09-051-0/+1
|
* ao_oss: do not add an entry to audio-device-list if device file missingwm42016-06-291-0/+7
| | | | | This effectively makes it go away on Linux (unless you have OSS emulation loaded).
* build: silence -Wunused-resultNiklas Haas2016-06-071-1/+1
| | | | | | | | For clang, it's enough to just put (void) around usages we are intentionally ignoring the result of. Since GCC does not seem to want to respect this decision, we are forced to disable the warning globally.
* ao_oss: use new sample format determination codewm42015-09-101-1/+2
|
* audio: fix format function consistency issueswm42015-06-261-5/+5
| | | | | | | | | | | 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".
* audio: remove S8, U16, U24, U32 formatswm42015-06-161-20/+0
| | | | | | | | | | | | | They are useless. Not only are they actually rarely in use; but libavcodec doesn't even output them, as libavcodec has no such sample formats for decoded audio. Even if it should happen that we actually still need them (e.g. if doing direct hardware output), there are better solutions. Swapping the sign is a fast and lossless operation and can be done inplace, so AO actually needing it could do this directly. If you wonder why we keep U8 instead of S8: because libavcodec does it.
* Update license headersMarcin Kurczewski2015-04-131-6/+5
| | | | Signed-off-by: wm4 <wm4@nowhere>
* Do not call strerror()wm42014-11-261-5/+8
| | | | | | | | | | | | | | | | | | | | | | | | | ...because everything is terrible. strerror() is not documented as having to be thread-safe by POSIX and C11. (Which is pretty much bullshit, because both mandate threads and some form of thread-local storage - so there's no excuse why implementation couldn't implement this in a thread-safe way. Especially with C11 this is ridiculous, because there is no way to use threads and convert error numbers to strings at the same time!) Since we heavily use threads now, we should avoid unsafe functions like strerror(). strerror_r() is in POSIX, but GNU/glibc deliberately fucks it up and gives the function different semantics than the POSIX one. It's a bit of work to convince this piece of shit to expose the POSIX standard function, and not the messed up GNU one. strerror_l() is also in POSIX, but only since the 2008 standard, and thus is not widespread. The solution is using avlibc (libavutil, by its official name), which handles the unportable details for us, mostly. We avoid some pain.
* ao_oss: check whether setting samplerate succeedswm42014-11-211-2/+4
| | | | | | | Independent from whether the samplerate was accepted or adjusted, errors returned by the ioctl are fatal errors. Found by Coverity.
* audio/out: consistently use double return type for get_delaywm42014-11-091-4/+4
| | | | | ao_get_delay() returns double, but the get_delay callback still returned float.
* ao_oss: wait for events with poll()wm42014-11-061-0/+13
| | | | | | | | | | The intention is to avoid using the timeout-based fallback. There's some minor hope that this will help with OpenBSD (see #1239), although it probably won't. Some chance that this will cause trouble with obscure OSS implementations or emulations.
* ao_oss: improve format negotiation, and hopefully fix pass-throughwm42014-09-241-45/+45
| | | | | | | Digital pass-through was probably broken. Possibly fix it (no way to test). This also should make the logic slightly saner. Fortunately, it's unlikely that anyone who uses OSS has a spdif setup.
* ao_oss: unbreakwm42014-09-231-2/+2
| | | | Oops.
* audio: cleanup spdif format definitionswm42014-09-231-13/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before this commit, there was AF_FORMAT_AC3 (the original spdif format, used for AC3 and DTS core), and AF_FORMAT_IEC61937 (used for AC3, DTS and DTS-HD), which was handled as some sort of superset for AF_FORMAT_AC3. There also was AF_FORMAT_MPEG2, which used IEC61937-framing, but still was handled as something "separate". Technically, all of them are pretty similar, but may use different bitrates. Since digital passthrough pretends to be PCM (just with special headers that wrap digital packets), this is easily detectable by the higher samplerate or higher number of channels, so I don't know why you'd need a separate "class" of sample formats (AF_FORMAT_AC3 vs. AF_FORMAT_IEC61937) to distinguish them. Actually, this whole thing is just a mess. Simplify this by handling all these formats the same way. AF_FORMAT_IS_IEC61937() now returns 1 for all spdif formats (even MP3). All AOs just accept all spdif formats now - whether that works or not is not really clear (seems inconsistent due to earlier attempts to make DTS-HD work). But on the other hand, enabling spdif requires manual user interaction, so it doesn't matter much if initialization fails in slightly less graceful ways if it can't work at all. At a later point, we will support passthrough with ao_pulse. It seems the PulseAudio API wants to know the codec type (or maybe not - feeding it DTS while telling it it's AC3 works), add separate formats for each codecs. While this reminds of the earlier chaos, it's stricter, and most code just uses AF_FORMAT_IS_IEC61937(). Also, modify AF_FORMAT_TYPE_MASK (renamed from AF_FORMAT_POINT_MASK) to include special formats, so that it always describes the fundamental sample format type. This also ensures valid AF formats are never 0 (this was probably broken in one of the earlier commits from today).
* audio: drop swapped-endian audio formatswm42014-09-231-25/+33
| | | | | | | | | | | | | | | | | | | | Until now, the audio chain could handle both little endian and big endian formats. This actually doesn't make much sense, since the audio API and the HW will most likely prefer native formats. Or at the very least, it should be trivial for audio drivers to do the byte swapping themselves. From now on, the audio chain contains native-endian formats only. All AOs and some filters are adjusted. af_convertsignendian.c is now wrongly named, but the filter name is adjusted. In some cases, the audio infrastructure was reused on the demuxer side, but that is relatively easy to rectify. This is a quite intrusive and radical change. It's possible that it will break some things (especially if they're obscure or not Linux), so watch out for regressions. It's probably still better to do it the bulldozer way, since slow transition and researching foreign platforms would take a lot of time and effort.
* ao_oss: prevent hang when unpausing after device was lostwm42014-09-171-0/+3
| | | | | | | | | | | | | | | | | | | | | | | Pausing/unpausing while the audio device can't be reopened, and then unpausing again when the device is finally reopened, can hang the player for a while. This happens because p->prepause_samples grows without bounds each time the player is unpaused while the device is lost. On unpause, ao_oss plays prepause_samples of silence to compensate for A/V timing issues due to the partially lost buffer (we can't pause the device at an arbitrary sample position, and the current period will be lost). This in turn will make the player appear to be frozen if too much audio is queued. (Normally, play() must never block, but here it happens because more data is written than get_space() reports. A better implementation would never let prepause_samples grow larger than the period size.) The unbounded growth happens because get_space() always returns that the device can be written while the device is lost. So limit it to 200ms. (A better implementation would limit it to the period size.) Also see #1080.
* ao_oss: move code aroundwm42014-09-171-26/+27
| | | | | More logical, and preparation for the next commit. No functional changes.
* ao_oss: don't break playback when device can't be reopenedwm42014-09-151-23/+42
| | | | | | | | | | | | | | Apparently NetBSD users want/need this (see issue #1080). In order not to break playback, we need at least to emulate get_delay(). We do this approximately by using the system clock. Also, always close the audio device on reset. Reopen it on play only. If we can't reopen it, don't retry until after the next time reset or resume is called, to avoid spam and unexpectedly "stealing" back the audio device. Also do something about framestepping causing audio desync.
* ao_oss: audio_buf_info isn't statewm42014-09-151-11/+11
| | | | | | | The context struct had an audio_buf_info field, but there's no reason why this would be needed. It's a tiny struct, and it isn't permanent state. It's always returned by SNDCTL_DSP_GETOSPACE. Keeping this as field is just confusing, so get rid of it.
* ao_oss: remove duplicate audio device open codewm42014-09-151-104/+108
| | | | | | | | | | | | | | | | | | | The code for reopening the audio device was separate, and duplicated some of the "real" open code. This was very badly done, and major required parts of initialization were skipped. Fix this by removing the code duplication. This consists mainly of moving the code for opening the device to a separate function, and adding some changes to handle format changes gracefully. (We can't change the audio format on the fly, but we can at least not explode and play noise when that happens.) As a minor change, actually always use SNDCTL_DSP_RESET when closing the audio device. We don't want to wait until the rest of the buffer is played. Also, don't use strerror() when printing the error message that reopening failed, simply because reopen_device() takes care of this, and also errno might be clobbered at this point.
* ao_oss: assume audio format reinit is not needed with SNDCTL_DSP_RESETwm42014-09-151-3/+2
| | | | | | | I have no idea whether this is true, because there literally doesn't seem to exist documentation for SNDCTL_DSP_RESET. But at least on Linux' OSS emulation, it is true. Also, it would be quite insane if it would be needed.
* ao_oss: don't use SNDCTL_DSP_RESET when pausing on NetBSDwm42014-09-151-5/+10
| | | | | | It seems on NetBSD SNDCTL_DSP_RESET exists, but using it for pausing is not feasible. We still use it to discard the audio buffer when closing the audio device.
* ao_oss: fix incorrect comments using bytes instead of sampleswm42014-09-151-3/+3
| | | | MPlayer uses bytes, mpv uses sample counts in the AO API.
* ao_oss: fix audio device leak on errorwm42014-09-111-21/+25
| | | | | Close the audio device if it was already opened, but the rest of initialization failed.
* ao_oss: use poll(), drop --disable-audio-select supportwm42014-09-111-32/+17
| | | | | | | | | | | | | | Replace select() usage with poll() (and reduce code duplication). Also, while we're at it, drop --disable-audio-select, since it has the wrong name anyway. And I have doubts that this is needed anywhere. If it is, it should probably fallback to doing the right thing by default, instead of requiring the user to do it manually. Since nobody has done that yet, and since this configure option has been part of MPlayer ever since ao_oss was added, it's probably safe to say it's not needed. The '#ifdef SNDCTL_DSP_GETOSPACE' was pointless, since it's already used unconditionally in another place.
* ao_oss: minor simplificationwm42014-09-061-3/+1
| | | | Equivalent code.
* audio/out: remove old thingswm42014-09-061-7/+6
| | | | | | | | 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.
* build: include <strings.h> for strcasecmp()wm42014-07-101-0/+1