예제 #1
0
void	HP_Object::Show() const
{
	//  the default implementation is to print the object's ID, class ID and name (if it has one)
	
	//  make a string for the class ID
	char theClassID[] = CA4CCToCString(mClassID);
	
	//  get the object's name
	CAPropertyAddress theAddress(kAudioObjectPropertyName, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster);
	CFStringRef theCFName = NULL;
	UInt32 theSize = sizeof(CFStringRef);
	try
	{
		GetPropertyData(theAddress, 0, NULL, theSize, &theCFName);
	}
	catch(...)
	{
		theCFName = NULL;
	}
	
	//  make a C string out of the name
	char theName[256];
	theName[0] = 0;
	if(theCFName != NULL)
	{
		CFIndex theLength = 0;
		CFRange theRange = { 0, CFStringGetLength(theCFName) };
		CFStringGetBytes(theCFName, theRange, kCFStringEncodingUTF8, 0, false, (UInt8*)theName, 255, &theLength);
		theName[theLength] = 0;
		CFRelease(theCFName);
	}
	
	//  print the information to the standard output
	printf("AudioObjectID:\t\t0x%lX\n\tAudioClassID:\t'%s'\n\tName:\t\t\t%s\n", (long unsigned int)mObjectID, theClassID, theName);
}
예제 #2
0
파일: JARLog.c 프로젝트: briancline/jackosx
void JARPrint4CharCode(const char* msg, long c)
{
    if (JAR_fDebug) {
        unsigned int  __4CC_number = (c);
        char __4CC_string[5] = CA4CCToCString(__4CC_number);
        JARLog("%s'%s'\n", (msg), __4CC_string);
    }
}
	void Control::Show() const
	{
		// Make a string for the class ID
		char classID[] = CA4CCToCString(mClassID);
		
		// Get the object's name
		PropertyAddress address(kCMIOObjectPropertyName, kCMIOObjectPropertyScopeGlobal, kCMIOObjectPropertyElementMaster);
		CFStringRef cfname = NULL;
		UInt32 dataUsed = 0;
		try
		{
			GetPropertyData(address, 0, NULL, sizeof(CFStringRef), dataUsed, &cfname);
		}
		catch(...)
		{
			cfname = NULL;
		}
		
		// Make a C string out of the name
		char name[256];
		name[0] = 0;
		if (cfname != NULL)
		{
			CFIndex length = 0;
			CFRange range = { 0, CFStringGetLength(cfname) };
			CFStringGetBytes(cfname, range, kCFStringEncodingUTF8, 0, false, (UInt8*)name, 255, &length);
			name[length] = 0;
			CFRelease(cfname);
		}
		
		// Get a string for the scope
		const char* scope = NULL;
		switch (GetPropertyScope())
		{
			case kCMIODevicePropertyScopeInput:
				scope = "Input";
				break;
			
			case kCMIODevicePropertyScopeOutput:
				scope = "Output";
				break;
			
			case kCMIODevicePropertyScopePlayThrough:
				scope = "Play Through";
				break;
			
			case kCMIOObjectPropertyScopeGlobal:
			default:
				scope = "Global";
				break;
		};
		
		// Print the information to the standard output
		printf("CMIOObjectID:\t\t0x%lX\n\tCMIOClassID:\t'%s'\n\tName:\t\t\t%s\n\tScope:\t\t\t%s\n\tChannel:\t\t%lu\n", (long unsigned int)mObjectID, classID, name, scope, (long unsigned int)GetPropertyElement());
	}
예제 #4
0
bool	HP_Object::IsSubClass(AudioClassID inClassID, AudioClassID inBaseClassID)
{
	bool theAnswer = false;
	
	switch(inBaseClassID)
	{
		case kAudioObjectClassID:
		{
			//  all classes are subclasses of AudioObject
			theAnswer = true;
		}
		break;
		
		case kAudioControlClassID:
		{
			switch(inClassID)
			{
				case kAudioControlClassID:
				case kAudioLevelControlClassID:
				case kAudioBooleanControlClassID:
				case kAudioSelectorControlClassID:
				case kAudioStereoPanControlClassID:
				case kAudioVolumeControlClassID:
				case kAudioLFEVolumeControlClassID:
				case kAudioBootChimeVolumeControlClassID:
				case kAudioMuteControlClassID:
				case kAudioSoloControlClassID:
				case kAudioJackControlClassID:
				case kAudioLFEMuteControlClassID:
				case kAudioISubOwnerControlClassID:
				case kAudioDataSourceControlClassID:
				case kAudioDataDestinationControlClassID:
				case kAudioClockSourceControlClassID:
				case kAudioLineLevelControlClassID:
				{
					theAnswer = true;
				}
				break;
			};
		}
		break;
		
		case kAudioLevelControlClassID:
		{
			switch(inClassID)
			{
				case kAudioLevelControlClassID:
				case kAudioVolumeControlClassID:
				case kAudioLFEVolumeControlClassID:
				case kAudioBootChimeVolumeControlClassID:
				{
					theAnswer = true;
				}
				break;
			};
		}
		break;
		
		case kAudioBooleanControlClassID:
		{
			switch(inClassID)
			{
				case kAudioBooleanControlClassID:
				case kAudioMuteControlClassID:
				case kAudioSoloControlClassID:
				case kAudioJackControlClassID:
				case kAudioLFEMuteControlClassID:
				case kAudioISubOwnerControlClassID:
				{
					theAnswer = true;
				}
				break;
			};
		}
		break;
		
		case kAudioSelectorControlClassID:
		{
			switch(inClassID)
			{
				case kAudioSelectorControlClassID:
				case kAudioDataSourceControlClassID:
				case kAudioDataDestinationControlClassID:
				case kAudioClockSourceControlClassID:
				case kAudioLineLevelControlClassID:
				{
					theAnswer = true;
				}
				break;
			};
		}
		break;
		
		case kAudioDeviceClassID:
		{
			switch(inClassID)
			{
				case kAudioDeviceClassID:
				case kAudioAggregateDeviceClassID:
				{
					theAnswer = true;
				}
				break;
			};
		}
		break;
		
		//  leaf classes
		case kAudioStereoPanControlClassID:
		case kAudioVolumeControlClassID:
		case kAudioLFEVolumeControlClassID:
		case kAudioBootChimeVolumeControlClassID:
		case kAudioMuteControlClassID:
		case kAudioSoloControlClassID:
		case kAudioJackControlClassID:
		case kAudioLFEMuteControlClassID:
		case kAudioISubOwnerControlClassID:
		case kAudioDataSourceControlClassID:
		case kAudioDataDestinationControlClassID:
		case kAudioClockSourceControlClassID:
		case kAudioLineLevelControlClassID:
		case kAudioSystemObjectClassID:
		case kAudioPlugInClassID:
		case kAudioStreamClassID:
		case kAudioAggregateDeviceClassID:
		case kAudioSubDeviceClassID:
		{
			theAnswer = inClassID == inBaseClassID;
		}
		break;
		
		default:
		{
			#if CoreAudio_Debug
				char theClassIDString[5] = CA4CCToCString(inBaseClassID);
				DebugMessageN1("HP_Object::IsSubClass: unknown base class '%s'", theClassIDString);
			#endif
			theAnswer = inClassID == inBaseClassID;
		}
		break;
		
	};
	
	return theAnswer;
}
예제 #5
0
// static
void    BGMDeviceControlSync::CopyVolume(CAHALAudioDevice inFromDevice, CAHALAudioDevice inToDevice, AudioObjectPropertyScope inScope)
{
    // Get the volume of the from device
    bool didGetFromVolume = false;
    Float32 fromVolume = FLT_MIN;
    
    if(inFromDevice.HasVolumeControl(inScope, kMasterChannel))
    {
        fromVolume = inFromDevice.GetVolumeControlScalarValue(inScope, kMasterChannel);
        didGetFromVolume = true;
    }

    // Use the average channel volume of the from device if it has no master volume
    if(!didGetFromVolume)
    {
        UInt32 fromNumChannels = inFromDevice.GetTotalNumberChannels(inScope == kAudioObjectPropertyScopeInput);
        fromVolume = 0;
        
        for(UInt32 channel = 1; channel <= fromNumChannels; channel++)
        {
            if(inFromDevice.HasVolumeControl(inScope, channel))
            {
                fromVolume += inFromDevice.GetVolumeControlScalarValue(inScope, channel);
                didGetFromVolume = true;
            }
        }
        
        fromVolume /= fromNumChannels;
    }

    // Set the volume of the to device
    if(didGetFromVolume && fromVolume != FLT_MIN)
    {
        bool didSetVolume = false;
        
        try
        {
            didSetVolume = SetMasterVolumeScalar(inToDevice, inScope, fromVolume);
        }
        catch(CAException e)
        {
            OSStatus err = e.GetError();
            char err4CC[5] = CA4CCToCString(err);
            CFStringRef uid = inToDevice.CopyDeviceUID();
            LogWarning("BGMDeviceControlSync::CopyVolume: CAException '%s' trying to set master volume of %s", err4CC, uid);
            CFRelease(uid);
        }

        if(!didSetVolume)
        {
            // Couldn't find a master volume control to set, so try to find a virtual one
            Float32 fromVirtualMasterVolume;
            bool success = GetVirtualMasterVolume(inFromDevice, inScope, fromVirtualMasterVolume);
            if(success)
            {
                didSetVolume = SetVirtualMasterVolume(inToDevice, inScope, fromVirtualMasterVolume);
            }
        }
    
        if(!didSetVolume)
        {
            // Couldn't set a master or virtual master volume, so as a fallback try to set each channel individually
            UInt32 numChannels = inToDevice.GetTotalNumberChannels(inScope == kAudioObjectPropertyScopeInput);
            for(UInt32 channel = 1; channel <= numChannels; channel++)
            {
                if(inToDevice.HasVolumeControl(inScope, channel) && inToDevice.VolumeControlIsSettable(inScope, channel))
                {
                    inToDevice.SetVolumeControlScalarValue(inScope, channel, fromVolume);
                }
            }
        }
    }
}