/** * This is called to run a VisActor. It also pump it's events when needed, checks for new song events and also does the fitting * and depth transformation actions when needed. * * Every run cycle one frame is created, so this function needs to be used in the main draw loop of the application. * * @param actor Pointer to a VisActor that needs to be runned. * @param audio Pointer to a VisAudio that contains all the audio data. * * return VISUAL_OK on succes, -VISUAL_ERROR_ACTOR_NULL, -VISUAL_ERROR_ACTOR_VIDEO_NULL, -VISUAL_ERROR_NULL or * -VISUAL_ERROR_ACTOR_PLUGIN_NULL on failure. */ int visual_actor_run (VisActor *actor, VisAudio *audio) { VisActorPlugin *actplugin; VisPluginData *plugin; VisVideo *video; VisVideo *transform; VisVideo *fitting; /* We don't check for video, because we don't always need a video */ /* * Really? take a look at visual_video_set_palette bellow */ visual_log_return_val_if_fail (actor != NULL, -VISUAL_ERROR_ACTOR_NULL); visual_log_return_val_if_fail (actor->video != NULL, -VISUAL_ERROR_ACTOR_VIDEO_NULL); visual_log_return_val_if_fail (audio != NULL, -VISUAL_ERROR_NULL); actplugin = get_actor_plugin (actor); plugin = visual_actor_get_plugin (actor); if (actplugin == NULL) { visual_log (VISUAL_LOG_CRITICAL, _("The given actor does not reference any actor plugin")); return -VISUAL_ERROR_ACTOR_PLUGIN_NULL; } /* Songinfo handling */ if(0) /*FIXME*/if (visual_songinfo_compare (&actor->songcompare, &actplugin->songinfo) == FALSE || actor->songcompare.elapsed != actplugin->songinfo.elapsed) { visual_songinfo_mark (&actplugin->songinfo); visual_event_queue_add_newsong ( visual_plugin_get_eventqueue (plugin), &actplugin->songinfo); visual_songinfo_free_strings (&actor->songcompare); visual_songinfo_copy (&actor->songcompare, &actplugin->songinfo); } video = actor->video; transform = actor->transform; fitting = actor->fitting; /* * This needs to happen before palette, render stuff, always, period. * Also internal vars can be initialized when params have been set in init on the param * events in the event loop. */ visual_plugin_events_pump (actor->plugin); visual_video_set_palette (video, visual_actor_get_palette (actor)); /* Set the palette to the target video */ video->pal = visual_actor_get_palette (actor); /* Yeah some transformation magic is going on here when needed */ if (transform != NULL && (transform->depth != video->depth)) { actplugin->render (plugin, transform, audio); if (transform->depth == VISUAL_VIDEO_DEPTH_8BIT) { visual_video_set_palette (transform, visual_actor_get_palette (actor)); visual_video_depth_transform (video, transform); } else { visual_video_set_palette (transform, actor->ditherpal); visual_video_depth_transform (video, transform); } } else { if (fitting != NULL && (fitting->width != video->width || fitting->height != video->height)) { actplugin->render (plugin, fitting, audio); visual_video_blit_overlay (video, fitting, 0, 0, FALSE); } else { actplugin->render (plugin, video, audio); } } return VISUAL_OK; }
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)); } }