]> git.sesse.net Git - vlc/blobdiff - modules/visualization/galaktos/plugin.c
Another bunch of useless test.
[vlc] / modules / visualization / galaktos / plugin.c
index e8043e51702fac435101944f7807dacecc4a3a60..7e1db91c75164e98cf1be46ede7dfb581ad1be56 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * plugin.c:
  *****************************************************************************
- * Copyright (C) 2004 VideoLAN
+ * Copyright (C) 2004 the VideoLAN team
  * $Id$
  *
  * Authors: Cyril Deguet <asmax@videolan.org>
@@ -21,7 +21,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 /*****************************************************************************
  *****************************************************************************/
 
 #include "plugin.h"
-#include "glx.h"
 #include "main.h"
 #include "PCM.h"
 #include "video_init.h"
 #include <GL/glu.h>
 
-#include <vlc/input.h>
-#include <vlc/vout.h>
-#include "aout_internal.h"
+#include <vlc_input.h>
+#include <vlc_playlist.h>
 
 /*****************************************************************************
  * Module descriptor
@@ -47,7 +45,7 @@ static void Close        ( vlc_object_t * );
 
 vlc_module_begin();
     set_description( _("GaLaktos visualization plugin") );
-    set_capability( "audio filter", 0 );
+    set_capability( "visualization", 0 );
     set_callbacks( Open, Close );
     add_shortcut( "galaktos" );
 vlc_module_end();
@@ -78,13 +76,12 @@ static int Open( vlc_object_t *p_this )
 {
     aout_filter_t     *p_filter = (aout_filter_t *)p_this;
     aout_filter_sys_t *p_sys;
-    galaktos_thread_t     *p_thread;
-    vlc_value_t       width, height;
+    galaktos_thread_t *p_thread;
 
     if ( p_filter->input.i_format != VLC_FOURCC('f','l','3','2' )
          || p_filter->output.i_format != VLC_FOURCC('f','l','3','2') )
     {
-        msg_Warn( p_filter, "Bad input or output format" );
+        msg_Warn( p_filter, "bad input or output format" );
         return VLC_EGENERIC;
     }
     if ( !AOUT_FMTS_SIMILAR( &p_filter->input, &p_filter->output ) )
@@ -116,7 +113,6 @@ static int Open( vlc_object_t *p_this )
     p_thread->i_width = 600;
     p_thread->i_height = 600;
     p_thread->b_fullscreen = 0;
-    galaktos_glx_init( p_thread );
     galaktos_init( p_thread );
 
     p_thread->i_channels = aout_FormatNbChannels( &p_filter->input );
@@ -127,9 +123,9 @@ static int Open( vlc_object_t *p_this )
                            VLC_THREAD_PRIORITY_LOW, VLC_FALSE ) )
     {
         msg_Err( p_filter, "cannot lauch galaktos thread" );
-        if( p_thread->psz_title ) free( p_thread->psz_title );
+        free( p_thread->psz_title );
         vlc_object_detach( p_thread );
-        vlc_object_destroy( p_thread );
+        vlc_object_release( p_thread );
         free( p_sys );
         return VLC_EGENERIC;
     }
@@ -137,7 +133,6 @@ static int Open( vlc_object_t *p_this )
     return VLC_SUCCESS;
 }
 
-
 /*****************************************************************************
  * float to s16 conversion
  *****************************************************************************/
@@ -151,7 +146,6 @@ static inline int16_t FloatToInt16( float f )
         return (int16_t)( f * 32768.0 );
 }
 
-
 /*****************************************************************************
  * DoWork: process samples buffer
  *****************************************************************************
@@ -203,7 +197,44 @@ static void Thread( vlc_object_t *p_this )
     int timestart=0;
     int mspf=0;
 
-    galaktos_glx_activate_window( p_thread );
+    /* Get on OpenGL provider */
+    p_thread->p_opengl =
+        (vout_thread_t *)vlc_object_create( p_this, VLC_OBJECT_OPENGL );
+    if( p_thread->p_opengl == NULL )
+    {
+        msg_Err( p_thread, "out of memory" );
+        return;
+    }
+    vlc_object_attach( p_thread->p_opengl, p_this );
+
+    /* Initialize vout parameters */
+    vout_InitFormat( &p_thread->p_opengl->fmt_in,
+                     VLC_FOURCC('R','V','3','2'),
+                     p_thread->i_width, p_thread->i_height, 1 );
+    p_thread->p_opengl->i_window_width = p_thread->i_width;
+    p_thread->p_opengl->i_window_height = p_thread->i_height;
+    p_thread->p_opengl->render.i_width = p_thread->i_width;
+    p_thread->p_opengl->render.i_height = p_thread->i_width;
+    p_thread->p_opengl->render.i_aspect = VOUT_ASPECT_FACTOR;
+    p_thread->p_opengl->b_scale = VLC_TRUE;
+    p_thread->p_opengl->b_fullscreen = VLC_FALSE;
+    p_thread->p_opengl->i_alignment = 0;
+    p_thread->p_opengl->fmt_in.i_sar_num = 1;
+    p_thread->p_opengl->fmt_in.i_sar_den = 1;
+    p_thread->p_opengl->fmt_render = p_thread->p_opengl->fmt_in;
+
+    p_thread->p_module =
+        module_Need( p_thread->p_opengl, "opengl provider", NULL, 0 );
+    if( p_thread->p_module == NULL )
+    {
+        msg_Err( p_thread, "unable to initialize OpenGL" );
+        vlc_object_detach( p_thread->p_opengl );
+        vlc_object_release( p_thread->p_opengl );
+        return;
+    }
+
+    p_thread->p_opengl->pf_init( p_thread->p_opengl );
+
     setup_opengl( p_thread->i_width, p_thread->i_height );
     CreateRenderTarget(512, &RenderTargetTextureID, NULL);
 
@@ -214,13 +245,10 @@ static void Thread( vlc_object_t *p_this )
         mspf = 1000 / 60;
         if( galaktos_update( p_thread ) == 1 )
         {
-            p_thread->b_die = 1;
-        }
-        if( p_thread->psz_title )
-        {
-            free( p_thread->psz_title );
-            p_thread->psz_title = NULL;
+            vlc_object_kill( p_thread );
         }
+        free( p_thread->psz_title );
+        p_thread->psz_title = NULL;
 
         if (++count%100==0)
         {
@@ -236,7 +264,10 @@ static void Thread( vlc_object_t *p_this )
         timestart=mdate()/1000;
     }
 
-    galaktos_glx_done( p_thread );
+    /* Free the openGL provider */
+    module_Unneed( p_thread->p_opengl, p_thread->p_module );
+    vlc_object_detach( p_thread->p_opengl );
+    vlc_object_release( p_thread->p_opengl );
 }
 
 /*****************************************************************************
@@ -248,7 +279,7 @@ static void Close( vlc_object_t *p_this )
     aout_filter_sys_t *p_sys = p_filter->p_sys;
 
     /* Stop galaktos Thread */
-    p_sys->p_thread->b_die = VLC_TRUE;
+    vlc_object_kill( p_sys->p_thread );
 
     galaktos_done( p_sys->p_thread );
 
@@ -256,8 +287,7 @@ static void Close( vlc_object_t *p_this )
 
     /* Free data */
     vlc_object_detach( p_sys->p_thread );
-
-    vlc_object_destroy( p_sys->p_thread );
+    vlc_object_release( p_sys->p_thread );
 
     free( p_sys );
 }
@@ -270,7 +300,8 @@ static char *TitleGet( vlc_object_t *p_this )
 
     if( p_input )
     {
-        char *psz = strrchr( p_input->input.p_item->psz_uri, '/' );
+        char *psz_orig = input_item_GetURI( input_GetItem( p_input ) );
+        char *psz = strrchr( psz_orig, '/' );
 
         if( psz )
         {
@@ -278,12 +309,13 @@ static char *TitleGet( vlc_object_t *p_this )
         }
         else
         {
-            psz = p_input->input.p_item->psz_uri;
+            psz = psz_orig;
         }
         if( psz && *psz )
         {
             psz_title = strdup( psz );
         }
+        free( psz_orig );
         vlc_object_release( p_input );
     }