Exemplo n.º 1
0
/**
 * Stops the service.
 *
 * @returns VBox status.
 */
int USBProxyService::stop(void)
{
    int rc = VINF_SUCCESS;
    if (mThread != NIL_RTTHREAD)
    {
        /*
         * Mark the thread for termination and kick it.
         */
        ASMAtomicXchgSize(&mTerminate, true);
        rc = interruptWait();
        AssertRC(rc);

        /*
         * Wait for the thread to finish and then update the state.
         */
        rc = RTThreadWait(mThread, 60000, NULL);
        if (rc == VERR_INVALID_HANDLE)
            rc = VINF_SUCCESS;
        if (RT_SUCCESS(rc))
        {
            LogFlowThisFunc(("stopped mThread=%RTthrd\n", mThread));
            mThread = NIL_RTTHREAD;
            mTerminate = false;
        }
        else
        {
            AssertRC(rc);
            mLastError = rc;
        }
    }
    else
        LogFlowThisFunc(("not active\n"));

    return rc;
}
Exemplo n.º 2
0
// This implementation is blocking, i.e. it will wait until the file
// is effectively loaded in the watchtower thread.
WinWatchTowerDriver::DirId WinWatchTowerDriver::addDir(
        const std::string& file_name )
{
    DirId dir_id { };

    // Add will be done in the watchtower thread
    {
        /*
        QMutexLocker lk( &action_mutex_ );
        scheduled_action_ = std::make_unique<Action>( [this, file_name, &dir_id] {
            serialisedAddDir( file_name, dir_id );
        } );
        */
        serialisedAddDir( file_name, dir_id );
    }

    // Poke the thread
    interruptWait();

    // Wait for the add task to be completed
    {
        /*
        QMutexLocker lk( &action_mutex_ );
        while( scheduled_action_ != nullptr ) {
            action_done_cv_.wait( &action_mutex_ );
        }
        */
    }

    LOG(logDEBUG) << "addDir returned " << dir_id.dir_record_;

    return dir_id;
}
Exemplo n.º 3
0
int USBProxyServiceDarwin::releaseDevice(HostUSBDevice *aDevice)
{
    /*
     * Check preconditions.
     */
    AssertReturn(aDevice, VERR_GENERAL_FAILURE);
    AssertReturn(!aDevice->isWriteLockOnCurrentThread(), VERR_GENERAL_FAILURE);

    AutoReadLock devLock(aDevice COMMA_LOCKVAL_SRC_POS);
    LogFlowThisFunc(("aDevice=%s\n", aDevice->getName().c_str()));

    Assert(aDevice->getUnistate() == kHostUSBDeviceState_ReleasingToHost);

#ifndef VBOX_WITH_NEW_USB_CODE_ON_DARWIN
    /*
     * Fake it.
     */
    ASMAtomicWriteBool(&mFakeAsync, true);
    devLock.release();
    interruptWait();
    return VINF_SUCCESS;

#else
    /*
     * Create a one-shot ignore filter for the device
     * and trigger a re-enumeration of it.
     */
    USBFILTER Filter;
    USBFilterInit(&Filter, USBFILTERTYPE_ONESHOT_IGNORE);
    initFilterFromDevice(&Filter, aDevice);
    Log(("USBFILTERIDX_PORT=%#x\n", USBFilterGetNum(&Filter, USBFILTERIDX_PORT)));
    Log(("USBFILTERIDX_BUS=%#x\n", USBFilterGetNum(&Filter, USBFILTERIDX_BUS)));

    void *pvId = USBLibAddFilter(&Filter);
    if (!pvId)
        return VERR_GENERAL_FAILURE;

    int rc = DarwinReEnumerateUSBDevice(aDevice->mUsb);
    if (RT_SUCCESS(rc))
        aDevice->mOneShotId = pvId;
    else
    {
        USBLibRemoveFilter(pvId);
        pvId = NULL;
    }
    LogFlowThisFunc(("returns %Rrc pvId=%p\n", rc, pvId));
    return rc;
#endif
}
Exemplo n.º 4
0
int USBProxyBackendFreeBSD::releaseDevice(HostUSBDevice *aDevice)
{
    AssertReturn(aDevice, VERR_GENERAL_FAILURE);
    AssertReturn(!aDevice->isWriteLockOnCurrentThread(), VERR_GENERAL_FAILURE);

    AutoReadLock devLock(aDevice COMMA_LOCKVAL_SRC_POS);
    LogFlowThisFunc(("aDevice=%s\n", aDevice->i_getName().c_str()));

    /*
     * We're not really holding it atm., just fake it.
     */
    Assert(aDevice->i_getUnistate() == kHostUSBDeviceState_ReleasingToHost);
    devLock.release();
    interruptWait();

    return VINF_SUCCESS;
}
Exemplo n.º 5
0
int USBProxyBackendFreeBSD::captureDevice(HostUSBDevice *aDevice)
{
    AssertReturn(aDevice, VERR_GENERAL_FAILURE);
    AssertReturn(!aDevice->isWriteLockOnCurrentThread(), VERR_GENERAL_FAILURE);

    AutoReadLock devLock(aDevice COMMA_LOCKVAL_SRC_POS);
    LogFlowThisFunc(("aDevice=%s\n", aDevice->i_getName().c_str()));

    /*
     * Don't think we need to do anything when the device is held... fake it.
     */
    Assert(aDevice->i_getUnistate() == kHostUSBDeviceState_Capturing);
    devLock.release();
    interruptWait();

    return VINF_SUCCESS;
}
Exemplo n.º 6
0
void cBuilder::mainLoop() {
	mQuit = false;
	mIntro = false;
	mNoInput = true;

	if( mStartCastle != -2 && mStartCastle > -1 ) {
		// Load Castle
		mCastle = mCreepParent->castleGet();
		mCastle->castleLoad( this );	
		
	} else {
	
		if(mStartCastle != -2) {
			// New Castle
			mScreen->levelNameSet("Untitled");
			mCastle = new cCastle( this, 0 );

			save( false );
		}
	}
	
	// Set the screen ptrs
	mScreen->bitmapLoad( &mMemory[ 0xE000 ], &mMemory[ 0xCC00 ], &mMemory[ 0xD800 ], 0 );

	// Prep Cursor
	mScreen->cursorSet( mCursorX, mCursorY );
	mScreen->cursorEnabled(true);

	// Change to first room
	roomChange(mMemory[ 0x7803 ]);

	// 
	while(!mQuit) {
		byte key = tolower( mInput->keyGet() );
		
		// Check keyboard input
		switch(key) {
			
			case 0x02:	// '1' Set player one starting door
				if( mCurrentObject && mCurrentObject->objectTypeGet() == eObjectDoor ) {
					mCastle->mStart_Room_Player1Set(mCurrentRoom->mNumber);
					mCastle->mStart_Door_Player1Set(findItemIndex( mCurrentObject ));
					castlePrepare();
				}
				break;

			case 0x03:	// '2' Set player two starting door
				if( mCurrentObject && mCurrentObject->objectTypeGet() == eObjectDoor ) {
					mCastle->mStart_Room_Player2Set(mCurrentRoom->mNumber);
					mCastle->mStart_Door_Player2Set(findItemIndex( mCurrentObject ));
					castlePrepare();
				}
				break;

			case 0x10:	// 'q' Change Selected Placement Object 'Up'
				selectedObjectChange( true );
				break;

			case 0x1E:	// 'a' Change Selected Placement Object 'Down'
				selectedObjectChange( false );
				break;

			case 0x1F:	// 's' Object State
				if(mCurrentObject) {
					mCurrentObject->stateChange();
					castlePrepare();
				}
				break;

			case 0x1A:	// '[' Select a placed object
				selectPlacedObject( false );
				break;

			case 0x1B:	// ']' Select a placed object
				selectPlacedObject( true );
				break;
			
			case 0x20:	// 'd' object direction
				if( mCurrentObject ) {
					mCurrentObject->directionChange();
					castlePrepare();
				}

				break;

			case 0x26:	// 'l' Link Objects
				selectedObjectLink();
				break;

			case 0x0C:	{// '-' Previous Room
				int newRoom = ((char) mCurrentRoom->mNumber) - 1;
				if(newRoom < 0)
					newRoom = 0;
				roomChange( newRoom );
				break;
						}

			case 0x0D:	{// '=' Next Room
				int newRoom = ((char) mCurrentRoom->mNumber) + 1;
				//if( newRoom >= (int) mRooms.size() )
				//	newRoom = mRooms.size() - 1;
				roomChange( newRoom );
				break;
						}

			case 0x21:	// 'f' edit final room
				if( mCastle->mFinalRoomGet() == mCurrentRoom )
					roomChange(0);
				else
					roomChange(-1);
				
				break;

			case 0x73:	// 'Delete' Delete selected object
				selectedObjectDelete();
				break;

			
			default:
				/*if(key) {
					cout << "0x";
					cout << hex << (int) key << endl;
				}*/
				break;
		}

		// Check 'joystick' input
		parseInput();

		interruptWait( 2 );

		// Draw
		Sprite_Execute();
		object_Execute();

		// Redraw screen
		hw_Update();
	}

	mScreen->cursorEnabled(false);
	if( mTest )
		save( true );
}