summaryrefslogtreecommitdiffstats
path: root/audio
Commit message (Collapse)AuthorAgeFilesLines
* ao_wasapi: Use OPT_STRING_VALIDATE for device suboptionDiogo Franco (Kovensky)2013-07-221-22/+82
| | | | | | | | | | | | | | | | | Validates by trying to pick the device using the device enumerator and aborting with out of range on failure. Refactors find_and_load_device to not use the wasapi_state; it might be called during validation. Adds missing CoInitialize/CoUninitialize calls. Remove unused variables (the SAFE_RELEASE macros keep them referenced so compiler warnings don't help finding them...). Remove the IMMDeviceEnumerator from the wasapi_state, it's only needed during initialization and initialization is now well factored enough to get rid of it. Try and connect to unplugged devices as well when using the device ID string.
* ao_wasapi: Fully convert to m_option APIDiogo Franco (Kovensky)2013-07-221-20/+10
|
* ao_wasapi: Don't leak the default device's ID when listing devicesDiogo Franco (Kovensky)2013-07-221-3/+4
| | | | Also remove unused variable.
* ao_wasapi: Annotate the default device when listing devicesDiogo Franco (Kovensky)2013-07-221-4/+17
|
* ao_wasapi: Refactor device listing/loadingDiogo Franco (Kovensky)2013-07-221-42/+97
| | | | | | | | | | | | Omit "{0.0.0.00000000}." on devices that start with that substring, re-add when searching for devices by ID. Log the device ID of the default device. Log the friendly name of the used device. Consistently refer to endpoints/devices as devices, as this is more consistent with mpv terminology.
* ao_wasapi0: Rename to ao_wasapiDiogo Franco (Kovensky)2013-07-222-46/+46
| | | | | Nobody knows what the 0 was for. There's no "WASAPI version 0". Just take it out.
* ao_wasapi0: Use the mix format directly in try_mix_formatDiogo Franco (Kovensky)2013-07-221-0/+2
|
* ao_wasapi0: Don't complain about failed init during AO probingDiogo Franco (Kovensky)2013-07-221-8/+10
| | | | Only if the user specifically asked for ao_wasapi0.
* ao_wasapi0: Don't fail init when listing devicesDiogo Franco (Kovensky)2013-07-221-2/+0
|
* ao_wasapi0: Demote "negotiation failed" message to MSGL_VDiogo Franco (Kovensky)2013-07-221-2/+2
| | | | | Could spam the console with what may be harmless in some cases. We already complain loudly if we're stuck checking this too many times.
* ao_wasapi0: Support shared mode, better format guessing methodDiogo Franco (Kovensky)2013-07-221-72/+258
| | | | | | | | | | | | | | | | | | | | | | Uses WASAPI in shared mode by default, add :exclusive flag to choose exclusive mode (duh). WASAPI works somewhat different in shared mode: the OS suggests the sample format to use, and the GetBuffer call is done slightly differently. The shared mode driver does not consume audio as fast as it notifies the thread; we need to check how much we're allowed to write. Not doing this correctly results in spamming the console with AUDCLNT_E_BUFFER_TOO_LARGE errors. When guessing formats for exclusive mode, try several sample size and sample rate combinations instead of just falling back to s16le@44100hz. If none of the rates are accepted, tries remixing >6 channels to 5.1 channels. Failing that, tries remixing to stereo. Failing everything, including the CD Red Book format, what else is left to test? Calculate buffer_block_size based on the configured channels and bytes per sample; MSDN docs say nBlockAlign is not guaranteed to be set for anything but integer PCM formats.
* ao_wasapi0: Support device enumeration and selectionDiogo Franco (Kovensky)2013-07-221-3/+215
| | | | | | | | | Adds the :list suboption to ao_wasapi0, which enumerates the audio endpoints in the system. Adds the :device=<n> suboption, which either takes an ID string (as output by list) or a device number and uses the requested device instead of the system default.
* ao_dsound: use new option APIwm42013-07-221-14/+14
|
* ao_jack: use new option APIwm42013-07-221-72/+34
|
* ao_oss: switch to new option APIwm42013-07-211-31/+30
|
* options: remove --mixer and --mixer-channel, turn them into alsa/oss suboptswm42013-07-212-36/+19
| | | | | | 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.
* ao_rsound: use new option APIwm42013-07-211-27/+17
| | | | | Untested. I don't even know if this compiles. I have no clue what rsound even is.
* ao_sdl: use new option APIwm42013-07-211-29/+19
|
* ao_openal: use new option APIwm42013-07-211-42/+29
|
* ao_pulse: use new option APIwm42013-07-211-17/+14
| | | | Untested, but should be fine.
* 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.
* ao_alsa: use new option API (changes syntax)wm42013-07-211-66/+25
| | | | | | | | | | | | This changes how device names are handled. Before this commit, device names were mangled in strange ways to avoid clashing with the option parser syntax. "." was replaced with ",", and "=" with ":" (the user had to do the inverse to get the correct device name). The "new" option parser has multiple ways to escape option strings, so we don't need this confusing hack anymore. Add an explicit note to the manpage as well.
* ao_pcm: use new option APIwm42013-07-211-16/+12
|
* ao_portaudio: use new option APIwm42013-07-211-32/+35
| | | | | This basically serves as example. All other AOs should be ported as well.
* options: use new option code for --aowm42013-07-212-91/+89
| | | | This requires completely refactoring the AO creation code too.
* ao_wasapi0: Don't starve the WASAPI thread on seeksDiogo Franco (Kovensky)2013-07-201-6/+11
| | | | | | | | | | Seeking calls thread_reset, but doesn't call thread_play. thread_reset would disable WASAPI events, but they would never get re-enabled unless the user paused and then unpaused. Keep track of whether the stream is paused or not (there already was a field for that, but it was apparently unused), and if it's not paused, call thread_play after thread_reset. Fixes mpv freezing after seeks.
* ao_wasapi0: Don't release WASAPI buffer twiceDiogo Franco (Kovensky)2013-07-201-0/+1
| | | | Would cause bogus AUDCLNT_E_OUT_OF_ORDER errors.
* ao_wasapi0: Make it compile on cygwin64Diogo Franco (Kovensky)2013-07-201-5/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | Fixes format specifies that assume windows TYPEDEFS are as long as they look like they are. Remove calls to _beginthreadex and _endthreadex, these are only present on microsoft's C runtimes. Replace by the otherwise identical CreateThread and ExitThread calls. This actually requires fixes to devicetopology.h, but the problem has been (kinda) reported to mingw-w64: <Kovensky> I see that those KSJACK* structs are supposedly declared in devicetopology.h itself, but for some reason (some of?) the decls that use them aren't seeing them? <Kovensky> ok, it seems that it expects ks.h and ksmedia.h to declare those structs, but it doesn't <Kovensky> the included files declare KDATAFORMAT, KSIDENTIFIER and LUID (and the associated pointer typedefs) <Kovensky> but everything else is essentially inside #if 0 <Kovensky> changing the #ifndef _KS_ to only include KDATAFORMAT, KSIDENTIFIER and LUID (and putting the KSJACK stuff outside that #ifndef) makes the header compile <Kovensky> it solves my immediate problem, but if that happened to begin with there's probably something more wrong with the ks headers :S
* demux_mkv: never force output sample ratewm42013-07-161-12/+5
| | | | | | | | | | | | | | Matroska has an output sample rate (OutputSamplingFrequency), which in theory should be forced instead of whatever the decoder outputs. But it appears no software (other than mplayer2 and mpv until now) actually respects this. Even worse, there were broken files around, which played correctly with (in theory) broken software, but not mplayer2/mpv. Hacks were added to our code to play these files correctly, but they didn't catch all cases. Simplify this by doing what everyone else does, and always use the decoder's sample rate instead. In particular, we try to handle all sample rate issues like libavformat's Matroska demuxer does.
* Merge branch 'remove_old_demuxers'wm42013-07-145-144/+51
|\ | | | | | | | | | | | | | | The merged branch doesn't actually just remove old demuxers, but also includes a branch of cleanups and some refactoring. Conflicts: stream/stream.c
| * ad_lavc: re-unsimplify, fix libavcodec API usagewm42013-07-111-2/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It turns out that some code that was removed earlier was still needed. avcodec_decode_audio4() can decode packets "partially". In that case, you have to "slice" the packet and call the decode function again. Codecs which need this are obscure and in low numbers. One sample that needs it is here: rsync://fate-suite.ffmpeg.org/fate-suite/lossless-audio/luckynight-partial.shn (This one decodes in rather small increments.) The new code is much simpler than what has been removed earlier, though. The fact that we own the packet returned by the demuxer helps a lot. Not sure what should happen if avcodec_decode_audio4() returns 0. Currently, we throw away the packet in this case. We don't want to be stuck in an endless loop (could happen if the decoder produces no output either).
| * mplayer: fix incorrect audio sync after format changeswm42013-07-111-8/+2
| | | | | | | | | | | | | | | | | | | | | | This is not directly related to the handling of format changes itself, but playing audio normally after the change. This was broken: the output byte rate was not recalculated, so audio-video sync was simply broken. Fix this by calculating the byte rate on the fly, instead of storing it in sh_audio. Format changes are relatively common (switches between stereo and 5.1 in TV recordings), so this fixes a somewhat critical bug.
| * ad_spdif: better PTS syncwm42013-07-111-1/+3
| | | | | | | | | | | | | | | | | | | | | | pts_bytes can't just be changed at the end. It must be offset to the pts value, which is reset with each packet read from the demuxer. Make sure the pts_byte field is always reset after receiving a new PTS, i.e. increment it after actually writing to the output buffer. Flush the AVFormatContext's write buffer, because otherwise the audio PTS will jump around too much: the calculation doesn't use the exact output buffer size if there's still data in the avio buffer.
| * demux: remove facility for partial packet readswm42013-07-115-73/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Partial packet reads were needed because the video/audio parsers were working on top of them. So it could happen that a parser read a part of a packet, and returned that to the decoder. With libavformat/libavcodec, packets are already parsed, and everything is much simpler. Most of the simplifications in ad_spdif could have been done earlier. Remove some other stuff as well, like the questionable slave mode start time reporting (could be replaced by proper code, but we don't bother). Remove the unused skip_audio_frame() functionality as well (it was used by old demuxers). Some functions become private to demux.c, like demux_fill_buffer(). Introduce new packet read functions, which have simpler semantics. Packets returned from them are owned by the caller, and all packets in the demux.c packet queue are considered unread. Remove special code that dropped subtitle packets with size 0. This used to be needed because it caused special cases in the old code.
| * ad_lavc: simplifywm42013-07-101-30/+5
| | | | | | | | | | | | | | | | | | We don't need to deal with partial packet reads, manually using an audio parser, or having to call the libavcodec decoder multiple times per packet. Actually, I'm not sure about the last point. ffplay still does this, but the ffmpeg demuxing.c example doesn't.
| * audio: remove decoder input bufferwm42013-07-102-12/+0
| | | | | | | | This was unused.
| * demux: remove audio parserwm42013-07-082-26/+5
| | | | | | | | | | | | | | | | | | | | | | The audio parser was needed only by the "old" demuxers, and demux_rawaudio. All other demuxers output already parsed packets. demux_rawaudio is usually for raw audio, so using a parser with it doesn't usually make sense. But you can also force it to read compressed formats with fixed packet sizes, in which case the parser would have been used. This use case is probably broken now, but you will be able to do the same thing with libavformat demuxers.
| * Remove old demuxerswm42013-07-071-0/+2
| | | | | | | | | | | | | | | | | | | | Delete demux_avi, demux_asf, demux_mpg, demux_ts. libavformat does better than them (except in rare corner cases), and the demuxers have a bad influence on the rest of the code. Often they don't output proper packets, and require additional audio and video parsing. Most work only in --no-correct-pts mode. Remove them to facilitate further cleanups.
* | ao_wasapi0: use new mp_ring bufferJonathan Yong2013-07-121-82/+25
|/
* ao_jack: allow more control about channel layoutswm42013-07-072-1/+22
|
* ao_jack: increase buffer size, always round up buffer sizewm42013-07-061-2/+2
| | | | | This should help with github issue #128, which reported stuttering distorted sound with 6 channel audio, but not with 2 channels.
* ao_wasapi0: add new wasapi event mode aoJonathan Yong2013-06-182-0/+844
|
* ao_dsound: fix compilationwm42013-06-161-0/+2
|
* audio/out: remove ao->outburst/buffersize fieldswm42013-06-1612-73/+64
| | | | | | | | | | | | | | | 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-169-40/+28
| | | | | | | 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: fix af_fmt_seconds_to_bytesStefano Pigozzi2013-06-164-8/+13
| | | | Was missing samplerate
* audio/out: remove wrapper for old AOswm42013-06-163-130/+0
| | | | It's unused now.
* ao_jack: use mp_ringStefano Pigozzi2013-06-161-31/+12
|
* ao_portaudio: use mp_ringStefano Pigozzi2013-06-162-57/+15
|
* core: add a spsc ringbuffer implementationStefano Pigozzi2013-06-165-164/+33
| | | | | | | | | | | | | | | | | Currently every single AO was implementing it's own ringbuffer, many times with slightly different semantics. This is an attempt to fix the problem. I stole some good ideas from ao_portaudio's ringbuffer and went from there. The main difference is this one stores wpos and rpos which are absolute positions in an "infinite" buffer. To find the actual position for writing / reading just apply modulo size. The producer only modifies wpos while the consumer only modifies rpos. This makes it pretty easy to reason about and make the operations thread safe by using barriers (thread safety is guaranteed only in the Single-Producer/Single- Consumer case). Also adapted ao_coreaudio to use this ringbuffer.
* ao_coreaudio: fix output with spdifStefano Pigozzi2013-06-161-5/+4
| | | | The mute condition was inverted...
* ao_coreaudio: split ringbuffer in it's own fileStefano Pigozzi2013-06-163-73/+159
| | | | | | | | | This is hopefully the start of something good. ca_ringbuffer_read and ca_ringbuffer_write can probably cleaned up from all the NULL checks once ao_coreaudio.c gets simplyfied. Conflicts: audio/out/ao_coreaudio.c
* ao_coreaudio: move to new libao APIStefano Pigozzi2013-06-161-310/+339
| | | | | This is just a first pass and the bare minimum to make it compile and work. SPDIF is untested for lack of hardware.
* ao_coreaudio: uncrustifyStefano Pigozzi2013-06-161-491/+553
| | | | | uncrustify -l C -c TOOLS/uncrustify.cfg --no-backup --replace \ audio/out/ao_coreaudio.c
* encode_lavc strings: use new option syntaxRudolf Polzer2013-06-161-1/+1
|
* options: remove --stereowm42013-06-132-14/+1
| | | | | | | Whatever this was supposed to be originally, it doesn't have much value anymore. It just forced ad_mpg123 to upmix mono to stereo by default (the audio chain can do that). As an option, it was mostly useless and misleading, so get rid of it.
* 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.
* core: make options.c compile standalonewm42013-06-081-0/+2
| | | | | This also removes the split between "mplayer" and "common" opts (common opts used to be shared between mencoder and mplayer).
* ao_jack: remove global variableswm42013-06-071-71/+79
|
* ao_jack: align data sizes on audio frame sizewm42013-06-071-5/+5
| | | | | | | | | | Fixes crashes when playing with certain numbers of channels. The core assumes AOs accept data aligned on channels * samplesize, and ao_jack's play() function broke that assumption: mpv: core/mplayer.c:2348: fill_audio_out_buffers: Assertion `played % unitsize == 0' failed. Fix by aligning the buffer and chunk sizes as needed.
* ao_jack: switch to new AO APIwm42013-06-071-62/+62
|
* ao_jack: uncrustifywm42013-06-071-211/+236
|
* 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