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; } }
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 } }
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; }
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; }
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; }
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)); } }
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; }
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"); }
// ------------------------------------------------------ // 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); }
void CCoreAudioHardware::ResetAudioDevices() { // Reset any devices with an AC3 stream back to a Linear PCM // so that they can become a default output device UInt32 size; AudioHardwareGetPropertyInfo(kAudioHardwarePropertyDevices, &size, NULL); AudioDeviceID *devices = (AudioDeviceID*)malloc(size); if (!devices) { CLog::Log(LOGERROR, "CCoreAudioHardware::ResetAudioDevices: ResetAudioDevices - out of memory?"); return; } int numDevices = size / sizeof(AudioDeviceID); AudioHardwareGetProperty(kAudioHardwarePropertyDevices, &size, devices); for (int i = 0; i < numDevices; i++) { AudioStreamID *streams; streams = StreamsList(devices[i]); for (int j = 0; streams[j] != kAudioHardwareBadStreamError; j++) ResetStream(streams[j]); free(streams); } free(devices); }
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); } }
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; }
QList<QByteArray> QAudioDeviceInfoInternal::availableDevices(QAudio::Mode mode) { QList<QByteArray> devices; UInt32 propSize = 0; if (AudioHardwareGetPropertyInfo(kAudioHardwarePropertyDevices, &propSize, 0) == noErr) { const int dc = propSize / sizeof(AudioDeviceID); if (dc > 0) { AudioDeviceID* audioDevices = new AudioDeviceID[dc]; if (AudioHardwareGetProperty(kAudioHardwarePropertyDevices, &propSize, audioDevices) == noErr) { for (int i = 0; i < dc; ++i) { QByteArray info = get_device_info(audioDevices[i], mode); if (!info.isNull()) devices << info; } } delete audioDevices; } } return devices; }
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; }
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; }
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; }
static int getDefaultDevice(AudioDeviceID *id, int direction) { UInt32 sz= sizeof(*id); return (!checkError(AudioHardwareGetProperty((direction ? kAudioHardwarePropertyDefaultInputDevice : kAudioHardwarePropertyDefaultOutputDevice), &sz, (void *)id), "GetProperty", (direction ? "DefaultInput" : "DefaultOutput"))); }
static OSStatus coreaudio_get_voice(AudioDeviceID *id) { UInt32 size = sizeof(*id); return AudioHardwareGetProperty( kAudioHardwarePropertyDefaultOutputDevice, &size, id); }
CoreAudioDriver::CoreAudioDriver( audioProcessCallback processCallback ) : H2Core::AudioOutput( __class_name ) , m_bIsRunning( false ) , mProcessCallback( processCallback ) , m_pOut_L( NULL ) , m_pOut_R( NULL ) { //INFOLOG( "INIT" ); m_nSampleRate = Preferences::get_instance()->m_nSampleRate; // m_nBufferSize = Preferences::get_instance()->m_nBufferSize; // BufferSize is currently set to match the default audio device. OSStatus err; UInt32 size = sizeof( AudioDeviceID ); err = AudioHardwareGetProperty( kAudioHardwarePropertyDefaultOutputDevice, &size, &m_outputDevice ); if ( err != noErr ) { ERRORLOG( "Could not get Default Output Device" ); } UInt32 dataSize = sizeof( m_nBufferSize ); err = AudioDeviceGetProperty( m_outputDevice, 0, false, kAudioDevicePropertyBufferFrameSize, &dataSize, ( void * )&m_nBufferSize ); if ( err != noErr ) { ERRORLOG( "get BufferSize error" ); } INFOLOG( QString( "Buffersize: %1" ).arg( m_nBufferSize ) ); // print some info AudioStreamBasicDescription outputStreamBasicDescription; UInt32 propertySize = sizeof( outputStreamBasicDescription ); err = AudioDeviceGetProperty( m_outputDevice, 0, 0, kAudioDevicePropertyStreamFormat, &propertySize, &outputStreamBasicDescription ); if ( err ) { printf( "AudioDeviceGetProperty: returned %d when getting kAudioDevicePropertyStreamFormat", err ); } INFOLOG( QString("SampleRate: %1").arg( outputStreamBasicDescription.mSampleRate ) ); INFOLOG( QString("BytesPerPacket: %1").arg( outputStreamBasicDescription.mBytesPerPacket ) ); INFOLOG( QString("FramesPerPacket: %1").arg( outputStreamBasicDescription.mFramesPerPacket ) ); INFOLOG( QString("BytesPerFrame: %1").arg( outputStreamBasicDescription.mBytesPerFrame ) ); INFOLOG( QString("ChannelsPerFrame: %1").arg( outputStreamBasicDescription.mChannelsPerFrame ) ); INFOLOG( QString("BitsPerChannel: %1").arg( outputStreamBasicDescription.mBitsPerChannel ) ); }
AudioDeviceID CCoreAudioHardware::GetDefaultOutputDevice() { UInt32 size = sizeof(AudioDeviceID); AudioDeviceID deviceId = 0; OSStatus ret = AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOutputDevice, &size, &deviceId); if (ret || !deviceId) // outputDevice is set to 0 if there is no audio device available, or if the default device is set to an encoded format { CLog::Log(LOGERROR, "CCoreAudioHardware::GetDefaultOutputDevice: Unable to identify default output device. Error = 0x%08x (%4.4s).", ret, CONVERT_OSSTATUS(ret)); return 0; } return deviceId; }
AudioDeviceID getCurrentlySelectedDeviceID(ASDeviceType typeRequested) { UInt32 propertySize; AudioDeviceID deviceID = kAudioDeviceUnknown; // get the default output device propertySize = sizeof(deviceID); switch(typeRequested) { case kAudioTypeInput: AudioHardwareGetProperty(kAudioHardwarePropertyDefaultInputDevice, &propertySize, &deviceID); break; case kAudioTypeOutput: AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOutputDevice, &propertySize, &deviceID); break; case kAudioTypeSystemOutput: AudioHardwareGetProperty(kAudioHardwarePropertyDefaultSystemOutputDevice, &propertySize, &deviceID); break; } return deviceID; }
static au_instance_t *audiounits_create_recorder(SEXP source, float rate, int chs, int flags) { UInt32 propsize=0; OSStatus err; au_instance_t *ap = (au_instance_t*) calloc(sizeof(au_instance_t), 1); ap->source = source; ap->sample_rate = rate; ap->done = NO; ap->position = 0; ap->length = LENGTH(source); ap->stereo = (chs == 2) ? YES : NO; propsize = sizeof(ap->inDev); err = AudioHardwareGetProperty(kAudioHardwarePropertyDefaultInputDevice, &propsize, &ap->inDev); if (err) { free(ap); Rf_error("unable to find default audio input (%08x)", err); } propsize = sizeof(ap->fmtIn); err = AudioDeviceGetProperty(ap->inDev, 0, YES, kAudioDevicePropertyStreamFormat, &propsize, &ap->fmtIn); if (err) { free(ap); Rf_error("unable to retrieve audio input format (%08x)", err); } /* Rprintf(" recording format: %f, chs: %d, fpp: %d, bpp: %d, bpf: %d, flags: %x\n", ap->fmtIn.mSampleRate, ap->fmtIn.mChannelsPerFrame, ap->fmtIn.mFramesPerPacket, ap->fmtIn.mBytesPerPacket, ap->fmtIn.mBytesPerFrame, ap->fmtIn.mFormatFlags); */ ap->srFrac = 1.0; if (ap->fmtIn.mSampleRate != ap->sample_rate) ap->srFrac = ap->sample_rate / ap->fmtIn.mSampleRate; ap->srRun = 0.0; #if defined(MAC_OS_X_VERSION_10_5) && (MAC_OS_X_VERSION_MIN_REQUIRED>=MAC_OS_X_VERSION_10_5) err = AudioDeviceCreateIOProcID(ap->inDev, inputRenderProc, ap, &ap->inIOProcID ); #else err = AudioDeviceAddIOProc(ap->inDev, inputRenderProc, ap); #endif if (err) { free(ap); Rf_error("unable to register recording callback (%08x)", err); } R_PreserveObject(ap->source); Rf_setAttrib(ap->source, Rf_install("rate"), Rf_ScalarInteger(rate)); /* we adjust the rate */ Rf_setAttrib(ap->source, Rf_install("bits"), Rf_ScalarInteger(16)); /* we say it's 16 because we don't know - float is always 32-bit */ Rf_setAttrib(ap->source, Rf_install("class"), Rf_mkString("audioSample")); if (ap->stereo) { SEXP dim = Rf_allocVector(INTSXP, 2); INTEGER(dim)[0] = 2; INTEGER(dim)[1] = LENGTH(ap->source) / 2; Rf_setAttrib(ap->source, R_DimSymbol, dim); } return ap; }
InputDeviceRef InputImplAudioUnit::getDefaultDevice() { AudioDeviceID aDeviceId; UInt32 param = sizeof( AudioDeviceID ); OSStatus err = AudioHardwareGetProperty( kAudioHardwarePropertyDefaultInputDevice, ¶m, &aDeviceId ); if( err != noErr ) { //TODO std::cout << "Error getting default device" << std::endl; throw; } return InputDeviceRef( new InputImplAudioUnit::Device( aDeviceId ) ); }
bool CCoreAudioHardware::GetAutoHogMode() { UInt32 val = 0; UInt32 size = sizeof(val); OSStatus ret = AudioHardwareGetProperty(kAudioHardwarePropertyHogModeIsAllowed, &size, &val); if (ret) { CLog::Log(LOGERROR, "CCoreAudioHardware::GetAutoHogMode: Unable to get auto 'hog' mode. Error = 0x%08x (%4.4s).", ret, CONVERT_OSSTATUS(ret)); return false; } return (val == 1); }
static OSStatus get_device_id_from_uid(char* UID, AudioDeviceID* id) { UInt32 size = sizeof(AudioValueTranslation); CFStringRef inIUD = CFStringCreateWithCString(NULL, UID, CFStringGetSystemEncoding()); AudioValueTranslation value = { &inIUD, sizeof(CFStringRef), id, sizeof(AudioDeviceID) }; if (inIUD == NULL) { return kAudioHardwareUnspecifiedError; } else { OSStatus res = AudioHardwareGetProperty(kAudioHardwarePropertyDeviceForUID, &size, &value); CFRelease(inIUD); return res; } }
QByteArray QAudioDeviceInfoInternal::defaultOutputDevice() { AudioDeviceID audioDevice; UInt32 size = sizeof(audioDevice); if (AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOutputDevice, &size, &audioDevice) != noErr) { qWarning() << "QAudioDeviceInfo: Unable to find default output device"; return QByteArray(); } return get_device_info(audioDevice, QAudio::AudioOutput); }
bool CCoreAudioHardware::GetAutoHogMode() { UInt32 val = 0; UInt32 size = sizeof(val); OSStatus ret = AudioHardwareGetProperty(kAudioHardwarePropertyHogModeIsAllowed, &size, &val); if (ret) { CLog::Log(LOGERROR, "CCoreAudioHardware::GetAutoHogMode: " "Unable to get auto 'hog' mode. Error = %s", GetError(ret).c_str()); return false; } return (val == 1); }
static OSStatus get_default_output_device(AudioDeviceID* id) { OSStatus res; UInt32 theSize = sizeof(UInt32); AudioDeviceID outDefault; if ((res = AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOutputDevice, &theSize, &outDefault)) != noErr) return res; JCALog("get_default_output_device: output = %ld\n", outDefault); *id = outDefault; return noErr; }
AudioDeviceID UBAudioQueueRecorder::defaultInputDeviceID() { AudioDeviceID deviceID; UInt32 size = sizeof(deviceID); if (noErr == AudioHardwareGetProperty(kAudioHardwarePropertyDefaultInputDevice, &size, &deviceID)) { return deviceID; } else { return 0; } }
PlexAudioDevicePtr PlexAudioDevices::FindDefault() { PlexAudioDevice* ret = 0; AudioDeviceID defaultDeviceID = 0; UInt32 paramSize = 0; OSStatus err = noErr; // Find the ID of the default Device. paramSize = sizeof(AudioDeviceID); SAFELY(AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOutputDevice, ¶mSize, &defaultDeviceID)); if (err == noErr) ret = new PlexAudioDevice(defaultDeviceID); return PlexAudioDevicePtr(ret); }