summaryrefslogtreecommitdiffstats
path: root/audio/out/ao_oss.c
Commit message (Collapse)AuthorAgeFilesLines
* 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
| | | | | | | 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.
* Add more constwm42014-06-111-2/+2
| | | | | | | While I'm not very fond of "const", it's important for declarations (it decides whether a symbol is emitted in a read-only or read/write section). Fix all these cases, so we have writeable global data only when we really need.
* 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.
* audio/out: make draining a separate operationwm42014-03-091-8/+13
| | | | | | | | | | | | 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.
* 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.
* Split mpvcore/ into common/, misc/, bstr/wm42013-12-171-1/+1
|
* 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_oss: when falling back from unknown prefer larger formatbugmen0t2013-12-041-0/+16
|
* ao_oss: add 24bit formatsbugmen0t2013-12-041-0/+12
|
* ao_oss: add 6.1 and 7.1 speaker placement from FreeBSDbugmen0t2013-11-301-1/+15
|
* ao_oss: SNDCTL_DSP_CHANNELS takes int, not uint8_twm42013-11-301-2/+3
| | | | | | | This caused weird issue, probably caused by setting up the wrong number of channels, or similar. See github issue #383. Patch by bugmen0t on github.
* audio: drop "_NE"/"ne" suffix from audio formatswm42013-11-151-6/+6
| | | | | | You get the native format by not appending any suffix to the format. This change includes user-facing names, e.g. for the --format option.
* audio/out: prepare for non-interleaved audiowm42013-11-121-8/+8
| | | | | | | | | | | | | | | | | | | This comes with two internal AO API changes: 1. ao_driver.play now can take non-interleaved audio. For this purpose, the data pointer is changed to void **data, where data[0] corresponds to the pointer in the old API. Also, the len argument as well as the return value are now in samples, not bytes. "Sample" in this context means the unit of the smallest possible audio frame, i.e. sample_size * channels. 2. ao_driver.get_space now returns samples instead of bytes. (Similar to the play function.) Change all AOs to use the new API. The AO API as exposed to the rest of the player still uses the old API. It's emulated in ao.c. This is purely to split the commits changing all AOs and the commits adding actual support for outputting N-I audio.
* audio/out: reject non-interleaved formatswm42013-11-121-0/+2
| | | | | | | | | | No AO can handle these, so it would be a problem if they get added later, and non-interleaved formats get accepted erroneously. Let them gracefully fall back to other formats. Most AOs actually would fall back, but to an unrelated formats. This is covered by this commit too, and if possible they should pick the interleaved variant if a non-interleaved format is requested.
* ao: add ao_play_silence, use for ao_alsa and ao_osswm42013-11-101-7/+4
| | | | | Also add a corresponding function to audio/format.c, which fills an audio block with silence.
* ao: print requested audio format on initwm42013-11-091-3/+0
| | | | Also remove the rather bad/incomplete log calls from ao_alsa and ao_oss.
* audio: replace af_fmt2str_short -> af_fmt_to_strwm42013-11-071-5/+5
| | | | Also, remove all af_fmt2str usages.
* ao_oss: fix previous ao_oss commitwm42013-11-061-1/+0
| | | | | Basically I introduced an inverted condition, and the line removed was inactive before commit ce72aaa.
* ao_oss: hide warningwm42013-11-061-2/+2
|
* ao_oss: don't enable -softvol by default on OSSv4bugmen0t2013-11-061-0/+4
|
* ao_oss: make no_persistent_volume volume work when seekingbugmen0t2013-11-061-0/+4
|
* configure: uniform the defines to #define HAVE_xxx (0|1)Stefano Pigozzi2013-11-031-5/+5
| | | | | | | | | | | | | | | | | | | | | The configure followed 5 different convetions of defines because the next guy always wanted to introduce a new better way to uniform it[1]. For an hypothetic feature 'hurr' you could have had: * #define HAVE_HURR 1 / #undef HAVE_DURR * #define HAVE_HURR / #undef HAVE_DURR * #define CONFIG_HURR 1 / #undef CONFIG_DURR * #define HAVE_HURR 1 / #define HAVE_DURR 0 * #define CONFIG_HURR 1 / #define CONFIG_DURR 0 All is now uniform and uses: * #define HAVE_HURR 1 * #define HAVE_DURR 0 We like definining to 0 as opposed to `undef` bcause it can help spot typos and is very helpful when doing big reorganizations in the code. [1]: http://xkcd.com/927/ related
* audio/out: remove useless info struct and redundant fieldswm42013-10-231-6/+3
|
* ao_oss: add support for SNDCTL_DSP_RESET and use it when pausingPaul B Mahol2013-09-231-0/+6
| | | | | Signed-off-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: wm4 <wm4@nowhere>
* mixer: make struct opaquewm42013-09-201-1/+0
| | | | Also remove stray include statements from ao_alsa and ao_oss.
* Some more mp_msg conversionswm42013-08-231-53/+37
| | | | | Also add a note to mp_msg.h, since it might be not clear which of the two mechanisms is preferred.
* core: move contents to mpvcore (2/2)Stefano Pigozzi2013-08-061-2/+2
| | | | Followup commit. Fixes all the files references.
* audio/out: remove options argument from init()wm42013-07-221-1/+1
| | | | Same as with VOs in the previous commit.
* ao_oss: switch to new option APIwm42013-07-211-31/+30
|
* options: remove --mixer and --mixer-channel, turn them into alsa/oss suboptswm42013-07-211-4/+3
| | | | | | These two options were supported by ALSA and OSS only. Further, their values were specific to the respective audio systems, so it doesn't make sense to keep them as top-level options.
* audio/out: remove ao->outburst/buffersize fieldswm42013-06-161-22/+25
| | | | | | | | | | | | | | | The core didn't use these fields, and use of them was inconsistent accross AOs. Some didn't use them at all. Some only set them; the values were completely unused by the core. Some made full use of them. Remove these fields. In places where they are still needed, make them private AO state. Remove the --abs option. It set the buffer size for ao_oss and ao_dsound (being ignored by all other AOs), and was already marked as obsolete. If it turns out that it's still needed for ao_oss or ao_dsound, their default buffer sizes could be adjusted, and if even that doesn't help, AO suboptions could be added in these cases.
* ao_oss: fix compilation on BSDwm42013-06-111-2/+3
| | | | | | This was overlooked with commit 32a898f, because OSS4 volume control is typically not available on Linux. BSD does have this feature, so the broken code broke compilation there.
* ao_oss: remove duplicated format infowm42013-06-071-50/+27
| | | | | Instead of having two big switch statements to convert between two audio formats, use a single table.
* ao_oss: remove global variableswm42013-06-071-80/+104
|
* ao_oss: switch to new AO APIwm42013-06-071-128/+117
|
* ao_oss: uncrustifywm42013-06-071-298/+334
|
* audio/out: channel map selectionwm42013-05-121-2/+6
| | | | | | | | | Make all AOs use what has been introduced in the previous commit. Note that even AOs which can handle all possible layouts (like ao_null) use the new functions. This might be important if in the future ao_select_champ() possibly honors global user options about downmixing and so on.
* audio/out: switch to channel mapwm42013-05-121-15/+17
| | | | | | This actually breaks audio for 5/6/8 channels. There's no reordering done yet. The actual reordering will be done inside of af_lavrresample and has to be made part of the format negotiation.
*