summaryrefslogtreecommitdiffstats
path: root/audio/out/ao.c
Commit message (Collapse)AuthorAgeFilesLines
* mpv_talloc.h: rename from talloc.hDmitrij D. Czarkoff2016-01-111-1/+1
| | | | This change helps avoiding conflict with talloc.h from libtalloc.
* ao_dsound: remove this audio outputwm42016-01-061-4/+0
| | | | | | | It existed for XP-compatibility only. There was also a time where ao_wasapi caused issues, but we're relatively confident that ao_wasapi works better or at least as good as ao_dsound on Windows Vista and later.
* ao: disambiguate default device list entrieswm42015-11-271-2/+6
| | | | | | | | | | | If there were many AO drivers without device selection, this added a "Default" entry for each AO. These entries were not distinguishable, as the device list feature is meant not to require to display the "raw" device name in GUIs. Disambiguate them by adding the driver name. If the AO is the first, the name will remain just "Default". (The condition checks "num > 1", because the very first entry is the dummy for AO autoselection.)
* audio: always log channel maps before determining final mapwm42015-10-261-11/+4
| | | | | Until now, this was done only in debug verbosity, while some AOs logged equivalent information in verbose mode. Clean this up.
* audio: add option for falling back to ao_nullwm42015-10-051-0/+6
| | | | | | | | | The manpage entry explains this. (Maybe this option could be always enabled and removed. I don't quite remember what valid use-cases there are for just disabling audio entirely, other than that this is also needed for audio decoder init failure.)
* ao: rework audio output driver probingwm42015-10-051-38/+42
| | | | | | | | | | | | | | | Make the code a bit more uniform. Always build a "dummy" audio output list before probing, which means that opening preferred devices and pure auto-probing is done with the same code. We can drop the second ao_init() call. This also makes the next commit easier, which wants to selectively fallback to ao_null. This could have been implemented by passing a different requested audio output list (instead of reading it from MPOptions), but I think it's better if this rather special feature is handled internally in the AO code. This also makes sure the AO code can handle its own options (such as the audio output list) in a self-contained way.
* ao: don't pass along AO arguments when redirectingwm42015-07-031-1/+1
| | | | Only causes problems.
* audio: fix format function consistency issueswm42015-06-261-2/+2
| | | | | | | | | | | 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: output human-readable channel layouts toowm42015-06-251-8/+2
| | | | | This gets you the "logical" channel layout, instead of the exact thing we're sending to the AO. (Tired of the cryptic shit ALSA gives me.)
* ao: standardize channel layout name in debug output furtherwm42015-06-251-0/+2
|
* ao: allow ao_uninit(NULL)wm42015-06-021-1/+2
|
* ao: make better use of atomicswm42015-05-111-13/+10
| | | | | The main reason for this was compatibility; but some associated problems have been solved in the previous commit.
* ao: log reordered versions of channel mapswm42015-05-081-3/+10
| | | | Useful for debugging cases when no standard orders are used.
* Update license headersMarcin Kurczewski2015-04-131-5/+4
| | | | Signed-off-by: wm4 <wm4@nowhere>
* audio: make all format query shortcuts macrosKevin Mitchell2015-04-031-1/+1
| | | | | af_fmt_is_float and af_fmt_is_planar were previously inconsistent with AF_FORAMT_IS_SPECIAL/AF_FORMAT_IS_IEC61937
* ao: slightly extend debug messageswm42015-03-161-1/+4
| | | | | This function already got uglified with debug printing; might as well go all the way.
* ao: align audio buffer sizewm42015-03-131-0/+3
| | | | Might or might not matter.
* ao: fix null dereferenceStefano Pigozzi2015-02-141-0/+2
|
* ao_coreaudio: add support for hotplug notificationsStefano Pigozzi2015-02-141-5/+5
| | | | | | | | | | This commit adds notifications for hot plugging of devices. It also extends the old behaviour of the `audio-out-detected-device` property which is now backed by the hotplugging code. This allows clients to be notified when the actual audio output device changes. Maybe hotplugging should be supported for ao_coreaudio_exclusive too, but it's device selection code is a bit fragile.
* audio: add device change notification for hotpluggingwm42015-02-121-14/+98
| | | | | | | | | | | | | | | | | | | | | | | | | | | Not very important for the command line player; but GUI applications will want to know about this. This only adds the internal API; support for specific audio outputs comes later. This reuses the ao struct as context for the hotplug event listener, similar to how the "old" device listing API did. This is probably a bit unclean and confusing. One argument got reusing it is that otherwise rewriting parts of ao_pulse would be required (because the PulseAudio API requires so damn much boilerplate). Another is that --ao-defaults is applied to the hotplug dummy ao struct, which automatically applies such defaults even to the hotplug context. Notification works through the property observation mechanism in the client API. The notification chain is a bit complicated: the AO notifies the player, which in turn notifies the clients, which in turn will actually retrieve the device list. (It still has the advantage that it's slightly cleaner, since the AO stuff doesn't need to know about client API issues.) The weird handling of atomic flags in ao.c is because we still don't require real atomics from the compiler. Otherwise we'd just use atomic bitwise operations.
* ao: set correct client name when listing deviceswm42015-02-121-4/+3
| | | | | | | | | | This is a small oversight. The client name (as set on command line options or, more importantly, the client API) was not set when listing devices e.g. via the "audio-device-list" property. Might or might not fix #1578. Also adjust the log level for an unrelated message.
* command: add property returning detected audio deviceStefano Pigozzi2015-02-031-0/+5
| | | | | This can be useful to adjust some other audio related properties at runtime depending on the audio device being used.
* ao: never autoselect ao_nullwm42015-01-201-1/+2
| | | | | | | | | Before this commit, ao_null was used as last fallback. This doesn't make too much sense. Why would you decode audio just to discard it? Let audio initialization fail instead. This also handles the weird but possible corner-case that ao_null might fail initializing, in which case e.g. ao_pcm could be autoselected. (This happened once, and had to be fixed manually.)
* ao: refactor --audio-device selection codewm42015-01-201-85/+73
| | | | | | | | | | | | | | This removes the slightly duplicated code for picking the required AO driver if --audio-device forces one. Now --audio-device reuses the same code as --ao for this. As a consequence, ao_alloc_pb() and ao_create() can be merged into ao_init(). Although the ao_init() argument list, which is already pretty big, grows by one, it's better than having all these similar sounding functions around. Actually, I just wanted to do the change the following commit will do, but I found this code was more of a mess than it had to be.
* ao: remove coreaudio_exclusive from autoprobing listwm42015-01-071-2/+2
| | | | Apparently this was a mistake.
* ao_portaudio: remove this audio outputwm42014-12-291-4/+0
| | | | | It's just completely useless. We have good native support for all 3 desktop platforms, and ao_sdl or ao_openal as fallbacks.
* ao: add debug log with the detected channel mapsStefano Pigozzi2014-12-291-0/+6
| | | | This could be helpful with bug reports.
* audio: make mp_chmap_to_str() return a stack-allocated stringwm42014-11-241-3/+2
| | | | Simplifies memory management.
* audio/out: always log retrieved audio device sizewm42014-11-181-2/+2
|
* audio/out: switch back to wasapi as default on win32wm42014-11-171-3/+3
| | | | | | dsound was set as default, because there were some hard to fix problems with wasapi. These problems were probably fixed now, so let's try with wasapi as default again.
* audio/out: make ao_request_reload() idempotentwm42014-11-091-7/+16
| | | | | | | | | | This is what you would expect. Before this commit, each ao_request_reload() call would just queue a reload command, and then recreate the AO for the number of times the function was called. Instead of sending a command, introduce some sort of event retrieval mechanism. At least for the reload case, use atomics, because we're too lazy to setup an extra mutex.
* audio: add --audio-client-name optionwm42014-11-071-0/+2
| | | | | | The main need I see for this is with libmpv - it would be confusing if some application showed up as "mpv" on whateverthehell PulseAudio uses it for (generally it does show up on various PA GUI tools).
* audio: add command/function to reload audio outputwm42014-10-271-0/+8
| | | | | Anticipated use: simple solution for dealing with audio APIs which request configuration changes via events.
* audio/out: add redirection-on-init mechanismwm42014-10-221-14/+44
| | | | | Looks like this will help us with making --audio-device and spdif work as expected on OSX. To be used ina following commit.
* audio/out: missing error checkwm42014-10-221-0/+2
| | | | Oops.
* audio/out: don't add special devices to --audio-device listwm42014-10-221-2/+2
| | | | | | | | | | | | | | | | | | Since the list associated with --audio-device is supposed to enable simple user-selection, it doesn't make much sense to include overly special things like ao_pcm or ao_null in the list. Specifically, ao_pcm is harmful, because it will just dump all audio to a file named audiodump.wav in the current working directory. The user can't choose the filename (it can be customized, but not through this option), and the working directory might be essentially random, especially if this is used from a GUI. Exclude "strange" entries. We reuse the fact that there's already a simple list ordered by auto-probe priority in order to avoid having to add an additional flag. This is also why coreaudio_exclusive was moved above ao_null: ao_null ends auto-probing and marks the start of "special" outputs, which don't show up on the device, but we want coreaudio_exclusive to be selectable (I think).
* audio/out: include coreaudio_exclusive in auto-probingwm42014-10-221-3/+3
| | | | | | | Move it above ao_null, so that it can be selected during auto-probing (even if it's only last). I see no reason why it should not be included, and it makes the following commit slightly more elegant. (See explanations there.)
* audio: quote devices in --audio-device=helpwm42014-10-191-1/+1
| | | | | The output is a bit confusing. Quoting the device name probably helps a little bit; also add minimal explanations to the manpage.
* audio/out: add "auto" pseudo-devicewm42014-10-131-1/+3
| | | | | Also, don't set an empty string for the fallback device if an AO doesn't list any devices.
* audio: don't list encoder AO with --audio-device=helpwm42014-10-101-0/+2
|
* audio: change internal device listing APIwm42014-10-101-19/+35
| | | | | Now we run ao_driver->list_devs on a dummy AO instance, which will probably confuse everyone. This is done for the sake of PulseAudio.
* audio: add device selection & listing with --audio-devicewm42014-10-091-6/+77
| | | | | | | Not sure how good of an idea this is. This commit doesn't add support for this to any AO yet; the AO implementations will follow later.
* audio/out: check device buffer size for push.c onlywm42014-09-271-7/+0
| | | | Should fix #1125.
* audio/out: disable ao_sndio by defaultwm42014-09-261-3/+3
| | | | | Don't build it, move it down the autoprobe list even if it's enabled. It doesn't work well enough.
* audio/out: fail init on unknown audio bufferwm42014-09-261-0/+7
| | | | A 0 audio buffer makes push.c go haywire. Shouldn't normally happen.
* audio/out: remove old thingswm42014-09-061-10/+1
| | | | | | | | 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-051-1/+1
| | | | | | | | | | | | | | | | | 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)
* audio: make buffer size configurablewm42014-09-051-1/+2
| | | | Really only for testing.
* audio: don't wait for draining if pausedwm42014-07-131-13/+1
| | | | | | | | | | | | | 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
* ao_coreaudio: move spdif code to a new AOStefano Pigozzi2014-07-021-0/+4
| | | | | | | | | | | | | | | | 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.
* audio: prefer dsound over wasapiwm42014-06-011-3/+3
| | | | | ao_wasapi has too many subtle failures that were reported, but there's nobody to fix them. ao_dsound seems to be more robust; so prefer it.
* 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.
* player: unrangle one aspect of audio EOF handlingwm42014-04-171-0/+5
| | | | | | | | | | | | | | | | | | 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.)
* ao: remove redundant get_delay checkwm42014-04-171-4/+0
| | | | It did nothing; the real check is in push.c.
* ao: print (estimated) device buffer size on init in verbose modewm42014-03-141-1/+3
|
* audio/out: reduce amount of audio bufferingwm42014-03-101-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | Since the addition of the AO feed thread, 200ms of latency (MIN_BUFFER) was added to all push-based AOs. This is not so nice, because even AOs with relatively small buffering (e.g. ao_alsa on my system with ~170ms of buffer size), the additional latency becomes noticable when e.g. toggling mute with softvol. Fix this by trying to keep not only 200ms minimum buffer, but also 200ms maximum buffer. In other words, never buffer beyond 200ms in total. Do this by estimating the AO's buffer fill status using get_space and the initially known AO buffer size (the get_space return value on initialization, before any audio was played). We limit the maximum amount of data written to the soft buffer so that soft buffer size and audio buffer size equal to 200ms (MIN_BUFFER). To avoid weird problems with weird AOs, we buffer beyond MIN_BUFFER if the AO's get_space requests more data than that, and as long as the soft buffer is large enough. Note that this is just a hack to improve the latency. When the audio chain gains the ability to refilter data, this won't be needed anymore, and instead we can introduce some sort of buffer replacement function in order to update data in the soft buffer.
* audio/out: make draining a separate operationwm42014-03-091-7/+15
| | | | | | | | | | | | 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: feed AOs from a separate threadwm42014-03-091-25/+45
| | | | | | | | | | | | | | | | | | This has 2 goals: - Ensure that AOs have always enough data, even if the device buffers are very small. - Reduce complexity in some AOs, which do their own buffering. One disadvantage is that performance is slightly reduced due to more copying. Implementation-wise, we don't change ao.c much, and instead "redirect" the driver's callback to an API wrapper in push.c. Additionally, we add code for dealing with AOs that have a pull API. These AOs usually do their own buffering (jack, coreaudio, portaudio), and adding a thread is basically a waste. The code in pull.c manages a ringbuffer, and allows callback-based AOs to read data directly.
* ao: remove opts fieldwm42014-03-091-1/+0
| | | | Apparently unused.
* audio/out: make ao struct opaquewm42014-03-091-2/+36
| | | | | | 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.
* ao: document some functionswm42014-02-281-0/+23
|
* build: fix usage of HAVE_SDL1 defineStefano Pigozzi2014-01-251-1/+1
| | | | This is needed after fd1f8ed49.
* msg: rename mp_msg_log -> mp_msgwm42013-12-211-1/+1
| | | | Same for companion functions.
* m_option, m_config: mp_msg conversionswm42013-12-211-1/+1
| | | | | | | | Always pass around mp_log contexts in the option parser code. This of course affects all users of this API as well. In stream.c, pass a mp_null_log, because we can't do it properly yet. This wi