mirror of
https://github.com/mpv-player/mpv.git
synced 2025-12-28 05:33:14 +00:00
ao_coreaudio: support non-interleaved output
This saves us the trouble of interleaving the audio data for no reason.
This commit is contained in:
@@ -77,11 +77,14 @@ static OSStatus render_cb_lpcm(void *ctx, AudioUnitRenderActionFlags *aflags,
|
||||
{
|
||||
struct ao *ao = ctx;
|
||||
struct priv *p = ao->priv;
|
||||
AudioBuffer buf = buffer_list->mBuffers[0];
|
||||
void *planes[MP_NUM_CHANNELS] = {0};
|
||||
|
||||
for (int n = 0; n < ao->num_planes; n++)
|
||||
planes[n] = buffer_list->mBuffers[n].mData;
|
||||
|
||||
int64_t end = mp_time_us();
|
||||
end += p->hw_latency_us + ca_get_latency(ts) + ca_frames_to_us(ao, frames);
|
||||
ao_read_data(ao, &buf.mData, frames, end);
|
||||
ao_read_data(ao, planes, frames, end);
|
||||
return noErr;
|
||||
}
|
||||
|
||||
@@ -163,8 +166,6 @@ static int init(struct ao *ao)
|
||||
if (!ca_init_chmap(ao, p->device))
|
||||
goto coreaudio_error;
|
||||
|
||||
ao->format = af_fmt_from_planar(ao->format);
|
||||
|
||||
AudioStreamBasicDescription asbd;
|
||||
ca_fill_asbd(ao, &asbd);
|
||||
|
||||
|
||||
@@ -175,6 +175,12 @@ static void ca_fill_asbd_raw(AudioStreamBasicDescription *asbd, int mp_format,
|
||||
asbd->mBitsPerChannel = af_fmt2bits(mp_format);
|
||||
asbd->mFormatFlags = kAudioFormatFlagIsPacked;
|
||||
|
||||
int channels_per_buffer = num_channels;
|
||||
if (AF_FORMAT_IS_PLANAR(mp_format)) {
|
||||
asbd->mFormatFlags |= kAudioFormatFlagIsNonInterleaved;
|
||||
channels_per_buffer = 1;
|
||||
}
|
||||
|
||||
if ((mp_format & AF_FORMAT_TYPE_MASK) == AF_FORMAT_F) {
|
||||
asbd->mFormatFlags |= kAudioFormatFlagIsFloat;
|
||||
} else if (!af_fmt_unsigned(mp_format)) {
|
||||
@@ -186,7 +192,7 @@ static void ca_fill_asbd_raw(AudioStreamBasicDescription *asbd, int mp_format,
|
||||
|
||||
asbd->mFramesPerPacket = 1;
|
||||
asbd->mBytesPerPacket = asbd->mBytesPerFrame =
|
||||
asbd->mFramesPerPacket * asbd->mChannelsPerFrame *
|
||||
asbd->mFramesPerPacket * channels_per_buffer *
|
||||
(asbd->mBitsPerChannel / 8);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user