示例#1
0
  bool Actor::video_negotiate (VisVideoDepth run_depth, bool noevent, bool forced)
  {
      auto output_width  = m_impl->video->get_width ();
      auto output_height = m_impl->video->get_height ();
      auto output_depth  = m_impl->video->get_depth ();

      // Ask actor for preferred rendering dimensions

      int run_width  = output_width;
      int run_height = output_height;

      m_impl->get_actor_plugin ()->requisition (m_impl->plugin, &run_width, &run_height);

      // Check to make sure requested run depth is supported. If not, pick the highest.

      auto supported_depths = get_supported_depths ();
      m_impl->run_depth = forced ? run_depth : visual_video_depth_get_highest_nogl (supported_depths);

      if (!visual_video_depth_is_supported (supported_depths, m_impl->run_depth)) {
          m_impl->run_depth = visual_video_depth_get_highest_nogl (supported_depths);
      }

      // Configure proxy videos to convert rendering

      m_impl->to_scale.reset ();
      m_impl->to_convert.reset ();

      visual_log (VISUAL_LOG_DEBUG, "Setting up any necessary video conversions..");

      if (output_depth != VISUAL_VIDEO_DEPTH_GL) {
          // Configure any necessary depth conversion
          if (m_impl->run_depth != output_depth) {
              visual_log (VISUAL_LOG_DEBUG, "Setting up depth conversion: %s -> %s",
                          visual_video_depth_name (m_impl->run_depth),
                          visual_video_depth_name (output_depth));

              m_impl->to_convert = Video::create (output_width, output_height, m_impl->run_depth);
          }

          // Configure any necessary scaling
          if (run_width != output_width || run_height != output_height) {
              visual_log (VISUAL_LOG_DEBUG, "Setting up scaling: (%dx%d) -> (%dx%d)",
                          run_width, run_height, output_width, output_height);

              m_impl->to_scale = Video::create (run_width, run_height, output_depth);
          }
      } else {
          visual_log (VISUAL_LOG_DEBUG, "Conversions skipped in OpenGL rendering mode");
      }

      // FIXME: This should be moved into the if block above. It's out
      // here because plugins depend on this to receive information
      // about initial dimensions
      if (!noevent) {
          visual_event_queue_add (visual_plugin_get_event_queue (m_impl->plugin),
                                  visual_event_new_resize (run_width, run_height));
      }

      return true;
  }
示例#2
0
int pipeline_container_propagate_event (LVAVSPipelineContainer *container, VisEvent *event)
{
    VisListEntry *le = NULL;
    VisEventQueue *pluginqueue;
    LVAVSPipelineElement *element;

    while ((element = visual_list_next (container->members, &le)) != NULL) {

        switch (element->type) {
            case LVAVS_PIPELINE_ELEMENT_TYPE_ACTOR:

                pluginqueue = visual_plugin_get_eventqueue (visual_actor_get_plugin (element->data.actor));

                visual_object_ref (VISUAL_OBJECT (event));
                visual_event_queue_add (pluginqueue, event);

                break;

            case LVAVS_PIPELINE_ELEMENT_TYPE_TRANSFORM:

                pluginqueue = visual_plugin_get_eventqueue (visual_actor_get_plugin (element->data.actor));

                visual_object_ref (VISUAL_OBJECT (event));
                visual_event_queue_add (pluginqueue, event);

                break;

            case LVAVS_PIPELINE_ELEMENT_TYPE_CONTAINER:

                pipeline_container_propagate_event (LVAVS_PIPELINE_CONTAINER (element), event);

                break;

            default:

                break;
        }
    }


    return VISUAL_OK;
}
int visual_transform_video_negotiate (VisTransform *transform)
{
    int depthflag;

    visual_return_val_if_fail (transform != NULL, -VISUAL_ERROR_TRANSFORM_NULL);
    visual_return_val_if_fail (transform->plugin != NULL, -VISUAL_ERROR_PLUGIN_NULL);

    depthflag = visual_transform_get_supported_depth (transform);

    if (!visual_video_depth_is_supported (depthflag, transform->video->depth))
        return -VISUAL_ERROR_TRANSFORM_NEGOTIATE;

    visual_event_queue_add (transform->plugin->eventqueue,
                            visual_event_new_resize (transform->video->width,
                                                     transform->video->height));

    visual_plugin_events_pump (transform->plugin);

    return -VISUAL_OK;
}
示例#4
0
int main (int argc, char **argv)
{
	SADisplay *display;
	VisVideo *video;

	VisInput *input;
	VisActor *actor;
	VisEventQueue *localqueue;
	VisVideoAttributeOptions *vidoptions;

	int running = TRUE;
	int fullscreen = FALSE;
	int visible = TRUE;

	int depth;

	//visual_mem_alloc_install_vtable (visual_mem_alloc_vtable_profile ());

	visual_init (&argc, &argv);

	display = display_new (sdl_driver_new ());

	/* Libvisual stuff */
	if (argc > 1)
		actor = visual_actor_new (argv[1]);
	else
		actor = visual_actor_new ("projectM");


	if (argc > 3) {
		depth = visual_video_depth_enum_from_value (atoi (argv[3]));
	} else
		depth = visual_video_depth_get_highest (visual_actor_get_supported_depth (actor));

	vidoptions = visual_actor_get_video_attribute_options (actor);

	display_create (display, depth, vidoptions, 480, 360, TRUE);

	visual_actor_realize (actor);

	video = display_get_video (display);

        visual_actor_set_video (actor, video);
	visual_actor_video_negotiate (actor, 0, FALSE, FALSE);

	if (argc > 2)
		input = visual_input_new (argv[2]);
	else
		input = visual_input_new ("alsa");

	visual_input_realize (input);

	localqueue = visual_event_queue_new ();

	while (running) {
		VisEventQueue *pluginqueue;
		VisEvent *ev;

		/* Handle all events */
		display_drain_events (display, localqueue);

		pluginqueue = visual_plugin_get_eventqueue (visual_actor_get_plugin (actor));
		while (visual_event_queue_poll_by_reference (localqueue, &ev)) {

			if (ev->type != VISUAL_EVENT_RESIZE)
				visual_event_queue_add (pluginqueue, ev);

			switch (ev->type) {
				case VISUAL_EVENT_RESIZE:
					video = display_get_video (display);
					visual_actor_set_video (actor, video);

					visual_actor_video_negotiate (actor, depth, FALSE, FALSE);
					break;

				case VISUAL_EVENT_MOUSEMOTION:
					break;

				case VISUAL_EVENT_MOUSEBUTTONDOWN:

					break;

				case VISUAL_EVENT_MOUSEBUTTONUP:
					break;

				case VISUAL_EVENT_KEYDOWN:
					switch (ev->event.keyboard.keysym.sym) {
						case VKEY_ESCAPE:
							running = FALSE;
							break;

						case VKEY_TAB:
							fullscreen = !fullscreen;

							display_set_fullscreen (display, fullscreen, TRUE);

							/* Resync video */
							video = display_get_video (display);
							visual_actor_set_video (actor, video);

							visual_actor_video_negotiate (actor, depth, FALSE, FALSE);

							break;

						default:
							printf ("key: %c\n", ev->event.keyboard.keysym.sym);
							break;
					}

					break;

				case VISUAL_EVENT_KEYUP:
					break;

				case VISUAL_EVENT_QUIT:
					running = FALSE;
					break;

				case VISUAL_EVENT_VISIBILITY:
					visible = ev->event.visibility.is_visible;
					break;

				default:
					break;
			}
		}

		if (visible == FALSE) {
			visual_input_run (input);

			visual_time_usleep (10000);

			continue;
		}

		/* Do a run cycle */
		visual_input_run (input);

		display_lock (display);
		visual_actor_run (actor, input->audio);
		display_unlock (display);

		display_update_all (display);

		display_fps_limit (display, 30);
	}

	/* Termination procedure */
	display_set_fullscreen (display, FALSE, TRUE);
	display_close (display);

	visual_quit ();

	//visual_mem_alloc_profile ();

	printf ("Total frames: %d, average fps: %f\n", display_fps_total (display), display_fps_average (display));

	return 0;
}
示例#5
0
  void Actor::run (Audio const& audio)
  {
      visual_return_if_fail (m_impl->video);

      auto actor_plugin = m_impl->get_actor_plugin ();
      if (!actor_plugin) {
          visual_log (VISUAL_LOG_ERROR, "The given actor does not reference any actor plugin");
          return;
      }

      auto plugin = get_plugin ();

      /* Songinfo handling */
      if (!visual_songinfo_compare (&m_impl->songcompare, actor_plugin->songinfo) ||
          m_impl->songcompare.get_elapsed () != actor_plugin->songinfo->get_elapsed ()) {

          actor_plugin->songinfo->mark ();

          visual_event_queue_add (visual_plugin_get_event_queue (plugin),
                                  visual_event_new_newsong (actor_plugin->songinfo));

          visual_songinfo_copy (&m_impl->songcompare, actor_plugin->songinfo);
      }

      // Get plugin to process all events
      visual_plugin_events_pump (m_impl->plugin);

      auto const& video      = m_impl->video;
      auto const& to_convert = m_impl->to_convert;
      auto const& to_scale   = m_impl->to_scale;

      if (video->get_depth () != VISUAL_VIDEO_DEPTH_GL) {
          auto palette = get_palette ();

          if (to_convert) {
              // Have depth conversion

              // Setup any palette
              if (palette) {
                  to_convert->set_palette (*palette);
              }

              // Render first
              actor_plugin->render (m_impl->plugin, to_convert.get (), const_cast<Audio*> (&audio));

              if (to_scale) {
                  // Convert depth, then scale
                  to_scale->convert_depth (to_convert);
                  video->scale (to_scale, VISUAL_VIDEO_SCALE_NEAREST);
              }
              else {
                  // Convert depth only
                  video->convert_depth (to_convert);
              }
          } else {
              // No depth conversion

              if (to_scale) {
                  // Setup any palette
                  if (palette) {
                      to_scale->set_palette (*palette);
                  }

                  // Render, then scale
                  actor_plugin->render (m_impl->plugin, to_scale.get (), const_cast<Audio*> (&audio));
                  video->scale (to_scale, VISUAL_VIDEO_SCALE_NEAREST);
              } else {
                  // Setup any palette
                  if (palette) {
                      video->set_palette (*palette);
                  }

                  // Render directly to video target
                  actor_plugin->render (m_impl->plugin, video.get (), const_cast<Audio*> (&audio));
              }
          }
      } else {
          // Render directly to video target (OpenGL)
          actor_plugin->render (m_impl->plugin, video.get (), const_cast<Audio*> (&audio));
      }
  }