]> git.sesse.net Git - vlc/blobdiff - plugins/dummy/vout_dummy.c
* Fixed the BeOS compile typo.
[vlc] / plugins / dummy / vout_dummy.c
index 5994843b485897c0e75ee6ae7a03542d8b741c65..8e4899fe522e72ca032d225aa5305679e84fbfb1 100644 (file)
@@ -1,9 +1,10 @@
 /*****************************************************************************
  * vout_dummy.c: Dummy video output display method for testing purposes
  *****************************************************************************
- * Copyright (C) 2000 VideoLAN
+ * Copyright (C) 2000, 2001 VideoLAN
+ * $Id: vout_dummy.c,v 1.8 2001/05/30 17:03:12 sam Exp $
  *
- * Authors:
+ * Authors: Samuel Hocevar <sam@zoy.org>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -20,6 +21,9 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
+#define MODULE_NAME dummy
+#include "modules_inner.h"
+
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
 #include "common.h"
 #include "threads.h"
 #include "mtime.h"
-#include "plugins.h"
+#include "tests.h"
 
 #include "video.h"
 #include "video_output.h"
 
 #include "intf_msg.h"
 
-#define WIDTH 16
-#define HEIGHT 16
-#define BITS_PER_PLANE 16
-#define BYTES_PER_PIXEL 2
+#include "modules.h"
+#include "modules_export.h"
+
+#define DUMMY_WIDTH 16
+#define DUMMY_HEIGHT 16
+#define DUMMY_BITS_PER_PLANE 16
+#define DUMMY_BYTES_PER_PIXEL 2
 
 /*****************************************************************************
  * vout_sys_t: dummy video output method descriptor
@@ -62,16 +69,49 @@ typedef struct vout_sys_s
 /*****************************************************************************
  * Local prototypes
  *****************************************************************************/
-static int     DummyOpenDisplay   ( vout_thread_t *p_vout );
-static void    DummyCloseDisplay  ( vout_thread_t *p_vout );
+static int  vout_Probe     ( probedata_t *p_data );
+static int  vout_Create    ( struct vout_thread_s * );
+static int  vout_Init      ( struct vout_thread_s * );
+static void vout_End       ( struct vout_thread_s * );
+static void vout_Destroy   ( struct vout_thread_s * );
+static int  vout_Manage    ( struct vout_thread_s * );
+static void vout_Display   ( struct vout_thread_s * );
+
+/*****************************************************************************
+ * Functions exported as capabilities. They are declared as static so that
+ * we don't pollute the namespace too much.
+ *****************************************************************************/
+void _M( vout_getfunctions )( function_list_t * p_function_list )
+{
+    p_function_list->pf_probe = vout_Probe;
+    p_function_list->functions.vout.pf_create     = vout_Create;
+    p_function_list->functions.vout.pf_init       = vout_Init;
+    p_function_list->functions.vout.pf_end        = vout_End;
+    p_function_list->functions.vout.pf_destroy    = vout_Destroy;
+    p_function_list->functions.vout.pf_manage     = vout_Manage;
+    p_function_list->functions.vout.pf_display    = vout_Display;
+    p_function_list->functions.vout.pf_setpalette = NULL;
+}
+
+/*****************************************************************************
+ * intf_Probe: return a score
+ *****************************************************************************/
+static int vout_Probe( probedata_t *p_data )
+{
+    if( TestMethod( VOUT_METHOD_VAR, "dummy" ) )
+    {
+        return( 999 );
+    }
+
+    return( 1 );
+}
 
 /*****************************************************************************
- * vout_DummyCreate: allocates dummy video thread output method
+ * vout_Create: allocates dummy video thread output method
  *****************************************************************************
  * This function allocates and initializes a dummy vout method.
  *****************************************************************************/
-int vout_DummyCreate( vout_thread_t *p_vout, char *psz_display,
-                    int i_root_window, void *p_data )
+static int vout_Create( vout_thread_t *p_vout )
 {
     /* Allocate structure */
     p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
@@ -81,109 +121,78 @@ int vout_DummyCreate( vout_thread_t *p_vout, char *psz_display,
         return( 1 );
     }
 
-    /* Open and initialize device */
-    if( DummyOpenDisplay( p_vout ) )
+    p_vout->i_width            = DUMMY_WIDTH;
+    p_vout->i_height           = DUMMY_HEIGHT;
+    p_vout->i_screen_depth     = DUMMY_BITS_PER_PLANE;
+    p_vout->i_bytes_per_pixel  = DUMMY_BYTES_PER_PIXEL;
+    p_vout->i_bytes_per_line   = DUMMY_WIDTH * DUMMY_BYTES_PER_PIXEL;
+
+    p_vout->p_sys->i_page_size = DUMMY_WIDTH * DUMMY_HEIGHT
+                                  * DUMMY_BYTES_PER_PIXEL;
+
+    /* Map two framebuffers a the very beginning of the fb */
+    p_vout->p_sys->p_video = malloc( 2 * p_vout->p_sys->i_page_size );
+    if( p_vout->p_sys->p_video == NULL )
     {
-        intf_ErrMsg("vout error: can't open display");
+        intf_ErrMsg( "vout error: can't map video memory (%s)",
+                     strerror(errno) );
         free( p_vout->p_sys );
         return( 1 );
     }
 
+    /* Set and initialize buffers */
+    p_vout->pf_setbuffers( p_vout, p_vout->p_sys->p_video,
+                     p_vout->p_sys->p_video + p_vout->p_sys->i_page_size );
+
     return( 0 );
 }
 
 /*****************************************************************************
- * vout_DummyInit: initialize dummy video thread output method
+ * vout_Init: initialize dummy video thread output method
  *****************************************************************************/
-int vout_DummyInit( vout_thread_t *p_vout )
+static int vout_Init( vout_thread_t *p_vout )
 {
     return( 0 );
 }
 
 /*****************************************************************************
- * vout_DummyEnd: terminate dummy video thread output method
+ * vout_End: terminate dummy video thread output method
  *****************************************************************************/
-void vout_DummyEnd( vout_thread_t *p_vout )
+static void vout_End( vout_thread_t *p_vout )
 {
     ;
 }
 
 /*****************************************************************************
- * vout_DummyDestroy: destroy dummy video thread output method
+ * vout_Destroy: destroy dummy video thread output method
  *****************************************************************************
  * Terminate an output method created by DummyCreateOutputMethod
  *****************************************************************************/
-void vout_DummyDestroy( vout_thread_t *p_vout )
+static void vout_Destroy( vout_thread_t *p_vout )
 {
-    DummyCloseDisplay( p_vout );
+    free( p_vout->p_sys->p_video );
     free( p_vout->p_sys );
 }
 
 /*****************************************************************************
- * vout_DummyManage: handle dummy events
+ * vout_Manage: handle dummy events
  *****************************************************************************
  * This function should be called regularly by video output thread. It manages
  * console events. It returns a non null value on error.
  *****************************************************************************/
-int vout_DummyManage( vout_thread_t *p_vout )
+static int vout_Manage( vout_thread_t *p_vout )
 {
     return( 0 );
 }
 
 /*****************************************************************************
- * vout_DummyDisplay: displays previously rendered output
+ * vout_Display: displays previously rendered output
  *****************************************************************************
  * This function send the currently rendered image to dummy image, waits until
  * it is displayed and switch the two rendering buffers, preparing next frame.
  *****************************************************************************/
-void vout_DummyDisplay( vout_thread_t *p_vout )
+static void vout_Display( vout_thread_t *p_vout )
 {
     ;
 }
 
-/* following functions are local */
-
-/*****************************************************************************
- * DummyOpenDisplay: open and initialize dummy device
- *****************************************************************************
- * XXX?? The framebuffer mode is only provided as a fast and efficient way to
- * display video, providing the card is configured and the mode ok. It is
- * not portable, and is not supposed to work with many cards. Use at your
- * own risk !
- *****************************************************************************/
-
-static int DummyOpenDisplay( vout_thread_t *p_vout )
-{
-    p_vout->i_width =                   WIDTH;
-    p_vout->i_height =                  HEIGHT;
-    p_vout->i_screen_depth =            BITS_PER_PLANE;
-    p_vout->i_bytes_per_pixel =         BYTES_PER_PIXEL;
-    p_vout->i_bytes_per_line =          WIDTH * BYTES_PER_PIXEL;
-
-    p_vout->p_sys->i_page_size = WIDTH * HEIGHT * BYTES_PER_PIXEL;
-
-    /* Map two framebuffers a the very beginning of the fb */
-    p_vout->p_sys->p_video = malloc( p_vout->p_sys->i_page_size * 2 );
-    if( (int)p_vout->p_sys->p_video == -1 )
-    {
-        intf_ErrMsg("vout error: can't map video memory (%s)", strerror(errno) );
-        return( 1 );
-    }
-
-    /* Set and initialize buffers */
-    vout_SetBuffers( p_vout, p_vout->p_sys->p_video,
-                     p_vout->p_sys->p_video + p_vout->p_sys->i_page_size );
-    return( 0 );
-}
-
-/*****************************************************************************
- * DummyCloseDisplay: close and reset dummy device
- *****************************************************************************
- * Returns all resources allocated by DummyOpenDisplay and restore the original
- * state of the device.
- *****************************************************************************/
-static void DummyCloseDisplay( vout_thread_t *p_vout )
-{
-    free( p_vout->p_sys->p_video );
-}
-