mirror of
https://github.com/mpv-player/mpv.git
synced 2026-10-28 14:29:25 +08:00
ao_coreaudio: refactor properties code
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.
This commit is contained in:
+26
-40
@@ -202,21 +202,17 @@ static void print_help(void)
|
|||||||
"Available output devices:\n");
|
"Available output devices:\n");
|
||||||
|
|
||||||
AudioDeviceID *devs;
|
AudioDeviceID *devs;
|
||||||
uint32_t devs_size =
|
size_t n_devs;
|
||||||
GetGlobalAudioPropertyArray(kAudioObjectSystemObject,
|
|
||||||
kAudioHardwarePropertyDevices,
|
|
||||||
(void **)&devs);
|
|
||||||
if (!devs_size) {
|
|
||||||
ca_msg(MSGL_FATAL, "Failed to get list of output devices.\n");
|
|
||||||
goto coreaudio_out;
|
|
||||||
}
|
|
||||||
|
|
||||||
int devs_n = devs_size / sizeof(AudioDeviceID);
|
OSStatus err =
|
||||||
|
CA_GET_ARY(kAudioObjectSystemObject, kAudioHardwarePropertyDevices,
|
||||||
|
&devs, &n_devs);
|
||||||
|
|
||||||
for (int i = 0; i < devs_n; i++) {
|
CHECK_CA_ERROR("Failed to get list of output devices.");
|
||||||
|
|
||||||
|
for (int i = 0; i < n_devs; i++) {
|
||||||
char *name;
|
char *name;
|
||||||
OSStatus err =
|
OSStatus err = CA_GET_STR(devs[i], kAudioObjectPropertyName, &name);
|
||||||
GetAudioPropertyString(devs[i], kAudioObjectPropertyName, &name);
|
|
||||||
|
|
||||||
if (err == noErr) {
|
if (err == noErr) {
|
||||||
help = talloc_asprintf_append(help,
|
help = talloc_asprintf_append(help,
|
||||||
@@ -229,7 +225,7 @@ static void print_help(void)
|
|||||||
|
|
||||||
free(devs);
|
free(devs);
|
||||||
|
|
||||||
coreaudio_out:
|
coreaudio_error:
|
||||||
ca_msg(MSGL_FATAL, "%s", help);
|
ca_msg(MSGL_FATAL, "%s", help);
|
||||||
talloc_free(help);
|
talloc_free(help);
|
||||||
}
|
}
|
||||||
@@ -290,10 +286,7 @@ static int init(struct ao *ao, char *params)
|
|||||||
}
|
}
|
||||||
|
|
||||||
char *device_name;
|
char *device_name;
|
||||||
err = GetAudioPropertyString(selected_device,
|
err = CA_GET_STR(selected_device, kAudioObjectPropertyName, &device_name);
|
||||||
kAudioObjectPropertyName,
|
|
||||||
&device_name);
|
|
||||||
|
|
||||||
CHECK_CA_ERROR("could not get selected audio device name");
|
CHECK_CA_ERROR("could not get selected audio device name");
|
||||||
|
|
||||||
ca_msg(MSGL_V,
|
ca_msg(MSGL_V,
|
||||||
@@ -548,11 +541,10 @@ static int init_digital(struct ao *ao, AudioStreamBasicDescription asbd)
|
|||||||
struct priv *p = ao->priv;
|
struct priv *p = ao->priv;
|
||||||
struct priv_d *d = p->digital;
|
struct priv_d *d = p->digital;
|
||||||
OSStatus err = noErr;
|
OSStatus err = noErr;
|
||||||
uint32_t size;
|
|
||||||
|
|
||||||
uint32_t is_alive = 1;
|
uint32_t is_alive = 1;
|
||||||
err = CA_GET(p->device, kAudioDevicePropertyDeviceIsAlive, &is_alive);
|
err = CA_GET(p->device, kAudioDevicePropertyDeviceIsAlive, &is_alive);
|
||||||
CHECK_CA_WARN( "could not check whether device is alive");
|
CHECK_CA_WARN("could not check whether device is alive");
|
||||||
|
|
||||||
if (!is_alive)
|
if (!is_alive)
|
||||||
ca_msg(MSGL_WARN, "device is not alive\n");
|
ca_msg(MSGL_WARN, "device is not alive\n");
|
||||||
@@ -565,44 +557,38 @@ static int init_digital(struct ao *ao, AudioStreamBasicDescription asbd)
|
|||||||
err = ca_disable_mixing(p->device, &d->changed_mixing);
|
err = ca_disable_mixing(p->device, &d->changed_mixing);
|
||||||
CHECK_CA_WARN("failed to disable mixing");
|
CHECK_CA_WARN("failed to disable mixing");
|
||||||
|
|
||||||
AudioStreamID *streams = NULL;
|
AudioStreamID *streams;
|
||||||
|
size_t n_streams;
|
||||||
|
|
||||||
/* Get a list of all the streams on this device. */
|
/* Get a list of all the streams on this device. */
|
||||||
size = GetAudioPropertyArray(p->device,
|
err = CA_GET_ARY_O(p->device, kAudioDevicePropertyStreams,
|
||||||
kAudioDevicePropertyStreams,
|
&streams, &n_streams);
|
||||||
kAudioDevicePropertyScopeOutput,
|
|
||||||
(void **)&streams);
|
|
||||||
|
|
||||||
if (!size) {
|
CHECK_CA_ERROR("could not get number of streams");
|
||||||
ca_msg(MSGL_WARN, "could not get number of streams\n");
|
|
||||||
goto coreaudio_error;
|
|
||||||
}
|
|
||||||
|
|
||||||
int streams_n = size / sizeof(AudioStreamID);
|
for (int i = 0; i < n_streams && d->stream_idx < 0; i++) {
|
||||||
|
|
||||||
for (int i = 0; i < streams_n && d->stream_idx < 0; i++) {
|
|
||||||
bool digital = ca_stream_supports_digital(streams[i]);
|
bool digital = ca_stream_supports_digital(streams[i]);
|
||||||
|
|
||||||
if (digital) {
|
if (digital) {
|
||||||
/* Find a stream with a cac3 stream. */
|
AudioStreamRangedDescription *formats;
|
||||||
AudioStreamRangedDescription *formats = NULL;
|
size_t n_formats;
|
||||||
size = GetGlobalAudioPropertyArray(streams[i],
|
|
||||||
kAudioStreamPropertyAvailablePhysicalFormats,
|
|
||||||
(void **)&formats);
|
|
||||||
|
|
||||||
if (!size) {
|
err = CA_GET_ARY(streams[i],
|
||||||
|
kAudioStreamPropertyAvailablePhysicalFormats,
|
||||||
|
&formats, &n_formats);
|
||||||
|
|
||||||
|
if (err != noErr) {
|
||||||
ca_msg(MSGL_WARN, "could not get number of stream formats\n");
|
ca_msg(MSGL_WARN, "could not get number of stream formats\n");
|
||||||
continue; // try next one
|
continue; // try next one
|
||||||
}
|
}
|
||||||
|
|
||||||
int formats_n = size / sizeof(AudioStreamRangedDescription);
|
|
||||||
/* If this stream supports a digital (cac3) format, then set it. */
|
|
||||||
int req_rate_format = -1;
|
int req_rate_format = -1;
|
||||||
int max_rate_format = -1;
|
int max_rate_format = -1;
|
||||||
|
|
||||||
d->stream = streams[i];
|
d->stream = streams[i];
|
||||||
d->stream_idx = i;
|
d->stream_idx = i;
|
||||||
|
|
||||||
for (int j = 0; j < formats_n; j++)
|
for (int j = 0; j < n_formats; j++)
|
||||||
if (ca_format_is_digital(formats[j].mFormat)) {
|
if (ca_format_is_digital(formats[j].mFormat)) {
|
||||||
// select the digital format that has exactly the same
|
// select the digital format that has exactly the same
|
||||||
// samplerate. If an exact match cannot be found, select
|
// samplerate. If an exact match cannot be found, select
|
||||||
|
|||||||
@@ -22,69 +22,65 @@
|
|||||||
#include "audio/out/ao_coreaudio_properties.h"
|
#include "audio/out/ao_coreaudio_properties.h"
|
||||||
#include "audio/out/ao_coreaudio_utils.h"
|
#include "audio/out/ao_coreaudio_utils.h"
|
||||||
|
|
||||||
OSStatus ca_get(AudioObjectID id, AudioObjectPropertySelector selector,
|
OSStatus ca_get(AudioObjectID id, ca_scope scope, ca_sel selector,
|
||||||
uint32_t size, void *data)
|
uint32_t size, void *data)
|
||||||
{
|
{
|
||||||
AudioObjectPropertyAddress p_addr = (AudioObjectPropertyAddress) {
|
AudioObjectPropertyAddress p_addr = (AudioObjectPropertyAddress) {
|
||||||
.mSelector = selector,
|
.mSelector = selector,
|
||||||
.mScope = kAudioObjectPropertyScopeGlobal,
|
.mScope = scope,
|
||||||
.mElement = kAudioObjectPropertyElementMaster,
|
.mElement = kAudioObjectPropertyElementMaster,
|
||||||
};
|
};
|
||||||
|
|
||||||
return AudioObjectGetPropertyData(id, &p_addr, 0, NULL, &size, data);
|
return AudioObjectGetPropertyData(id, &p_addr, 0, NULL, &size, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t GetAudioPropertyArray(AudioObjectID id,
|
OSStatus ca_set(AudioObjectID id, ca_scope scope, ca_sel selector,
|
||||||
AudioObjectPropertySelector selector,
|
uint32_t size, void *data)
|
||||||
AudioObjectPropertyScope scope, void **data)
|
{
|
||||||
|
AudioObjectPropertyAddress p_addr = (AudioObjectPropertyAddress) {
|
||||||
|
.mSelector = selector,
|
||||||
|
.mScope = scope,
|
||||||
|
.mElement = kAudioObjectPropertyElementMaster,
|
||||||
|
};
|
||||||
|
|
||||||
|
return AudioObjectSetPropertyData(id, &p_addr, 0, NULL, size, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
OSStatus ca_get_ary(AudioObjectID id, ca_scope scope, ca_sel selector,
|
||||||
|
uint32_t element_size, void **data, size_t *elements)
|
||||||
{
|
{
|
||||||
OSStatus err;
|
OSStatus err;
|
||||||
AudioObjectPropertyAddress p_addr;
|
uint32_t p_size;
|
||||||
UInt32 p_size;
|
|
||||||
|
|
||||||
p_addr.mSelector = selector;
|
AudioObjectPropertyAddress p_addr = (AudioObjectPropertyAddress) {
|
||||||
p_addr.mScope = scope;
|
.mSelector = selector,
|
||||||
p_addr.mElement = kAudioObjectPropertyElementMaster;
|
.mScope = scope,
|
||||||
|
.mElement = kAudioObjectPropertyElementMaster,
|
||||||
|
};
|
||||||
|
|
||||||
err = AudioObjectGetPropertyDataSize(id, &p_addr, 0, NULL, &p_size);
|
err = AudioObjectGetPropertyDataSize(id, &p_addr, 0, NULL, &p_size);
|
||||||
CHECK_CA_ERROR("Can't fetch property size");
|
CHECK_CA_ERROR("can't fetch property size");
|
||||||
|
|
||||||
*data = malloc(p_size);
|
*data = malloc(p_size);
|
||||||
|
*elements = p_size / element_size;
|
||||||
|
|
||||||
err = AudioObjectGetPropertyData(id, &p_addr, 0, NULL, &p_size, *data);
|
err = ca_get(id, scope, selector, p_size, *data);
|
||||||
CHECK_CA_ERROR_L(coreaudio_error_free, "Can't fetch property data %s");
|
CHECK_CA_ERROR_L(coreaudio_error_free, "can't fetch property data");
|
||||||
|
|
||||||
return p_size;
|
|
||||||
|
|
||||||
|
return err;
|
||||||
coreaudio_error_free:
|
coreaudio_error_free:
|
||||||
free(*data);
|
free(*data);
|
||||||
coreaudio_error:
|
coreaudio_error:
|
||||||
return 0;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t GetGlobalAudioPropertyArray(AudioObjectID id,
|
OSStatus ca_get_str(AudioObjectID id, ca_scope scope, ca_sel selector,
|
||||||
AudioObjectPropertySelector selector,
|
char **data)
|
||||||
void **data)
|
|
||||||
{
|
{
|
||||||
return GetAudioPropertyArray(id, selector, kAudioObjectPropertyScopeGlobal,
|
|
||||||
data);
|
|
||||||
}
|
|
||||||
|
|
||||||
OSStatus GetAudioPropertyString(AudioObjectID id,
|
|
||||||
AudioObjectPropertySelector selector,
|
|
||||||
char **data)
|
|
||||||
{
|
|
||||||
OSStatus err;
|
|
||||||
AudioObjectPropertyAddress p_addr;
|
|
||||||
UInt32 p_size = sizeof(CFStringRef);
|
|
||||||
CFStringRef string;
|
CFStringRef string;
|
||||||
|
OSStatus err =
|
||||||
p_addr.mSelector = selector;
|
ca_get(id, scope, selector, sizeof(CFStringRef), (void **)&string);
|
||||||
p_addr.mScope = kAudioObjectPropertyScopeGlobal;
|
CHECK_CA_ERROR("Can't fetch string property");
|
||||||
p_addr.mElement = kAudioObjectPropertyElementMaster;
|
|
||||||
|
|
||||||
err = AudioObjectGetPropertyData(id, &p_addr, 0, NULL, &p_size, &string);
|
|
||||||
CHECK_CA_ERROR("Can't fetch array property");
|
|
||||||
|
|
||||||
CFIndex size =
|
CFIndex size =
|
||||||
CFStringGetMaximumSizeForEncoding(
|
CFStringGetMaximumSizeForEncoding(
|
||||||
@@ -97,29 +93,14 @@ coreaudio_error:
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
OSStatus SetAudioProperty(AudioObjectID id,
|
Boolean ca_settable(AudioObjectID id, ca_scope scope, ca_sel selector,
|
||||||
AudioObjectPropertySelector selector,
|
Boolean *data)
|
||||||
uint32_t size, void *data)
|
|
||||||
{
|
{
|
||||||
AudioObjectPropertyAddress p_addr;
|
AudioObjectPropertyAddress p_addr = (AudioObjectPropertyAddress) {
|
||||||
|
.mSelector = selector,
|
||||||
p_addr.mSelector = selector;
|
.mScope = kAudioObjectPropertyScopeGlobal,
|
||||||
p_addr.mScope = kAudioObjectPropertyScopeGlobal;
|
.mElement = kAudioObjectPropertyElementMaster,
|
||||||
p_addr.mElement = kAudioObjectPropertyElementMaster;
|
};
|
||||||
|
|
||||||
return AudioObjectSetPropertyData(id, &p_addr, 0, NULL,
|
|
||||||
size, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
Boolean IsAudioPropertySettable(AudioObjectID id,
|
|
||||||
AudioObjectPropertySelector selector,
|
|
||||||
Boolean *data)
|
|
||||||
{
|
|
||||||
AudioObjectPropertyAddress p_addr;
|
|
||||||
|
|
||||||
p_addr.mSelector = selector;
|
|
||||||
p_addr.mScope = kAudioObjectPropertyScopeGlobal;
|
|
||||||
p_addr.mElement = kAudioObjectPropertyElementMaster;
|
|
||||||
|
|
||||||
return AudioObjectIsPropertySettable(id, &p_addr, data);
|
return AudioObjectIsPropertySettable(id, &p_addr, data);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,29 +21,38 @@
|
|||||||
|
|
||||||
#include <AudioToolbox/AudioToolbox.h>
|
#include <AudioToolbox/AudioToolbox.h>
|
||||||
|
|
||||||
OSStatus ca_get(AudioObjectID id, AudioObjectPropertySelector selector,
|
// CoreAudio names are way too verbose
|
||||||
|
#define ca_sel AudioObjectPropertySelector
|
||||||
|
#define ca_scope AudioObjectPropertyScope
|
||||||
|
#define CA_GLOBAL kAudioObjectPropertyScopeGlobal
|
||||||
|
#define CA_OUTPUT kAudioObjectPropertyScopeOutput
|
||||||
|
|
||||||
|
OSStatus ca_get(AudioObjectID id, ca_scope scope, ca_sel selector,
|
||||||
uint32_t size, void *data);
|
uint32_t size, void *data);
|
||||||
|
|
||||||
#define CA_GET(id, selector, data) ca_get(id, selector, sizeof(*(data)), data)
|
OSStatus ca_set(AudioObjectID id, ca_scope scope, ca_sel selector,
|
||||||
|
uint32_t size, void *data);
|
||||||
|
|
||||||
uint32_t GetAudioPropertyArray(AudioObjectID id,
|
#define CA_GET(id, sel, data) ca_get(id, CA_GLOBAL, sel, sizeof(*(data)), data)
|
||||||
AudioObjectPropertySelector selector,
|
#define CA_SET(id, sel, data) ca_set(id, CA_GLOBAL, sel, sizeof(*(data)), data)
|
||||||
AudioObjectPropertyScope scope, void **data);
|
|
||||||
|
|
||||||
uint32_t GetGlobalAudioPropertyArray(AudioObjectID id,
|
OSStatus ca_get_ary(AudioObjectID id, ca_scope scope, ca_sel selector,
|
||||||
AudioObjectPropertySelector selector,
|
uint32_t element_size, void **data, size_t *elements);
|
||||||
void **data);
|
|
||||||
|
|
||||||
OSStatus GetAudioPropertyString(AudioObjectID id,
|
#define CA_GET_ARY(id, sel, data, elements) \
|
||||||
AudioObjectPropertySelector selector,
|
ca_get_ary(id, CA_GLOBAL, sel, sizeof(**(data)), (void **)data, elements)
|
||||||
char **data);
|
|
||||||
|
|
||||||
OSStatus SetAudioProperty(AudioObjectID id,
|
#define CA_GET_ARY_O(id, sel, data, elements) \
|
||||||
AudioObjectPropertySelector selector,
|
ca_get_ary(id, CA_OUTPUT, sel, sizeof(**(data)), (void **)data, elements)
|
||||||
uint32_t size, void *data);
|
|
||||||
|
|
||||||
Boolean IsAudioPropertySettable(AudioObjectID id,
|
OSStatus ca_get_str(AudioObjectID id, ca_scope scope,ca_sel selector,
|
||||||
AudioObjectPropertySelector selector,
|
char **data);
|
||||||
Boolean *outData);
|
|
||||||
|
#define CA_GET_STR(id, sel, data) ca_get_str(id, CA_GLOBAL, sel, data)
|
||||||
|
|
||||||
|
Boolean ca_settable(AudioObjectID id, ca_scope scope, ca_sel selector,
|
||||||
|
Boolean *data);
|
||||||
|
|
||||||
|
#define CA_SETTABLE(id, sel, data) ca_settable(id, CA_GLOBAL, sel, data)
|
||||||
|
|
||||||
#endif /* MPV_COREAUDIO_PROPERTIES_H */
|
#endif /* MPV_COREAUDIO_PROPERTIES_H */
|
||||||
|
|||||||
@@ -104,19 +104,14 @@ bool ca_format_is_digital(AudioStreamBasicDescription asbd)
|
|||||||
bool ca_stream_supports_digital(AudioStreamID stream)
|
bool ca_stream_supports_digital(AudioStreamID stream)
|
||||||
{
|
{
|
||||||
AudioStreamRangedDescription *formats = NULL;
|
AudioStreamRangedDescription *formats = NULL;
|
||||||
|
size_t n_formats;
|
||||||
|
|
||||||
/* Retrieve all the stream formats supported by each output stream. */
|
OSStatus err =
|
||||||
uint32_t size =
|
CA_GET_ARY(stream, kAudioStreamPropertyAvailablePhysicalFormats,
|
||||||
GetGlobalAudioPropertyArray(stream,
|
&formats, &n_formats);
|
||||||
kAudioStreamPropertyAvailablePhysicalFormats,
|
|
||||||
(void **)&formats);
|
|
||||||
|
|
||||||
if (!size) {
|
CHECK_CA_ERROR("Could not get number of stream formats.");
|
||||||
ca_msg(MSGL_WARN, "Could not get number of stream formats.\n");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const int n_formats = size / sizeof(AudioStreamRangedDescription);
|
|
||||||
for (int i = 0; i < n_formats; i++) {
|
for (int i = 0; i < n_formats; i++) {
|
||||||
AudioStreamBasicDescription asbd = formats[i].mFormat;
|
AudioStreamBasicDescription asbd = formats[i].mFormat;
|
||||||
ca_print_asbd("supported format:", &(asbd));
|
ca_print_asbd("supported format:", &(asbd));
|
||||||
@@ -127,25 +122,21 @@ bool ca_stream_supports_digital(AudioStreamID stream)
|
|||||||
}
|
}
|
||||||
|
|
||||||
free(formats);
|
free(formats);
|
||||||
|
coreaudio_error:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ca_device_supports_digital(AudioDeviceID device)
|
bool ca_device_supports_digital(AudioDeviceID device)
|
||||||
{
|
{
|
||||||
AudioStreamID *streams = NULL;
|
AudioStreamID *streams = NULL;
|
||||||
|
size_t n_streams;
|
||||||
|
|
||||||
/* Retrieve all the output streams. */
|
/* Retrieve all the output streams. */
|
||||||
uint32_t size = GetAudioPropertyArray(device,
|
OSStatus err =
|
||||||
kAudioDevicePropertyStreams,
|
CA_GET_ARY_O(device, kAudioDevicePropertyStreams, &streams, &n_streams);
|
||||||
kAudioDevicePropertyScopeOutput,
|
|
||||||
(void **)&streams);
|
|
||||||
|
|
||||||
if (!size) {
|
CHECK_CA_ERROR("could not get number of streams.");
|
||||||
ca_msg(MSGL_WARN, "could not get number of streams.\n");
|
|
||||||
return CONTROL_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
const int n_streams = size / sizeof(AudioStreamID);
|
|
||||||
for (int i = 0; i < n_streams; i++) {
|
for (int i = 0; i < n_streams; i++) {
|
||||||
if (ca_stream_supports_digital(streams[i])) {
|
if (ca_stream_supports_digital(streams[i])) {
|
||||||
free(streams);
|
free(streams);
|
||||||
@@ -154,6 +145,8 @@ bool ca_device_supports_digital(AudioDeviceID device)
|
|||||||
}
|
}
|
||||||
|
|
||||||
free(streams);
|
free(streams);
|
||||||
|
|
||||||
|
coreaudio_error:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,8 +187,7 @@ OSStatus ca_device_listener(AudioObjectID object, uint32_t n_addresses,
|
|||||||
|
|
||||||
OSStatus ca_lock_device(AudioDeviceID device, pid_t *pid) {
|
OSStatus ca_lock_device(AudioDeviceID device, pid_t *pid) {
|
||||||
*pid = getpid();
|
*pid = getpid();
|
||||||
OSStatus err = SetAudioProperty(device, kAudioDevicePropertyHogMode,
|
OSStatus err = CA_SET(device, kAudioDevicePropertyHogMode, pid);
|
||||||
sizeof(*pid), pid);
|
|
||||||
if (err != noErr)
|
if (err != noErr)
|
||||||
*pid = -1;
|
*pid = -1;
|
||||||
|
|
||||||
@@ -205,8 +197,7 @@ OSStatus ca_lock_device(AudioDeviceID device, pid_t *pid) {
|
|||||||
OSStatus ca_unlock_device(AudioDeviceID device, pid_t *pid) {
|
OSStatus ca_unlock_device(AudioDeviceID device, pid_t *pid) {
|
||||||
if (*pid == getpid()) {
|
if (*pid == getpid()) {
|
||||||
*pid = -1;
|
*pid = -1;
|
||||||
return SetAudioProperty(device, kAudioDevicePropertyHogMode,
|
return CA_SET(device, kAudioDevicePropertyHogMode, &pid);
|
||||||
sizeof(*pid), &pid);
|
|
||||||
}
|
}
|
||||||
return noErr;
|
return noErr;
|
||||||
}
|
}
|
||||||
@@ -224,8 +215,8 @@ static OSStatus ca_change_mixing(AudioDeviceID device, uint32_t val,
|
|||||||
if (AudioObjectHasProperty(device, &p_addr)) {
|
if (AudioObjectHasProperty(device, &p_addr)) {
|
||||||
OSStatus err;
|
OSStatus err;
|
||||||
Boolean writeable = 0;
|
Boolean writeable = 0;
|
||||||
err = IsAudioPropertySettable(device, kAudioDevicePropertySupportsMixing,
|
err = CA_SETTABLE(device, kAudioDevicePropertySupportsMixing,
|
||||||
&writeable);
|
&writeable);
|
||||||
|
|
||||||
if (!CHECK_CA_WARN("can't tell if mixing property is settable")) {
|
if (!CHECK_CA_WARN("can't tell if mixing property is settable")) {
|
||||||
return err;
|
return err;
|
||||||
@@ -234,8 +225,7 @@ static OSStatus ca_change_mixing(AudioDeviceID device, uint32_t val,
|
|||||||
if (!writeable)
|
if (!writeable)
|
||||||
return noErr;
|
return noErr;
|
||||||
|
|
||||||
err = SetAudioProperty(device, kAudioDevicePropertySupportsMixing,
|
err = CA_SET(device, kAudioDevicePropertySupportsMixing, &val);
|
||||||
sizeof(uint32_t), &val);
|
|
||||||
if (err != noErr)
|
if (err != noErr)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
@@ -311,8 +301,7 @@ bool ca_change_format(AudioStreamID stream,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Change the format. */
|
/* Change the format. */
|
||||||
err = SetAudioProperty(stream, kAudioStreamPropertyPhysicalFormat,
|
err = CA_SET(stream, kAudioStreamPropertyPhysicalFormat, &change_format);
|
||||||
sizeof(AudioStreamBasicDescription), &change_format);
|
|
||||||
if (!CHECK_CA_WARN("error changing physical format")) {
|
if (!CHECK_CA_WARN("error changing physical format")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user