summaryrefslogtreecommitdiffstats
path: root/audio/out/ao.c
Commit message (Collapse)AuthorAgeFilesLines
* 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 will be fixed later.
* ao: some missing mp_msg conversionswm42013-12-211-13/+17
|
* Split mpvcore/ into common/, misc/, bstr/wm42013-12-171-2/+2
|
* Move options/config related files from mpvcore/ to options/wm42013-12-171-2/+2
| | | | | | | | | 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.
* Replace mp_tmsg, mp_dbg -> mp_msg, remove mp_gtext(), remove set_osd_tmsgwm42013-12-161-2/+2
| | | | | | | | | The tmsg stuff was for the internal gettext() based translation system, which nobody ever attempted to use and thus was removed. mp_gtext() and set_osd_tmsg() were also for this. mp_dbg was once enabled in debug mode only, but since we have log level for enabling debug messages, it seems utterly useless.
* options: add options that set defaults for af/vf/ao/vowm42013-12-011-0/+2
| | | | | | | | There are some use cases for this. For example, you can use it to set defaults of automatically inserted filters (like af_lavrresample). It's also useful if you have a non-trivial VO configuration, and want to use --vo to quickly change between the drivers without repeating the whole configuration in the --vo argument.
* audio: switch output to mp_audio_bufferwm42013-11-121-5/+7
| | | | | | Replace the code that used a single buffer with mp_audio_buffer. This also enables non-interleaved output operation, although it's still disabled, and no AO supports it yet.
* audio/out: prepare for non-interleaved audiowm42013-11-121-7/+10
| | | | | | | | | | | | | | | | | | | 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.
* ao: add ao_play_silence, use for ao_alsa and ao_osswm42013-11-101-0/+12
| | | | | 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-0/+4
| | | | Also remove the rather bad/incomplete log calls from ao_alsa and ao_oss.
* audio: don't let ao_lavc access frontend internals, change gapless audiowm42013-11-081-6/+0
| | | | | | | | | | | | | | | | | | | | | | | ao_lavc.c accesses ao->buffer, which I consider internal. The access was done in ao_lavc.c/uninit(), which tried to get the left-over audio in order to write the last (possibly partial) audio frame. The play() function didn't accept partial frames, because the AOPLAY_FINAL_CHUNK flag was not correctly set, and handling it otherwise would require an internal FIFO. Fix this by making sure that with gapless audio (used with encoding), the AOPLAY_FINAL_CHUNK is set only once, instead when each file ends. Basically, move the hack in ao_lavc's uninit to uninit_player. One thing can not be entirely correctly handled: if gapless audio is active, we don't know really whether the AO is closed because the file ended playing (i.e. we want to send the buffered remainder of the audio to the AO), or whether the user is quitting the player. (The stop_play flag is overwritten, fixing that is perhaps not worth it.) Handle this by adding additional code to drain the AO and the buffers when playback is quit (see play_current_file() change). Test case: mpv avdevice://lavfi:sine=441 avdevice://lavfi:sine=441 -length 0.2267 -gapless-audio
* configure: uniform the defines to #define HAVE_xxx (0|1)Stefano Pigozzi2013-11-031-13/+13
| | | | | | | | | | | | | | | | | | | | | 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-3/+3
|
* mp_msg: remove gettext() supportwm42013-10-181-1/+1
| | | | | | | | | Was disabled by default, was never used, internal support was inconsistent and poor, and there has been virtually no interest in creating translations. And I don't even think that a terminal program should be translated. This is something for (hypothetical) GUIs.
* audio/out: add sndio supportChristian Neukirchen2013-10-031-0/+4
| | | | Based on an earlier patch for mplayer by Alexandre Ratchov <alex@caoua.org>
* ao: remove some leftoverswm42013-08-221-5/+0
|
* core: move contents to mpvcore (2/2)Stefano Pigozzi2013-08-061-4/+4
| | | | Followup commit. Fixes all the files references.
* audio/out: add support for new logging APIStefano Pigozzi2013-08-011-7/+12
|
* audio/out: remove options argument from init()wm42013-07-221-2/+3
| | | | Same as with VOs in the previous commit.
* ao_wasapi: Make default on Windows.Diogo Franco (Kovensky)2013-07-221-3/+3
| | | | Ahead of OSS because cygwin provides OSS.
* ao_wasapi0: Rename to ao_wasapiDiogo Franco (Kovensky)2013-07-221-3/+3
| | | | | Nobody knows what the 0 was for. There's no "WASAPI version 0". Just take it out.
* options: hide encoding AO/VO in help outputwm42013-07-211-0/+1
| | | | | These can't be used manually. Encoding is enabled with -o instead, and the encoding AO/VO is selected using internal mechanisms.
* options: use new option code for --aowm42013-07-211-86/+80
| | | | This requires completely refactoring the AO creation code too.
* ao_wasapi0: add new wasapi event mode aoJonathan Yong2013-06-181-0/+4
|
* audio/out: remove ao->outburst/buffersize fieldswm42013-06-161-2/+1
| | | | | | | | | | | | | | | 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.
* audio/out: don't require AOs to set ao->bpswm42013-06-161-9/+8
| | | | | | | Some still do, because they use the value in other places of the init function. ao_portaudio is tricky and reads ao->bps in the stream thread, which might be started on initialization (not sure about that, but better safe than sorry).
* audio/out: remove wrapper for old AOswm42013-06-161-54/+0
| | | | It's unused now.
* audio: add channel map selection functionwm42013-05-121-0/+10
| | | | | | | |