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