1 /*****************************************************************************
2 * vout_dummy.c: Dummy video output display method for testing purposes
3 *****************************************************************************
4 * Copyright (C) 2000, 2001 VideoLAN
6 * Authors: Samuel Hocevar <sam@zoy.org>
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.
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.
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 *****************************************************************************/
23 /*****************************************************************************
25 *****************************************************************************/
28 #include <errno.h> /* ENOMEM */
29 #include <stdlib.h> /* free() */
30 #include <string.h> /* strerror() */
40 #include "video_output.h"
44 #define DUMMY_WIDTH 16
45 #define DUMMY_HEIGHT 16
46 #define DUMMY_BITS_PER_PLANE 16
47 #define DUMMY_BYTES_PER_PIXEL 2
49 /*****************************************************************************
50 * vout_sys_t: dummy video output method descriptor
51 *****************************************************************************
52 * This structure is part of the video output thread descriptor.
53 * It describes the dummy specific properties of an output thread.
54 *****************************************************************************/
55 typedef struct vout_sys_s
57 /* Dummy video memory */
58 byte_t * p_video; /* base adress */
59 size_t i_page_size; /* page size */
63 /*****************************************************************************
65 *****************************************************************************/
66 static int vout_Probe ( probedata_t *p_data );
67 static int vout_Create ( struct vout_thread_s * );
68 static int vout_Init ( struct vout_thread_s * );
69 static void vout_End ( struct vout_thread_s * );
70 static void vout_Destroy ( struct vout_thread_s * );
71 static int vout_Manage ( struct vout_thread_s * );
72 static void vout_Display ( struct vout_thread_s * );
74 /*****************************************************************************
75 * Functions exported as capabilities. They are declared as static so that
76 * we don't pollute the namespace too much.
77 *****************************************************************************/
78 void vout_getfunctions( function_list_t * p_function_list )
80 p_function_list->pf_probe = vout_Probe;
81 p_function_list->functions.vout.pf_create = vout_Create;
82 p_function_list->functions.vout.pf_init = vout_Init;
83 p_function_list->functions.vout.pf_end = vout_End;
84 p_function_list->functions.vout.pf_destroy = vout_Destroy;
85 p_function_list->functions.vout.pf_manage = vout_Manage;
86 p_function_list->functions.vout.pf_display = vout_Display;
87 p_function_list->functions.vout.pf_setpalette = NULL;
90 /*****************************************************************************
91 * intf_Probe: return a score
92 *****************************************************************************/
93 static int vout_Probe( probedata_t *p_data )
95 if( TestMethod( VOUT_METHOD_VAR, "dummy" ) )
103 /*****************************************************************************
104 * vout_Create: allocates dummy video thread output method
105 *****************************************************************************
106 * This function allocates and initializes a dummy vout method.
107 *****************************************************************************/
108 static int vout_Create( vout_thread_t *p_vout )
110 /* Allocate structure */
111 p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
112 if( p_vout->p_sys == NULL )
114 intf_ErrMsg("error: %s", strerror(ENOMEM) );
118 p_vout->i_width = DUMMY_WIDTH;
119 p_vout->i_height = DUMMY_HEIGHT;
120 p_vout->i_screen_depth = DUMMY_BITS_PER_PLANE;
121 p_vout->i_bytes_per_pixel = DUMMY_BYTES_PER_PIXEL;
122 p_vout->i_bytes_per_line = DUMMY_WIDTH * DUMMY_BYTES_PER_PIXEL;
124 p_vout->p_sys->i_page_size = DUMMY_WIDTH * DUMMY_HEIGHT
125 * DUMMY_BYTES_PER_PIXEL;
127 /* Map two framebuffers a the very beginning of the fb */
128 p_vout->p_sys->p_video = malloc( 2 * p_vout->p_sys->i_page_size );
129 if( p_vout->p_sys->p_video == NULL )
131 intf_ErrMsg( "vout error: can't map video memory (%s)",
133 free( p_vout->p_sys );
137 /* Set and initialize buffers */
138 vout_SetBuffers( p_vout, p_vout->p_sys->p_video,
139 p_vout->p_sys->p_video + p_vout->p_sys->i_page_size );
144 /*****************************************************************************
145 * vout_Init: initialize dummy video thread output method
146 *****************************************************************************/
147 static int vout_Init( vout_thread_t *p_vout )
152 /*****************************************************************************
153 * vout_End: terminate dummy video thread output method
154 *****************************************************************************/
155 static void vout_End( vout_thread_t *p_vout )
160 /*****************************************************************************
161 * vout_Destroy: destroy dummy video thread output method
162 *****************************************************************************
163 * Terminate an output method created by DummyCreateOutputMethod
164 *****************************************************************************/
165 static void vout_Destroy( vout_thread_t *p_vout )
167 free( p_vout->p_sys->p_video );
168 free( p_vout->p_sys );
171 /*****************************************************************************
172 * vout_Manage: handle dummy events
173 *****************************************************************************
174 * This function should be called regularly by video output thread. It manages
175 * console events. It returns a non null value on error.
176 *****************************************************************************/
177 static int vout_Manage( vout_thread_t *p_vout )
182 /*****************************************************************************
183 * vout_Display: displays previously rendered output
184 *****************************************************************************
185 * This function send the currently rendered image to dummy image, waits until
186 * it is displayed and switch the two rendering buffers, preparing next frame.
187 *****************************************************************************/
188 static void vout_Display( vout_thread_t *p_vout )