]> git.sesse.net Git - vlc/blob - plugins/dummy/vout_dummy.c
* Ported Glide and MGA plugins to the new module API. MGA never worked,
[vlc] / plugins / dummy / vout_dummy.c
1 /*****************************************************************************
2  * vout_dummy.c: Dummy video output display method for testing purposes
3  *****************************************************************************
4  * Copyright (C) 2000, 2001 VideoLAN
5  *
6  * Authors: Samuel Hocevar <sam@zoy.org>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  * 
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
21  *****************************************************************************/
22
23 #define MODULE_NAME dummy
24 #include "modules_inner.h"
25
26 /*****************************************************************************
27  * Preamble
28  *****************************************************************************/
29 #include "defs.h"
30
31 #include <errno.h>                                                 /* ENOMEM */
32 #include <stdlib.h>                                                /* free() */
33 #include <string.h>                                            /* strerror() */
34
35 #include "config.h"
36 #include "common.h"
37 #include "threads.h"
38 #include "mtime.h"
39 #include "tests.h"
40
41 #include "video.h"
42 #include "video_output.h"
43
44 #include "intf_msg.h"
45
46 #include "modules.h"
47
48 #define DUMMY_WIDTH 16
49 #define DUMMY_HEIGHT 16
50 #define DUMMY_BITS_PER_PLANE 16
51 #define DUMMY_BYTES_PER_PIXEL 2
52
53 /*****************************************************************************
54  * vout_sys_t: dummy video output method descriptor
55  *****************************************************************************
56  * This structure is part of the video output thread descriptor.
57  * It describes the dummy specific properties of an output thread.
58  *****************************************************************************/
59 typedef struct vout_sys_s
60 {
61     /* Dummy video memory */
62     byte_t *                    p_video;                      /* base adress */
63     size_t                      i_page_size;                    /* page size */
64
65 } vout_sys_t;
66
67 /*****************************************************************************
68  * Local prototypes
69  *****************************************************************************/
70 static int  vout_Probe     ( probedata_t *p_data );
71 static int  vout_Create    ( struct vout_thread_s * );
72 static int  vout_Init      ( struct vout_thread_s * );
73 static void vout_End       ( struct vout_thread_s * );
74 static void vout_Destroy   ( struct vout_thread_s * );
75 static int  vout_Manage    ( struct vout_thread_s * );
76 static void vout_Display   ( struct vout_thread_s * );
77
78 /*****************************************************************************
79  * Functions exported as capabilities. They are declared as static so that
80  * we don't pollute the namespace too much.
81  *****************************************************************************/
82 void _M( vout_getfunctions )( function_list_t * p_function_list )
83 {
84     p_function_list->pf_probe = vout_Probe;
85     p_function_list->functions.vout.pf_create     = vout_Create;
86     p_function_list->functions.vout.pf_init       = vout_Init;
87     p_function_list->functions.vout.pf_end        = vout_End;
88     p_function_list->functions.vout.pf_destroy    = vout_Destroy;
89     p_function_list->functions.vout.pf_manage     = vout_Manage;
90     p_function_list->functions.vout.pf_display    = vout_Display;
91     p_function_list->functions.vout.pf_setpalette = NULL;
92 }
93
94 /*****************************************************************************
95  * intf_Probe: return a score
96  *****************************************************************************/
97 static int vout_Probe( probedata_t *p_data )
98 {
99     if( TestMethod( VOUT_METHOD_VAR, "dummy" ) )
100     {
101         return( 999 );
102     }
103
104     return( 1 );
105 }
106
107 /*****************************************************************************
108  * vout_Create: allocates dummy video thread output method
109  *****************************************************************************
110  * This function allocates and initializes a dummy vout method.
111  *****************************************************************************/
112 static int vout_Create( vout_thread_t *p_vout )
113 {
114     /* Allocate structure */
115     p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
116     if( p_vout->p_sys == NULL )
117     {
118         intf_ErrMsg("error: %s", strerror(ENOMEM) );
119         return( 1 );
120     }
121
122     p_vout->i_width            = DUMMY_WIDTH;
123     p_vout->i_height           = DUMMY_HEIGHT;
124     p_vout->i_screen_depth     = DUMMY_BITS_PER_PLANE;
125     p_vout->i_bytes_per_pixel  = DUMMY_BYTES_PER_PIXEL;
126     p_vout->i_bytes_per_line   = DUMMY_WIDTH * DUMMY_BYTES_PER_PIXEL;
127
128     p_vout->p_sys->i_page_size = DUMMY_WIDTH * DUMMY_HEIGHT
129                                   * DUMMY_BYTES_PER_PIXEL;
130
131     /* Map two framebuffers a the very beginning of the fb */
132     p_vout->p_sys->p_video = malloc( 2 * p_vout->p_sys->i_page_size );
133     if( p_vout->p_sys->p_video == NULL )
134     {
135         intf_ErrMsg( "vout error: can't map video memory (%s)",
136                      strerror(errno) );
137         free( p_vout->p_sys );
138         return( 1 );
139     }
140
141     /* Set and initialize buffers */
142     vout_SetBuffers( p_vout, p_vout->p_sys->p_video,
143                      p_vout->p_sys->p_video + p_vout->p_sys->i_page_size );
144
145     return( 0 );
146 }
147
148 /*****************************************************************************
149  * vout_Init: initialize dummy video thread output method
150  *****************************************************************************/
151 static int vout_Init( vout_thread_t *p_vout )
152 {
153     return( 0 );
154 }
155
156 /*****************************************************************************
157  * vout_End: terminate dummy video thread output method
158  *****************************************************************************/
159 static void vout_End( vout_thread_t *p_vout )
160 {
161     ;
162 }
163
164 /*****************************************************************************
165  * vout_Destroy: destroy dummy video thread output method
166  *****************************************************************************
167  * Terminate an output method created by DummyCreateOutputMethod
168  *****************************************************************************/
169 static void vout_Destroy( vout_thread_t *p_vout )
170 {
171     free( p_vout->p_sys->p_video );
172     free( p_vout->p_sys );
173 }
174
175 /*****************************************************************************
176  * vout_Manage: handle dummy events
177  *****************************************************************************
178  * This function should be called regularly by video output thread. It manages
179  * console events. It returns a non null value on error.
180  *****************************************************************************/
181 static int vout_Manage( vout_thread_t *p_vout )
182 {
183     return( 0 );
184 }
185
186 /*****************************************************************************
187  * vout_Display: displays previously rendered output
188  *****************************************************************************
189  * This function send the currently rendered image to dummy image, waits until
190  * it is displayed and switch the two rendering buffers, preparing next frame.
191  *****************************************************************************/
192 static void vout_Display( vout_thread_t *p_vout )
193 {
194     ;
195 }
196