mirror of
https://github.com/mpv-player/mpv
synced 2024-12-19 21:31:52 +00:00
ao_coreaudio: fill asbd with an helper function
This commit is contained in:
parent
fa85bfde69
commit
80ec0ba6d0
@ -127,26 +127,7 @@ static int init(struct ao *ao)
|
|||||||
|
|
||||||
// Build ASBD for the input format
|
// Build ASBD for the input format
|
||||||
AudioStreamBasicDescription asbd;
|
AudioStreamBasicDescription asbd;
|
||||||
asbd.mSampleRate = ao->samplerate;
|
ca_fill_asbd(ao, &asbd);
|
||||||
asbd.mFormatID = kAudioFormatLinearPCM;
|
|
||||||
asbd.mChannelsPerFrame = ao->channels.num;
|
|
||||||
asbd.mBitsPerChannel = af_fmt2bits(ao->format);
|
|
||||||
asbd.mFormatFlags = kAudioFormatFlagIsPacked;
|
|
||||||
|
|
||||||
if ((ao->format & AF_FORMAT_POINT_MASK) == AF_FORMAT_F)
|
|
||||||
asbd.mFormatFlags |= kAudioFormatFlagIsFloat;
|
|
||||||
|
|
||||||
if ((ao->format & AF_FORMAT_SIGN_MASK) == AF_FORMAT_SI)
|
|
||||||
asbd.mFormatFlags |= kAudioFormatFlagIsSignedInteger;
|
|
||||||
|
|
||||||
if ((ao->format & AF_FORMAT_END_MASK) == AF_FORMAT_BE)
|
|
||||||
asbd.mFormatFlags |= kAudioFormatFlagIsBigEndian;
|
|
||||||
|
|
||||||
asbd.mFramesPerPacket = 1;
|
|
||||||
asbd.mBytesPerPacket = asbd.mBytesPerFrame =
|
|
||||||
asbd.mFramesPerPacket * asbd.mChannelsPerFrame *
|
|
||||||
(asbd.mBitsPerChannel / 8);
|
|
||||||
|
|
||||||
return init_lpcm(ao, asbd);
|
return init_lpcm(ao, asbd);
|
||||||
|
|
||||||
coreaudio_error:
|
coreaudio_error:
|
||||||
|
@ -432,25 +432,7 @@ static int init(struct ao *ao)
|
|||||||
|
|
||||||
// Build ASBD for the input format
|
// Build ASBD for the input format
|
||||||
AudioStreamBasicDescription asbd;
|
AudioStreamBasicDescription asbd;
|
||||||
asbd.mSampleRate = ao->samplerate;
|
ca_fill_asbd(ao, &asbd);
|
||||||
asbd.mFormatID = kAudioFormat60958AC3;
|
|
||||||
asbd.mChannelsPerFrame = ao->channels.num;
|
|
||||||
asbd.mBitsPerChannel = af_fmt2bits(ao->format);
|
|
||||||
asbd.mFormatFlags = kAudioFormatFlagIsPacked;
|
|
||||||
|
|
||||||
if ((ao->format & AF_FORMAT_POINT_MASK) == AF_FORMAT_F)
|
|
||||||
asbd.mFormatFlags |= kAudioFormatFlagIsFloat;
|
|
||||||
|
|
||||||
if ((ao->format & AF_FORMAT_SIGN_MASK) == AF_FORMAT_SI)
|
|
||||||
asbd.mFormatFlags |= kAudioFormatFlagIsSignedInteger;
|
|
||||||
|
|
||||||
if ((ao->format & AF_FORMAT_END_MASK) == AF_FORMAT_BE)
|
|
||||||
asbd.mFormatFlags |= kAudioFormatFlagIsBigEndian;
|
|
||||||
|
|
||||||
asbd.mFramesPerPacket = 1;
|
|
||||||
asbd.mBytesPerPacket = asbd.mBytesPerFrame =
|
|
||||||
asbd.mFramesPerPacket * asbd.mChannelsPerFrame *
|
|
||||||
(asbd.mBitsPerChannel / 8);
|
|
||||||
|
|
||||||
return init_digital(ao, asbd);
|
return init_digital(ao, asbd);
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include "audio/out/ao_coreaudio_utils.h"
|
#include "audio/out/ao_coreaudio_utils.h"
|
||||||
#include "audio/out/ao_coreaudio_properties.h"
|
#include "audio/out/ao_coreaudio_properties.h"
|
||||||
#include "osdep/timer.h"
|
#include "osdep/timer.h"
|
||||||
|
#include "audio/format.h"
|
||||||
|
|
||||||
void ca_print_device_list(struct ao *ao)
|
void ca_print_device_list(struct ao *ao)
|
||||||
{
|
{
|
||||||
@ -125,6 +126,31 @@ bool check_ca_st(struct ao *ao, int level, OSStatus code, const char *message)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ca_fill_asbd(struct ao *ao, AudioStreamBasicDescription *asbd)
|
||||||
|
{
|
||||||
|
asbd->mSampleRate = ao->samplerate;
|
||||||
|
asbd->mFormatID = AF_FORMAT_IS_AC3(ao->format) ?
|
||||||
|
kAudioFormat60958AC3 :
|
||||||
|
kAudioFormatLinearPCM;
|
||||||
|
asbd->mChannelsPerFrame = ao->channels.num;
|
||||||
|
asbd->mBitsPerChannel = af_fmt2bits(ao->format);
|
||||||
|
asbd->mFormatFlags = kAudioFormatFlagIsPacked;
|
||||||
|
|
||||||
|
if ((ao->format & AF_FORMAT_POINT_MASK) == AF_FORMAT_F)
|
||||||
|
asbd->mFormatFlags |= kAudioFormatFlagIsFloat;
|
||||||
|
|
||||||
|
if ((ao->format & AF_FORMAT_SIGN_MASK) == AF_FORMAT_SI)
|
||||||
|
asbd->mFormatFlags |= kAudioFormatFlagIsSignedInteger;
|
||||||
|
|
||||||
|
if ((ao->format & AF_FORMAT_END_MASK) == AF_FORMAT_BE)
|
||||||
|
asbd->mFormatFlags |= kAudioFormatFlagIsBigEndian;
|
||||||
|
|
||||||
|
asbd->mFramesPerPacket = 1;
|
||||||
|
asbd->mBytesPerPacket = asbd->mBytesPerFrame =
|
||||||
|
asbd->mFramesPerPacket * asbd->mChannelsPerFrame *
|
||||||
|
(asbd->mBitsPerChannel / 8);
|
||||||
|
}
|
||||||
|
|
||||||
void ca_print_asbd(struct ao *ao, const char *description,
|
void ca_print_asbd(struct ao *ao, const char *description,
|
||||||
const AudioStreamBasicDescription *asbd)
|
const AudioStreamBasicDescription *asbd)
|
||||||
{
|
{
|
||||||
|
@ -49,6 +49,7 @@ bool check_ca_st(struct ao *ao, int level, OSStatus code, const char *message);
|
|||||||
void ca_print_device_list(struct ao *ao);
|
void ca_print_device_list(struct ao *ao);
|
||||||
OSStatus ca_select_device(struct ao *ao, int selection, AudioDeviceID *device);
|
OSStatus ca_select_device(struct ao *ao, int selection, AudioDeviceID *device);
|
||||||
|
|
||||||
|
void ca_fill_asbd(struct ao *ao, AudioStreamBasicDescription *asbd);
|
||||||
void ca_print_asbd(struct ao *ao, const char *description,
|
void ca_print_asbd(struct ao *ao, const char *description,
|
||||||
const AudioStreamBasicDescription *asbd);
|
const AudioStreamBasicDescription *asbd);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user