• 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
str2OSType in utils.cpp in ConvertFile example
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

str2OSType in utils.cpp in ConvertFile example


  • Subject: str2OSType in utils.cpp in ConvertFile example
  • From: "William DeShazer" <email@hidden>
  • Date: Wed, 28 Mar 2007 23:27:33 -0400

I am trying to understand one of the CoreAudio examples and I am
really having a hard time. In the utils.cpp file, there is a method
called str2OSType.

void str2OSType (const char * inString, OSType &outType)
{
	if (inString == NULL) {
		outType = 0;
		return;
	}

	size_t len = strlen(inString);
	if (len <= 4) {
		char workingString[5];

		workingString[4] = 0;
		workingString[0] = workingString[1] = workingString[2] =
workingString[3] = ' ';
		memcpy (workingString, inString, strlen(inString));
		outType = 	*(workingString + 0) <<	24	|
					*(workingString + 1) <<	16	|
					*(workingString + 2) <<	8	|
					*(workingString + 3);
		return;
	}

	if (len <= 8) {
		if (sscanf (inString, "%lx", &outType) == 0) {
			printf ("* * Bad conversion for OSType\n");
			UsageString(1);
		}
		return;
	}
	printf ("* * Bad conversion for OSType\n");
	UsageString(1);
}


First, I don't understand the need to convert a 4 byte string into a 4 byte OSType. That being said, where is there any documentation on OSTypes. I found a definition in wikipedia that says that it is a 4 byte sequence used as a File/Directory identifier. However, I can't find anything beyond that. For instance, what are the accepted values for the identifiers? Furthermore, is the type definition in CoreFoundation or does it reside deeper than that? I can't find anything to give me any guidance on this.

Beyond my inability to locate documentation on OSType, I am having a
hard time with the assignment of "outType". I generally don't have an
appreciation for bit mathematics. If inString is a 4 character string
and workingString is a 4 character array, what is the function of the
bit shift and the bit Or? I don't understand what this section of code
is trying to do.

Any guidance would be greatly appreciated.

Thanks,
Will DeShazer
_______________________________________________
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: Re: setting Input property for USB headsets
  • Next by Date: 192000 Hz won't render
  • Previous by thread: Re: setting Input property for USB headsets
  • Next by thread: 192000 Hz won't render
  • Index(es):
    • Date
    • Thread