Esempio n. 1
0
void	SMACscom::GetInfo(SoundSource inSourceID, OSType inSelector, void* outData)
{
	switch(inSelector)
	{
		case siCompressionFactor:
			GetCompressionInfo(*static_cast<CompressionInfo*>(outData));
			break;
		
		case siCompressionParams:
			GetCompressionParams(outData);
			break;

		default:
			ThrowIf(mSourceComponent == NULL, siUnknownInfoType, "SMACscom::GetInfo: no source to pass request to")
			ComponentResult theError = SoundComponentGetInfo(mSourceComponent, inSourceID, inSelector, outData);
			ThrowIfError(theError, (CAException)theError, "SMACscom::GetInfo: got an error from SoundComponentGetInfo");
			break;
	};
}
Esempio n. 2
0
pascal ComponentResult 
__SoundComponentGetInfo( void *dummy, SoundSource sourceID, OSType selector, void *infoPtr ) 
{
	ComponentResult result = noErr;
	SoundInfoListPtr listPtr;
	UnsignedFixed *lp;
	TimeRecord *latency;
	Handle h;
	short *sp;
	int i;
#if DEBUG
	char sel[5];
	sel[4]=0;
	*(long*)&sel = *(long*)&selector;
	lprintf("GetInfo '%s'\n", sel);
#endif

	switch( selector ) {
	case siHardwareVolumeSteps: /* #volume steps */
	case siHeadphoneVolumeSteps:
		*((short*)infoPtr) = 0x100;
		break;

	case siSampleSize: /* return current sample size */
		*((short*)infoPtr) = HW_GLOBAL.sampleSize;
		break;

	case siOutputLatency:
		lprintf("siOuputLatency\n");
		latency = (TimeRecord*)infoPtr;
		if( latency ) {
			latency->value.hi = 0;
			latency->value.lo = 25;		/* sound latency */
			latency->scale = 1000;		/* 1 ms scale */
			latency->base = NULL;
		}
		break;

	case siSampleSizeAvailable: /* return samples sizes available */
		/* space for sample sizes */
		h = NewHandle( sizeof(short) * kSampleSizesCount );
		if( h ) {
			listPtr = (SoundInfoListPtr) infoPtr;
			listPtr->count = 0;
			listPtr->infoHandle = h;

			/* store sample sizes in handle */			
			sp = (short*) *h; 
			for( i=0; i < kSampleSizesCount; i++ ) {
				if( HW_GLOBAL.sampleSizesActive[i]) {
					listPtr->count++;
					*sp++ = HW_GLOBAL.sampleSizes[i];
				}
			}
		} else {
			result = MemError();
		}
		break;
		
	case siSampleRate: /* return current sample rate */
		*((Fixed*)infoPtr) = HW_GLOBAL.sampleRate;
		break;
		
	case siSampleRateAvailable: /* return sample rates available */
		/* space for sample rates */
		if( !(h=NewHandle(sizeof(UnsignedFixed) * kSampleRatesCount)) )
			return MemError();
		listPtr = (SoundInfoListPtr)infoPtr;
		listPtr->count = 0;
		listPtr->infoHandle = h;
			
		lp = (UnsignedFixed*) *h;
			
		/* If the hardware supports a limited set of sample rates, then the list count
		 * should be set to the number of sample rates and this list of rates should be
		 * stored in the handle.
		 */
		for( i=0; i < kSampleRatesCount; i++ ) {
			if( HW_GLOBAL.sampleRatesActive[i] ) {
				listPtr->count++;
				*lp++ = HW_GLOBAL.sampleRates[i];
			}
		}
		break;
		
	case siNumberChannels: /* return current no. channels */
		*((short*)infoPtr) = HW_GLOBAL.numChannels;
		break;
		
	case siChannelAvailable: /* return channels available */
		if( !(h=NewHandle(sizeof(short) * kChannelsCount)) )
			return MemError();
		listPtr = (SoundInfoListPtr)infoPtr;
		listPtr->count = 0;
		listPtr->infoHandle = h;
			
		sp = (short*)*h;
		for( i=0; i < kChannelsCount; ++i ) {
			if( HW_GLOBAL.channelsActive[i]) {
				listPtr->count++;
				*sp++ = HW_GLOBAL.channels[i];
			}
		}
		break;
		
	case siHardwareVolume:
		*((long*)infoPtr) = HW_GLOBAL.volume;
		break;
		
	case siSpeakerVolume:
		*((long*)infoPtr) = HW_GLOBAL.speakerVolume;
		break;
		
	case siHardwareMute:
	case siSpeakerMute:
		*((short*)infoPtr) = HW_GLOBAL.hardwareMute;
		break;

	case siHardwareBusy:
		*((short*)infoPtr) = GLOBAL.hardwareOn;	/* ?? */
		break;
	default: 
#if 0
	{
		char *s[5];
		*(long*)s = selector;
		s[5] = 0;
		lprintf("Unknown selector: '%s'\n", s );
	}
#endif
		/* if you do not handle this selector, then delegate it up the chain */
		result = SoundComponentGetInfo( GLOBAL.sourceComponent, sourceID, selector, infoPtr );
		break;
	}
	return result;
}