diff options
Diffstat (limited to 'audio/out')
-rw-r--r-- | audio/out/ao.c | 4 | ||||
-rw-r--r-- | audio/out/ao_alsa.c | 18 | ||||
-rw-r--r-- | audio/out/ao_coreaudio.c | 2 | ||||
-rw-r--r-- | audio/out/ao_coreaudio_exclusive.c | 2 | ||||
-rw-r--r-- | audio/out/ao_coreaudio_utils.c | 10 | ||||
-rw-r--r-- | audio/out/ao_dsound.c | 10 | ||||
-rw-r--r-- | audio/out/ao_lavc.c | 6 | ||||
-rw-r--r-- | audio/out/ao_oss.c | 10 | ||||
-rw-r--r-- | audio/out/ao_pcm.c | 6 | ||||
-rw-r--r-- | audio/out/ao_pulse.c | 2 | ||||
-rwxr-xr-x | audio/out/ao_wasapi_utils.c | 16 | ||||
-rw-r--r-- | audio/out/push.c | 2 |
12 files changed, 45 insertions, 43 deletions
diff --git a/audio/out/ao.c b/audio/out/ao.c index c1333ab584..abf50b6b81 100644 --- a/audio/out/ao.c +++ b/audio/out/ao.c @@ -196,9 +196,9 @@ static struct ao *ao_init(bool probing, struct mpv_global *global, goto fail; } - ao->sstride = af_fmt2bps(ao->format); + ao->sstride = af_fmt_to_bytes(ao->format); ao->num_planes = 1; - if (AF_FORMAT_IS_PLANAR(ao->format)) { + if (af_fmt_is_planar(ao->format)) { ao->num_planes = ao->channels.num; } else { ao->sstride *= ao->channels.num; diff --git a/audio/out/ao_alsa.c b/audio/out/ao_alsa.c index fddc637e53..d81df23f9d 100644 --- a/audio/out/ao_alsa.c +++ b/audio/out/ao_alsa.c @@ -101,7 +101,7 @@ static int control(struct ao *ao, enum aocontrol cmd, void *arg) long get_vol, set_vol; float f_multi; - if (AF_FORMAT_IS_SPECIAL(ao->format)) + if (!af_fmt_is_pcm(ao->format)) return CONTROL_FALSE; snd_mixer_selem_id_alloca(&sid); @@ -376,7 +376,7 @@ static int try_open_device(struct ao *ao, const char *device) struct priv *p = ao->priv; int err; - if (AF_FORMAT_IS_IEC61937(ao->format)) { + if (af_fmt_is_spdif(ao->format)) { void *tmp = talloc_new(NULL); char *params = talloc_asprintf(tmp, "AES0=%d,AES1=%d,AES2=0,AES3=%d", @@ -453,7 +453,7 @@ static int init_device(struct ao *ao, bool second_try) err = snd_pcm_hw_params_any(p->alsa, alsa_hwparams); CHECK_ALSA_ERROR("Unable to get initial parameters"); - if (AF_FORMAT_IS_IEC61937(ao->format)) { + if (af_fmt_is_spdif(ao->format)) { if (ao->format == AF_FORMAT_S_MP3) { p->alsa_fmt = SND_PCM_FORMAT_MPEG; } else { @@ -469,7 +469,7 @@ static int init_device(struct ao *ao, bool second_try) err = snd_pcm_hw_params_test_format(p->alsa, alsa_hwparams, p->alsa_fmt); if (err < 0) { - if (AF_FORMAT_IS_IEC61937(ao->format)) + if (af_fmt_is_spdif(ao->format)) CHECK_ALSA_ERROR("Unable to set IEC61937 format"); MP_INFO(ao, "Format %s is not supported by hardware, trying default.\n", af_fmt_to_str(ao->format)); @@ -480,11 +480,11 @@ static int init_device(struct ao *ao, bool second_try) err = snd_pcm_hw_params_set_format(p->alsa, alsa_hwparams, p->alsa_fmt); CHECK_ALSA_ERROR("Unable to set format"); - snd_pcm_access_t access = AF_FORMAT_IS_PLANAR(ao->format) + snd_pcm_access_t access = af_fmt_is_planar(ao->format) ? SND_PCM_ACCESS_RW_NONINTERLEAVED : SND_PCM_ACCESS_RW_INTERLEAVED; err = snd_pcm_hw_params_set_access(p->alsa, alsa_hwparams, access); - if (err < 0 && AF_FORMAT_IS_PLANAR(ao->format)) { + if (err < 0 && af_fmt_is_planar(ao->format)) { ao->format = af_fmt_from_planar(ao->format); access = SND_PCM_ACCESS_RW_INTERLEAVED; err = snd_pcm_hw_params_set_access(p->alsa, alsa_hwparams, access); @@ -492,7 +492,7 @@ static int init_device(struct ao *ao, bool second_try) CHECK_ALSA_ERROR("Unable to set access type"); struct mp_chmap dev_chmap = ao->channels; - if (AF_FORMAT_IS_IEC61937(ao->format) || p->cfg_ignore_chmap) { + if (af_fmt_is_spdif(ao->format) || p->cfg_ignore_chmap) { dev_chmap.num = 0; // disable chmap API } else if (dev_chmap.num == 1 && dev_chmap.speaker[0] == MP_SPEAKER_ID_FC) { // As yet another ALSA API inconsistency, mono is not reported correctly. @@ -597,7 +597,7 @@ static int init_device(struct ao *ao, bool second_try) if (p->cfg_ignore_chmap) { MP_VERBOSE(ao, "user set ignore-chmap; ignoring the channel map.\n"); - } else if (AF_FORMAT_IS_IEC61937(ao->format)) { + } else if (af_fmt_is_spdif(ao->format)) { MP_VERBOSE(ao, "using spdif passthrough; ignoring the channel map.\n"); } else if (mp_chmap_is_valid(&chmap)) { // Is it one that contains NA channels? @@ -849,7 +849,7 @@ static int play(struct ao *ao, void **data, int samples, int flags) return 0; do { - if (AF_FORMAT_IS_PLANAR(ao->format)) { + if (af_fmt_is_planar(ao->format)) { res = snd_pcm_writen(p->alsa, data, samples); } else { res = snd_pcm_writei(p->alsa, data[0], samples); diff --git a/audio/out/ao_coreaudio.c b/audio/out/ao_coreaudio.c index b424e66661..3585c1d9d3 100644 --- a/audio/out/ao_coreaudio.c +++ b/audio/out/ao_coreaudio.c @@ -151,7 +151,7 @@ static int init(struct ao *ao) { struct priv *p = ao->priv; - if (AF_FORMAT_IS_IEC61937(ao->format)) { + if (af_fmt_is_spdif(ao->format)) { MP_WARN(ao, "detected IEC61937, redirecting to coreaudio_exclusive\n"); ao->redirect = "coreaudio_exclusive"; return CONTROL_ERROR; diff --git a/audio/out/ao_coreaudio_exclusive.c b/audio/out/ao_coreaudio_exclusive.c index b16641483d..e62ccee2ba 100644 --- a/audio/out/ao_coreaudio_exclusive.c +++ b/audio/out/ao_coreaudio_exclusive.c @@ -169,7 +169,7 @@ static int init(struct ao *ao) ao->format = af_fmt_from_planar(ao->format); - if (!AF_FORMAT_IS_IEC61937(ao->format)) { + if (!af_fmt_is_spdif(ao->format)) { MP_ERR(ao, "Only compressed formats are supported.\n"); goto coreaudio_error_nounlock; } diff --git a/audio/out/ao_coreaudio_utils.c b/audio/out/ao_coreaudio_utils.c index 96382512e8..77e87b7c23 100644 --- a/audio/out/ao_coreaudio_utils.c +++ b/audio/out/ao_coreaudio_utils.c @@ -168,22 +168,22 @@ static void ca_fill_asbd_raw(AudioStreamBasicDescription *asbd, int mp_format, { asbd->mSampleRate = samplerate; // Set "AC3" for other spdif formats too - unknown if that works. - asbd->mFormatID = AF_FORMAT_IS_IEC61937(mp_format) ? + asbd->mFormatID = af_fmt_is_spdif(mp_format) ? kAudioFormat60958AC3 : kAudioFormatLinearPCM; asbd->mChannelsPerFrame = num_channels; - asbd->mBitsPerChannel = af_fmt2bits(mp_format); + asbd->mBitsPerChannel = af_fmt_to_bytes(mp_format) * 8; asbd->mFormatFlags = kAudioFormatFlagIsPacked; int channels_per_buffer = num_channels; - if (AF_FORMAT_IS_PLANAR(mp_format)) { + if (af_fmt_is_planar(mp_format)) { asbd->mFormatFlags |= kAudioFormatFlagIsNonInterleaved; channels_per_buffer = 1; } - if (AF_FORMAT_IS_FLOAT(mp_format)) { + if (af_fmt_is_float(mp_format)) { asbd->mFormatFlags |= kAudioFormatFlagIsFloat; - } else if (!af_fmt_unsigned(mp_format)) { + } else if (!af_fmt_is_unsigned(mp_format)) { asbd->mFormatFlags |= kAudioFormatFlagIsSignedInteger; } diff --git a/audio/out/ao_dsound.c b/audio/out/ao_dsound.c index 8b1e10a10b..c581bf512e 100644 --- a/audio/out/ao_dsound.c +++ b/audio/out/ao_dsound.c @@ -444,7 +444,7 @@ static int init(struct ao *ao) int format = af_fmt_from_planar(ao->format); int rate = ao->samplerate; - if (!AF_FORMAT_IS_IEC61937(format)) { + if (!af_fmt_is_spdif(format)) { struct mp_chmap_sel sel = {0}; mp_chmap_sel_add_waveext(&sel); if (!ao_chmap_sel_adjust(ao, &sel, &ao->channels)) @@ -456,7 +456,7 @@ static int init(struct ao *ao) case AF_FORMAT_U8: break; default: - if (AF_FORMAT_IS_IEC61937(format)) + if (af_fmt_is_spdif(format)) break; MP_VERBOSE(ao, "format %s not supported defaulting to Signed 16-bit Little-Endian\n", af_fmt_to_str(format)); @@ -465,7 +465,7 @@ static int init(struct ao *ao) //set our audio parameters ao->samplerate = rate; ao->format = format; - ao->bps = ao->channels.num * rate * af_fmt2bps(format); + ao->bps = ao->channels.num * rate * af_fmt_to_bytes(format); int buffersize = ao->bps * p->cfg_buffersize / 1000; MP_VERBOSE(ao, "Samplerate:%iHz Channels:%i Format:%s\n", rate, ao->channels.num, af_fmt_to_str(format)); @@ -478,7 +478,7 @@ static int init(struct ao *ao) ? sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX) : 0; wformat.Format.nChannels = ao->channels.num; wformat.Format.nSamplesPerSec = rate; - if (AF_FORMAT_IS_IEC61937(format)) { + if (af_fmt_is_spdif(format)) { // Whether it also works with e.g. DTS is unknown, but probably does. wformat.Format.wFormatTag = WAVE_FORMAT_DOLBY_AC3_SPDIF; wformat.Format.wBitsPerSample = 16; @@ -486,7 +486,7 @@ static int init(struct ao *ao) } else { wformat.Format.wFormatTag = (ao->channels.num > 2) ? WAVE_FORMAT_EXTENSIBLE : WAVE_FORMAT_PCM; - int bps = af_fmt2bps(format); + int bps = af_fmt_to_bytes(format); wformat.Format.wBitsPerSample = bps * 8; wformat.Format.nBlockAlign = wformat.Format.nChannels * bps; } diff --git a/audio/out/ao_lavc.c b/audio/out/ao_lavc.c index b322982566..0106a64475 100644 --- a/audio/out/ao_lavc.c +++ b/audio/out/ao_lavc.c @@ -136,7 +136,7 @@ static int init(struct ao *ao) select_format(ao, codec); - ac->sample_size = af_fmt2bps(ao->format); + ac->sample_size = af_fmt_to_bytes(ao->format); ac->stream->codec->sample_fmt = af_to_avformat(ao->format); ac->stream->codec->bits_per_raw_sample = ac->sample_size * 8; @@ -241,7 +241,7 @@ static int encode(struct ao *ao, double apts, void **data) frame->format = af_to_avformat(ao->format); frame->nb_samples = ac->aframesize; - size_t num_planes = AF_FORMAT_IS_PLANAR(ao->format) ? ao->channels.num : 1; + size_t num_planes = af_fmt_is_planar(ao->format) ? ao->channels.num : 1; assert(num_planes <= AV_NUM_DATA_POINTERS); for (int n = 0; n < num_planes; n++) frame->extended_data[n] = data[n]; @@ -350,7 +350,7 @@ static int play(struct ao *ao, void **data, int samples, int flags) double pts = ectx->last_audio_in_pts; pts += ectx->samples_since_last_pts / (double)ao->samplerate; - size_t num_planes = AF_FORMAT_IS_PLANAR(ao->format) ? ao->channels.num : 1; + size_t num_planes = af_fmt_is_planar(ao->format) ? ao->channels.num : 1; void *tempdata = NULL; void *padded[MP_NUM_CHANNELS]; diff --git a/audio/out/ao_oss.c b/audio/out/ao_oss.c index bcb21aeffd..32190877f6 100644 --- a/audio/out/ao_oss.c +++ b/audio/out/ao_oss.c @@ -184,7 +184,7 @@ static int control(struct ao *ao, enum aocontrol cmd, void *arg) return CONTROL_OK; #endif - if (AF_FORMAT_IS_SPECIAL(ao->format)) + if (!af_fmt_is_pcm(ao->format)) return CONTROL_TRUE; if ((fd = open(p->oss_mixer_device, O_RDONLY)) != -1) { @@ -247,7 +247,7 @@ static bool try_format(struct ao *ao, int *format) struct priv *p = ao->priv; int oss_format = format2oss(*format); - if (oss_format == -1 && AF_FORMAT_IS_IEC61937(*format)) + if (oss_format == -1 && af_fmt_is_spdif(*format)) oss_format = AFMT_AC3; if (oss_format == -1) { @@ -303,7 +303,7 @@ static int reopen_device(struct ao *ao, bool allow_format_changes) fcntl(p->audio_fd, F_SETFD, FD_CLOEXEC); #endif - if (AF_FORMAT_IS_IEC61937(format)) { + if (af_fmt_is_spdif(format)) { if (ioctl(p->audio_fd, SNDCTL_DSP_SPEED, &samplerate) == -1) goto fail; // Probably could be fixed by setting number of channels; needs testing. @@ -327,7 +327,7 @@ static int reopen_device(struct ao *ao, bool allow_format_changes) MP_VERBOSE(ao, "sample format: %s\n", af_fmt_to_str(format)); - if (!AF_FORMAT_IS_IEC61937(format)) { + if (!af_fmt_is_spdif(format)) { struct mp_chmap_sel sel = {0}; for (int n = 0; n < MP_NUM_CHANNELS + 1; n++) mp_chmap_sel_add_map(&sel, &oss_layouts[n]); @@ -392,7 +392,7 @@ static int reopen_device(struct ao *ao, bool allow_format_changes) } } - p->outburst -= p->outburst % (channels.num * af_fmt2bps(format)); // round down + p->outburst -= p->outburst % (channels.num * af_fmt_to_bytes(format)); // round down return 0; diff --git a/audio/out/ao_pcm.c b/audio/out/ao_pcm.c index 5b9d61b450..76f0315bef 100644 --- a/audio/out/ao_pcm.c +++ b/audio/out/ao_pcm.c @@ -73,7 +73,7 @@ static void fput32le(uint32_t val, FILE *fp) static void write_wave_header(struct ao *ao, FILE *fp, uint64_t data_length) { uint16_t fmt = ao->format == AF_FORMAT_FLOAT ? WAV_ID_FLOAT_PCM : WAV_ID_PCM; - int bits = af_fmt2bits(ao->format); + int bits = af_fmt_to_bytes(ao->format) * 8; // Master RIFF chunk fput32le(WAV_ID_RIFF, fp); @@ -135,7 +135,7 @@ static int init(struct ao *ao) case AF_FORMAT_FLOAT: break; default: - if (!AF_FORMAT_IS_IEC61937(ao->format)) + if (!af_fmt_is_spdif(ao->format)) ao->format = AF_FORMAT_S16; break; } @@ -146,7 +146,7 @@ static int init(struct ao *ao) if (!ao_chmap_sel_adjust(ao, &sel, &ao->channels)) return -1; - ao->bps = ao->channels.num * ao->samplerate * af_fmt2bps(ao->format); + ao->bps = ao->channels.num * ao->samplerate * af_fmt_to_bytes(ao->format); MP_INFO(ao, "File: %s (%s)\nPCM: Samplerate: %d Hz Channels: %d Format: %s\n", priv->outputfilename, diff --git a/audio/out/ao_pulse.c b/audio/out/ao_pulse.c index f797802797..78d8ac2561 100644 --- a/audio/out/ao_pulse.c +++ b/audio/out/ao_pulse.c @@ -210,7 +210,7 @@ static pa_encoding_t map_digital_format(int format) case AF_FORMAT_S_AAC: return PA_ENCODING_MPEG2_AAC_IEC61937; #endif default: - if (AF_FORMAT_IS_IEC61937(format)) + if (af_fmt_is_spdif(format)) return PA_ENCODING_ANY; return PA_ENCODING_PCM; } diff --git a/audio/out/ao_wasapi_utils.c b/audio/out/ao_wasapi_utils.c index b0b0c10575..d7dc3ad07f 100755 --- a/audio/out/ao_wasapi_utils.c +++ b/audio/out/ao_wasapi_utils.c @@ -85,13 +85,13 @@ const struct wasapi_fmt_mapping wasapi_fmt_table[] = { static const GUID *format_to_subtype(int format) { - if (AF_FORMAT_IS_SPECIAL(format)) { + if (af_fmt_is_spdif(format)) { for (int i = 0; wasapi_fmt_table[i].format; i++) { if (wasapi_fmt_table[i].format == format) return wasapi_fmt_table[i].subtype; } return &KSDATAFORMAT_SPECIFIER_NONE; - } else if (AF_FORMAT_IS_FLOAT(format)) { + } else if (af_fmt_is_float(format)) { return &KSDATAFORMAT_SUBTYPE_IEEE_FLOAT; } return &KSDATAFORMAT_SUBTYPE_PCM; @@ -229,7 +229,7 @@ static void set_waveformat(WAVEFORMATEXTENSIBLE *wformat, wformat->Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE; wformat->Format.nChannels = channels->num; wformat->Format.nSamplesPerSec = samplerate; - wformat->Format.wBitsPerSample = af_fmt2bits(format); + wformat->Format.wBitsPerSample = af_fmt_to_bytes(format) * 8; wformat->Format.cbSize = sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX); wformat->SubFormat = *format_to_subtype(format); @@ -306,9 +306,11 @@ static int format_from_waveformat(WAVEFORMATEX *wf) // Since mpv doesn't have the notion of "valid bits", we just specify a // format with the container size. The least significant, "invalid" // bits will be excess precision ignored by wasapi. - // The change_bits operations should be a no-op for properly + // The change_bytes operations should be a no-op for properly // configured "special" formats, otherwise it will return 0. - return af_fmt_change_bits(format, wf->wBitsPerSample); + if (wf->wBitsPerSample % 8) + return 0; + return af_fmt_change_bytes(format, wf->wBitsPerSample / 8) * 8; } static bool chmap_from_waveformat(struct mp_chmap *channels, const WAVEFORMATEX *wf) @@ -365,7 +367,7 @@ static bool set_ao_format(struct ao *ao, WAVEFORMATEX *wf, AUDCLNT_SHAREMODE sha } // Do not touch the ao for passthrough, just assume that we set WAVEFORMATEX correctly. - if (!AF_FORMAT_IS_SPECIAL(format)) { + if (af_fmt_is_pcm(format)) { struct mp_chmap channels; if (!chmap_from_waveformat(&channels, wf)) { MP_ERR(ao, "Unable to construct channel map from WAVEFORMAT %s\n", @@ -575,7 +577,7 @@ static bool find_formats(struct ao *ao) // might be passthrough). If that fails, do a pcm format // search. return find_formats_exclusive(ao, true); - } else if (AF_FORMAT_IS_SPECIAL(ao->format)) { + } else if (af_fmt_is_spdif(ao->format)) { // If a passthrough format is requested, but exclusive mode // was not explicitly set, try only the requested passthrough // format in exclusive mode. Fall back on shared mode if that diff --git a/audio/out/push.c b/audio/out/push.c index beafd36a13..301004bd99 100644 --- a/audio/out/push.c +++ b/audio/out/push.c @@ -438,7 +438,7 @@ const struct ao_driver ao_api_push = { int ao_play_silence(struct ao *ao, int samples) { assert(ao->api == &ao_api_push); - if (samples <= 0 || AF_FORMAT_IS_SPECIAL(ao->format) || !ao->driver->play) + if (samples <= 0 || !af_fmt_is_pcm(ao->format) || !ao->driver->play) return 0; char *p = talloc_size(NULL, samples * ao->sstride); af_fill_silence(p, samples * ao->sstride, ao->format); |