本文整理汇总了C++中AudioObjectGetPropertyDataSize函数的典型用法代码示例。如果您正苦于以下问题:C++ AudioObjectGetPropertyDataSize函数的具体用法?C++ AudioObjectGetPropertyDataSize怎么用?C++ AudioObjectGetPropertyDataSize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了AudioObjectGetPropertyDataSize函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AudioObjectGetPropertyDataSize
Array AudioDriverCoreAudio::_get_device_list(bool capture) {
Array list;
list.push_back("Default");
AudioObjectPropertyAddress prop;
prop.mSelector = kAudioHardwarePropertyDevices;
prop.mScope = kAudioObjectPropertyScopeGlobal;
prop.mElement = kAudioObjectPropertyElementMaster;
UInt32 size = 0;
AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &prop, 0, NULL, &size);
AudioDeviceID *audioDevices = (AudioDeviceID *)malloc(size);
AudioObjectGetPropertyData(kAudioObjectSystemObject, &prop, 0, NULL, &size, audioDevices);
UInt32 deviceCount = size / sizeof(AudioDeviceID);
for (UInt32 i = 0; i < deviceCount; i++) {
prop.mScope = capture ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
prop.mSelector = kAudioDevicePropertyStreamConfiguration;
AudioObjectGetPropertyDataSize(audioDevices[i], &prop, 0, NULL, &size);
AudioBufferList *bufferList = (AudioBufferList *)malloc(size);
AudioObjectGetPropertyData(audioDevices[i], &prop, 0, NULL, &size, bufferList);
UInt32 channelCount = 0;
for (UInt32 j = 0; j < bufferList->mNumberBuffers; j++)
channelCount += bufferList->mBuffers[j].mNumberChannels;
free(bufferList);
if (channelCount >= 1) {
CFStringRef cfname;
size = sizeof(CFStringRef);
prop.mSelector = kAudioObjectPropertyName;
AudioObjectGetPropertyData(audioDevices[i], &prop, 0, NULL, &size, &cfname);
CFIndex length = CFStringGetLength(cfname);
CFIndex maxSize = CFStringGetMaximumSizeForEncoding(length, kCFStringEncodingUTF8) + 1;
char *buffer = (char *)malloc(maxSize);
if (CFStringGetCString(cfname, buffer, maxSize, kCFStringEncodingUTF8)) {
// Append the ID to the name in case we have devices with duplicate name
list.push_back(String(buffer) + " (" + itos(audioDevices[i]) + ")");
}
free(buffer);
}
}
free(audioDevices);
return list;
}
示例2: AudioObjectGetPropertyDataSize
bool CCoreAudioDevice::GetStreams(AudioStreamIdList* pList)
{
if (!pList || !m_DeviceId)
return false;
AudioObjectPropertyAddress propertyAddress;
propertyAddress.mScope = kAudioDevicePropertyScopeOutput;
propertyAddress.mElement = 0;
propertyAddress.mSelector = kAudioDevicePropertyStreams;
UInt32 propertySize = 0;
OSStatus ret = AudioObjectGetPropertyDataSize(m_DeviceId, &propertyAddress, 0, NULL, &propertySize);
if (ret != noErr)
return false;
UInt32 streamCount = propertySize / sizeof(AudioStreamID);
AudioStreamID* pStreamList = new AudioStreamID[streamCount];
ret = AudioObjectGetPropertyData(m_DeviceId, &propertyAddress, 0, NULL, &propertySize, pStreamList);
if (ret == noErr)
{
for (UInt32 stream = 0; stream < streamCount; stream++)
pList->push_back(pStreamList[stream]);
}
delete[] pStreamList;
return ret == noErr;
}
示例3: AudioObjectGetPropertyDataSize
int AudioDevice::CountChannels()
{
OSStatus err;
UInt32 propSize;
int result = 0;
AudioObjectPropertyScope theScope = mIsInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
AudioObjectPropertyAddress theAddress = { kAudioDevicePropertyStreamConfiguration,
theScope,
0 }; // channel
err = AudioObjectGetPropertyDataSize(mID, &theAddress, 0, NULL, &propSize);
if (err) return 0;
AudioBufferList *buflist = (AudioBufferList *)malloc(propSize);
err = AudioObjectGetPropertyData(mID, &theAddress, 0, NULL, &propSize, buflist);
if (!err) {
for (UInt32 i = 0; i < buflist->mNumberBuffers; ++i) {
result += buflist->mBuffers[i].mNumberChannels;
}
}
free(buflist);
return result;
}
示例4: GetAudioPropertyArray
static UInt32 GetAudioPropertyArray(AudioObjectID id,
AudioObjectPropertySelector selector,
AudioObjectPropertyScope scope,
void **outData)
{
OSStatus err;
AudioObjectPropertyAddress property_address;
UInt32 i_param_size;
property_address.mSelector = selector;
property_address.mScope = scope;
property_address.mElement = kAudioObjectPropertyElementMaster;
err = AudioObjectGetPropertyDataSize(id, &property_address, 0, NULL, &i_param_size);
if (err != noErr)
return 0;
*outData = malloc(i_param_size);
err = AudioObjectGetPropertyData(id, &property_address, 0, NULL, &i_param_size, *outData);
if (err != noErr) {
free(*outData);
return 0;
}
return i_param_size;
}
示例5: verify_noerr
void AudioDeviceList::BuildList()
{
mDevices.clear();
UInt32 propsize;
AudioObjectPropertyAddress aopa;
aopa.mSelector = kAudioHardwarePropertyDevices;
aopa.mScope = kAudioObjectPropertyScopeGlobal;
aopa.mElement = kAudioObjectPropertyElementMaster;
verify_noerr(AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &aopa, 0, NULL, &propsize));
int nDevices = propsize / sizeof(AudioDeviceID);
AudioDeviceID *devids = new AudioDeviceID[nDevices];
verify_noerr(AudioObjectGetPropertyData(kAudioObjectSystemObject, &aopa, 0, NULL, &propsize, devids));
for (int i = 0; i < nDevices; ++i) {
AudioDevice dev(devids[i], mInputs);
if (dev.CountChannels() > 0) {
Device d;
d.mID = devids[i];
dev.GetName(d.mName, sizeof(d.mName));
mDevices.push_back(d);
}
}
delete[] devids;
}
示例6: getNumChannels
static int getNumChannels (AudioDeviceID deviceID, bool input)
{
int total = 0;
UInt32 size;
AudioObjectPropertyAddress pa;
pa.mSelector = kAudioDevicePropertyStreamConfiguration;
pa.mScope = input ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
pa.mElement = kAudioObjectPropertyElementMaster;
if (AudioObjectGetPropertyDataSize (deviceID, &pa, 0, 0, &size) == noErr)
{
HeapBlock <AudioBufferList> bufList;
bufList.calloc (size, 1);
if (AudioObjectGetPropertyData (deviceID, &pa, 0, 0, &size, bufList) == noErr)
{
const int numStreams = bufList->mNumberBuffers;
for (int i = 0; i < numStreams; ++i)
{
const AudioBuffer& b = bufList->mBuffers[i];
total += b.mNumberChannels;
}
}
}
return total;
}
示例7: _audio_system_get_devices
static inline AudioDeviceID *
_audio_system_get_devices (gint * ndevices)
{
OSStatus status = noErr;
UInt32 propertySize = 0;
AudioDeviceID *devices = NULL;
AudioObjectPropertyAddress audioDevicesAddress = {
kAudioHardwarePropertyDevices,
kAudioObjectPropertyScopeGlobal,
kAudioObjectPropertyElementMaster
};
status = AudioObjectGetPropertyDataSize (kAudioObjectSystemObject,
&audioDevicesAddress, 0, NULL, &propertySize);
if (status != noErr) {
GST_WARNING ("failed getting number of devices: %d", (int) status);
return NULL;
}
*ndevices = propertySize / sizeof (AudioDeviceID);
devices = (AudioDeviceID *) g_malloc (propertySize);
if (devices) {
status = AudioObjectGetPropertyData (kAudioObjectSystemObject,
&audioDevicesAddress, 0, NULL, &propertySize, devices);
if (status != noErr) {
GST_WARNING ("failed getting the list of devices: %d", (int) status);
g_free (devices);
*ndevices = 0;
return NULL;
}
}
return devices;
}
示例8: fluid_core_audio_driver_settings
void
fluid_core_audio_driver_settings(fluid_settings_t* settings)
{
int i;
UInt32 size;
AudioObjectPropertyAddress pa;
pa.mSelector = kAudioHardwarePropertyDevices;
pa.mScope = kAudioObjectPropertyScopeWildcard;
pa.mElement = kAudioObjectPropertyElementMaster;
fluid_settings_register_str (settings, "audio.coreaudio.device", "default", 0, NULL, NULL);
fluid_settings_add_option (settings, "audio.coreaudio.device", "default");
if (OK (AudioObjectGetPropertyDataSize (kAudioObjectSystemObject, &pa, 0, 0, &size))) {
int num = size / (int) sizeof (AudioDeviceID);
AudioDeviceID devs [num];
if (OK (AudioObjectGetPropertyData (kAudioObjectSystemObject, &pa, 0, 0, &size, devs))) {
for (i = 0; i < num; ++i) {
char name [1024];
size = sizeof (name);
pa.mSelector = kAudioDevicePropertyDeviceName;
if (OK (AudioObjectGetPropertyData (devs[i], &pa, 0, 0, &size, name))) {
if ( get_num_outputs (devs[i]) > 0) {
fluid_settings_add_option (settings, "audio.coreaudio.device", name);
}
}
}
}
}
}
示例9: AudioObjectGetPropertyDataSize
UInt32 CCoreAudioDevice::GetTotalOutputChannels()
{
UInt32 channels = 0;
if (!m_DeviceId)
return channels;
AudioObjectPropertyAddress propertyAddress;
propertyAddress.mScope = kAudioDevicePropertyScopeOutput;
propertyAddress.mElement = 0;
propertyAddress.mSelector = kAudioDevicePropertyStreamConfiguration;
UInt32 size = 0;
OSStatus ret = AudioObjectGetPropertyDataSize(m_DeviceId, &propertyAddress, 0, NULL, &size);
if (ret != noErr)
return channels;
AudioBufferList* pList = (AudioBufferList*)malloc(size);
ret = AudioObjectGetPropertyData(m_DeviceId, &propertyAddress, 0, NULL, &size, pList);
if (ret == noErr)
{
for(UInt32 buffer = 0; buffer < pList->mNumberBuffers; ++buffer)
channels += pList->mBuffers[buffer].mNumberChannels;
}
else
{
CLog::Log(LOGERROR, "CCoreAudioDevice::GetTotalOutputChannels: "
"Unable to get total device output channels - id: 0x%04x. Error = %s",
(uint)m_DeviceId, GetError(ret).c_str());
}
free(pList);
return channels;
}
示例10: ca_query_layout
static AudioChannelLayout* ca_query_layout(struct ao *ao,
AudioDeviceID device,
void *talloc_ctx)
{
OSStatus err;
uint32_t psize;
AudioChannelLayout *r = NULL;
AudioObjectPropertyAddress p_addr = (AudioObjectPropertyAddress) {
.mSelector = kAudioDevicePropertyPreferredChannelLayout,
.mScope = kAudioDevicePropertyScopeOutput,
.mElement = kAudioObjectPropertyElementWildcard,
};
err = AudioObjectGetPropertyDataSize(device, &p_addr, 0, NULL, &psize);
CHECK_CA_ERROR("could not get device preferred layout (size)");
r = talloc_size(talloc_ctx, psize);
err = AudioObjectGetPropertyData(device, &p_addr, 0, NULL, &psize, r);
CHECK_CA_ERROR("could not get device preferred layout (get)");
coreaudio_error:
return r;
}
示例11: verify_noerr
void AudioDeviceList::BuildList()
{
mDeviceList.clear();
mDeviceDict.clear();
UInt32 propsize;
AudioObjectPropertyAddress theAddress = { kAudioHardwarePropertyDevices,
kAudioObjectPropertyScopeGlobal,
kAudioObjectPropertyElementMaster
};
verify_noerr(AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &theAddress, 0, NULL, &propsize));
int nDevices = propsize / sizeof(AudioDeviceID);
AudioDeviceID *devids = new AudioDeviceID[nDevices];
verify_noerr(AudioObjectGetPropertyData(kAudioObjectSystemObject, &theAddress, 0, NULL, &propsize, devids));
for (int i = 0; i < nDevices; ++i) {
AudioDevice dev(devids[i], true, mForInput);
if (dev.CountChannels() > 0) {
Device d;
d.mID = devids[i];
dev.GetName(d.mName, sizeof(d.mName));
mDeviceList.push_back(d);
QString name = QString::fromUtf8(d.mName);
if (!mDeviceDict.contains(name)) {
mDeviceDict[name] = d.mID;
}
}
}
delete[] devids;
}
示例12: AudioObjectGetPropertyDataSize
bool CCoreAudioStream::GetAvailablePhysicalFormats(AudioStreamID id, StreamFormatList* pList)
{
if (!pList || !id)
return false;
AudioObjectPropertyAddress propertyAddress;
propertyAddress.mScope = kAudioObjectPropertyScopeGlobal;
propertyAddress.mElement = kAudioObjectPropertyElementMaster;
propertyAddress.mSelector = kAudioStreamPropertyAvailablePhysicalFormats;
UInt32 propertySize = 0;
OSStatus ret = AudioObjectGetPropertyDataSize(id, &propertyAddress, 0, NULL, &propertySize);
if (ret)
return false;
UInt32 formatCount = propertySize / sizeof(AudioStreamRangedDescription);
AudioStreamRangedDescription *pFormatList = new AudioStreamRangedDescription[formatCount];
ret = AudioObjectGetPropertyData(id, &propertyAddress, 0, NULL, &propertySize, pFormatList);
if (!ret)
{
for (UInt32 format = 0; format < formatCount; format++)
pList->push_back(pFormatList[format]);
}
delete[] pFormatList;
return (ret == noErr);
}
示例13: AudioObjectGetPropertyDataSize
UInt32 CAHALAudioObject::GetPropertyDataSize(AudioObjectPropertyAddress& inAddress, UInt32 inQualifierDataSize, const void* inQualifierData) const
{
UInt32 theDataSize = 0;
OSStatus theError = AudioObjectGetPropertyDataSize(mObjectID, &inAddress, inQualifierDataSize, inQualifierData, &theDataSize);
ThrowIfError(theError, CAException(theError), "CAHALAudioObject::GetPropertyDataSize: got an error getting the property data size");
return theDataSize;
}
示例14: coreaudio_enum_devices
static void coreaudio_enum_devices(struct device_list *list, bool input)
{
AudioObjectPropertyAddress addr = {
kAudioHardwarePropertyDevices,
kAudioObjectPropertyScopeGlobal,
kAudioObjectPropertyElementMaster
};
UInt32 size = 0;
UInt32 count;
OSStatus stat;
AudioDeviceID *ids;
stat = AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &addr,
0, NULL, &size);
if (!enum_success(stat, "get kAudioObjectSystemObject data size"))
return;
ids = bmalloc(size);
count = size / sizeof(AudioDeviceID);
stat = AudioObjectGetPropertyData(kAudioObjectSystemObject, &addr,
0, NULL, &size, ids);
if (enum_success(stat, "get kAudioObjectSystemObject data"))
for (UInt32 i = 0; i < count; i++)
coreaudio_enum_add_device(list, ids[i], input);
bfree(ids);
}
示例15: scanForDevices
//==============================================================================
void scanForDevices()
{
hasScanned = true;
inputDeviceNames.clear();
outputDeviceNames.clear();
inputIds.clear();
outputIds.clear();
UInt32 size;
AudioObjectPropertyAddress pa;
pa.mSelector = kAudioHardwarePropertyDevices;
pa.mScope = kAudioObjectPropertyScopeWildcard;
pa.mElement = kAudioObjectPropertyElementMaster;
if (AudioObjectGetPropertyDataSize (kAudioObjectSystemObject, &pa, 0, 0, &size) == noErr)
{
HeapBlock <AudioDeviceID> devs;
devs.calloc (size, 1);
if (AudioObjectGetPropertyData (kAudioObjectSystemObject, &pa, 0, 0, &size, devs) == noErr)
{
const int num = size / (int) sizeof (AudioDeviceID);
for (int i = 0; i < num; ++i)
{
char name [1024];
size = sizeof (name);
pa.mSelector = kAudioDevicePropertyDeviceName;
if (AudioObjectGetPropertyData (devs[i], &pa, 0, 0, &size, name) == noErr)
{
const String nameString (String::fromUTF8 (name, (int) strlen (name)));
const int numIns = getNumChannels (devs[i], true);
const int numOuts = getNumChannels (devs[i], false);
if (numIns > 0)
{
inputDeviceNames.add (nameString);
inputIds.add (devs[i]);
}
if (numOuts > 0)
{
outputDeviceNames.add (nameString);
outputIds.add (devs[i]);
}
}
}
}
}
inputDeviceNames.appendNumbersToDuplicates (false, true);
outputDeviceNames.appendNumbersToDuplicates (false, true);
}