當前位置: 首頁>>代碼示例>>C++>>正文


C++ ALooper_pollAll函數代碼示例

本文整理匯總了C++中ALooper_pollAll函數的典型用法代碼示例。如果您正苦於以下問題:C++ ALooper_pollAll函數的具體用法?C++ ALooper_pollAll怎麽用?C++ ALooper_pollAll使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了ALooper_pollAll函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: android_main

void android_main( struct android_app *app )
{
	int ident, events;
	struct android_poll_source *source;
	unsigned int oldtime, newtime, time;

	app_dummy();

	sys_android_app = app;
	app->inputPollSource.process = Sys_Android_ProcessInput;
	ANativeActivity_setWindowFlags( app->activity, AWINDOW_FLAG_KEEP_SCREEN_ON, 0 ); // flags must be set before window creation

	app->onAppCmd = Sys_Android_WaitOnAppCmd;
	while( !sys_android_initialized )
	{
		Sys_Sleep( 0 );
		while( ( ident = ALooper_pollAll( 0, NULL, &events, ( void ** )( &source ) ) ) >= 0 )
		{
			if ( source )
				source->process( app, source );
		}
	}

	Sys_Android_Init();
	Qcommon_Init( 0, NULL );

	oldtime = Sys_Milliseconds();
	for( ;; )
	{
		if( dedicated && dedicated->integer )
			Sys_Sleep( 1 );

		while( ( ident = ALooper_pollAll( 0, NULL, &events, ( void ** )( &source ) ) ) >= 0 )
		{
			if( source )
				source->process( app, source );
		}

		for( ;; )
		{
			newtime = Sys_Milliseconds();
			time = newtime - oldtime;
			if( time > 0 )
				break;
			Sys_Sleep( 0 );
		}
		oldtime = newtime;

		Sys_Android_ExecuteIntent();
		Qcommon_Frame( time );
	}
}
開發者ID:MGXRace,項目名稱:racesow,代碼行數:52,代碼來源:android_sys.c

示例2: SkDebugf

void* SkiaAndroidApp::pthread_main(void* arg) {
    SkDebugf("pthread_main begins");

    auto skiaAndroidApp = (SkiaAndroidApp*)arg;

    // Because JNIEnv is thread sensitive, we need AttachCurrentThread to set our fPThreadEnv
    skiaAndroidApp->fJavaVM->AttachCurrentThread(&(skiaAndroidApp->fPThreadEnv), nullptr);

    ALooper* looper = ALooper_prepare(ALOOPER_PREPARE_ALLOW_NON_CALLBACKS);
    pipe(skiaAndroidApp->fPipes);
    ALooper_addFd(looper, skiaAndroidApp->fPipes[0], LOOPER_ID_MESSAGEPIPE, ALOOPER_EVENT_INPUT,
                  message_callback, skiaAndroidApp);

    skiaAndroidApp->fApp = Application::Create(0, nullptr, skiaAndroidApp);

    double currentTime = 0.0;
    double previousTime = 0.0;
    while (true) {
        const int ident = ALooper_pollAll(0, nullptr, nullptr, nullptr);

        if (ident >= 0) {
            SkDebugf("Unhandled ALooper_pollAll ident=%d !", ident);
        } else {
            previousTime = currentTime;
            currentTime = now_ms();
            skiaAndroidApp->fApp->onIdle(currentTime - previousTime);
        }
    }

    SkDebugf("pthread_main ends");

    return nullptr;
}
開發者ID:VarcoDevs,項目名稱:skia,代碼行數:33,代碼來源:surface_glue_android.cpp

示例3: while

void CEventLoop::run(IActivityHandler &activityHandler, IInputHandler &inputHandler)
{
  int ident;
  int events;
  struct android_poll_source* source;

  m_activityHandler = &activityHandler;
  m_inputHandler = &inputHandler;

  CXBMCApp::android_printf("CEventLoop: starting event loop");
  while (1)
  {
    // We will block forever waiting for events.
    while ((ident = ALooper_pollAll(-1, NULL, &events, (void**)&source)) >= 0)
    {
      // Process this event.
      if (source != NULL)
        source->process(m_application, source);

      // Check if we are exiting.
      if (m_application->destroyRequested)
      {
        CXBMCApp::android_printf("CEventLoop: we are being destroyed");
        return;
      }
    }
  }
}
開發者ID:OV3RDOSE,項目名稱:xbmc,代碼行數:28,代碼來源:EventLoop.cpp

示例4: SkDebugf

void* SkiaAndroidApp::pthread_main(void* arg) {
    SkDebugf("pthread_main begins");

    auto skiaAndroidApp = (SkiaAndroidApp*)arg;

    // Because JNIEnv is thread sensitive, we need AttachCurrentThread to set our fPThreadEnv
    skiaAndroidApp->fJavaVM->AttachCurrentThread(&(skiaAndroidApp->fPThreadEnv), nullptr);

    ALooper* looper = ALooper_prepare(ALOOPER_PREPARE_ALLOW_NON_CALLBACKS);
    pipe(skiaAndroidApp->fPipes);
    ALooper_addFd(looper, skiaAndroidApp->fPipes[0], LOOPER_ID_MESSAGEPIPE, ALOOPER_EVENT_INPUT,
                  message_callback, skiaAndroidApp);

    int ident;
    int events;
    struct android_poll_source* source;

    skiaAndroidApp->fApp = Application::Create(0, nullptr, skiaAndroidApp);

    while ((ident = ALooper_pollAll(-1, nullptr, &events, (void**)&source)) >= 0) {
        SkDebugf("ALooper_pollAll ident=%d", ident);
    }

    return nullptr;
}
開發者ID:jszwedko,項目名稱:skia,代碼行數:25,代碼來源:surface_glue_android.cpp

示例5: fprintf

inline bool CSensorAndroidBuiltIn::read_xyz(float& x1, float& y1, float& z1)
{
    if (qcn_main::g_iStop) return false;

    if (! m_pSensor || ! m_pLooper | ! m_pSensorEventQueue) {
        fprintf(stderr, "read_xyz error: no sensor %x or looper %x or event queue %x setup!\n", m_pSensor, m_pLooper, m_pSensorEventQueue);
        return false;  // no open file descriptor
    }

    int ident, events;
    float fCtr = 0.0;

    // should probably be while loop but taking too long on some devices
    // set the member vars m_xyz so can be reused if it has a timeout (so x1 etc aren't 0, ie carries over)
    if ((ident = ALooper_pollAll(m_minDelayMsec/2, NULL, &events, NULL)) >= 0) {
        if (ident == LOOPER_ID_QCN) {
            ASensorEvent event;
            if (ASensorEventQueue_getEvents(m_pSensorEventQueue, &event, 1) > 0) {
                m_xyz[0] = event.acceleration.x;
                m_xyz[1] = event.acceleration.y;
                m_xyz[2] = event.acceleration.z;
            }
        }
    }

    // m_xyz (ie android accelerometer return values) are in G's already, so just multiply by earth g 9.8
    x1 = m_xyz[0] * EARTH_G;
    y1 = m_xyz[1] * EARTH_G;
    z1 = m_xyz[2] * EARTH_G;

    //fprintf(stdout, "read_xyz:  %f %f %f\n", x1, y1, z1);

    return true;
}
開發者ID:happyj,項目名稱:qcn,代碼行數:34,代碼來源:csensor_android_built_in.cpp

示例6: gtk_android_exit

void gtk_android_exit(struct android_app *state)
{
    int ident;
    int events;
    struct android_poll_source* source;

    // replace onDestroy handler to terminate the process AFTER everything is unloaded
    if (!defaultActivityDestroyHandler)
    {
        defaultActivityDestroyHandler = state->activity->callbacks->onDestroy;
        state->activity->callbacks->onDestroy = onActivityDestroy;
    }

    ANativeActivity_finish(state->activity);

    while (!state->destroyRequested)
    {
        // Read all pending events.
        while ((ident = ALooper_pollAll(0, NULL, &events, (void**)&source)) >= 0)
        {
            // Process this event.
            if (source != NULL)
                source->process(state, source);
        }
    }
}
開發者ID:ericwlange,項目名稱:hemroid,代碼行數:26,代碼來源:gtkainit.c

示例7: while

void NativeEngine::GameLoop() {
    mApp->userData = this;
    mApp->onAppCmd = _handle_cmd_proxy;
    mApp->onInputEvent = _handle_input_proxy;

    while (1) {
        int ident, events;
        struct android_poll_source* source;
        bool wasAnimating = IsAnimating();

        // If not animating, block until we get an event; if animating, don't block.
        while ((ident = ALooper_pollAll(IsAnimating() ? 0 : -1, NULL, &events,
                (void**)&source)) >= 0) {

            // process event
            if (source != NULL) {
                source->process(mApp, source);
            }

            // are we exiting?
            if (mApp->destroyRequested) {
                return;
            }
        }

        if (IsAnimating()) {
            DoFrame();
        }
    }
}
開發者ID:Uliori,項目名稱:Origami,代碼行數:30,代碼來源:native_engine.cpp

示例8: run

		void run(android_app* _app)
		{
			m_app = _app;
			m_app->userData = (void*)this;
			m_app->onAppCmd = onAppCmdCB;
			m_app->onInputEvent = onInputEventCB;

			const char* argv[1] = { "android.so" };
			m_mte.m_argc = 1;
			m_mte.m_argv = const_cast<char**>(argv);
			
			while (0 == m_app->destroyRequested)
			{
				int32_t num;
				android_poll_source* source;
				/*int32_t id =*/ ALooper_pollAll(-1, NULL, &num, (void**)&source);

				if (NULL != source)
				{
					source->process(m_app, source);
				}
			}

			m_thread.shutdown();
		}
開發者ID:miguelmartin75,項目名稱:bgfx,代碼行數:25,代碼來源:entry_android.cpp

示例9: android_main

void android_main(struct android_app* state) {
    struct engine engine;

    // Make sure glue isn't stripped.
    app_dummy();

    memset(&engine, 0, sizeof(engine));
    state->userData = &engine;
    state->onAppCmd = engine_handle_cmd;
    state->onInputEvent = engine_handle_input;
    engine.app = state;
	PlatfromInit();

	//_InitSensor();
	//InitSensor();
	
	ANativeActivity_setWindowFlags(state->activity, AWINDOW_FLAG_KEEP_SCREEN_ON, 0);

    if (state->savedState != NULL) {
        // We are starting with a previous saved state; restore from it.
        engine.state = *(struct saved_state*)state->savedState;
    }

    // loop waiting for stuff to do.

    while (1) {
        // Read all pending events.
        int ident;
        int events;
        struct android_poll_source* source;

        // If not animating, we will block forever waiting for events.
        // If animating, we loop until all events are read, then continue
        // to draw the next frame of animation.
        while ((ident = ALooper_pollAll(engine.animating ? 0 : -1, 
			NULL, &events,  (void**)&source)) >= 0) {

            // Process this event.
            if (source != NULL) {
                source->process(state, source);
            }

			//_ProcessSensorData(ident);

            // Check if we are exiting.
            if (state->destroyRequested != 0) {
                engine_term_display(&engine);
				PlatfromShutDown();
                return;
            }
        }

        if (engine.animating) {

            // Drawing is throttled to the screen update rate, so there
            // is no need to do timing here.
            engine_draw_frame(&engine);
        }
    }
}
開發者ID:garudaxc,項目名稱:AndroidGL,代碼行數:60,代碼來源:main.cpp

示例10: gdk_android_process_events_until_display_ready

gboolean gdk_android_process_events_until_display_ready(struct android_app *app)
{
    int ident;
    int events;
    struct android_poll_source* source;
    while (1)
    {
        // Read all pending events.
        while ((ident = ALooper_pollAll(0, NULL, &events, (void**)&source)) >= 0)
        {
            // Process this event.
            if (source != NULL)
                source->process(app, source);

            // Check if we are exiting.
            if (app->destroyRequested != 0)
            {
                gdk_android_term_display();
                return FALSE;
            }

            if (_gdk_display)
                return TRUE;
        }
    }
}
開發者ID:ericwlange,項目名稱:hemroid,代碼行數:26,代碼來源:gdkevents-android.c

示例11: android_main

void android_main(struct android_app* state) 
{
	state->onAppCmd     = app_handle_cmd;
	state->onInputEvent = app_handle_input;

	if (state->savedState != NULL) {
		// We are starting with a previous saved state; restore from it.
	}

	// loop waiting for stuff to do.
	while (1) {
		// Read all pending events.
		int ident;
		int events;
		struct android_poll_source* source;

		// If not animating, we will block forever waiting for events.
		// If animating, we loop until all events are read, then continue
		// to draw the next frame of animation.
		while ((ident = ALooper_pollAll(-1, NULL, &events, (void**)&source)) >= 0) {

			// Process this event.
			if (source != NULL) {
				source->process(state, source);
			}

			// Check if we are exiting.
			if (state->destroyRequested != 0) {
				break;
			}
		}
	}
}
開發者ID:rrrfff,項目名稱:ApkTest,代碼行數:33,代碼來源:main.cpp

示例12: engineContext

void EngineCore::mainLoop() {
    int ident;
    int events;
    struct android_poll_source* source;
    shared_ptr<EngineContext> engineContext(getEngineContext());
    app_dummy();

    while (true) {
        // If not animating, block forever waiting for events.
        // otherwise,  loop until all events are read, then continue
        // to draw the next frame of animation.
        while ((ident = ALooper_pollAll(
                    engineContext->isRendering() ? 0 : -1,
                    NULL, &events, (void**)&source)) >= 0) {
            if (ident == LOOPER_ID_MAIN || ident == LOOPER_ID_INPUT) {
                if (source != NULL) {
                    source->process(mApp, source);
                }
            }

            if (mApp->destroyRequested != 0) {
                DEBUG(Log::F_APP_CMD_EVENT, "destroy request received");
                return;
            }
        }

        // check needQuit() to give an early chance to stop drawing.
        if (engineContext->isRendering() && !engineContext->needQuit()) {
            // Drawing is throttled to the screen update rate, so there
            // is no need to do timing here.
            getEngineContext()->updateDisplay();
        }
    }

}
開發者ID:jiayu1016,項目名稱:dizzy,代碼行數:35,代碼來源:engine_core.cpp

示例13: ev_loop

void ev_loop(android_app *papp) {
    int32_t lr;
    int32_t le;
    bool first = true;
    android_poll_source *ps;

    log("starting event loop");
    ros::Time::init();

    while (true) {
        lr = ALooper_pollAll(-1, NULL, &le, (void **) &ps);
        if (lr < 0) {
            break;
        }
        if (ps) {
            log("event received");
            if (first) {
                open_bag();
                papp->onInputEvent = handle_event;
                first = false;
            }
            ps->process(papp, ps);
        }
        if (papp->destroyRequested) {
            log("quitting event loop");
            return;
        }
    }
}
開發者ID:osrf,項目名稱:rosbag_ndk_player,代碼行數:29,代碼來源:record.cpp

示例14: _glfwPlatformPollEvents

void _glfwPlatformPollEvents( void )
{
    EGLint w, h;
    int events;
    struct android_poll_source *source;

    // Callback resized window event
    if( _glfwWin.opened == GL_TRUE && _glfwWin.resized == GL_TRUE ){
        _glfwWin.resized = GL_FALSE;
        eglQuerySurface( _glfwWin.display, _glfwWin.surface, EGL_WIDTH, &w );
        eglQuerySurface( _glfwWin.display, _glfwWin.surface, EGL_HEIGHT, &h );
        _glfwWin.width = w;
        _glfwWin.height = h;
        if( _glfwWin.windowSizeCallback )
        {
            _glfwWin.windowSizeCallback( _glfwWin.width, _glfwWin.height );
        }
    }

    // Callback other events
    while (ALooper_pollAll(0, NULL, &events, (void**) &source) >= 0) {
        if (source != NULL) {
            source->process(_glfwWin.app, source);
        }
        if(_glfwWin.app->destroyRequested != 0){
           _glfwWin.app->destroyRequested = 0;
           _glfwWin.opened = GL_FALSE;
           return;
        }
    }
}
開發者ID:KTaskn,項目名稱:MMDAgent,代碼行數:31,代碼來源:android_window.c

示例15: while

void ShellAndroid::run()
{
    PosixTimer timer;

    double current_time = timer.get();

    while (true) {
        struct android_poll_source *source;
        while (true) {
            int timeout = (settings_.animate && app_.window) ? 0 : -1;
            if (ALooper_pollAll(timeout, nullptr, nullptr,
                    reinterpret_cast<void **>(&source)) < 0)
                break;

            if (source)
                source->process(&app_, source);
        }

        if (app_.destroyRequested)
            break;

        if (!app_.window)
            continue;

        acquire_back_buffer();

        double t = timer.get();
        add_game_time(static_cast<float>(t - current_time));

        present_back_buffer();

        current_time = t;
    }
}
開發者ID:AdamRLukaitis,項目名稱:VulkanSamples,代碼行數:34,代碼來源:ShellAndroid.cpp


注:本文中的ALooper_pollAll函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。