Example #1
0
void KnotsPlayer::onBacklightTimer()
{
#if defined(Q_WS_MAEMO_5)
    osso_return_t err = osso_display_state_on(_ossoContext);
    //qWarning() << "Turned on display for playback with result " << err;

    err = osso_display_blanking_pause( _ossoContext );
    //qWarning() << "Request backlight result " << err ;
#endif
}
Example #2
0
/**
 * Callback function for SDL_AddTimer.
 * Tell OSSO to keep display on and prevent suspending device for 60s.
 **/
static Uint32 OssoKeepBacklightAlive(Uint32 interval, void *)
{
	if (!osso) {
		return 0;
	}

	osso_display_state_on(osso);
	osso_display_blanking_pause(osso);

	return interval;
}
Example #3
0
/*
 * Adds a timeout to periodically disable screen blanking.
 */
void blanking_prohibit(void)
{
        is_blanking_prohibited = TRUE;
	if ((!osso_ctx) || (!can_control_blanking))
		return;
	osso_display_state_on(osso_ctx);
	osso_display_blanking_pause(osso_ctx);
	if (blanking_timeout_id == 0) {
		blanking_timeout_id =
			g_timeout_add_seconds(VIDEO_BLANKING_TIMER_INTERVAL,
                                              (gpointer)no_blanking_timeout,
                                              NULL);
	}
}
Example #4
0
static void read_for_player(zeemote_player_t *player, uint32 *joypad)
{
	if (!player->zeemote) return;

	zeemote_state_t *state = zeemote_get_state(player->zeemote);
	if (!state) return; // Some error
	 // Zeemote was disconnected
	if (state->state != ZEEMOTE_STATE_CONNECTED) return;

	uint32 buttons = 0;
	int i;

	/* check zeemote buttons A-D */
	for (i = 0; i < 4; i++) {
		if (state->buttons & (1<<i))
			buttons |= zeemote_mask[i];
	}

	/* handle direction */
	if (state->axis[0] < -ZEEMOTE_LIMIT) buttons |= SNES_LEFT_MASK;
	if (state->axis[0] >  ZEEMOTE_LIMIT) buttons |= SNES_RIGHT_MASK;
	if (state->axis[1] < -ZEEMOTE_LIMIT) buttons |= SNES_UP_MASK;
	if (state->axis[1] >  ZEEMOTE_LIMIT) buttons |= SNES_DOWN_MASK;

	/* check which actual buttons were pressed or released */
	uint32 buttons_changed = buttons ^ player->prev_buttons;
	uint32 buttons_pressed = buttons_changed & buttons;
	uint32 buttons_released = buttons_changed & player->prev_buttons;

	/* prevent device screensaver when zeemote state changes */
	if (buttons_changed)
	{
		osso_display_blanking_pause(ossoContext);
		player->prev_buttons = buttons;
	}

	*joypad = (*joypad & ~buttons_released) | buttons_pressed;
}
Example #5
0
void runTest(Test& test)
{
    int frames = 0;
    int frameLimit = 100;
    int warmup = 20;
    int64_t minTime = options.minTime * 1000 * 1000 * 1000LL;
    struct timespec res, start, end;

    if (options.listTests)
    {
        printf("%s\n", test.name().c_str());
        return;
    }

    if (!shouldRunTest(test.name()))
    {
        return;
    }

    clock_getres(CLOCK_REALTIME, &res);
    //printf("Timer resolution: %d.%09d s\n", res.tv_sec, res.tv_nsec);
    printf("%-40s", (test.name() + ":").c_str());
    fflush(stdout);

    try
    {
        test.prepare();
        ASSERT_GL();
        ASSERT_EGL();
    } catch (const std::exception& e)
    {
        printf("%s\n", e.what());
        return;
    }

    nativeVerifyWindow(ctx.nativeDisplay, ctx.win);

    while (warmup--)
    {
        test(0);
        swapBuffers();
    }

    ASSERT_GL();
    ASSERT_EGL();

#if defined(HAVE_LIBOSSO)
    if (ossoContext)
    {
        osso_display_blanking_pause(ossoContext);
    }
#endif

    clock_gettime(CLOCK_REALTIME, &start);
    while (frames < frameLimit)
    {
        test(frames);
        swapBuffers();
        clock_gettime(CLOCK_REALTIME, &end);
        frames++;
        if (frames >= frameLimit && timeDiff(start, end) < minTime)
        {
            frameLimit *= 2;
        }
    }

    ASSERT_GL();
    ASSERT_EGL();

    test.teardown();
    ASSERT_GL();
    ASSERT_EGL();

    int64_t diff = timeDiff(start, end);
    int fps = static_cast<int>((1000 * 1000 * 1000LL * frames) / diff);
    //printf("%d frames in %6.2f ms (%3d fps) ", frames, diff / (1000.0f * 1000.0f), fps);
    printf("%3d fps ", fps);

    while (fps > 0)
    {
        fputc('#', stdout);
        fps -= 3;
    }
    fputc('\n', stdout);
}
Example #6
0
static gboolean no_blanking_timeout(void)
{
	/* Stop trying if it fails. */
	return osso_display_blanking_pause(osso_ctx) == OSSO_OK;
}
Example #7
0
File: omapfb.c Project: Kafay/vlc
/*****************************************************************************
 * Manage: handle omapfb events
 *****************************************************************************
 * This function should be called regularly by video output thread.
 *****************************************************************************/
static int Manage( vout_thread_t *p_vout )
{
    XEvent xevent;

    while( XPending( p_vout->p_sys->p_display ) )
    {
        XNextEvent( p_vout->p_sys->p_display, &xevent );

        if( xevent.type == ButtonPress &&
            ((XButtonEvent *)&xevent)->button == Button1 )
        {
            /* detect double-clicks */
            if( ( ((XButtonEvent *)&xevent)->time -
                    p_vout->p_sys->i_time_button_last_pressed ) < 300 )
            {
                p_vout->i_changes |= VOUT_FULLSCREEN_CHANGE;
            }

            p_vout->p_sys->i_time_button_last_pressed =
                        ((XButtonEvent *)&xevent)->time;
        }
        else if( xevent.type == KeyPress )
        {
            KeySym x_key_symbol;
            vlc_value_t val;

            x_key_symbol = XKeycodeToKeysym( p_vout->p_sys->p_display,
                                             xevent.xkey.keycode, 0 );

            switch( x_key_symbol )
            {
            case XK_Return:
                val.i_int = ACTIONID_PLAY_PAUSE; break;
            case XK_Escape:
                val.i_int = ACTIONID_QUIT; break;
            case XK_Down:
                val.i_int = ACTIONID_JUMP_BACKWARD_MEDIUM; break;
            case XK_Up:
                val.i_int = ACTIONID_JUMP_FORWARD_MEDIUM; break;
            case XK_Right:
                val.i_int = ACTIONID_JUMP_FORWARD_SHORT; break;
            case XK_Left:
                val.i_int = ACTIONID_JUMP_BACKWARD_SHORT; break;
            case XK_F6:
                val.i_int = ACTIONID_TOGGLE_FULLSCREEN; break;
            case XK_F7:
                val.i_int = ACTIONID_VOL_UP; break;
            case XK_F8:
                val.i_int = ACTIONID_VOL_DOWN; break;
            }
            var_SetInteger( p_vout->p_libvlc, "key-action", val.i_int );
        }
        else if( ( xevent.type == VisibilityNotify &&
                 xevent.xvisibility.state == VisibilityUnobscured ) ||
                 xevent.type == FocusIn )
        {
            p_vout->p_sys->b_video_enabled = true;
            p_vout->p_sys->p_output_picture->p->p_pixels =
                p_vout->p_sys->p_center;
            XSetInputFocus( p_vout->p_sys->p_display, p_vout->p_sys->window,
                            RevertToParent, CurrentTime );
        }
        else if( ( xevent.type == VisibilityNotify &&
                 xevent.xvisibility.state != VisibilityUnobscured ) ||
                 xevent.type == FocusOut || xevent.type == UnmapNotify )
        {
            UpdateScreen( p_vout, 0, 0,
                          p_vout->p_sys->fb_vinfo.xres,
                          p_vout->p_sys->fb_vinfo.yres,
                          p_vout->p_sys->fb_vinfo.xres,
                          p_vout->p_sys->fb_vinfo.yres,
                          OMAPFB_COLOR_RGB565 );
            p_vout->p_sys->b_video_enabled = false;
            p_vout->p_sys->p_output_picture->p->p_pixels =
                p_vout->p_sys->p_null;
         }
    }

    if( p_vout->i_changes & VOUT_FULLSCREEN_CHANGE )
    {
        /* Update the object variable and trigger callback */
        var_SetBool( p_vout, "fullscreen", !p_vout->b_fullscreen );

        if( p_vout->p_sys->b_embed )
            ToggleFullScreen( p_vout );
        p_vout->i_changes &= ~VOUT_FULLSCREEN_CHANGE;
    }

    if( p_vout->i_changes & VOUT_SIZE_CHANGE )
    {
        FreePicture( p_vout, p_vout->p_sys->p_output_picture );
        if( Init( p_vout ) )
        {
            msg_Err( p_vout, "cannot reinit framebuffer screen" );
            return VLC_EGENERIC;
        }
    }


#ifdef HAVE_OSSO
    if ( p_vout->p_sys->p_octx != NULL ) {
        if ( p_vout->p_sys->i_backlight_on_counter == i_backlight_on_interval ) {
            if ( osso_display_blanking_pause( p_vout->p_sys->p_octx ) != OSSO_OK ) {
                msg_Err( p_vout, "Could not disable backlight blanking" );
        } else {
                msg_Dbg( p_vout, "Backlight blanking disabled" );
            }
            p_vout->p_sys->i_backlight_on_counter = 0;
        } else {
            p_vout->p_sys->i_backlight_on_counter ++;
        }
    }
#endif

    return VLC_SUCCESS;
}
Example #8
0
static void gps_callback(gps_mask_t set, struct gps_t *fix, void *data) {
  OsmGpsMap *map = OSM_GPS_MAP(data);
#ifdef USE_MAEMO
  GtkWidget *toplevel = gtk_widget_get_toplevel(GTK_WIDGET(map));
#endif

  gps_mask_t gps_set = 
    (gps_mask_t)GPOINTER_TO_INT(g_object_get_data(G_OBJECT(map), "gps_set")); 

  g_error("impl");
  /* ... and enable "goto" button if it's valid */
  /* if((set & FIX_LATLON_SET) != (gps_set & FIX_LATLON_SET)) { */
  /*   osm_gps_map_osd_enable_gps(map,   */
  /*      OSM_GPS_MAP_OSD_CALLBACK((set&FIX_LATLON_SET)?cb_map_gps:NULL), map); */

  /*   g_object_set_data(G_OBJECT(map), "gps_set", GINT_TO_POINTER(set));  */
  /* } */

  if(set & FIX_LATLON_SET) {
    /* save fix in case the user later wants to enable gps */
    g_object_set_data(G_OBJECT(map), "gps_fix", fix); 

    /* get error */
    int radius = (set & FIX_HERR_SET)?dist2pixel(map, fix->eph/1000):0;

    g_object_set(map, "gps-track-highlight-radius", radius, NULL);
    osm_gps_map_draw_gps(map, fix->latitude, fix->longitude, fix->track);

  } else {
    g_object_set_data(G_OBJECT(map), "gps_fix", NULL); 
    osm_gps_map_clear_gps(map);
  }

#ifdef USE_MAEMO
  if((set & FIX_LATLON_SET) && toplevel) {
    /* check gps position every 10 seconds and trigger */
    /* screen saver if useful */
    time_t last = (time_t)g_object_get_data(G_OBJECT(map), "gps_timer"); 
    time_t now = time(NULL);
    if(now-last > 10) {
      /* get last saved position */
      coord_t *last_pos = g_object_get_data(G_OBJECT(map), "gps_pos"); 
      coord_t cur = { .rlat = deg2rad(fix->latitude),
		      .rlon = deg2rad(fix->longitude) };
      
      if(last_pos) {
	/* consider everything under 3 kph (~2 mph) to be static and */
	/* disable (trigger) screensaver only above this. 3.6kph = 10m/10sec */
	
	/* compare with reported position */
	if(get_distance(last_pos, &cur) > (now-last)) {
	  printf("SCREENSAVER: trigger after %d ...\n", (int)(now-last));
	  
	  osso_context_t *osso_context =  
	    g_object_get_data(G_OBJECT(toplevel), "osso-context");
	  g_assert(osso_context);
	  
	  osso_display_blanking_pause(osso_context);
	  
	} else
	  printf("SCREENSAVER: too slow, no trigger\n");
      } else {
	printf("SCREENSAVER: no last pos\n");
	last_pos = g_new0(coord_t, 1);
      }
      
      /* make current position the old one */
      last_pos->rlat = cur.rlat;
      last_pos->rlon = cur.rlon;
      
      g_object_set_data(G_OBJECT(map), "gps_timer", (gpointer)now); 
      g_object_set_data(G_OBJECT(map), "gps_pos", last_pos); 
    }
  }