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;
}
Beispiel #3
0
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;
}
Beispiel #4
0
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");
}
Beispiel #5
0
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;
}
UInt32	CAAudioHardwareSystem::GetPropertyDataSize(AudioHardwarePropertyID inPropertyID)
{
	UInt32 theSize = 0;
	OSStatus theError = AudioHardwareGetPropertyInfo(inPropertyID, &theSize, NULL);
	ThrowIfError(theError, CAException(theError), "CAAudioHardwareSystem::GetPropertyDataSize: got an error getting info about a property");
	return theSize;
}
Beispiel #8
0
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;
}
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;
}
bool	CAAudioHardwareSystem::PropertyIsSettable(AudioHardwarePropertyID inPropertyID)
{
	Boolean isWritable = false;
	OSStatus theError = AudioHardwareGetPropertyInfo(inPropertyID, NULL, &isWritable);
	ThrowIfError(theError, CAException(theError), "CAAudioHardwareSystem::PropertyIsSettable: got an error getting info about a property");
	return isWritable != 0;
}
Beispiel #11
0
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);
}
Beispiel #12
0
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;
}
Beispiel #13
0
int macosx_audio_device_count(void)
/* Then this one tells us the number of 'em */
{

    OSStatus err = noErr;
    UInt32 theSize;
    err = AudioHardwareGetPropertyInfo ( kAudioHardwarePropertyDevices, &theSize, NULL );
    int num_devices;
    num_devices = theSize / sizeof(AudioDeviceID);
    //return num_devices;
    return 1;
};
Beispiel #14
0
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;
}
Beispiel #15
0
static void au_card_detect(MSSndCardManager * m)
{
    OSStatus err;
    UInt32 slen;
    int count;
    Boolean writable;
    int i;
    writable = 0;
    slen = 0;
    err =
        AudioHardwareGetPropertyInfo(kAudioHardwarePropertyDevices, &slen,
                                     &writable);
    if (err != kAudioHardwareNoError) {
        ms_error("get kAudioHardwarePropertyDevices error %ld", err);
        return;
    }
    AudioDeviceID devices[slen / sizeof(AudioDeviceID)];
    err =
        AudioHardwareGetProperty(kAudioHardwarePropertyDevices, &slen, devices);
    if (err != kAudioHardwareNoError) {
        ms_error("get kAudioHardwarePropertyDevices error %ld", err);
        return;
    }
    /*first, add Default AudioUnit
    does not work: why ?
    */
    /*ms_snd_card_manager_add_card(m,ca_card_new("Default", "",-1, MS_SND_CARD_CAP_CAPTURE|MS_SND_CARD_CAP_PLAYBACK));
    */

    count = slen / sizeof(AudioDeviceID);
    for (i = 0; i < count; i++) {
        MSSndCard *card;
        char uidname[256]= {0},devname[256]= {0};
        int card_capacity=0;
        if (check_card_capability(devices[i],FALSE,devname,uidname,sizeof(uidname))) {
            card_capacity|=MS_SND_CARD_CAP_PLAYBACK;
        }
        if (check_card_capability(devices[i],TRUE,devname,uidname,sizeof(uidname))) {
            card_capacity|=MS_SND_CARD_CAP_CAPTURE;
        }
        if (card_capacity) {
            card=ca_card_new(devname, uidname, devices[i], card_capacity);
            ms_snd_card_manager_add_card(m, card);
        }

    }
}
Beispiel #16
0
AudioDeviceID CCoreAudioHardware::FindAudioDevice(CStdString searchName)
{
  if (!searchName.length())
    return 0;
  
  UInt32 size = 0;
  AudioDeviceID deviceId = 0;
  OSStatus ret;
 
  if (searchName.Equals("Default Output Device"))
  {
    AudioDeviceID defaultDevice = GetDefaultOutputDevice();
    CLog::Log(LOGDEBUG, "CCoreAudioHardware::FindAudioDevice: Returning default device [0x%04x].", defaultDevice);
    return defaultDevice;  
  }
  CLog::Log(LOGDEBUG, "CCoreAudioHardware::FindAudioDevice: Searching for device - %s.", searchName.c_str());
  
  // Obtain a list of all available audio devices
  AudioHardwareGetPropertyInfo(kAudioHardwarePropertyDevices, &size, NULL);
  UInt32 deviceCount = size / sizeof(AudioDeviceID);
  AudioDeviceID* pDevices = new AudioDeviceID[deviceCount];
  ret = AudioHardwareGetProperty(kAudioHardwarePropertyDevices, &size, pDevices);
  if (ret)
  { 
    CLog::Log(LOGERROR, "CCoreAudioHardware::FindAudioDevice: Unable to retrieve the list of available devices. Error = 0x%08x (%4.4s)", ret, CONVERT_OSSTATUS(ret));
    delete[] pDevices;
    return 0; 
  }
  
  // Attempt to locate the requested device
  CStdString deviceName;
  for (UInt32 dev = 0; dev < deviceCount; dev++)
  {
    CCoreAudioDevice device;
    device.Open((pDevices[dev]));
    device.GetName(deviceName);
    UInt32 totalChannels = device.GetTotalOutputChannels();
    CLog::Log(LOGDEBUG, "CCoreAudioHardware::FindAudioDevice:   Device[0x%04x] - Name: '%s', Total Ouput Channels: %u. ", pDevices[dev], deviceName.c_str(), totalChannels);
    if (searchName.Equals(deviceName))
      deviceId = pDevices[dev];
    if (deviceId)
      break;
  }
  delete[] pDevices;  
  
  return deviceId;
}
Beispiel #17
0
static OSStatus display_device_names()
{
	UInt32 size;
	Boolean isWritable;
	int i, deviceNum;
	OSStatus err;
	CFStringRef UIname;
	
	err = AudioHardwareGetPropertyInfo(kAudioHardwarePropertyDevices, &size, &isWritable);
    if (err != noErr) 
		return err;
		
	deviceNum = size/sizeof(AudioDeviceID);
	AudioDeviceID devices[deviceNum];
	
	err = AudioHardwareGetProperty(kAudioHardwarePropertyDevices, &size, devices);
    if (err != noErr) 
		return err;
	
	for (i = 0; i < deviceNum; i++) {
        char device_name[256];
		char internal_name[256];
		
		size = sizeof(CFStringRef);
		UIname = NULL;
		err = AudioDeviceGetProperty(devices[i], 0, false, kAudioDevicePropertyDeviceUID, &size, &UIname);
		if (err == noErr) {
			CFStringGetCString(UIname, internal_name, 256, CFStringGetSystemEncoding());
		} else {
			goto error;
		}
		
		size = 256;
		err = AudioDeviceGetProperty(devices[i], 0, false, kAudioDevicePropertyDeviceName, &size, device_name);
		if (err != noErr) 
			return err; 
		jack_info("ICI");
		jack_info("Device name = \'%s\', internal_name = \'%s\' (to be used as -d parameter)", device_name, internal_name); 
	}
	
	return noErr;

error:
	if (UIname != NULL)
		CFRelease(UIname);
	return err;
}
AudioDeviceID getNextDeviceID(AudioDeviceID currentDeviceID, ASDeviceType typeRequested) {
	UInt32 propertySize;
	AudioDeviceID dev_array[64];
	int numberOfDevices = 0;
	AudioDeviceID first_dev = kAudioDeviceUnknown;
	int found = -1;
	
	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:
                if (!isAnInputDevice(dev_array[i])) continue;
                break;
                
			case kAudioTypeOutput:
                if (!isAnOutputDevice(dev_array[i])) continue;
				break;

			case kAudioTypeSystemOutput:
				if (getDeviceType(dev_array[i]) != kAudioTypeOutput) continue;
				break;
            default: break;
		}

		if (first_dev == kAudioDeviceUnknown) {
			first_dev = dev_array[i];
		}
		if (found >= 0) {
			return dev_array[i];
		}
		if (dev_array[i] == currentDeviceID) {
			found = i;
		}
	}
	
	return first_dev;
}
Beispiel #19
0
static OSStatus get_device_id_from_num(int i, AudioDeviceID * id)
{
    OSStatus theStatus;
    UInt32 theSize;
    int nDevices;
    AudioDeviceID *theDeviceList;

    theStatus =
	AudioHardwareGetPropertyInfo(kAudioHardwarePropertyDevices,
				     &theSize, NULL);
    nDevices = theSize / sizeof(AudioDeviceID);
    theDeviceList =
	(AudioDeviceID *) malloc(nDevices * sizeof(AudioDeviceID));
    theStatus =
	AudioHardwareGetProperty(kAudioHardwarePropertyDevices, &theSize,
				 theDeviceList);

    *id = theDeviceList[i];
    return theStatus;
}
AudioDeviceID getRequestedDeviceID(char* requestedDeviceName) {
    UInt32 propertySize;
    AudioDeviceID dev_array[64];
    int numberOfDevices = 0;
    char deviceName[256];
    
    AudioHardwareGetPropertyInfo(kAudioHardwarePropertyDevices, &propertySize, NULL);
    
    AudioHardwareGetProperty(kAudioHardwarePropertyDevices, &propertySize, dev_array);
    numberOfDevices = (propertySize / sizeof(AudioDeviceID));
    
    for(int i = 0; i < numberOfDevices; ++i) {
        if (!isAnOutputDevice(dev_array[i])) continue;
        
        getDeviceName(dev_array[i], deviceName);
        if (strcmp(requestedDeviceName, deviceName) == 0) {
            return dev_array[i];
        }
    }
    
    return kAudioDeviceUnknown;
}
std::vector<AudioDeviceID> CoreAudioUtilities::audioDeviceList(bool isInput) {
	OSStatus status = noErr;
	UInt32 numberOfDevices = 0;
	UInt32 deviceListSize = 0;
	AudioDeviceID * deviceList = NULL;
	std::vector<AudioDeviceID> result;

	// Getting number of devices
	status = AudioHardwareGetPropertyInfo(kAudioHardwarePropertyDevices, &deviceListSize, NULL);
	if (status) {
		LOG_ERROR("Can't get property info: kAudioHardwarePropertyDevices");
		return result;
	}

	numberOfDevices = deviceListSize / sizeof(AudioDeviceID);
	////

	// Getting device list
	deviceList = (AudioDeviceID *) calloc(sizeof(AudioDeviceID), deviceListSize);

	status = AudioHardwareGetProperty(kAudioHardwarePropertyDevices, &deviceListSize, deviceList);
	if (status) {
		LOG_ERROR("Can't get property: kAudioHardwarePropertyDevices");
		return result;
	}
	////

	// Populating the result
	for (unsigned i = 0 ; i < numberOfDevices ; ++i) {
		if ((isInput && hasChannel(deviceList[i], true))
			|| (!isInput && hasChannel(deviceList[i], false))) {
			result.push_back(deviceList[i]);
		}
	}
	////

	return result;
}
void	AudioDeviceList::BuildList()
{
	mDevices.clear();
	
	UInt32 propsize;
	
	verify_noerr(AudioHardwareGetPropertyInfo(kAudioHardwarePropertyDevices, &propsize, NULL));
	int nDevices = propsize / sizeof(AudioDeviceID);	
	AudioDeviceID *devids = new AudioDeviceID[nDevices];
	verify_noerr(AudioHardwareGetProperty(kAudioHardwarePropertyDevices, &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;
}
Beispiel #23
0
UInt32 CCoreAudioHardware::GetOutputDevices(CoreAudioDeviceList *pList)
{
  UInt32 found = 0;
  if (!pList)
    return found;

  // Obtain a list of all available audio devices
  size_t size = 0;
  AudioHardwareGetPropertyInfo(kAudioHardwarePropertyDevices, &size, NULL);
  size_t deviceCount = size / sizeof(AudioDeviceID);
  AudioDeviceID* pDevices = new AudioDeviceID[deviceCount];

  AudioObjectPropertyAddress  propertyAddress;
  propertyAddress.mScope    = kAudioObjectPropertyScopeGlobal;
  propertyAddress.mElement  = kAudioObjectPropertyElementMaster;
  propertyAddress.mSelector = kAudioHardwarePropertyDevices;
  OSStatus ret = AudioObjectGetPropertyData(kAudioObjectSystemObject,
    &propertyAddress, 0, NULL, &size, pDevices);
  if (ret)
    CLog::Log(LOGERROR, "CCoreAudioHardware::GetOutputDevices:"
      " Unable to retrieve the list of available devices. Error = %s", GetError(ret).c_str());
  else
  {
    for (size_t dev = 0; dev < deviceCount; dev++)
    {
      CCoreAudioDevice device(pDevices[dev]);
      if (device.GetTotalOutputChannels() == 0)
        continue;
      found++;
      pList->push_back(pDevices[dev]);
    }
  }
  delete[] pDevices;

  return found;
}
Beispiel #24
0
// ----------------------------------------------------------
bool ofxAudioUnitOutput::configureOutputDevice(int deviceID)
// ----------------------------------------------------------
{
    
    OSStatus    err = noErr;
    UInt32      outSize;
    Boolean     outWritable;
    
    err = AudioHardwareGetPropertyInfo(kAudioHardwarePropertyDevices, &outSize, &outWritable);
    if ( err != noErr ) cout<<"err 1"<<endl;
    UInt16 devicesAvailable = outSize / sizeof(AudioDeviceID);
    if ( devicesAvailable < 1 )
    {
        fprintf(stderr, "No devices\n" );
        //return err;
    }else{
        
        cout<<"*devicesAvailable "<<devicesAvailable<<endl;
    }
    
	UInt32 on  = 1;
    UInt32 off = 0;
	OFXAU_RET_FALSE(AudioUnitSetProperty(*_unit,
										 kAudioOutputUnitProperty_EnableIO,
										 kAudioUnitScope_Input,
										 1,
										 &off,
										 sizeof(off)),
					"disabling input on HAL unit");
	
	
	OFXAU_RET_FALSE(AudioUnitSetProperty(*_unit,
										 kAudioOutputUnitProperty_EnableIO,
										 kAudioUnitScope_Output,
										 0,
										 &on,
										 sizeof(on)),
					"enabling output on HAL unit");
	
	AudioDeviceID outputDeviceID = kAudioObjectUnknown;
    
	UInt32 deviceIDSize = sizeof( AudioDeviceID );
	AudioObjectPropertyAddress prop_addr = {
		kAudioHardwarePropertyDefaultOutputDevice,
		kAudioObjectPropertyScopeGlobal,
		kAudioObjectPropertyElementMaster
	};
	
    
	OFXAU_RET_FALSE(AudioObjectGetPropertyData(kAudioObjectSystemObject,
											   &prop_addr,
											   0,
											   NULL,
											   &deviceIDSize,
											   &outputDeviceID),
					"getting device ID for default input");
	
    if(deviceID != -1) outputDeviceID = deviceID;
    
	OFXAU_RET_FALSE(AudioUnitSetProperty(*_unit,
										 kAudioOutputUnitProperty_CurrentDevice,
										 kAudioUnitScope_Global,
										 0,
										 &outputDeviceID,
										 deviceIDSize),
					"setting HAL unit's device ID");
	cout<<"outputDeviceID "<<outputDeviceID<<endl;
	
	OFXAU_RET_BOOL(AudioUnitInitialize(*_unit),
				   "initializing hardware input unit after setting it to input mode");
    
    
}
PlexAudioDevicesPtr PlexAudioDevices::FindAll()
{
	OSStatus          err = noErr;
	UInt32            paramSize = 0;
	PlexAudioDevices* audioDevices = new PlexAudioDevices();
	
	// Get number of devices.
  SAFELY(AudioHardwareGetPropertyInfo(kAudioHardwarePropertyDevices, &paramSize, NULL));
  if (err == noErr)
  {
    int totalDeviceCount = paramSize / sizeof(AudioDeviceID);
    if (totalDeviceCount > 0)
    {
      CLog::Log(LOGDEBUG, "System has %ld device(s)", totalDeviceCount);

      // Allocate the device ID array and retreive them.
      AudioDeviceID* pDevices = (AudioDeviceID* )malloc(paramSize);
      SAFELY(AudioHardwareGetProperty( kAudioHardwarePropertyDevices, &paramSize, pDevices));
      if (err == noErr)
      {
        AudioDeviceID defaultDeviceID = 0;

        // Find the ID of the default Device.
        paramSize = sizeof(AudioDeviceID);
        SAFELY(AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOutputDevice, &paramSize, &defaultDeviceID));
        if (err == noErr)
        {
          for (int i=0; i<totalDeviceCount; i++)
          {
            PlexAudioDevicePtr audioDevice = PlexAudioDevicePtr(new PlexAudioDevice(pDevices[i]));
            
            // Add valid devices that support output.
            if (audioDevice->isValid() && audioDevice->hasOutput())
            {
              audioDevices->m_audioDevices.push_back(audioDevice);
  
              // Set the default device.
              if (defaultDeviceID == pDevices[i])
                audioDevices->m_defaultDevice = audioDevice;
               
              // Set the selected device.
              if (g_guiSettings.GetSetting("audiooutput.audiodevice") && g_guiSettings.GetString("audiooutput.audiodevice") == audioDevice->getName())
                audioDevices->m_selectedDevice = audioDevice;
            }
          }
           
          // If we haven't selected any devices, select the default one.
          if (!audioDevices->m_selectedDevice)
            audioDevices->m_selectedDevice = audioDevices->m_defaultDevice;
          
          // Check if the selected device is alive and usable.
          if (audioDevices->m_selectedDevice->isAlive() == false)
          {
            CLog::Log(LOGWARNING, "Selected audio device [%s] is not alive, switching to default device", audioDevices->m_selectedDevice->getName().c_str());
            audioDevices->m_selectedDevice = audioDevices->m_defaultDevice;
          }
        }
      }
      
      free(pDevices);
    }
  }
  
  // FIXME? Attach a Listener so that we are notified of a change in the Device setup.
  // AudioHardwareAddPropertyListener( kAudioHardwarePropertyDevices, HardwareListener, (void *)p_aout);

  return PlexAudioDevicesPtr(audioDevices);
}
Beispiel #26
0
int macosx_audio_open(audio_desc_t ad, audio_format* ifmt, audio_format *ofmt)
{
	OSStatus err = noErr;
	UInt32   propertySize;
	Boolean  writable;
	obtained_ = false;
	add = ad;
	//dev[0] = devices[ad];
	UNUSED(ofmt);

	// Get the default input device ID. 
	err = AudioHardwareGetPropertyInfo(kAudioHardwarePropertyDefaultInputDevice, &propertySize, &writable);              
	if (err != noErr) {
		return 0;
	}
	err = AudioHardwareGetProperty(kAudioHardwarePropertyDefaultInputDevice, &propertySize, &(devices[ad].inputDeviceID_));
	if (err != noErr) {
		debug_msg("error kAudioHardwarePropertyDefaultInputDevice");
		return 0;
	}
	if (devices[ad].inputDeviceID_ == kAudioDeviceUnknown) {
		debug_msg("error kAudioDeviceUnknown");
		return 0;
	}
	// Get the input stream description.
	err = AudioDeviceGetPropertyInfo(devices[ad].inputDeviceID_, 0, true, kAudioDevicePropertyStreamFormat, &propertySize, &writable);
	if (err != noErr) {
		debug_msg("error AudioDeviceGetPropertyInfo");
		return 0;
	}
	err = AudioDeviceGetProperty(devices[ad].inputDeviceID_, 0, true, kAudioDevicePropertyStreamFormat, &propertySize, &(devices[ad].inputStreamBasicDescription_));
	//printf("inputStreamBasicDescription_.mBytesPerFrame %d\n", devices[add].inputStreamBasicDescription_);
	if (err != noErr) {
		debug_msg("error AudioDeviceGetProperty");
		return 0;
	}

	// nastavime maly endian
	devices[ad].inputStreamBasicDescription_.mFormatFlags &= (kAudioFormatFlagIsBigEndian & 0);

	if (writable) {
	        err = AudioDeviceSetProperty(devices[ad].inputDeviceID_, NULL, 0, true, kAudioDevicePropertyStreamFormat, sizeof(AudioStreamBasicDescription), &(devices[ad].inputStreamBasicDescription_));
	        if (err != noErr) printf("err: AudioDeviceSetProperty: kAudioDevicePropertyStreamFormat\n");
	}
	
	/* set the buffer size of the device */
	
	/*
	int bufferByteSize = 8192;
	propertySize = sizeof(bufferByteSize);
	err = AudioDeviceSetProperty(devices[ad].inputDeviceID_, NULL, 0, true, kAudioDevicePropertyBufferSize, propertySize, &bufferByteSize);
	if (err != noErr) debug_msg("err: Set kAudioDevicePropertyBufferSize to %d\n", bufferByteSize);
	else debug_msg("sucessfully set kAudioDevicePropertyBufferSize to %d\n", bufferByteSize);
	*/

        // Set the device sample rate -- a temporary fix for the G5's
        //   built-in audio and possibly other audio devices.
	Boolean IsInput = 0;
	int inChannel = 0;
         
	Float64 theAnswer = 44100;
	UInt32 theSize = sizeof(theAnswer);
	err = AudioDeviceSetProperty(devices[ad].inputDeviceID_, NULL, inChannel, IsInput,
                                kAudioDevicePropertyNominalSampleRate, theSize, &theAnswer);

	if (err != noErr) {
		debug_msg("error AudioDeviceSetProperty\n");
		return 0;
	}
	debug_msg("Sample rate, %f\n", theAnswer);
#if defined(MAC_OS_X_VERSION_10_5) && (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5)
	err = AudioDeviceCreateIOProcID(devices[ad].inputDeviceID_, audioIOProc, (void*)NULL, &devices[ad].inputDeviceProcID_);
	if (err != noErr) {
		debug_msg("error AudioDeviceCreateIOProcID, %s\n", GetMacOSStatusCommentString(err));
		return 0;
	}
	err = OpenADefaultComponent(kAudioUnitType_Output, kAudioUnitSubType_DefaultOutput, &(devices[ad].outputUnit_));
	// The HAL AU maybe a better way to in the future...
	//err = OpenADefaultComponent(kAudioUnitType_Output, kAudioUnitSubType_HALOutput, &(devices[ad].outputUnit_));
	if (err != noErr) {
		debug_msg("error OpenADefaultComponent\n");
		return 0;
	}
#else
	// Register the AudioDeviceIOProc.
	err = AudioDeviceAddIOProc(devices[ad].inputDeviceID_, audioIOProc, NULL);
	if (err != noErr) {
		debug_msg("error AudioDeviceAddIOProc\n");
		return 0;
	}
	err = OpenDefaultAudioOutput(&(devices[ad].outputUnit_));
	if (err != noErr) {
		debug_msg("error OpenDefaultAudioOutput\n");
		return 0;
	}
#endif
	// Register a callback function to provide output data to the unit.
	devices[ad].input.inputProc = outputRenderer;
	devices[ad].input.inputProcRefCon = 0;
	/* These would be needed if HAL used
	 * UInt32 enableIO =1; 
	err = AudioUnitSetProperty(devices[ad].outputUnit_, kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Output, 0, (const void*)&enableIO, sizeof(UInt32));
	enableIO=0;
	err = AudioUnitSetProperty(devices[ad].outputUnit_, kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Input, 1, (const void*)&enableIO, sizeof(UInt32));
	if (err != noErr) {
		debug_msg("error AudioUnitSetProperty EnableIO with error %ld: %s\n", err, GetMacOSStatusErrorString(err));
		return 0;
	}*/
#if defined(MAC_OS_X_VERSION_10_5) && (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5)
	err = AudioUnitSetProperty(devices[ad].outputUnit_, kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Global, 0, &(devices[ad].input), sizeof(AURenderCallbackStruct));
#else
	err = AudioUnitSetProperty(devices[ad].outputUnit_, kAudioOutputUnitProperty_SetInputCallback, kAudioUnitScope_Global, 0, &(devices[ad].input), sizeof(AURenderCallbackStruct));
#endif

	if (err != noErr) {
		debug_msg("error AudioUnitSetProperty1 with error %ld: %s\n", err, GetMacOSStatusErrorString(err));
		return 0;
	}
	// Define the Mash stream description. Mash puts 20ms of data into each read
	// and write call. 20ms at 8000Hz equals 160 samples. Each sample is a u_char,
	// so that's 160 bytes. Mash uses 8-bit mu-law internally, so we need to convert
	// to 16-bit linear before using the audio data.
	devices[ad].mashStreamBasicDescription_.mSampleRate = 8000.0;
	//devices[ad].mashStreamBasicDescription_.mSampleRate = ifmt->sample_rate;
	devices[ad].mashStreamBasicDescription_.mFormatID = kAudioFormatLinearPCM;
#ifdef WORDS_BIGENDIAN
	devices[ad].mashStreamBasicDescription_.mFormatFlags =kLinearPCMFormatFlagIsSignedInteger | kLinearPCMFormatFlagIsBigEndian |kLinearPCMFormatFlagIsPacked;
#else
	devices[ad].mashStreamBasicDescription_.mFormatFlags =kLinearPCMFormatFlagIsSignedInteger | kLinearPCMFormatFlagIsPacked;
#endif
	devices[ad].mashStreamBasicDescription_.mBytesPerPacket = 2;
	devices[ad].mashStreamBasicDescription_.mFramesPerPacket = 1;
	devices[ad].mashStreamBasicDescription_.mBytesPerFrame = 2;
	devices[ad].mashStreamBasicDescription_.mChannelsPerFrame = 1;
	devices[ad].mashStreamBasicDescription_.mBitsPerChannel = 16;

	// Inform the default output unit of our source format.
	err = AudioUnitSetProperty(devices[ad].outputUnit_, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0, &(devices[ad].mashStreamBasicDescription_), sizeof(AudioStreamBasicDescription));
	if (err != noErr) {
		debug_msg("error AudioUnitSetProperty2");
		printf("error setting output unit source format\n");
		return 0;
	}

	// check the stream format
	err = AudioUnitGetPropertyInfo(devices[ad].outputUnit_, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0, &propertySize, &writable);
	if (err != noErr) debug_msg("err getting propert info for kAudioUnitProperty_StreamFormat\n");

	err = AudioUnitGetProperty(devices[ad].outputUnit_, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0, &streamdesc_, &propertySize);
	if (err != noErr) debug_msg("err getting values for kAudioUnitProperty_StreamFormat\n");
	
	char name[128];
	audio_format_name(ifmt, name, 128);
	debug_msg("Requested ifmt %s\n",name);
	debug_msg("ifmt bytes pre block: %d\n",ifmt->bytes_per_block);

	// handle the requested format
	if (ifmt->encoding != DEV_S16) {
		audio_format_change_encoding(ifmt, DEV_S16);
		debug_msg("Requested ifmt changed to %s\n",name);
		debug_msg("ifmt bytes pre block: %d\n",ifmt->bytes_per_block);
	}

	audio_format_name(ofmt, name, 128);
	debug_msg("Requested ofmt %s\n",name);
	debug_msg("ofmt bytes pre block: %d\n",ofmt->bytes_per_block);
	
	// Allocate the read buffer and Z delay line.
	//readBufferSize_ = 8192;
	readBufferSize_ = ifmt->bytes_per_block * ringBufferFactor_;
	//readBufferSize_ = 320;
	//printf("readBufferSize_ %d\n", readBufferSize_);
	readBuffer_ = malloc(sizeof(u_char)*readBufferSize_);
	bzero(readBuffer_, readBufferSize_ * sizeof(u_char));
	//memset(readBuffer_, PCMU_AUDIO_ZERO, readBufferSize_);
	//inputReadIndex_ = -1; 
	inputReadIndex_ = 0; inputWriteIndex_ = 0;
	zLine_ = malloc(sizeof(double)*DECIM441_LENGTH / 80);
	availableInput_ = 0;

	// Allocate the write buffer.
	//writeBufferSize_ = 8000;
	writeBufferSize_ = ofmt->bytes_per_block * ringBufferFactor_;
	writeBuffer_ = malloc(sizeof(SInt16)*writeBufferSize_);
	bzero(writeBuffer_, writeBufferSize_ * sizeof(SInt16));
	outputReadIndex_ = 0; outputWriteIndex_ = 0;
	//outputWriteIndex_ = -1;
    	// Start audio processing.
	err = AudioUnitInitialize(devices[ad].outputUnit_);
	if (err != noErr) {
		debug_msg("error AudioUnitInitialize\n");
		return 0;
	}
	err = AudioDeviceStart(devices[ad].inputDeviceID_, audioIOProc);
	if (err != noErr) {
		fprintf(stderr, "Input device error: AudioDeviceStart\n");
		return 0;
	}
	err = AudioOutputUnitStart(devices[ad].outputUnit_);
	if (err != noErr) {
		fprintf(stderr, "Output device error: AudioOutputUnitStart\n");
		return 0;
	}
	// Inform the default output unit of our source format.
	/*
	err = AudioUnitSetProperty(devices[ad].outputUnit_, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0, &(devices[ad].mashStreamBasicDescription_), sizeof(AudioStreamBasicDescription));
	if (err != noErr) {
		debug_msg("error AudioUnitSetProperty3");
		return 0;
	}
	*/
	return 1;
};
bool	CAAudioHardwareSystem::HasProperty(AudioHardwarePropertyID inPropertyID)
{
	OSStatus theError = AudioHardwareGetPropertyInfo(inPropertyID, NULL, NULL);
	return theError == 0;
}
Beispiel #28
0
bool JARInsert::OpenAudioClient()
{
    OSStatus err;
    UInt32 size;
    Boolean isWritable;

    err = AudioHardwareGetPropertyInfo(kAudioHardwarePropertyDevices, &size, &isWritable);
    if (err != noErr) {
        c_error = kErrCoreAudio;
        return false;
    }

    int nDevices = size / sizeof(AudioDeviceID);
	JARILog("There are %d audio devices\n", nDevices);

    AudioDeviceID *device = (AudioDeviceID*)calloc(nDevices, sizeof(AudioDeviceID));
    err = AudioHardwareGetProperty(kAudioHardwarePropertyDevices, &size, device);
    if (err != noErr) {
        c_error = kErrCoreAudio;
        return false;
    }

    for (int i = 0; i < nDevices; i++) {

        JARILog("ID: %ld\n", device[i]);

        char name[256];
        size = 256;
        err = AudioDeviceGetProperty(device[i], 0, true, kAudioDevicePropertyDeviceName, &size, &name);
        if (err == noErr) {
            JARILog("Name: %s\n", name);

            if (strcmp(&name[0], "JackRouter") == 0) {
                c_jackDevID = device[i];
                if (device != NULL)
                    free(device);
					
				JARILog("Get Jack client\n");
				size = sizeof(UInt32); 
                err = AudioDeviceGetProperty(c_jackDevID, 0, true, kAudioDevicePropertyGetJackClient, &size, &c_client);
                if (err != noErr) {
					JARILog("Get Jack client error = %d\n", err);
                    c_error = kErrNoClient;
                    return false;
                }
				
				JARILog("Get Jack client OK\n");
#if 0
				size = sizeof(UInt32);
                err = AudioDeviceGetProperty(c_jackDevID, 0, true, kAudioDevicePropertyDeviceIsRunning, &size, &c_isRunning);
                if (err != noErr) {
                    c_error = kErrNoClient;
                    return false;
                }
#endif
                if (c_client != NULL) {
                    c_error = kNoErr;
                    return true;
                } else
                    return false;
            }
        }
    }
    c_error = kErrNoClient;
    return false;
}
Beispiel #29
0
int gviHardwareListDevices(GVDeviceInfo devices[], int maxDevices, GVDeviceType types)
{
	OSStatus result;
	UInt32 size;
	int numDevices;
	int deviceCount;
	AudioDeviceID * deviceIDs;
	AudioDeviceID defaultCaptureDeviceID;
	AudioDeviceID defaultPlaybackDeviceID;
	GVDeviceType defaultTypes;
	int i;

	// get the default device ids
	size = sizeof(AudioDeviceID);
	result = AudioHardwareGetProperty(kAudioHardwarePropertyDefaultInputDevice, &size, &defaultCaptureDeviceID);
	if(result != noErr)
		defaultCaptureDeviceID = kAudioDeviceUnknown;
	result = AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOutputDevice, &size, &defaultPlaybackDeviceID);
	if(result != noErr)
		defaultPlaybackDeviceID = kAudioDeviceUnknown;

	// get the size of the device ids array
	result = AudioHardwareGetPropertyInfo(kAudioHardwarePropertyDevices, &size, NULL);
	if(result != noErr)
		return 0;

	// calc the number of devices
	numDevices = (size / sizeof(AudioDeviceID));

	// allocate the array of device ids
	deviceIDs = (AudioDeviceID *)gsimalloc(size);
	if(deviceIDs == NULL)
		return 0;

	// get the device ids
	result = AudioHardwareGetProperty(kAudioHardwarePropertyDevices, &size, deviceIDs);
	if(result != noErr)
	{
		gsifree(deviceIDs);
		return 0;
	}

	// fill the array of devices with info
	deviceCount = 0;
	for(i = 0 ; (i < maxDevices) && (deviceCount < numDevices) ; i++)
	{
		// try to add the device to the list
		GVBool addedDevice = gviFillDeviceInfo(deviceIDs[i], &devices[deviceCount], types);

		// check if it was added successfully
		if(addedDevice)
		{
			// check it against the defaults
			defaultTypes = (GVDeviceType)0;
			if(deviceIDs[i] == defaultCaptureDeviceID)
				defaultTypes |= GV_CAPTURE;
			if(deviceIDs[i] == defaultPlaybackDeviceID)
				defaultTypes |= GV_PLAYBACK;
			devices[deviceCount].m_defaultDevice = defaultTypes;

			// increment the count
			deviceCount++;
		}
	}

	// free the array
	gsifree(deviceIDs);

	return deviceCount;
}
JNIEXPORT jint JNICALL Java_com_apple_audio_hardware_AudioHardware_AudioHardwareGetPropertyInfo
  (JNIEnv *, jclass, jint inPropertyID, jint outSize, jint outWritable)
{
	return (jint)AudioHardwareGetPropertyInfo((AudioHardwarePropertyID)inPropertyID, (UInt32 *)outSize, (Boolean *)outWritable);
}