string CIncomingFriendList :: GetDescription( ) { string Description; Description += GetAccount( ) + "\n"; Description += ExtractStatus( GetStatus( ) ) + "\n"; Description += ExtractArea( GetArea( ) ) + "\n"; Description += ExtractLocation( GetLocation( ) ) + "\n\n"; return Description; }
/* ========== idAudioHardwareOSX::Reset ========== */ void idAudioHardwareOSX::Reset() { OSStatus status; if( activeIOProc ) { status = AudioDeviceStop( selectedDevice, DeviceIOProc ); if( status != kAudioHardwareNoError ) { common->Warning( "idAudioHardwareOSX::Reset: AudioDeviceStop failed. status: %s", ExtractStatus( status ) ); } status = AudioDeviceRemoveIOProc( selectedDevice, DeviceIOProc ); if( status != kAudioHardwareNoError ) { common->Warning( "idAudioHardwareOSX::Reset: AudioDeviceRemoveIOProc failed. status %s\n", ExtractStatus( status ) ); } activeIOProc = false; } selectedDevice = kAudioDeviceUnknown; AudioHardwareUnload(); }
/* ========== idAudioHardwareOSX::GetAvailableNominalSampleRates ========== */ void idAudioHardwareOSX::GetAvailableNominalSampleRates( void ) { UInt32 size; OSStatus status; int i, rangeCount; AudioValueRange *rangeArray; status = AudioDeviceGetPropertyInfo( selectedDevice, 0, false, kAudioDevicePropertyAvailableNominalSampleRates, &size, NULL ); if ( status != kAudioHardwareNoError ) { common->Warning( "AudioDeviceGetPropertyInfo %d kAudioDevicePropertyAvailableNominalSampleRates failed. status: %s", selectedDevice, ExtractStatus( status ) ); return; } rangeCount = size / sizeof( AudioValueRange ); rangeArray = (AudioValueRange *)malloc( size ); common->Printf( "%d possible rate(s)\n", rangeCount ); status = AudioDeviceGetProperty( selectedDevice, 0, false, kAudioDevicePropertyAvailableNominalSampleRates, &size, rangeArray ); if ( status != kAudioHardwareNoError ) { common->Warning( "AudioDeviceGetProperty %d kAudioDevicePropertyAvailableNominalSampleRates failed. status: %s", selectedDevice, ExtractStatus( status ) ); free( rangeArray ); return; } for( i = 0; i < rangeCount; i++ ) { common->Printf( " %d: min %g max %g\n", i, rangeArray[ i ].mMinimum, rangeArray[ i ].mMaximum ); } free( rangeArray ); }
/* ========== idAudioHardwareOSX::Initialize ========== */ bool idAudioHardwareOSX::Initialize( ) { UInt32 size; OSStatus status; int i, deviceCount; AudioDeviceID *deviceList; char buf[ 1024 ]; status = AudioHardwareGetPropertyInfo( kAudioHardwarePropertyDevices, &size, NULL ); if ( status != kAudioHardwareNoError ) { common->Warning( "AudioHardwareGetPropertyInfo kAudioHardwarePropertyDevices failed. status: %s", ExtractStatus( status ) ); InitFailed(); return false; } deviceCount = size / sizeof( AudioDeviceID ); if ( !deviceCount ) { common->Printf( "No sound device found\n" ); InitFailed(); return false; } deviceList = (AudioDeviceID*)malloc( size ); status = AudioHardwareGetProperty( kAudioHardwarePropertyDevices, &size, deviceList ); if ( status != kAudioHardwareNoError ) { common->Warning( "AudioHardwareGetProperty kAudioHardwarePropertyDevices failed. status: %s", ExtractStatus( status ) ); free( deviceList ); InitFailed(); return false; } common->Printf( "%d sound device(s)\n", deviceCount ); for( i = 0; i < deviceCount; i++ ) { size = 1024; status = AudioDeviceGetProperty( deviceList[ i ], 0, false, kAudioDevicePropertyDeviceName, &size, buf ); if ( status != kAudioHardwareNoError ) { common->Warning( "AudioDeviceGetProperty kAudioDevicePropertyDeviceName %d failed. status: %s", i, ExtractStatus( status ) ); free( deviceList ); InitFailed(); return false; } common->Printf( " %d: ID %d, %s - ", i, deviceList[ i ], buf ); size = 1024; status = AudioDeviceGetProperty( deviceList[ i ], 0, false, kAudioDevicePropertyDeviceManufacturer, &size, buf ); if ( status != kAudioHardwareNoError ) { common->Warning( "AudioDeviceGetProperty kAudioDevicePropertyDeviceManufacturer %d failed. status: %s", i, ExtractStatus( status ) ); free( deviceList ); InitFailed(); return false; } common->Printf( "%s\n", buf ); } if ( s_device.GetInteger() != -1 && s_device.GetInteger() < deviceCount ) { selectedDevice = deviceList[ s_device.GetInteger() ]; common->Printf( "s_device: device ID %d\n", selectedDevice ); } else { size = sizeof( selectedDevice ); status = AudioHardwareGetProperty( kAudioHardwarePropertyDefaultOutputDevice, &size, &selectedDevice ); if ( status != kAudioHardwareNoError ) { common->Warning( "AudioHardwareGetProperty kAudioHardwarePropertyDefaultOutputDevice failed. status: %s", ExtractStatus( status ) ); free( deviceList ); InitFailed(); return false; } common->Printf( "select default device, ID %d\n", selectedDevice ); } free( deviceList ); deviceList = NULL; /* // setup a listener to watch for changes to properties status = AudioDeviceAddPropertyListener( selectedDevice, 0, false, kAudioDeviceProcessorOverload, DeviceListener, this ); if ( status != kAudioHardwareNoError ) { common->Warning( "AudioDeviceAddPropertyListener kAudioDeviceProcessorOverload failed. status: %s", ExtractStatus( status ) ); InitFailed(); return; } */ Float64 sampleRate; size = sizeof( sampleRate ); status = AudioDeviceGetProperty( selectedDevice, 0, false, kAudioDevicePropertyNominalSampleRate, &size, &sampleRate ); if ( status != kAudioHardwareNoError ) { common->Warning( "AudioDeviceGetProperty %d kAudioDevicePropertyNominalSampleRate failed. status: %s", selectedDevice, ExtractStatus( status ) ); InitFailed(); return false; } common->Printf( "current nominal rate: %g\n", sampleRate ); if ( sampleRate != PRIMARYFREQ ) { GetAvailableNominalSampleRates(); sampleRate = PRIMARYFREQ; common->Printf( "setting rate to: %g\n", sampleRate ); status = AudioDeviceSetProperty( selectedDevice, NULL, 0, false, kAudioDevicePropertyNominalSampleRate, size, &sampleRate ); if ( status != kAudioHardwareNoError ) { common->Warning( "AudioDeviceSetProperty %d kAudioDevicePropertyNominalSampleRate %g failed. status: %s", selectedDevice, sampleRate, ExtractStatus( status ) ); InitFailed(); return false; } } UInt32 frameSize; size = sizeof( UInt32 ); status = AudioDeviceGetProperty( selectedDevice, 0, false, kAudioDevicePropertyBufferFrameSize, &size, &frameSize ); if ( status != kAudioHardwareNoError ) { common->Warning( "AudioDeviceGetProperty %d kAudioDevicePropertyBufferFrameSize failed.status: %s", selectedDevice, ExtractStatus( status ) ); InitFailed(); return false; } common->Printf( "current frame size: %d\n", frameSize ); // get the allowed frame size range AudioValueRange frameSizeRange; size = sizeof( AudioValueRange ); status = AudioDeviceGetProperty( selectedDevice, 0, false, kAudioDevicePropertyBufferFrameSizeRange, &size, &frameSizeRange ); if ( status != kAudioHardwareNoError ) { common->Warning( "AudioDeviceGetProperty %d kAudioDevicePropertyBufferFrameSizeRange failed. status: %s", selectedDevice, ExtractStatus( status ) ); InitFailed(); return false; } common->Printf( "frame size allowed range: %g %g\n", frameSizeRange.mMinimum, frameSizeRange.mMaximum ); if ( frameSizeRange.mMaximum < MIXBUFFER_SAMPLES ) { common->Warning( "can't obtain the required frame size of %d bits", MIXBUFFER_SAMPLES ); InitFailed(); return false; } if ( frameSize != (unsigned int)MIXBUFFER_SAMPLES ) { frameSize = MIXBUFFER_SAMPLES; common->Printf( "setting frame size to: %d\n", frameSize ); size = sizeof( frameSize ); status = AudioDeviceSetProperty( selectedDevice, NULL, 0, false, kAudioDevicePropertyBufferFrameSize, size, &frameSize ); if ( status != kAudioHardwareNoError ) { common->Warning( "AudioDeviceSetProperty %d kAudioDevicePropertyBufferFrameSize failed. status: %s", selectedDevice, ExtractStatus( status ) ); InitFailed(); return false; } } if ( idSoundSystemLocal::s_numberOfSpeakers.GetInteger() != 2 ) { common->Warning( "only stereo sound currently supported" ); idSoundSystemLocal::s_numberOfSpeakers.SetInteger( 2 ); } UInt32 channels[ 2 ]; size = 2 * sizeof( UInt32 ); status = AudioDeviceGetProperty( selectedDevice, 0, false, kAudioDevicePropertyPreferredChannelsForStereo, &size, &channels ); if ( status != kAudioHardwareNoError ) { common->Warning( "AudioDeviceGetProperty %d kAudioDevicePropertyPreferredChannelsForStereo failed. status: %s", selectedDevice, ExtractStatus( status ) ); InitFailed(); return false; } common->Printf( "using stereo channel IDs %d %d\n", channels[ 0 ], channels[ 1 ] ); status = AudioDeviceAddIOProc( selectedDevice, DeviceIOProc, NULL ); if ( status != kAudioHardwareNoError ) { common->Warning( "AudioDeviceAddIOProc failed. status: %s", ExtractStatus( status ) ); InitFailed(); return false; } activeIOProc = true; status = AudioDeviceStart( selectedDevice, DeviceIOProc ); if ( status != kAudioHardwareNoError ) { common->Warning( "AudioDeviceStart failed. status: %s", ExtractStatus( status ) ); InitFailed(); return false; } /* // allocate the mix buffer // it has the space for ROOM_SLICES_IN_BUFFER DeviceIOProc loops mixBufferSize = dwSpeakers * dwSampleSize * dwPrimaryBitRate * ROOM_SLICES_IN_BUFFER / 8; mixBuffer = malloc( mixBufferSize ); memset( mixBuffer, 0, mixBufferSize ); */ return true; }