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 $
7 * Authors: Samuel Hocevar <sam@zoy.org>
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.
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.
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 *****************************************************************************/
24 #define MODULE_NAME dummy
25 #include "modules_inner.h"
27 /*****************************************************************************
29 *****************************************************************************/
32 #include <errno.h> /* ENOMEM */
33 #include <stdlib.h> /* free() */
34 #include <string.h> /* strerror() */
43 #include "video_output.h"
48 #include "modules_export.h"
50 #define DUMMY_WIDTH 16
51 #define DUMMY_HEIGHT 16
52 #define DUMMY_BITS_PER_PLANE 16
53 #define DUMMY_BYTES_PER_PIXEL 2
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
63 /* Dummy video memory */
64 byte_t * p_video; /* base adress */
65 size_t i_page_size; /* page size */
69 /*****************************************************************************
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 * );
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 )
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;
96 /*****************************************************************************
97 * intf_Probe: return a score
98 *****************************************************************************/
99 static int vout_Probe( probedata_t *p_data )
101 if( TestMethod( VOUT_METHOD_VAR, "dummy" ) )
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 )
116 /* Allocate structure */
117 p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
118 if( p_vout->p_sys == NULL )
120 intf_ErrMsg("error: %s", strerror(ENOMEM) );
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;
130 p_vout->p_sys->i_page_size = DUMMY_WIDTH * DUMMY_HEIGHT
131 * DUMMY_BYTES_PER_PIXEL;
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 )
137 intf_ErrMsg( "vout error: can't map video memory (%s)",
139 free( p_vout->p_sys );
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 );
150 /*****************************************************************************
151 * vout_Init: initialize dummy video thread output method
152 *****************************************************************************/
153 static int vout_Init( vout_thread_t *p_vout )
158 /*****************************************************************************
159 * vout_End: terminate dummy video thread output method
160 *****************************************************************************/
161 static void vout_End( vout_thread_t *p_vout )
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 )
173 free( p_vout->p_sys->p_video );
174 free( p_vout->p_sys );
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 )
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 )