• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
2003332927 error code when getting the channels number property of Build-in Microphone
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

2003332927 error code when getting the channels number property of Build-in Microphone


  • Subject: 2003332927 error code when getting the channels number property of Build-in Microphone
  • From: Anonymous <email@hidden>
  • Date: Fri, 23 Mar 2012 18:20:24 -0500

I was trying to get the audio device channels of my Mac pro. The
build-in microphone was shown an error of  2003332927 which I think it
is kAudioHardwareUnknownPropertyError. Am I right?

The built-in Output has 2 channels, I understand it, but why Built-in
Microphone has error?

I have read and modified the code from the following URL,

"http://developer.apple.com/library/mac/#technotes/tn2112/_index.html";

Your answer is highly appreciated!


//Result

xiaofengmaclap:Debug wolfram$ ./DeviceTest
{{"DeviceID":260,"DeviceName":"Built-in
Microphone",},{"DeviceID":258,"DeviceName":"Built-in
Input",},{"DeviceID":262,"DeviceName":"Built-in Output",}}
Another test

ID:258 0
ID:260 2003332927
ID:262 2
ID:264 560227702


//Code

//"http://developer.apple.com/library/mac/#technotes/tn2112/_index.html";

int GetDesiredRenderChannelCount (AudioDeviceID deviceID)
{
    OSStatus result;;




	UInt32    returnValue=0 ; // return stereo by default


    UInt32 outSize =  sizeof(deviceID);


	//	kAudioHardwareUnknownPropertyError


    //Get the users speaker configuration
	result = AudioDeviceGetPropertyInfo(deviceID,
										0,
										false,
										kAudioDevicePropertyPreferredChannelLayout,
										&outSize,
										NULL);




    if (result)
    {
		    return (result); // return default (stereo)

	//	printf("%d",result);

	}



    AudioChannelLayout    *layout = NULL;
    layout = (AudioChannelLayout *) calloc(1, outSize);





	if (layout != NULL)
    {
        result = AudioDeviceGetProperty(deviceID,
											0,
											false,
											kAudioDevicePropertyPreferredChannelLayout,
											&outSize,
											layout
									   );



        if (layout->mChannelLayoutTag ==
kAudioChannelLayoutTag_UseChannelDescriptions)
        {
			// no channel layout tag is returned,
			//so walk through the channel descriptions and count
			// the channels that are associated with a speaker





			if (layout->mNumberChannelDescriptions == 2)
			{
                returnValue = 2; // there is no channel info for stereo




			}

			else
			{
				returnValue = 0;

				for (UInt32 i = 0; i < layout->mNumberChannelDescriptions; i++)
				{
					if (layout->mChannelDescriptions[i].mChannelLabel !=
kAudioChannelLabel_Unknown)
						returnValue++;
                }


            }
        }



        else
        {



            switch (layout->mChannelLayoutTag)
            {
                case kAudioChannelLayoutTag_AudioUnit_5_0:
                case kAudioChannelLayoutTag_AudioUnit_5_1:
                case kAudioChannelLayoutTag_AudioUnit_6:
                    returnValue = 5;
                    break;
                case kAudioChannelLayoutTag_AudioUnit_4:
                    returnValue = 4;
                default:
                    returnValue = 2;
            }
        }

        free(layout);
    }


	return returnValue;
	//return result;
}




int main(void)
{
	getDeviceInfo();
	puts("Another test\n");
	int num=0;



	GetDesiredRenderChannelCount(258);
      printf("ID:258 %d\n",num);

	num=GetDesiredRenderChannelCount(260);
    printf("ID:260 %d\n",num);



	num=GetDesiredRenderChannelCount(262);
    printf("ID:262 %d\n",num);



    num=GetDesiredRenderChannelCount(264);
     printf("ID:264 %d\n",num);

}



--
Xiaofeng Li
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: AudioQueueSetProperty Channel Layout
  • Next by Date: simplest way to send buffers to hardware on a mac?
  • Previous by thread: AudioQueueSetProperty Channel Layout
  • Next by thread: simplest way to send buffers to hardware on a mac?
  • Index(es):
    • Date
    • Thread