Exemple #1
0
	bool CheckControllerLibrary(FULogFile& fileOut, FCDControllerLibrary* library)
	{
		FailIf(library == NULL);

		FCDController* morpher = NULL,* skin = NULL;
		for (size_t i = 0; i < library->GetEntityCount(); ++i)
		{
			FCDController* c = library->GetEntity(i);
			if (c->IsMorph()) { PassIf(morpher == NULL); morpher = c; }
			else if (c->IsSkin()) { PassIf(skin == NULL); skin = c; }
			else Fail;
		}
		PassIf(morpher != NULL && skin != NULL);

		// Check the morpher
		FailIf(morpher->IsSkin());
		PassIf(morpher->IsMorph());
		PassIf(morpher->GetMorphController() != NULL);
		PassIf(CheckControllerMorph(fileOut, morpher->GetMorphController()));

		// Check the skin
		PassIf(skin->GetSkinController() != NULL);
		//FailIf(skin->HasMorphController());
		FailIf(skin->IsMorph());
		PassIf(skin->GetNote() == FC("A nicey skinny controller. "));
		PassIf(CheckControllerSkin(fileOut, skin->GetSkinController()));
		return true;
	}
Exemple #2
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//  This method is invoked from the 'codecErrorInterruptHandler' residing in the
//  platform interface object.  The 'codecErrorInterruptHandler' may be invoked
//  through GPIO hardware interrupt dispatch services or throught timer polled
//  services.
void AppleTopazAudio::notifyHardwareEvent ( UInt32 statusSelector, UInt32 newValue )
{
	UInt8					saveMAP = 0;
	
	switch ( mCodecID ) {
		case kCodec_CS8406:		debugIOLog ( 5,  "+ AppleTopazAudio::notifyHardwareEvent ( %d, %d ) using AppleTopazPluginCS8406", statusSelector, newValue );		break;
		case kCodec_CS8416:		debugIOLog ( 5,  "+ AppleTopazAudio::notifyHardwareEvent ( %d, %d ) using AppleTopazPluginCS8416", statusSelector, newValue );		break;
		case kCodec_CS8420:		debugIOLog ( 5,  "+ AppleTopazAudio::notifyHardwareEvent ( %d, %d ) using AppleTopazPluginCS8420", statusSelector, newValue );		break;
		default:				debugIOLog ( 5,  "+ AppleTopazAudio::notifyHardwareEvent ( %d, %d ) using AppleTopazPluginUNKNOWN", statusSelector, newValue );		break;
	}
	
	FailIf ( NULL == mTopazPlugin, Exit );
	FailIf ( NULL == mAudioDeviceProvider, Exit );
	FailIf ( NULL == mPlatformInterface, Exit );

	saveMAP = (UInt8)mPlatformInterface->getSavedMAP ( mCodecID );	//  Preserve illusion of atomic I2C register access outside of this interrupt handler
	
	//  [3629501]   If there is a digital input detect (either a dedicated detect or a combo jack detect) then indicate 'Unlock' when the detect 
	//	indicates that the digital plug is removed.  If no digital input is located then the initial digital detect status that was written to 
	//	the 'mDigitalInStatus' member variable, which indicates that a device is connected to the digital input, will be used.  NOTE:  The digital 
	//	input detect may not be associated with this AppleOnboardAudio instance.  It is necessary to receive notifications from the AppleOnboardAudio 
	//	object of the current digital input detect status and the source of these messages may be from a broadcast message conveyed from
	//  another AppleOnboardAudio instance!
	
	if ( kDigitalInStatus == statusSelector )
	{
		mDigitalInStatus = newValue;
		debugIOLog ( 6, "  AppleTopazAudio::notifyHardwareEvent ( %d, %d ) updates mDigitalInStatus to %d", statusSelector, newValue, mDigitalInStatus );
	}
	
	if ( ( kCodecErrorInterruptStatus == statusSelector ) || ( kCodecInterruptStatus == statusSelector ) )
	{
		if ( kGPIO_Disconnected == mDigitalInStatus )
		{
			//	Override the CODEC status if the detect indicates that nothing is connected.
			mAudioDeviceProvider->interruptEventHandler ( kClockUnLockStatus, (UInt32)0 );
		}
		else
		{
			mTopazPlugin->notifyHardwareEvent ( statusSelector, newValue );
		}
	}

	if ( saveMAP != (UInt8)mPlatformInterface->getSavedMAP ( mCodecID ) )
	{
		mPlatformInterface->setMAP ( mCodecID, saveMAP );
	}
Exit:
	switch ( mCodecID )
	{
		case kCodec_CS8406:		debugIOLog ( 5,  "- AppleTopazAudio::notifyHardwareEvent ( %d, %d ) using AppleTopazPluginCS8406", statusSelector, newValue );		break;
		case kCodec_CS8416:		debugIOLog ( 5,  "- AppleTopazAudio::notifyHardwareEvent ( %d, %d ) using AppleTopazPluginCS8416", statusSelector, newValue );		break;
		case kCodec_CS8420:		debugIOLog ( 5,  "- AppleTopazAudio::notifyHardwareEvent ( %d, %d ) using AppleTopazPluginCS8420", statusSelector, newValue );		break;
		default:				debugIOLog ( 5,  "- AppleTopazAudio::notifyHardwareEvent ( %d, %d ) using AppleTopazPluginUNKNOWN", statusSelector, newValue );		break;
	}
	return;
}
Exemple #3
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
IOReturn	AppleTopazPluginCS8420::makeClockSelectPreLock ( UInt32 clockSource ) {
    IOReturn			result;
    UInt8				data;

    debugIOLog (5,  "+ AppleTopazPluginCS8420::makeClockSelect ( %d )", (unsigned int)clockSource );

    //	Clear any pending error interrupt status and re-enable error interrupts after completing clock source selection
    result = CODEC_ReadRegister ( map_CS8420_RX_ERROR, &data, 1 );
    FailIf ( kIOReturnSuccess != result, Exit );

    //	Enable error (i.e. RERR) interrupts ONLY IF C28420 IS CLOCK MASTER
    if ( kTRANSPORT_SLAVE_CLOCK == clockSource ) {
        result = CODEC_WriteRegister ( map_CS8420_RX_ERROR_MASK, kCS8420_RX_ERROR_MASK_ENABLE_RERR );
        FailIf ( kIOReturnSuccess != result, Exit );
    }

    switch ( clockSource ) {
    case kTRANSPORT_MASTER_CLOCK:
        data = mShadowRegs[map_CS8420_DATA_FLOW_CTRL];
        data &= ~( bvCS8420_spdMASK << baCS8420_SPD );
        data |= ( bvCS8420_spdSrcOut << baCS8420_SPD );
        result = CODEC_WriteRegister ( map_CS8420_DATA_FLOW_CTRL, data );

        data = mShadowRegs[map_CS8420_CLOCK_SOURCE_CTRL];
        data &= ~( 1 << baCS8420_OUTC );
        data |= ( bvCS8420_outcOmckXbaCLK << baCS8420_OUTC );
        result = CODEC_WriteRegister ( map_CS8420_CLOCK_SOURCE_CTRL, data );
        break;
    case kTRANSPORT_SLAVE_CLOCK:
        data = mShadowRegs[map_CS8420_DATA_FLOW_CTRL];
        data &= ~( bvCS8420_spdMASK << baCS8420_SPD );
        data |= ( bvCS8420_spdAES3 << baCS8420_SPD );
        result = CODEC_WriteRegister ( map_CS8420_DATA_FLOW_CTRL, data );

        data = mShadowRegs[map_CS8420_CLOCK_SOURCE_CTRL];
        data &= ~( 1 << baCS8420_OUTC );
        data |= ( bvCS8420_outcRecIC << baCS8420_OUTC );
        result = CODEC_WriteRegister ( map_CS8420_CLOCK_SOURCE_CTRL, data );
        break;
    }

    //	restart the codec after switching clocks
    data = mShadowRegs[map_CS8420_CLOCK_SOURCE_CTRL];
    data &= ~( 1 << baCS8420_RUN );
    data |= ( bvCS8420_runNORMAL << baCS8420_RUN );
    result = CODEC_WriteRegister ( map_CS8420_CLOCK_SOURCE_CTRL, data );

    setChannelStatus ( &mChanStatusStruct );		//  [3669626]   Flush channel status buffer

Exit:
    debugIOLog (5,  "- AppleTopazPluginCS8420::makeClockSelect ( %d ) returns %d", (unsigned int)clockSource, (unsigned int)result );

    return result;
}
Exemple #4
0
//	------------------------------------------------------------------------------------------------------------------------------------
//	Switching bewteen a system mastered clock and an external clock, such as a recovered clock from an S/PDIF AES3 stream, requires a 
//	"BREAK BEFORE MAKE" sequence to avoid having two hardware drivers connected together.  If selecting the master clock then the 
//	external MUX must be disconnected prior to enabling the system master clock.  If selecting an external MUX clock source then the 
//	internal system master clock must be disconnected first.  Sequences are:
//
//	TRANSITION						CYCLE					ACTION
//	----------------------------|-----------------------|-------------------------------------------------------------------------------
//	kTRANSPORT_MASTER_CLOCK to	|	1 Transport Break	|	Set MUX to alternate clock source, set I2S to SLAVE (BCLKMaster = SLAVE).
//	kTRANSPORT_SLAVE_CLOCK		|	2 Topaz Break		|	Stop CS84xx & mute TX.  Set all registers to act as a clock master.
//								|						|	A.	Data Flow Control Register:		TXD = 01, SPD = 10, SRCD = 0
//								|						|	B.	Clock Source Control Register:	OUTC = 1, INC = 0, RXD = 01
//								|						|	C.	Serial Input Control Register:	SIMS = 0
//								|						|	D.	Serial Output Control Register:	SOMS = 1
//								|	3 TAS3004 Break		|	No Action.
//								|	4 Transport Make	|	No Action.
//								|	5 Topaz Make		|	Start CS84xx.  Send request to restart transport hardware.
//								|	6 TAS3004 Make		|	Reset and flush register cache to hardware.
//	----------------------------|-----------------------|-------------------------------------------------------------------------------
//	kTRANSPORT_SLAVE_CLOCK to	|	1 Transport Break	|	No Action.
//	kTRANSPORT_MASTER_CLOCK		|	2 Topaz Break		|	Stop CS84xx & disable TX.  Set all registers to act as a clock slave.
//								|						|	A.	Data Flow Control Register:		TXD = 01, SPD = 00, SRCD = 1
//								|						|	B.	Clock Source Control Register:	OUTC = 0, INC = 0, RXD = 01
//								|						|	C.	Serial Input Control Register:	SIMS = 0
//								|						|	D.	Serial Output Control Register:	SOMS = 0
//								|	3 TAS3004 Break		|	No Action.
//								|	4 Transport Make	|	Set MUX to default clock source, set I2S to SLAVE (BCLKMaster = MASTER).
//								|	5 Topaz Make		|	Start CS84xx & unmute TX.  Send request to restart transport hardware.
//								|						|	A.	Clear pending receiver errors.
//								|						|	B.	Enable receiver errors.
//								|						|	C.	Set CS8420 to RUN.
//								|						|	D.	Request a restart of the I2S transport.
//								|	6 TAS3004 Make		|	Reset and flush register cache to hardware.
//	----------------------------|-----------------------|-------------------------------------------------------------------------------
IOReturn	AppleTopazAudio::makeClockSelect ( UInt32 clockSource ) {
	IOReturn			result = kIOReturnError;
	
	switch ( mCodecID ) {
		case kCodec_CS8406:		debugIOLog ( 5,  "+ AppleTopazAudio::makeClockSelect ( %d ) using AppleTopazPluginCS8406", (unsigned int)clockSource );		break;
		case kCodec_CS8416:		debugIOLog ( 5,  "+ AppleTopazAudio::makeClockSelect ( %d ) using AppleTopazPluginCS8416", (unsigned int)clockSource );		break;
		case kCodec_CS8420:		debugIOLog ( 5,  "+ AppleTopazAudio::makeClockSelect ( %d ) using AppleTopazPluginCS8420", (unsigned int)clockSource );		break;
		default:				debugIOLog ( 5,  "+ AppleTopazAudio::makeClockSelect ( %d ) using AppleTopazPluginUNKNOWN", (unsigned int)clockSource );	break;
	}

	FailIf ( NULL == mTopazPlugin, Exit );
	FailIf ( NULL == mAudioDeviceProvider, Exit );
	result = mTopazPlugin->makeClockSelectPreLock ( clockSource ); 
	
	if ( kTRANSPORT_SLAVE_CLOCK == clockSource && mTopazPlugin->supportsDigitalInput() ) {
		//	It is necessary to restart the I2S cell here after the clocks have been
		//	established using the CS8420 as the clock source.  Ask AOA to restart
		//	the I2S cell.  This is only done if the CODEC can provide a clock source
		//  and should not be done if the CODEC is an output only device such as the CS8406.
		debugIOLog ( 4, "  *** AppleTopazAudio::makeClockSelect about to post kRestartTransport request" );
		mAudioDeviceProvider->interruptEventHandler ( kRestartTransport, (UInt32)0 );
		// [3253678], set flag to broadcast lock success to AOA so it can unmute analog part
		mAttemptingExternalLock = true;
	}
	
	result = mTopazPlugin->makeClockSelectPostLock ( clockSource ); 
	mUnlockErrorCount = 0;

	if ( kTRANSPORT_MASTER_CLOCK == clockSource && mTopazPlugin->supportsDigitalInput() ) {
		if ( mUnlockStatus ) {
			mUnlockStatus = false;
		}
		
		if ( false == mDisableStateMachine2 ) {
			mCurrentMachine2State = kMachine2_startState;
		}
		else {
			mCurrentMachine2State = kMachine2_idleState;
		}
	}
	
	mClockSource = clockSource;
	
Exit:
	mUnlockErrorCount = 0;
	switch ( mCodecID ) {
		case kCodec_CS8406:		debugIOLog ( 5,  "- AppleTopazAudio::makeClockSelect ( %d ) using AppleTopazPluginCS8406 returns %lX", (unsigned int)clockSource, (unsigned int)result );		break;
		case kCodec_CS8416:		debugIOLog ( 5,  "- AppleTopazAudio::makeClockSelect ( %d ) using AppleTopazPluginCS8416 returns %lX", (unsigned int)clockSource, (unsigned int)result );		break;
		case kCodec_CS8420:		debugIOLog ( 5,  "- AppleTopazAudio::makeClockSelect ( %d ) using AppleTopazPluginCS8420 returns %lX", (unsigned int)clockSource, (unsigned int)result );		break;
		default:				debugIOLog ( 5,  "- AppleTopazAudio::makeClockSelect ( %d ) using AppleTopazPluginUNKNOWN returns %lX", (unsigned int)clockSource, (unsigned int)result );		break;
	}

	return result;
}
Exemple #5
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
UInt8 	AppleTopazAudio::CODEC_ReadID ( void ) {
	UInt8			result = 0;

	debugIOLog ( 5, "+ AppleTopazAudio::CODEC_ReadID ()" );

	FailIf ( NULL == mPlatformInterface, Exit );
	//	The codec reference in the following dispatch can be ambiguous because the CS8406, CS8416 or CS8420 all
	//	share the same address assignment relative to the I2S I/O Module that is connected to the CODEC.
	FailIf ( kIOReturnSuccess != mPlatformInterface->readCodecRegister ( kCodec_CS8420, map_ID_VERSION, &result, 1 ), Exit );
	
Exit:	
	debugIOLog ( 5, "- AppleTopazAudio::CODEC_ReadID () returns 0x%2X", result );
	return result;
}
Exemple #6
0
	bool CheckGeometryMesh(FULogFile& fileOut, FCDGeometryMesh* mesh)
	{
		// Verify the mesh and its sources
		PassIf(mesh->GetSourceCount() == 3);
		FCDGeometrySource* posSource = NULL,* colorSource = NULL,* dummySource = NULL;
		for (size_t i = 0; i < 3; ++i)
		{
			FCDGeometrySource* source = mesh->GetSource(i);
			FailIf(source == NULL);
			switch (source->GetType())
			{
			case FUDaeGeometryInput::POSITION: posSource = source; PassIf(source->GetName() == FC("TestPositionSource")); break;
			case FUDaeGeometryInput::COLOR: colorSource = source; PassIf(source->GetName() == FC("TestColorSource")); break;
			case FUDaeGeometryInput::EXTRA: dummySource = source; PassIf(source->GetName() == FC("TestDummySource")); break;
			default: Fail; break;
			}
		}
		FailIf(posSource == NULL || colorSource == NULL || dummySource == NULL);
		PassIf(IsEquivalent(posSource->GetData(), posSource->GetDataCount(), positionData, 12));
		PassIf(posSource->GetStride() == 3);
		PassIf(IsEquivalent(colorSource->GetData(), colorSource->GetDataCount(), colorData, 12));
		PassIf(colorSource->GetStride() == 4);
		PassIf(IsEquivalent(dummySource->GetData(), dummySource->GetDataCount(), dummyData, 10));
		PassIf(dummySource->GetStride() == 3);
		PassIf(CheckExtraTree(fileOut, dummySource->GetExtra(), false));

		// Find the non-empty polygon set and verify that one of the polygon set is, in fact, empty.
		FCDGeometryPolygons* polys1 = NULL,* polysEmpty = NULL;
		for (size_t i = 0; i < mesh->GetPolygonsCount(); ++i)
		{
			FCDGeometryPolygons* p = mesh->GetPolygons(i);
			if (p->GetFaceCount() == 0) { PassIf(polysEmpty == NULL); polysEmpty = p; }
			else { PassIf(polys1 == NULL); polys1 = p; }

			CheckExtraTree(fileOut, p->GetExtra(), true);
		}
		PassIf(polys1 != NULL && polysEmpty != NULL);

		// Check that we have the wanted tetrahedron in the non-empty polygon set.
		PassIf(polys1->GetFaceCount() == 4);
		PassIf(polys1->GetHoleCount() == 0);
		PassIf(polys1->GetFaceVertexCount(0) == 3 && polys1->GetFaceVertexCount(1) == 3 && polys1->GetFaceVertexCount(2) == 3 && polys1->GetFaceVertexCount(3) == 3);
		FCDGeometryPolygonsInput* posInput = polys1->FindInput(posSource);
		FailIf(posInput == NULL || posInput->GetIndexCount() != 12);
		FCDGeometryPolygonsInput* colorInput = polys1->FindInput(colorSource);
		FailIf(colorInput == NULL || colorInput == posInput || colorInput->GetIndexCount() != 12);
		PassIf(IsEquivalent(posInput->GetIndices(), 12, positionIndices, 12));
		PassIf(IsEquivalent(colorInput->GetIndices(), 12, colorIndices, 12));
		return true;
	}
Exemple #7
0
OSStatus LoadSMF(const char *filename, MusicSequence& sequence, MusicSequenceLoadFlags loadFlags)
{
	OSStatus result = noErr;
    CFURLRef url = NULL;
	
	FailIf ((result = NewMusicSequence(&sequence)), home, "NewMusicSequence");
	
	url = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault, (const UInt8*)filename, strlen(filename), false);
	
	FailIf ((result = MusicSequenceFileLoad (sequence, url, 0, loadFlags)), home, "MusicSequenceFileLoad");
	
home:
    if (url) CFRelease(url);
	return result;
}
Exemple #8
0
int main(int argc, char *argv[])
{
    ar_stream *stream = NULL;
    ar_archive *ar = NULL;
    int entry_count = 1;
    int entry_skips = 0;
    int error_step = 1;

#if !defined(NDEBUG) && defined(_MSC_VER)
    if (!IsDebuggerPresent()) {
        _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
        _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
    }
    _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
#endif

    FailIf(argc != 2, "Syntax: %s <filename.ext>", argv[0]);

    stream = ar_open_file(argv[1]);
    FailIf(!stream, "Error: File \"%s\" not found!", argv[1]);

    printf("Parsing \"%s\":\n", argv[1]);
    ar = ar_open_any_archive(stream, strrchr(argv[1], '.'));
    FailIf(!ar, "Error: No valid %s archive!", "RAR, ZIP, 7Z or TAR");

    while (ar_parse_entry(ar)) {
        size_t size = ar_entry_get_size(ar);
        printf("%02d. %s (@%" PRIi64 ")\n", entry_count++, ar_entry_get_name(ar), ar_entry_get_offset(ar));
        while (size > 0) {
            unsigned char buffer[1024];
            size_t count = size < sizeof(buffer) ? size : sizeof(buffer);
            if (!ar_entry_uncompress(ar, buffer, count))
                break;
            size -= count;
        }
        if (size > 0) {
            fprintf(stderr, "Warning: Failed to uncompress... skipping\n");
            entry_skips++;
        }
    }
    FailIf(!ar_at_eof(ar), "Error: Failed to parse entry %d!", entry_count);
    error_step = entry_skips > 0 ? 1000 + entry_skips : 0;

CleanUp:
    ar_close_archive(ar);
    ar_close(stream);
    return error_step;
}
Exemple #9
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
IOReturn	AppleTopazPluginCS8420::setPluginState ( HardwarePluginDescriptorPtr inState ) {
    IOReturn		result = kIOReturnBadArgument;

    FailIf ( NULL == inState, Exit );
    FailIf ( sizeof ( mShadowRegs ) != inState->registerCacheSize, Exit );
    result = kIOReturnSuccess;
    for ( UInt32 registerAddress = map_CS8420_MISC_CNTRL_1; ( registerAddress < map_ID_VERSION ) && ( kIOReturnSuccess == result ); registerAddress++ ) {
        if ( inState->registerCache[registerAddress] != mShadowRegs[registerAddress] ) {
            if ( kIOReturnSuccess == CODEC_IsControlRegister ( (UInt8)registerAddress ) ) {
                result = CODEC_WriteRegister ( registerAddress, inState->registerCache[registerAddress] );
            }
        }
    }
Exit:
    return result;
}
Exemple #10
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
IOReturn	AppleTopazAudio::setSampleDepth ( UInt32 sampleDepth ) {
	IOReturn		result = kIOReturnBadArgument;
	
	switch ( mCodecID ) {
		case kCodec_CS8406:		debugIOLog ( 5,  "+ AppleTopazAudio::setSampleDepth ( %ld ) using AppleTopazPluginCS8406", sampleDepth );		break;
		case kCodec_CS8416:		debugIOLog ( 5,  "+ AppleTopazAudio::setSampleDepth ( %ld ) using AppleTopazPluginCS8416", sampleDepth );		break;
		case kCodec_CS8420:		debugIOLog ( 5,  "+ AppleTopazAudio::setSampleDepth ( %ld ) using AppleTopazPluginCS8420", sampleDepth );		break;
		default:				debugIOLog ( 5,  "+ AppleTopazAudio::setSampleDepth ( %ld ) using AppleTopazPluginUNKNOWN", sampleDepth );		break;
	}
	
	FailIf ( !( 16 == sampleDepth || 24 == sampleDepth ), Exit );
	//	Avoid general recovery when running on external clock as a reset
	//	will set the clocks back to internal.  Just indicate if the bit
	//	depth is valid so that AppleOnboardAudio's poll method that validates
	//	sample rate changes can operate correctly but leave the hardware alone!
	if ( kTRANSPORT_MASTER_CLOCK == mClockSource ) {
		generalRecovery();
	}
	
	mChannelStatus.sampleDepth = sampleDepth;
	
	if ( 0 != mTopazPlugin ) { 
		result = mTopazPlugin->setChannelStatus ( &mChannelStatus ); 
	}
	
Exit:
	switch ( mCodecID ) {
		case kCodec_CS8406:		debugIOLog ( 5,  "- AppleTopazAudio::setSampleDepth ( %ld ) using AppleTopazPluginCS8406", sampleDepth );		break;
		case kCodec_CS8416:		debugIOLog ( 5,  "- AppleTopazAudio::setSampleDepth ( %ld ) using AppleTopazPluginCS8416", sampleDepth );		break;
		case kCodec_CS8420:		debugIOLog ( 5,  "- AppleTopazAudio::setSampleDepth ( %ld ) using AppleTopazPluginCS8420", sampleDepth );		break;
		default:				debugIOLog ( 5,  "- AppleTopazAudio::setSampleDepth ( %ld ) using AppleTopazPluginUNKNOWN", sampleDepth );		break;
	}
	return result;
}
Exemple #11
0
ERR PKImageDecode_Copy_BMP(
    PKTestDecode* pID,
    const PKRect* pRect,
    U8* pb,
    U32 cbStride)
{
    ERR err = WMP_errSuccess;

    struct WMPStream* pS = pID->pStream;

    size_t cbLineS = (pID->EXT.BMP.cbPixel * pID->uWidth + 3) / 4 * 4;
    size_t cbLineM = pID->EXT.BMP.cbPixel * pRect->Width;
    
    I32 i = 0;

    //FailIf(pRect->X < 0 || pID->uWidth <= pRect->X, WMP_errInvalidParameter);
    //FailIf(pRect->Y < 0 || pID->uHeight <= pRect->Y, WMP_errInvalidParameter);
    //FailIf(pRect->Width < 0 || pID->uWidth < pRect->X + pRect->Width, WMP_errInvalidParameter);
    //FailIf(pRect->Height < 0 || pID->uHeight < pRect->Y + pRect->Height, WMP_errInvalidParameter);
    FailIf(cbStride < cbLineM, WMP_errInvalidParameter);

    for (i = pRect->Y + pRect->Height - 1; pRect->Y <= i; --i)
    {
        size_t offLine = pID->EXT.BMP.cbPixel * pRect->X;
        size_t offS = cbLineS * (pID->uHeight - i - 1) + offLine;
        size_t offM = cbStride * (i - pRect->Y) + offLine;

        Call(pS->SetPos(pS, pID->EXT.BMP.offPixel + offS));
        Call(pS->Read(pS, pb + offM, cbLineM));
    }

Cleanup:
    return err;
}
Exemple #12
0
//================================================
ERR PKImageDecode_Initialize_WMP(
    PKImageDecode* pID,
    struct WMPStream* pWS)
{
    ERR err = WMP_errSuccess;

    CWMImageInfo* pII = NULL;

    //================================
    Call(PKImageDecode_Initialize(pID, pWS));

    //================================
    Call(ReadContainer(pID));

    //================================
    pID->WMP.wmiSCP.pWStream = pWS;

    FailIf(ICERR_OK != ImageStrDecGetInfo(&pID->WMP.wmiI, &pID->WMP.wmiSCP), WMP_errFail);
    assert(Y_ONLY <= pID->WMP.wmiSCP.cfColorFormat && pID->WMP.wmiSCP.cfColorFormat < CFT_MAX);
    assert(BD_SHORT == pID->WMP.wmiSCP.bdBitDepth || BD_LONG == pID->WMP.wmiSCP.bdBitDepth);

    pII = &pID->WMP.wmiI;
    pID->uWidth = (U32)pII->cWidth;
    pID->uHeight = (U32)pII->cHeight;

Cleanup:
    return err;
}
Exemple #13
0
ERR PKImageEncode_Transcode_WMP(
    PKImageEncode* pIE,
    PKImageDecode* pID,
    CWMTranscodingParam* pParam)
{
    ERR err = WMP_errSuccess;
    Float fResX = 0, fResY = 0;
    PKPixelFormatGUID pixGUID = {0};

    struct WMPStream* pWSDec = NULL;
    struct WMPStream* pWSEnc= pIE->pStream;

    // pass through metadata
    Call(pID->GetPixelFormat(pID, &pixGUID));
    Call(pIE->SetPixelFormat(pIE, pixGUID));

    Call(pIE->SetSize(pIE, (I32)pParam->cWidth, (I32)pParam->cHeight));

    Call(pID->GetResolution(pID, &fResX, &fResY));
    Call(pIE->SetResolution(pIE, fResX, fResY));

    // write matadata
    Call(WriteContainerPre(pIE));

    // write compressed bitstream
    Call(pID->GetRawStream(pID, &pWSDec));
    FailIf(ICERR_OK != WMPhotoTranscode(pWSDec, pWSEnc, pParam), WMP_errFail);

    // fixup matadata
    Call(WriteContainerPost(pIE));

Cleanup:
    return err;
}
Exemple #14
0
ERR PKTestFactory_CreateDecoderFromFile(const char* szFilename, PKImageDecode** ppDecoder)
{
    ERR err = WMP_errSuccess;

    char *pExt = NULL;
    PKIID* pIID = NULL;

    struct WMPStream* pStream = NULL;
    PKImageDecode* pDecoder = NULL;

    // get file extension
    pExt = strrchr(szFilename, '.');
    FailIf(NULL == pExt, WMP_errUnsupportedFormat);

    // get decode PKIID
    Call(GetTestDecodeIID(pExt, &pIID));

    // create stream
    Call(CreateWS_File(&pStream, szFilename, "rb"));

    // Create decoder
    Call(PKTestFactory_CreateCodec(pIID, ppDecoder));
    pDecoder = *ppDecoder;

    // attach stream to decoder
    Call(pDecoder->Initialize(pDecoder, pStream));
    pDecoder->fStreamOwner = !0;

Cleanup:
    return err;
}
Exemple #15
0
//================================================================
// PKImageDecode_HDR
//================================================================
ERR ParseHDRHeader(
    PKTestDecode* pID,
    struct WMPStream* pWS)
{
    ERR err = WMP_errSuccess;

    char txtbuff[512];
    Bool done = FALSE;

    FailIf(NULL == fgets(txtbuff, 12, pWS->state.file.pFile), WMP_errUnsupportedFormat);
    FailIf(0 != strcmp(txtbuff, "#?RADIANCE\n"), WMP_errUnsupportedFormat);

    // Read lines to image size
    while (!done) {
        FailIf(NULL == fgets(txtbuff, 512, pWS->state.file.pFile), WMP_errUnsupportedFormat);

        if (0 == strncmp(txtbuff, "FORMAT", 6)) {
            FailIf(0 != strcmp(txtbuff, "FORMAT=32-bit_rle_rgbe\n"), WMP_errUnsupportedFormat);
        }
        if (0 == strncmp(txtbuff, "-Y", 2)) {
            sscanf(txtbuff, "-Y %d +X %d\n", &pID->uHeight, &pID->uWidth);
            done = TRUE;
        }
      }

    Call(pWS->Read(pWS, txtbuff, 3));

    if(((2 == txtbuff[0]) && (2 == txtbuff[1]) && (0 == (txtbuff[2] & 0x80))) ||
       ((1 == txtbuff[0]) && (1 == txtbuff[1]) && (1 == txtbuff[2])))
    {
        printf("Doesn't support compressed HDR files.\n");
        err = WMP_errUnsupportedFormat;
        goto Cleanup;
    }

    // Set header other header parameters
    pID->guidPixFormat = GUID_PKPixelFormat32bppRGBE;
    pID->EXT.HDR.cbPixel = 4; 
    // Set pointer to first pixel
    Call(pWS->GetPos(pWS, &pID->EXT.HDR.offPixel));
    pID->EXT.HDR.offPixel -= 3;
    Call(pWS->SetPos(pWS, pID->EXT.HDR.offPixel));

    // We don't need: pID->fResX and pID->fResY
Cleanup:
    return err;
}
Exemple #16
0
	bool CheckControllerSkin(FULogFile& fileOut, FCDSkinController* controller)
	{
		FailIf(controller == NULL);

		// Check the base target's identity
		FailIf(controller->GetTarget() == NULL);
		PassIf(controller->GetTarget()->GetType() == FCDEntity::GEOMETRY);
		PassIf(controller->GetTarget()->GetDaeId() == meshId);

		// Retrieve the two joints and verify their ids/bind-pose.
		PassIf(controller->GetJointCount() == 2);
		const FMMatrix44* joint1 = NULL,* joint2 = NULL;
		for (size_t i = 0; i < 2; ++i)
		{
			FCDSkinControllerJoint* joint = controller->GetJoint(i);
			if (joint->GetId() == jointId1) { FailIf(joint1 != NULL); joint1 = &joint->GetBindPoseInverse(); }
			else if (joint->GetId() == jointId2) { FailIf(joint2 != NULL); joint2 = &joint->GetBindPoseInverse(); }
			else Fail;
		}
		FailIf(joint1 == NULL || joint2 == NULL);
		PassIf(IsEquivalent(*joint1, FMMatrix44::Identity));
		FMMatrix44 sbp = FMMatrix44(sampleBindPose1).Inverted();
		PassIf(IsEquivalent(*joint2, FMMatrix44(sampleBindPose1).Inverted()));

		// Verify the influences
		PassIf(controller->GetInfluenceCount() == 4);
		FCDSkinControllerVertex* influence = controller->GetVertexInfluence(0);
		FailIf(influence == NULL);
		PassIf(influence->GetPairCount() == 2);
		PassIf(IsEquivalent(influence->GetPair(0)->jointIndex, 0));
		PassIf(IsEquivalent(influence->GetPair(0)->weight, 0.5f));
		PassIf(IsEquivalent(influence->GetPair(1)->jointIndex, 1));
		PassIf(IsEquivalent(influence->GetPair(1)->weight, 0.5f));

		influence = controller->GetVertexInfluence(1);
		FailIf(influence == NULL);
		PassIf(influence->GetPairCount() == 0);

		influence = controller->GetVertexInfluence(2);
		FailIf(influence == NULL);
		PassIf(influence->GetPairCount() == 1);
		PassIf(IsEquivalent(influence->GetPair(0)->jointIndex, 0));
		PassIf(IsEquivalent(influence->GetPair(0)->weight, 1.0f)); // the weight should have been normalized.

		influence = controller->GetVertexInfluence(3);
		FailIf(influence == NULL);
		PassIf(influence->GetPairCount() == 1);
		PassIf(IsEquivalent(influence->GetPair(0)->jointIndex, 1));
		PassIf(IsEquivalent(influence->GetPair(0)->weight, 1.0f));
		return true;
	}
Exemple #17
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void	AppleTopazAudio::CODEC_Reset ( void ) {
	IOReturn		err;
	
	FailIf ( NULL == mPlatformInterface, Exit );

	err = mPlatformInterface->setCodecReset ( kCODEC_RESET_Digital, kGPIO_Run );
	FailIf ( kIOReturnSuccess != err, Exit );
	IODelay ( 250 );
	err = mPlatformInterface->setCodecReset ( kCODEC_RESET_Digital, kGPIO_Reset );
	FailIf ( kIOReturnSuccess != err, Exit );
	IODelay ( 250 );
	err = mPlatformInterface->setCodecReset ( kCODEC_RESET_Digital, kGPIO_Run );
	FailIf ( kIOReturnSuccess != err, Exit );
	IODelay ( 250 );
Exit:
	return;
}
Exemple #18
0
	bool FillControllerSkin(FULogFile& fileOut, FCDSkinController* controller)
	{
		FailIf(controller == NULL);

		// Create two joints.
		FCDSceneNode* visualScene = controller->GetDocument()->GetVisualSceneLibrary()->AddEntity();
		PassIf(visualScene != NULL);
		FCDSceneNode* joint1 = visualScene->AddChildNode();
		PassIf(joint1 != NULL);
		FCDSceneNode* joint2 = joint1->AddChildNode();
		PassIf(joint2 != NULL);
		// In the standard course of operations, we would either load a file
		// with subId Info, or link it in when loading the instance.  Here we have no instance
		fm::string jid1("joint1");
		fm::string jid2("joint2");
		joint1->SetSubId(jid1);
		joint2->SetSubId(jid2);
		jointId1 = joint1->GetSubId();
		jointId2 = joint2->GetSubId();
		FailIf(jointId1.empty() || jointId2.empty());
		controller->AddJoint(joint1->GetSubId(), FMMatrix44::Identity);
		controller->AddJoint(joint2->GetSubId(), FMMatrix44(sampleBindPose1).Inverted());
		controller->SetBindShapeTransform(FMMatrix44(sampleBindPose2));
		PassIf(controller->GetJointCount() == 2);

		// Retrieve and assign the base target
		FCDGeometry* geometricTarget = controller->GetDocument()->FindGeometry(meshId);
		controller->SetTarget(geometricTarget);

		// Set some influences
		PassIf(controller->GetInfluenceCount() == 4);
		FCDSkinControllerVertex* influence = controller->GetVertexInfluence(0);
		FailIf(influence == NULL);
		influence->AddPair(0, 0.5f);
		influence->AddPair(1, 0.5f);

		influence = controller->GetVertexInfluence(3);
		FailIf(influence == NULL);
		influence->AddPair(1, 1.0f);

		influence = controller->GetVertexInfluence(2);
		FailIf(influence == NULL);
		influence->AddPair(0, 0.1f);
		return true;
	}
Exemple #19
0
ERR ReadContainer(
    PKImageDecode* pID)
{
    ERR err = WMP_errSuccess;

    struct WMPStream* pWS = pID->pStream;
    size_t offPos = 0;

    char szSig[2] = {0};
    U16 uWmpID = 0;
    U32 offPFD = 0;
    U16 cPFDEntry = 0;
    U8 bVersion;
    
    //================================
    Call(pWS->GetPos(pWS, &offPos));
    FailIf(0 != offPos, WMP_errUnsupportedFormat);

    //================================
    // Header
    Call(pWS->Read(pWS, szSig, sizeof(szSig))); offPos += 2;
    FailIf(szSig != strstr(szSig, "II"), WMP_errUnsupportedFormat);

    Call(GetUShort(pWS, offPos, &uWmpID)); offPos += 2;
    FailIf(WMP_valWMPhotoID != (0x00FF & uWmpID), WMP_errUnsupportedFormat);

    // We accept version 00 and version 01 bitstreams - all others rejected
    bVersion = (0xFF00 & uWmpID) >> 8;
    FailIf(bVersion != 0 && bVersion != 1, WMP_errUnsupportedFormat);

    Call(GetULong(pWS, offPos, &offPFD)); offPos += 4;

    //================================
    // PFD
    offPos = (size_t)offPFD;
    Call(GetUShort(pWS, offPos, &cPFDEntry)); offPos += 2;
    FailIf(0 == cPFDEntry || USHRT_MAX == cPFDEntry, WMP_errUnsupportedFormat);
    Call(ParsePFD(pID, offPos, cPFDEntry));

    //================================
    Call(pWS->SetPos(pWS, pID->WMP.wmiDEMisc.uImageOffset));

Cleanup:
    return err;
}
Exemple #20
0
ERR iSetPosWS_File(struct WMPStream* pWS, size_t offPos)
{
    ERR err = WMP_errSuccess;

    //FailIf(0 != fseek(pWS->state.file.pFile, (long)offPos, SEEK_SET), WMP_errFileIO);
	FailIf(0 != iseek((ILuint)offPos, IL_SEEK_SET), WMP_errFileIO);

Cleanup:
    return err;
}
Exemple #21
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
IOReturn	AppleTopazPluginCS8420::performDeviceSleep ( void ) {
    IOReturn			result;

    debugIOLog (3, "+ AppleTopazPluginCS8420::performDeviceSleep()");

    mShadowRegs[map_CS8420_DATA_FLOW_CTRL] &= ~( kCS84XX_BIT_MASK << baCS8420_TXOFF );
    mShadowRegs[map_CS8420_DATA_FLOW_CTRL] |= ( bvCS8420_aes3TX0v << baCS8420_TXOFF );
    result = CODEC_WriteRegister ( map_CS8420_DATA_FLOW_CTRL, mShadowRegs[map_CS8420_DATA_FLOW_CTRL] );
    FailIf ( kIOReturnSuccess != result, Exit );

    mShadowRegs[map_CS8420_CLOCK_SOURCE_CTRL] &= ~( kCS84XX_BIT_MASK << baCS8420_RUN );
    mShadowRegs[map_CS8420_CLOCK_SOURCE_CTRL] |= ( bvCS8420_runSTOP << baCS8420_RUN );
    result = CODEC_WriteRegister ( map_CS8420_CLOCK_SOURCE_CTRL, mShadowRegs[map_CS8420_CLOCK_SOURCE_CTRL] );
    FailIf ( kIOReturnSuccess != result, Exit );

Exit:
    debugIOLog (3, "- AppleTopazPluginCS8420::performDeviceSleep()");
    return result;
}
Exemple #22
0
int mainVerify(const WCHAR *archivePath)
{
    int errorStep = 1;
    size_t fileDataLen;
    ScopedMem<char> fileData(file::ReadAll(archivePath, &fileDataLen));
    FailIf(!fileData, "Failed to read \"%S\"", archivePath);

    lzma::SimpleArchive lzsa;
    bool ok = lzma::ParseSimpleArchive(fileData, fileDataLen, &lzsa);
    FailIf(!ok, "\"%S\" is no valid LzSA file", archivePath);

    for (int i = 0; i < lzsa.filesCount; i++) {
        ScopedMem<char> data(lzma::GetFileDataByIdx(&lzsa, i, NULL));
        FailIf(!data, "Failed to extract data for \"%s\"", lzsa.files[i].name);
    }

    printf("Verified all %d archive entries\n", lzsa.filesCount);
    return 0;
}
Exemple #23
0
ERR iWriteWS_File(struct WMPStream* pWS, const void* pv, size_t cb)
{
    ERR err = WMP_errSuccess;

    if (0 != cb) {
		FailIf(1 != iwrite(pv, (ILuint)cb, 1), WMP_errFileIO);
    }

Cleanup:
    return err;
}
Exemple #24
0
	bool FillExtraTree(FULogFile& fileOut, FCDExtra* extra, bool hasTypes)
	{
		FailIf(extra == NULL);

		// Add a test technique.
		PassIf(extra->GetDefaultType()->GetTechniqueCount() == 0);
		FCDETechnique* technique1 = extra->GetDefaultType()->AddTechnique("FCTEI_TestProfile");
		FCDETechnique* technique2 = extra->GetDefaultType()->AddTechnique("FCTEI_TestProfile");
		FailIf(technique1 == NULL);
		FailIf(technique2 == NULL);
		PassIf(technique1 == technique2);
		PassIf(extra->GetDefaultType()->GetTechniqueCount() == 1);

		// Add a parent parameter to the technique and two subsequent parameters with the same name.
		FCDENode* parameterTree = technique1->AddChildNode();
		parameterTree->SetName("MainParameterTree");
		FCDENode* firstParameter = parameterTree->AddChildNode();
		firstParameter->SetName("SomeParameter");
		firstParameter->SetContent(FS("Test_SomeParameter"));
		firstParameter->AddAttribute("Guts", 0);
		FCDENode* secondParameter = parameterTree->AddChildNode();
		secondParameter->SetName("SomeParameter");
		secondParameter->AddAttribute("Guts", 3);
		secondParameter->SetContent(FS("Test_ThatParameter!"));
		PassIf(parameterTree->GetChildNodeCount() == 2);

		// Add some attributes to the parameter tree
		parameterTree->AddAttribute("Vicious", FC("Squirrel"));
		parameterTree->AddAttribute("Gross", 1002);

		if (hasTypes)
		{
			// Add a second extra type
			// Empty named-types should be supported.
			FCDEType* secondType = extra->AddType("verificator");
			PassIf(secondType != NULL);
			PassIf(secondType != extra->GetDefaultType());
			PassIf(secondType->GetTechniqueCount() == 0);
		}
		return true;
	}
Exemple #25
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bool	AppleTopazPluginCS8420::preDMAEngineInit ( void ) {
    bool			result = false;
    IOReturn		err;

    //	Place device into power down state prior to initialization
    err = CODEC_WriteRegister ( map_CS8420_CLOCK_SOURCE_CTRL, kCS8420_CLOCK_SOURCE_CTRL_INIT_STOP );
    FailIf ( kIOReturnSuccess != err, Exit );

    err = CODEC_WriteRegister ( map_CS8420_MISC_CNTRL_1, kCS8420_MISC_CNTRL_1_INIT );
    FailIf ( kIOReturnSuccess != err, Exit );

    err = CODEC_WriteRegister ( map_CS8420_MISC_CNTRL_2, kCS8420_MISC_CNTRL_2_INIT );
    FailIf ( kIOReturnSuccess != err, Exit );

    err = CODEC_WriteRegister ( map_CS8420_DATA_FLOW_CTRL, kCS8420_DATA_FLOW_CTRL_INIT );
    FailIf ( kIOReturnSuccess != err, Exit );

    err = CODEC_WriteRegister ( map_CS8420_SERIAL_INPUT_FMT, kCS8420_SERIAL_AUDIO_INPUT_FORMAT_INIT );
    FailIf ( kIOReturnSuccess != err, Exit );

    err = CODEC_WriteRegister ( map_CS8420_SERIAL_OUTPUT_FMT, kCS8420_SERIAL_AUDIO_OUTPUT_FORMAT_INIT );
    FailIf ( kIOReturnSuccess != err, Exit );

    //	Enable receiver error (i.e. RERR) interrupts
    err = CODEC_WriteRegister ( map_CS8420_RX_ERROR_MASK, kCS8420_RX_ERROR_MASK_ENABLE_RERR );
    FailIf ( kIOReturnSuccess != err, Exit );

    //	Clear any pending error interrupt
    err = CODEC_ReadRegister ( map_CS8420_RX_ERROR, NULL, 1 );
    FailIf ( kIOReturnSuccess != err, Exit );

    err = CODEC_WriteRegister ( map_CS8420_CLOCK_SOURCE_CTRL, kCS8420_CLOCK_SOURCE_CTRL_INIT );
    FailIf ( kIOReturnSuccess != err, Exit );

    err = CODEC_WriteRegister ( map_CS8420_USER_DATA_BUF_CTRL, bvCS8420_ubmBlock << baCS8420_UBM );
    FailIf ( kIOReturnSuccess != err, Exit );

    result = true;
Exit:
    return result;
}
Exemple #26
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
IOReturn	AppleTopazPluginCS8420::flushControlRegisters ( void ) {
    IOReturn		result = kIOReturnSuccess;

    for ( UInt32 regAddr = map_CS8420_MISC_CNTRL_1; regAddr <= map_CS8420_BUFFER_23; regAddr++ ) {
        if ( kIOReturnSuccess == CODEC_IsControlRegister ( regAddr ) ) {
            result = CODEC_WriteRegister ( regAddr, mShadowRegs[regAddr] );
            FailIf ( kIOReturnSuccess != result, Exit );
        }
    }
Exit:
    return result;
}
Exemple #27
0
	bool CheckControllerMorph(FULogFile& fileOut, FCDMorphController* controller)
	{
		FailIf(controller == NULL);
		PassIf(controller->GetMethod() == FUDaeMorphMethod::RELATIVE);

		// Check that there are two targets, that the weights are correct, as well as the ids.
		PassIf(controller->GetTargetCount() == 2);
		PassIf(controller->GetBaseTarget() != NULL);
		PassIf(controller->GetBaseTarget()->GetDaeId() == splineId);

		FCDMorphTarget* target1 = controller->GetTarget(0);
		FailIf(target1 == NULL);
		FCDMorphTarget* target2 = controller->GetTarget(1);
		FailIf(target2 == NULL);
		PassIf(target1->GetGeometry() == controller->GetBaseTarget());
		PassIf(target2->GetGeometry() == controller->GetBaseTarget());
		PassIf(IsEquivalent(target1->GetWeight(), 0.6f) || IsEquivalent(target1->GetWeight(), 0.3f));
		PassIf(IsEquivalent(target2->GetWeight(), 0.6f) || IsEquivalent(target2->GetWeight(), 0.3f));
		FailIf(IsEquivalent(target1->GetWeight(), target2->GetWeight()));
		return true;
	}
Exemple #28
0
	bool FillGeometryLibrary(FULogFile& fileOut, FCDGeometryLibrary* library)
	{
		FCDGeometry* geometry = library->AddEntity();
		PassIf(geometry->GetType() == FCDEntity::GEOMETRY);
		FailIf(geometry->IsMesh());
		FailIf(geometry->IsSpline());
		meshId = geometry->GetDaeId();
		FailIf(meshId.empty());

		// Creates a mesh to export
		FCDGeometryMesh* mesh = geometry->CreateMesh();
		FailIf(geometry->IsSpline());
		PassIf(geometry->IsMesh());
		PassIf(geometry->GetMesh() == mesh);
		PassIf(geometry->GetSpline() == NULL);
		FillGeometryMesh(fileOut, mesh);

		// Create a spline to export
		geometry = library->AddEntity();
		geometry->CreateMesh();
		FCDGeometrySpline* spline = geometry->CreateSpline();
		PassIf(geometry->IsSpline());
		FailIf(geometry->IsMesh());
		PassIf(geometry->GetMesh() == NULL);
		PassIf(geometry->GetSpline() == spline);
		FillGeometrySpline(fileOut, spline);
		splineId = geometry->GetDaeId();
		FailIf(splineId.empty());
		return true;
	}
Exemple #29
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//  This method is invoked from the 'codecErrorInterruptHandler' residing in the
//  platform interface object.  The 'codecErrorInterruptHandler' may be invoked
//  through GPIO hardware interrupt dispatch services or throught timer polled
//  services.
void AppleTopazPluginCS8420::notifyHardwareEvent ( UInt32 statusSelector, UInt32 newValue ) {
    IOReturn    error;
    UInt8       ratio;

    if ( kCodecErrorInterruptStatus == statusSelector ) {
        error = CODEC_ReadRegister ( map_CS8420_RX_ERROR, &mShadowRegs[map_CS8420_RX_ERROR], 1 );
        FailIf ( kIOReturnSuccess != error, Exit );

        // [4073140] - validate OMCK/RMCK ratio register
        error = CODEC_ReadRegister ( map_CS8420_SAMPLE_RATE_RATIO, &mShadowRegs[map_CS8420_SAMPLE_RATE_RATIO], 1 );
        FailIf ( kIOReturnSuccess != error, Exit );

        ratio = mShadowRegs[map_CS8420_SAMPLE_RATE_RATIO];

        if ( ( ( bvCS8420_pllLocked << baCS8420_UNLOCK ) == ( ( bvCS8420_pllUnlocked << baCS8420_UNLOCK ) & mShadowRegs[map_CS8420_RX_ERROR] ) ) &&
                ( ( kCS84XX_OMCK_RMCK_RATIO_LOCKED_MIN <= ratio ) && ( kCS84XX_OMCK_RMCK_RATIO_LOCKED_MAX >= ratio ) ) ) {
            mUnlockErrorCount = 0;
            mLockStatus = TRUE;
        } else {
            mUnlockErrorCount++;
            if ( kCLOCK_UNLOCK_ERROR_TERMINAL_COUNT < mUnlockErrorCount ) {
                mUnlockErrorCount = 0;
                mLockStatus = FALSE;
            }
        }

        if ( mLockStatus ) {
            debugIOLog ( 4, "  AppleTopazPluginCS8420::notifyHardwareEvent posts kClockLockStatus, mShadowRegs[map_CS8420_RX_ERROR] = 0x%0.2X, OMCK/RMCK ratio = 0x%0.2X", mShadowRegs[map_CS8420_RX_ERROR], ratio );
            mAudioDeviceProvider->interruptEventHandler ( kClockLockStatus, (UInt32)0 );
        } else {
            debugIOLog ( 4, "  AppleTopazPluginCS8420::notifyHardwareEvent posts kClockUnLockStatus, mShadowRegs[map_CS8420_RX_ERROR] = 0x%0.2X, OMCK/RMCK ratio = 0x%0.2X", mShadowRegs[map_CS8420_RX_ERROR], ratio );
            mAudioDeviceProvider->interruptEventHandler ( kClockUnLockStatus, (UInt32)0 );
        }
    } else if ( kCodecInterruptStatus == statusSelector ) {
    }

Exit:

    return;
}
Exemple #30
0
void PlayLoop (MusicPlayer &player, AUGraph &graph, MusicTimeStamp sequenceLength, bool shouldPrint, bool waitAtEnd)
{
	OSStatus result;
	int waitCounter = 0;
	while (1) {
		usleep (2 * 1000 * 1000);
		
		if (didOverload) {
			printf ("* * * * * %lu Overloads detected on device playing audio\n", (unsigned long)didOverload);
			overloadTime = CAHostTimeBase::ConvertToNanos (overloadTime - startRunningTime);
			printf ("\tSeconds after start = %lf\n", double(overloadTime / 1000000000.));
			didOverload = 0;
		}

		if (waitAtEnd && ++waitCounter > 10) break;
		
		MusicTimeStamp time;
		FailIf ((result = MusicPlayerGetTime (player, &time)), fail, "MusicPlayerGetTime");
					
		if (shouldPrint) {
			printf ("current time: %6.2f beats", time);
			if (graph) {
				Float32 load;
				FailIf ((result = AUGraphGetCPULoad(graph, &load)), fail, "AUGraphGetCPULoad");
				printf (", CPU load = %.2f%%\n", (load * 100.));
			} else
				printf ("\n"); //no cpu load on AUGraph - its not running - if just playing out to MIDI
		}
		
		if (time >= sequenceLength)
			break;
	}
	
	return;
fail:
	if (shouldPrint) printf ("Error = %ld\n", (long)result);
	exit(1);
}