summaryrefslogtreecommitdiffstats
path: root/audio/out/ao_coreaudio_utils.c
Commit message (Collapse)AuthorAgeFilesLines
* ao_coreaudio: replace fourcc_repr()wm42016-01-111-28/+3
| | | | Replace with the more general mp_tag_str().
* ao_coreaudio: log current format before setting new formatwm42015-10-211-0/+2
|
* ao_coreaudio: raise timeout for change-physical-formatwm42015-10-201-1/+1
| | | | | | | | | | Reportedly fixes operation with "USB connected Parasound ZDAC v.2". (OSX and USB audio sure is not nice at all.) This might be perceived as hang by some users, so it's quite possible that this will have to be adjusted again somehow. Fixes #2409.
* ao_coreaudio_utils: fix error handling in device listing codewm42015-09-281-3/+10
| | | | | | | | This could sometimes cause crashes in hotplug events. (Apparently in cases when CoreAudio changes its state asynchronously, or such.) CA_GET_STR() does not set the string if there was an error, so errors have to be strictly checked before using it.
* ao_coreaudio: fix device latency, share the codewm42015-07-061-0/+22
| | | | | | | | | ao_coreaudio (using AudioUnit) accounted only for part of the latency - move the code in ao_coreaudio_exclusive to utils, and use that for the AudioUnit code. (There's still the question why CoreAudio and AudioUnit require you to jump through hoops this much, but apparently that's how it is.)
* ao_coreaudio_exclusive: continue even if setting physical format failswm42015-07-061-0/+1
| | | | | Makes it work with (apparently) crappy drivers, which refuse to set the physical format in some cases.
* ao_coreaudio_utils: reduce spamwm42015-07-031-1/+0
|
* ao_coreaudio_utils: fix format back-mappingwm42015-07-031-5/+7
| | | | | | | | | | | Mapping of spdif formats was imperfect. Since the first format on the list is somehow AAC, it was returned first, which is confusing, because CoreAudio calls all spdif formats AC3. Since the spdif formats have some rather arbitrary, reverse mapping the formats didn"t actually work either. Fix by explicitly ignoring these when spdif is used. Also, don't forget to set the samplerate in ca_asbd_to_mpformat(), or it will work only in some cases.
* ao_coreaudio: restore physical format if it can't be set exactlywm42015-06-301-1/+12
| | | | | | | | May help with (supposedly) bad drivers, which can put the device into some sort of broken state when trying to set a different physical format. When the previous format is restored, it apparently recovers. This might make the change-physical-format suboption more robust.
* 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: replace format name tablewm42015-06-261-4/+3
| | | | Having a big switch() is simpler.
* ao_coreaudio_utils: use a macrowm42015-06-261-1/+1
| | | | | This is actually the last line of code outside of format.c/h which still tries to fiddle with the format bitfields.
* ao_coreaudio: support non-interleaved outputwm42015-06-261-1/+7
| | | | | This saves us the trouble of interleaving the audio data for no reason.
* ao_coreaudio_utils: compare full AudioStreamBasicDescriptionwm42015-06-251-1/+3
| | | | | | Originally, this was written for comparing the sample format only, but ca_change_physical_format_sync() actually expects that the full format is compared. (For all other uses it doesn't matter.)
* audio: remove S8, U16, U24, U32 formatswm42015-06-161-1/+1
| | | | | | | | | | | | | 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.
* ao_coreaudio: change physical stream format synchronouslywm42015-06-091-1/+1
|
* ao_coreaudio_exclusive: move generic functions to utilswm42015-06-021-2/+196
|
* ao_coreaudio_utils: don't list some formats as "unusable"wm42015-05-071-1/+1
| | | | | While mpv has no internal equivalent representation, they can still be used as physical CoreAudio formats. Thus this label is confusing.
* ao_coreaudio_utils: decide formats by comparing raw bitswm42015-05-051-5/+6
| | | | | | | | | | | | | | | | Instead of trying to use af_format_conversion_score() (which tries to be all kinds of clever), just compare the raw bits as a quality measure. Do this because otherwise, weird formats like padded 24 bit formats will be excluded, even though they might be the highest precision formats for some hardware. This means that for now, the user would have to check whether the format is usable at all before calling ca_asbd_is_better(). But since this is currently only used for ao_coreaudio.c and for the physical format, it doesn't matter. If coreaudio-exclusive should get PCM support, the best would be to revert this change, and to add support for 24 bit formats directly.
* ao_coreaudio_utils: don't require talloc for fourcc_repr()wm42015-05-051-12/+6
| | | | | Instead, apply a trick to make the caller allocate enough space on the stack.
* ao_coreaudio_utils: unbreak default device selectionwm42015-05-051-4/+3
| | | | | | It appears this is the reason coreaudio-exclusive does not work without explicitly specifying a device, even if the default device maps to something passthrough-capable.
* ao_coreaudio_utils: refine format selectionwm42015-05-051-19/+25
| | | | | | | | | | | Instead of always picking a somehow better format over the previous one, select a format that is equal to or better the requested format, but is also reasonably close. Drop the mFormatID comparison - checking the sample format handles this already. Make sure to exclude channel counts that can't be used.
* ao_coreaudio_utils: add a format negotiation helper functionwm42015-05-051-0/+34
|
* ao_coreaudio_utils: log mp format with CoreAudio format descriptionwm42015-04-291-2/+4
| | | | As a consequence, it also logs whether mpv can a this format at all.
* ao_coreaudio_utils: add function for ASBD -> mp format lookupwm42015-04-291-7/+56
| | | | | | | | | | Useful with some of the following commits. ca_fill_asbd() should behave exactly as before. Instead of actually implementing the inverse function of ca_fill_asbd(), just loop over the (small) list of mpv functions and check if any mpv equivalent to a given ASBD exists.
* ao_coreaudio_utils: float is not a signed integer formatwm42015-04-291-3/+3
| | | | | | | | | kAudioFormatFlagIsSignedInteger implicates that it's only used with integer formats. The mpv internal flag on the other hand signals the presence of a sign, and this is set on float formats. Until now, this probably worked fine, because at least AudioUnit is ignoring the uncorrect flag.
* ao_coreaudio_utils: change audio format loggingwm42015-04-281-3/+3
| | | | Make it easier to distinguish the fields.
* ao_coreaudio: fix inverted conditionwm42015-04-101-3/+4
| | | | And also use the correct type for the printf call below.
* ao_coreaudio: do not error if retrieving info for verbose mode failswm42015-04-071-6/+6
| | | | | | The message log level shouldn't get to decide whether something fails or not. So replace the fatal error check on the verbose output code path with a warning.
* ao_coreaudio: move some helpers to utilswm42015-03-101-0/+17
| | | | Needed by ao_coreaudio_exclusive.c in the next commit.
* ao_coreaudio: fix small memory leakStefano Pigozzi2015-02-031-0/+4
|
* ao_coreaudio: use device UID instead of ID for selectionStefano Pigozzi2015-02-031-12/+38
| | | | | | | | | | Previously we let the user use the audio device ID, but this is not persistent and can change when plugging in new devices. That of course made it quite worthless for storing it as a user setting for GUIs, or for user scripts. In theory getting the kAudioDevicePropertyDeviceUID can fail but it doesn't on any of my devices, so I'm leaving the error reporting quite high and see if someone complains.
* ao_coreaudio: reset possibly random errno valuewm42015-01-201-1/+2
| | | | | | | | | | In general, you need to check errno when using strtol(), but as far as I know, strtol() won't reset errno on success. This has to be done manually. The code could have failed sporadically if strtol() succeeded, and errno was already set to one of the checked values. (This strtol() still isn't fully error checked, but I don't know if it's intentional, e.g. for parsing a numeric prefix only.)
* coreaudio: only list output devicesStefano Pigozzi2014-10-281-0/+12
|
* coreaudio: redirect IEC61937 to coreaudio_exclusiveStefano Pigozzi2014-10-231-1/+1
|
* coreaudio: use the new device selection APIStefano Pigozzi2014-10-121-25/+19
| | | | | The CoreAudio API is built around device IDs so we store the integer as string and read it back.
* audio: cleanup spdif format definitionswm42014-09-231-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-1/+2
| | | | | | | | | | | | | | | | | | | | 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_coreaudio: move channel mapping away from utilsStefano Pigozzi2014-07-021-123/+0
| | | | | Channel mapping functions are only used in the AUHAL based coreaudio, so move them there.
* ao_coreaudio: fill asbd with an helper functionStefano Pigozzi2014-07-021-0/+26
|
* ao_coreaudio: move device related functions to the new AOStefano Pigozzi2014-07-021-249/+0
|
* ao_coreaudio: move spdif code to a new AOStefano Pigozzi2014-07-021-0/+62
| | | | | | | | | | | | | | | | 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.
* Audit and replace all ctype.h useswm42014-07-011-2/+2
| | | | | | | | | | | | | | | | Something like "char *s = ...; isdigit(s[0]);" triggers undefined behavior, because char can be signed, and thus s[0] can be a negative value. The is*() functions require unsigned char _or_ EOF. EOF is a special value outside of unsigned char range, thus the argument to the is*() functions can't be a char. This undefined behavior can actually trigger crashes if the implementation of these functions e.g. uses lookup tables, which are then indexed with out-of-range values. Replace all <ctype.h> uses with our own custom mp_is*() functions added with misc/ctype.h. As a bonus, these functions are locale-independent. (Although currently, we _require_ C locale for other reasons.)
* ao_coreaudio: skip unknown channel labelsStefano Pigozzi2014-05-101-0/+2
| | | | | | | | | | | | | I don't think this is really a very good idea because it is conceptually incorrect but other prominent multimedia programs use this approach (VLC and xbmc), and it seems to make the conversion more robust in certain cases. For example it has been reported, that configuring a receiver that can output 7.1 to output 5.1, will make CoreAudio report 8 channel descriptions, and the last 2 descriptions will be tagged kAudioChannelLabel_Unknown. Fixes #737
* ao_coreaudio: cosmetic change of loop ending conditionStefano Pigozzi2014-05-101-1/+1
|
* ao_coreaudio: use description-based channel layoutsStefano Pigozzi2014-05-101-74/+47
| | | | | | | | | | | | CoreAudio supports 3 kinds of layouts: bitmap based, tag based, and speaker description based (using either channel labels or positional data). Previously we tried to convert everything to bitmap based channel layouts, but it turns out description based ones are the most generic and there are built-in CoreAudio APIs to perform the conversion in this direction. Moreover description based layouts support waveext extensions (like SDL and SDR), and are easier to map to mp_chmaps.
* ao_coreaudio: pass layout by reference to logging functionStefano Pigozzi2014-05-101-7/+7
| | | | | Apparently passing the struct by value somehow messed with the value of some fields.
* ao_coreaudio: log even more info in verbose modeStefano Pigozzi2014-04-241-5/+27
| | | | | This logs more info that can be used for debugging purposes, in particular it prints all the AudioChannelDescription in the descriptions array.
* ao_coreaudio: add verbose output of detected channel layoutsStefano Pigozzi2014-04-231-0/+5
| | | | This can be useful for debugging purposes.
* msg: rename mp_msg_log -> mp_msgwm42013-12-211-1/+1
| | | | Same for companion functions.
* ao_coreaudio: simplify ch label to speaker id conversionStefano Pigozzi2013-11-271-23/+37
| | | | | | | | Previous code was using the values of the AudioChannelLabel enum directly to create the channel bitmap. While this was quite smart it was pretty unreadable and fragile (what if Apple changes the values of those enums?). Change it to use a 'dumb' conversion table.
* ao_coreaudio: map channel labels needed for 8ch layoutsStefano Pigozzi2013-11-271-4/+30
| | | | | | The code stopped at kAudioChannelLabel_TopBackRight and missed mapping for 5 more channel labels. These are in a completely different order that the mpv ones so they must be mapped manually.
* ao_coreaudio: move to new log APIStefano Pigozzi2013-08-011-54/+53
|
* ao_coreaudio: remove useless definesStefano Pigozzi2013-08-011-3/+0
| | | | They are already defined in the header file
* ao_coreaudio: switch properties getters to tallocStefano Pigozzi2013-07-221-4/+4
|
* ao_coreaudio: reduce verbosity of the chmapping codeStefano Pigozzi2013-07-221-2/+2
|
* ao_coreaudio: refactor chmap detectionStefano Pigozzi2013-07-221-0/+81
| | | | | | b2f9e0610 introduced this functionality with code that was quite 'monolithic'. Split the functionality over several functions and ose the new macros to get array properties.
* ao_coreaudio: refactor properties codeStefano Pigozzi2013-07-221-30/+19
| | | | | | | | Introduce some macros to deal with properties. These allow to work around the limitation of CoreAudio's API being `void **` based. The macros allow to keep their client's code DRY, by not asking size and other details which can be derived by the macro itself. I have no idea why Apple didn't design their API like this in the first place.
* ao_coreaudio: move utils functions to snake_caseStefano Pigozzi2013-07-221-28/+23
|
* ao_coreaudio: split ao_coreaudio_common in two filesStefano Pigozzi2013-07-221-0/+358
* ao_coreaudio_utils: contains several utility function * ao_coreaudio_properties: contains functions to set and get audio object properties. Conflicts: audio/out/ao_coreaudio.c