Пример #1
0
/** LibVisual.init() */
JNIEXPORT jboolean JNICALL Java_org_libvisual_android_LibVisual_init(JNIEnv * env, jobject  obj)
{
    if(visual_is_initialized())
                return JNI_TRUE;

    LOGI("LibVisual.init(): %s", visual_get_version());

#ifndef NDEBUG
    /* endless loop to wait for debugger to attach */
    int foo = 1;
    while(foo);
#endif
        
    /* register VisLog handler to make it log to android logcat */
    visual_log_set_handler(VISUAL_LOG_DEBUG, _log_handler, NULL);
    visual_log_set_handler(VISUAL_LOG_INFO, _log_handler, NULL);
    visual_log_set_handler(VISUAL_LOG_WARNING, _log_handler, NULL);
    visual_log_set_handler(VISUAL_LOG_CRITICAL, _log_handler, NULL);
    visual_log_set_handler(VISUAL_LOG_ERROR, _log_handler, NULL);
    visual_log_set_verbosity(VISUAL_LOG_DEBUG);


    /* initialize libvisual */
    char *v[] = { "lvclient", NULL };
    char **argv = v;
    int argc=1;
    visual_init(&argc,  &argv);

    /* add our plugin search path */
    visual_plugin_registry_add_path("/data/data/org.libvisual.android/lib");

        
    return JNI_TRUE;
}
Пример #2
0
    static void
    init( int &argc, char **&argv )
    {
        VisVideoDepth depth;

        visual_init( &argc, &argv );

        bin    = visual_bin_new ();
        depth  = visual_video_depth_enum_from_value( 24 );

        if( !plugin ) plugin = visual_actor_get_next_by_name( 0 );
        if( !plugin ) exit( "Actor plugin not found!" );

        visual_bin_set_supported_depth( bin, VISUAL_VIDEO_DEPTH_ALL );

        if( NULL == (video = visual_video_new()) )       exit( "Cannot create a video surface" );
        if( visual_video_set_depth( video, depth ) < 0 ) exit( "Cannot set video depth" );

        visual_video_set_dimension( video, 320, 200 );

        if( visual_bin_set_video( bin, video ) ) exit( "Cannot set video" );

        visual_bin_connect_by_names( bin, (char*)plugin, 0 );

        if( visual_bin_get_depth( bin ) == VISUAL_VIDEO_DEPTH_GL )
        {
            visual_video_set_depth( video, VISUAL_VIDEO_DEPTH_GL );
            pluginIsGL = true;
        }

        SDL::create( 320, 200 );

        SDL_WM_SetCaption( plugin, 0 );

        /* Called so the flag is set to false, seen we create the initial environment here */
        visual_bin_depth_changed( bin );

        VisInput *input = visual_bin_get_input( bin );
        if( visual_input_set_callback( input, upload_callback, NULL ) < 0 ) exit( "Cannot set input plugin callback" );

        visual_bin_switch_set_style( bin, VISUAL_SWITCH_STYLE_MORPH );
        visual_bin_switch_set_automatic( bin, true );
        visual_bin_switch_set_steps( bin, 100 );

        visual_bin_realize( bin );
        visual_bin_sync( bin, false );

        std::cout << "[PANA] Libvisual version " << visual_get_version() << '\n';
        std::cout << "[PANA] bpp: " << video->bpp << std::endl;
        std::cout << "[PANA]  GL: "  << (pluginIsGL ? "true\n" : "false\n");
    }
  PluginRef* load_plugin_ref (std::string const& plugin_path)
  {
      // NOTE: This does not check if a plugin has already been loaded

      try {
          ModulePtr module = Module::load (plugin_path);

          int* plugin_version = static_cast<int*> (module->get_symbol (VISUAL_PLUGIN_VERSION_TAG));

          if (!plugin_version || *plugin_version != VISUAL_PLUGIN_API_VERSION) {
              visual_log (VISUAL_LOG_ERROR, _("Plugin %s is not compatible with version %s of libvisual"),
                          plugin_path.c_str (), visual_get_version ());
              return NULL;
          }

          VisPluginGetInfoFunc get_plugin_info =
              reinterpret_cast<VisPluginGetInfoFunc> (module->get_symbol ("get_plugin_info"));

          if (!get_plugin_info) {
              visual_log (VISUAL_LOG_ERROR, _("Cannot get function that returns plugin info"));
              return NULL;
          }

          VisPluginInfo const* plugin_info = get_plugin_info ();

          if (!plugin_info) {
              visual_log (VISUAL_LOG_ERROR, _("Cannot get plugin info"));
              return NULL;
          }

          PluginRef* ref = new PluginRef;

          ref->info   = plugin_info;
          ref->file   = plugin_path;
          ref->module = module;

          return ref;
      }
      catch (LV::Error& error) {
          visual_log (VISUAL_LOG_ERROR, "Cannot load plugin (%s): %s", plugin_path.c_str (), error.what());
          return NULL;
      }
  }