本文整理汇总了C++中AudioHardwareGetProperty函数的典型用法代码示例。如果您正苦于以下问题:C++ AudioHardwareGetProperty函数的具体用法?C++ AudioHardwareGetProperty怎么用?C++ AudioHardwareGetProperty使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了AudioHardwareGetProperty函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: get_default_device
static OSStatus get_default_device(AudioDeviceID * id)
{
OSStatus res;
UInt32 theSize = sizeof(UInt32);
AudioDeviceID inDefault;
AudioDeviceID outDefault;
if ((res = AudioHardwareGetProperty(kAudioHardwarePropertyDefaultInputDevice,
&theSize, &inDefault)) != noErr)
return res;
if ((res = AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOutputDevice,
&theSize, &outDefault)) != noErr)
return res;
JCALog("get_default_device: input %ld output %ld\n", inDefault, outDefault);
// Get the device only if default input and ouput are the same
if (inDefault == outDefault) {
*id = inDefault;
return noErr;
} else {
jack_error("Default input and output devices are not the same !!");
return kAudioHardwareBadDeviceError;
}
}
示例2: sizeof
void SHP_PlugIn::Teardown()
{
// first figure out if this is being done as part of the process being torn down
UInt32 isInitingOrExiting = 0;
UInt32 theSize = sizeof(UInt32);
AudioHardwareGetProperty(kAudioHardwarePropertyIsInitingOrExiting, &theSize, &isInitingOrExiting);
// next figure out if this is the master process
UInt32 isMaster = 0;
theSize = sizeof(UInt32);
AudioHardwareGetProperty(kAudioHardwarePropertyProcessIsMaster, &theSize, &isMaster);
// do the full teardown if this is outside of the process being torn down or this is the master process
if((isInitingOrExiting == 0) || (isMaster != 0))
{
// stop all IO on the device
mDevice->Do_StopAllIOProcs();
// send the necessary IsAlive notifications
CAPropertyAddress theIsAliveAddress(kAudioDevicePropertyDeviceIsAlive);
mDevice->PropertiesChanged(1, &theIsAliveAddress);
// save it's settings if necessary
if(isMaster != 0)
{
HP_DeviceSettings::SaveToPrefs(*mDevice, HP_DeviceSettings::sStandardControlsToSave, HP_DeviceSettings::kStandardNumberControlsToSave);
}
// tell the HAL that the device has gone away
AudioObjectID theObjectID = mDevice->GetObjectID();
#if (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_4)
OSStatus theError = AudioHardwareDevicesDied(GetInterface(), 1, &theObjectID);
#else
OSStatus theError = AudioObjectsPublishedAndDied(GetInterface(), kAudioObjectSystemObject, 0, NULL, 1, &theObjectID);
#endif
AssertNoError(theError, "SHP_PlugIn::Teardown: got an error telling the HAL a device died");
// remove the object state mutex
HP_Object::SetObjectStateMutexForID(theObjectID, NULL);
// toss it
mDevice->Teardown();
delete mDevice;
mDevice = NULL;
// teardown the super class
HP_HardwarePlugIn::Teardown();
}
else
{
// otherwise, only stop the IOProcs
mDevice->Do_StopAllIOProcs();
// finalize (rather than tear down) the devices
mDevice->Finalize();
// and leave the rest to die with the process
}
}
示例3: InitializeDeviceInfos
static PaError InitializeDeviceInfos( PaMacCoreHostApiRepresentation *macCoreHostApi, PaHostApiIndex hostApiIndex )
{
PaError result = paNoError;
PaUtilHostApiRepresentation *hostApi;
PaMacCoreDeviceInfo *deviceInfoArray;
// initialise device counts and default devices under the assumption that there are no devices. These values are incremented below if and when devices are successfully initialized.
hostApi = &macCoreHostApi->inheritedHostApiRep;
hostApi->info.deviceCount = 0;
hostApi->info.defaultInputDevice = paNoDevice;
hostApi->info.defaultOutputDevice = paNoDevice;
UInt32 propsize;
AudioHardwareGetPropertyInfo(kAudioHardwarePropertyDevices, &propsize, NULL);
int numDevices = propsize / sizeof(AudioDeviceID);
hostApi->info.deviceCount = numDevices;
if (numDevices > 0) {
hostApi->deviceInfos = (PaDeviceInfo**)PaUtil_GroupAllocateMemory(
macCoreHostApi->allocations, sizeof(PaDeviceInfo*) * numDevices );
if( !hostApi->deviceInfos )
{
return paInsufficientMemory;
}
// allocate all device info structs in a contiguous block
deviceInfoArray = (PaMacCoreDeviceInfo*)PaUtil_GroupAllocateMemory(
macCoreHostApi->allocations, sizeof(PaMacCoreDeviceInfo) * numDevices );
if( !deviceInfoArray )
{
return paInsufficientMemory;
}
macCoreHostApi->macCoreDeviceIds = PaUtil_GroupAllocateMemory(macCoreHostApi->allocations, propsize);
AudioHardwareGetProperty(kAudioHardwarePropertyDevices, &propsize, macCoreHostApi->macCoreDeviceIds);
AudioDeviceID defaultInputDevice, defaultOutputDevice;
propsize = sizeof(AudioDeviceID);
AudioHardwareGetProperty(kAudioHardwarePropertyDefaultInputDevice, &propsize, &defaultInputDevice);
AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOutputDevice, &propsize, &defaultOutputDevice);
UInt32 i;
for (i = 0; i < numDevices; ++i) {
if (macCoreHostApi->macCoreDeviceIds[i] == defaultInputDevice) {
hostApi->info.defaultInputDevice = i;
}
if (macCoreHostApi->macCoreDeviceIds[i] == defaultOutputDevice) {
hostApi->info.defaultOutputDevice = i;
}
InitializeDeviceInfo(&deviceInfoArray[i], macCoreHostApi->macCoreDeviceIds[i], hostApiIndex);
hostApi->deviceInfos[i] = &(deviceInfoArray[i].inheritedDeviceInfo);
}
}
return result;
}
示例4: scanDevices
static bool scanDevices(unsigned index)
{
OSStatus err = noErr;
UInt32 size;
AudioDeviceID *id;
unsigned i;
if(!devlist) {
if(AudioHardwareGetPropertyInfo(kAudioHardwarePropertyDevices, &size, NULL) != noErr)
return false;
devcount = size / sizeof(AudioDeviceID);
devlist = (AudioDeviceID *)malloc(size);
if(AudioHardwareGetProperty(kAudioHardwarePropertyDevices, &size, (void *) devlist) != noErr) {
free(devlist);
return false;
}
size = sizeof(AudioDeviceID);
if(AudioHardwareGetProperty(kAudioHardwarePropertyDefaultInputDevice, &size, &id) == noErr) {
for(i = 0; i < devcount; ++i)
{
if(!memcmp(&devlist[i], &id, sizeof(AudioDeviceID))) {
devinput = &devlist[i];
break;
}
}
}
size = sizeof(AudioDeviceID);
if(AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOutputDevice, &size, &id) == noErr) {
for(i = 0; i < devcount; ++i)
{
if(!memcmp(&devlist[i], &id, sizeof(AudioDeviceID))) {
devoutput = &devlist[i];
break;
}
}
}
}
if(!devcount)
return false;
if(index > devcount)
return false;
return true;
}
示例5: GetDefaultOutputDevice
AudioDeviceID CCoreAudioHardware::FindAudioDevice(const std::string &searchName)
{
AudioDeviceID deviceId = 0;
if (!searchName.length())
return deviceId;
std::string searchNameLowerCase = searchName;
std::transform(searchNameLowerCase.begin(), searchNameLowerCase.end(), searchNameLowerCase.begin(), ::tolower );
if (searchNameLowerCase.compare("default") == 0)
{
AudioDeviceID defaultDevice = GetDefaultOutputDevice();
CLog::Log(LOGDEBUG, "CCoreAudioHardware::FindAudioDevice: "
"Returning default device [0x%04x].", (uint)defaultDevice);
return defaultDevice;
}
CLog::Log(LOGDEBUG, "CCoreAudioHardware::FindAudioDevice: "
"Searching for device - %s.", searchName.c_str());
// Obtain a list of all available audio devices
UInt32 size = 0;
AudioHardwareGetPropertyInfo(kAudioHardwarePropertyDevices, &size, NULL);
size_t deviceCount = size / sizeof(AudioDeviceID);
AudioDeviceID* pDevices = new AudioDeviceID[deviceCount];
OSStatus ret = AudioHardwareGetProperty(kAudioHardwarePropertyDevices, &size, pDevices);
if (ret)
{
CLog::Log(LOGERROR, "CCoreAudioHardware::FindAudioDevice: "
"Unable to retrieve the list of available devices. Error = %s", GetError(ret).c_str());
delete[] pDevices;
return 0;
}
// Attempt to locate the requested device
std::string deviceName;
for (size_t dev = 0; dev < deviceCount; dev++)
{
CCoreAudioDevice device;
device.Open((pDevices[dev]));
deviceName = device.GetName();
UInt32 totalChannels = device.GetTotalOutputChannels();
CLog::Log(LOGDEBUG, "CCoreAudioHardware::FindAudioDevice: "
#if __LP64__
"Device[0x%04x]"
#else
"Device[0x%04lx]"
#endif
" - Name: '%s', Total Ouput Channels: %u. ",
pDevices[dev], deviceName.c_str(), (uint)totalChannels);
std::transform( deviceName.begin(), deviceName.end(), deviceName.begin(), ::tolower );
if (searchNameLowerCase.compare(deviceName) == 0)
deviceId = pDevices[dev];
if (deviceId)
break;
}
delete[] pDevices;
return deviceId;
}
示例6: showAllDevices
void showAllDevices(ASDeviceType typeRequested) {
UInt32 propertySize;
AudioDeviceID dev_array[64];
int numberOfDevices = 0;
ASDeviceType device_type;
char deviceName[256];
AudioHardwareGetPropertyInfo(kAudioHardwarePropertyDevices, &propertySize, NULL);
AudioHardwareGetProperty(kAudioHardwarePropertyDevices, &propertySize, dev_array);
numberOfDevices = (propertySize / sizeof(AudioDeviceID));
for(int i = 0; i < numberOfDevices; ++i) {
device_type = getDeviceType(dev_array[i]);
switch(typeRequested) {
case kAudioTypeInput:
case kAudioTypeOutput:
if (device_type != typeRequested) continue;
break;
case kAudioTypeSystemOutput:
if (device_type != kAudioTypeOutput) continue;
break;
}
getDeviceName(dev_array[i], deviceName);
printf("%s (%s)\n",deviceName,deviceTypeName(device_type));
}
}
示例7: getRequestedDeviceID
AudioDeviceID getRequestedDeviceID(char * requestedDeviceName, ASDeviceType typeRequested) {
UInt32 propertySize;
AudioDeviceID dev_array[64];
int numberOfDevices = 0;
char deviceName[256];
AudioHardwareGetPropertyInfo(kAudioHardwarePropertyDevices, &propertySize, NULL);
// printf("propertySize=%d\n",propertySize);
AudioHardwareGetProperty(kAudioHardwarePropertyDevices, &propertySize, dev_array);
numberOfDevices = (propertySize / sizeof(AudioDeviceID));
// printf("numberOfDevices=%d\n",numberOfDevices);
for(int i = 0; i < numberOfDevices; ++i) {
switch(typeRequested) {
case kAudioTypeInput:
case kAudioTypeOutput:
if (getDeviceType(dev_array[i]) != typeRequested) continue;
break;
case kAudioTypeSystemOutput:
if (getDeviceType(dev_array[i]) != kAudioTypeOutput) continue;
break;
}
getDeviceName(dev_array[i], deviceName);
// printf("For device %d, id = %d and name is %s\n",i,dev_array[i],deviceName);
if (strcmp(requestedDeviceName, deviceName) == 0) {
return dev_array[i];
}
}
return kAudioDeviceUnknown;
}
示例8: audio_cap_ca_help
static void audio_cap_ca_help(const char *driver_name)
{
UNUSED(driver_name);
OSErr ret;
AudioDeviceID *dev_ids;
int dev_items;
int i;
UInt32 size;
printf("\tcoreaudio : default CoreAudio input\n");
ret = AudioHardwareGetPropertyInfo(kAudioHardwarePropertyDevices, &size, NULL);
if(ret) goto error;
dev_ids = malloc(size);
dev_items = size / sizeof(AudioDeviceID);
ret = AudioHardwareGetProperty(kAudioHardwarePropertyDevices, &size, dev_ids);
if(ret) goto error;
for(i = 0; i < dev_items; ++i)
{
char name[128];
size = sizeof(name);
ret = AudioDeviceGetProperty(dev_ids[i], 0, 0, kAudioDevicePropertyDeviceName, &size, name);
fprintf(stderr,"\tcoreaudio:%d : %s\n", (int) dev_ids[i], name);
}
free(dev_ids);
return;
error:
fprintf(stderr, "[CoreAudio] error obtaining device list.\n");
}
示例9: AUDIO_Init_Driver
// ------------------------------------------------------
// Name: AUDIO_Init_Driver()
// Desc: Init the audio driver
int AUDIO_Init_Driver(void (*Mixer)(Uint8 *, Uint32))
{
AUDIO_Mixer = Mixer;
AUDIO_Device = kAudioDeviceUnknown;
Amount = sizeof(AudioDeviceID);
if(AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOutputDevice,
&Amount,
(void *) &AUDIO_Device) == noErr)
{
if(AudioDeviceAddIOProc(AUDIO_Device,
AUDIO_Callback,
NULL) == noErr)
{
return(AUDIO_Create_Sound_Buffer(AUDIO_Milliseconds));
}
#if !defined(__STAND_ALONE__) && !defined(__WINAMP__)
else
{
Message_Error("Error while calling AudioDeviceAddIOProc()");
}
#endif
}
#if !defined(__STAND_ALONE__) && !defined(__WINAMP__)
else
{
Message_Error("Error while calling AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOutputDevice)");
}
#endif
return(FALSE);
}
示例10: gst_osx_audio_src_select_device
static void
gst_osx_audio_src_select_device (GstOsxAudioSrc * osxsrc)
{
OSStatus status;
UInt32 propertySize;
if (osxsrc->device_id == kAudioDeviceUnknown) {
/* If no specific device has been selected by the user, then pick the
* default device */
GST_DEBUG_OBJECT (osxsrc, "Selecting device for OSXAudioSrc");
propertySize = sizeof (osxsrc->device_id);
status = AudioHardwareGetProperty (kAudioHardwarePropertyDefaultInputDevice,
&propertySize, &osxsrc->device_id);
if (status) {
GST_WARNING_OBJECT (osxsrc,
"AudioHardwareGetProperty returned %d", (int) status);
} else {
GST_DEBUG_OBJECT (osxsrc, "AudioHardwareGetProperty returned 0");
}
if (osxsrc->device_id == kAudioDeviceUnknown) {
GST_WARNING_OBJECT (osxsrc,
"AudioHardwareGetProperty: device_id is kAudioDeviceUnknown");
}
GST_DEBUG_OBJECT (osxsrc, "AudioHardwareGetProperty: device_id is %lu",
(long) osxsrc->device_id);
}
}
示例11: AudioHardwareGetPropertyInfo
const std::vector<InputDeviceRef>& InputImplAudioUnit::getDevices( bool forceRefresh )
{
if( forceRefresh || ! sDevicesEnumerated ) {
sDevices.clear();
UInt32 propSize;
AudioHardwareGetPropertyInfo( kAudioHardwarePropertyDevices, &propSize, NULL );
uint32_t deviceCount = ( propSize / sizeof(AudioDeviceID) );
AudioDeviceID deviceIds[deviceCount];
AudioHardwareGetProperty( kAudioHardwarePropertyDevices, &propSize, &deviceIds );
for( uint32_t i = 0; i < deviceCount; i++ ) {
try {
InputDeviceRef aDevice = InputDeviceRef( new Device( deviceIds[i] ) );
sDevices.push_back( aDevice );
} catch( InvalidDeviceInputExc ) {
continue;
}
}
sDevicesEnumerated = true;
}
return sDevices;
}
示例12: sizeof
OSStatus CAPlayThrough::SetInputDeviceAsCurrent(AudioDeviceID in)
{
UInt32 size = sizeof(AudioDeviceID);
OSStatus err = noErr;
if(in == kAudioDeviceUnknown) //get the default input device if device is unknown
{
err = AudioHardwareGetProperty(kAudioHardwarePropertyDefaultInputDevice,
&size,
&in);
checkErr(err);
}
mInputDevice.Init(in, true);
//Set the Current Device to the AUHAL.
//this should be done only after IO has been enabled on the AUHAL.
err = AudioUnitSetProperty(mInputUnit,
kAudioOutputUnitProperty_CurrentDevice,
kAudioUnitScope_Global,
0,
&mInputDevice.mID,
sizeof(mInputDevice.mID));
checkErr(err);
return err;
}
示例13: AudioHardwareGetPropertyInfo
UInt32 CCoreAudioHardware::GetOutputDevices(CoreAudioDeviceList* pList)
{
if (!pList)
return 0;
// Obtain a list of all available audio devices
UInt32 found = 0;
UInt32 size = 0;
AudioHardwareGetPropertyInfo(kAudioHardwarePropertyDevices, &size, NULL);
UInt32 deviceCount = size / sizeof(AudioDeviceID);
AudioDeviceID* pDevices = new AudioDeviceID[deviceCount];
OSStatus ret = AudioHardwareGetProperty(kAudioHardwarePropertyDevices, &size, pDevices);
if (ret)
CLog::Log(LOGERROR, "CCoreAudioHardware::GetOutputDevices: Unable to retrieve the list of available devices. Error = 0x%08x (%4.4s)", ret, CONVERT_OSSTATUS(ret));
else
{
for (UInt32 dev = 0; dev < deviceCount; dev++)
{
if (CCoreAudioDevice::GetTotalOutputChannels(pDevices[dev]) == 0)
continue;
found++;
pList->push_back(pDevices[dev]);
}
}
delete[] pDevices;
return found;
}
示例14: deviceIDsArraySize
QList<AudioDeviceID> UBAudioQueueRecorder::inputDeviceIDs()
{
QList<AudioDeviceID> inputDeviceIDs;
UInt32 deviceIDsArraySize(0);
AudioHardwareGetPropertyInfo(kAudioHardwarePropertyDevices, &deviceIDsArraySize, 0);
AudioDeviceID deviceIDs[deviceIDsArraySize / sizeof(AudioDeviceID)];
AudioHardwareGetProperty(kAudioHardwarePropertyDevices, &deviceIDsArraySize, deviceIDs);
int deviceIDsCount = deviceIDsArraySize / sizeof(AudioDeviceID);
for (int i = 0; i < deviceIDsCount; i ++)
{
AudioStreamBasicDescription sf;
UInt32 size = sizeof(AudioStreamBasicDescription);
if (noErr == AudioDeviceGetProperty(deviceIDs[i], 0, true, kAudioDevicePropertyStreamFormat, &size, &sf))
{
inputDeviceIDs << deviceIDs[i];
}
}
/*
foreach(AudioDeviceID id, inputDeviceIDs)
{
qDebug() << "Device" << id << deviceNameFromDeviceID(id) << deviceUIDFromDeviceID(id);
}
*/
return inputDeviceIDs;
}
示例15: getDefaultDevice
static int getDefaultDevice(AudioDeviceID *id, int direction)
{
UInt32 sz= sizeof(*id);
return (!checkError(AudioHardwareGetProperty((direction
? kAudioHardwarePropertyDefaultInputDevice
: kAudioHardwarePropertyDefaultOutputDevice),
&sz, (void *)id),
"GetProperty", (direction ? "DefaultInput" : "DefaultOutput")));
}