1 /*****************************************************************************
2 * vout_macosx.c: MacOS X video output plugin
3 *****************************************************************************
4 * Copyright (C) 2001 VideoLAN
5 * $Id: vout_macosx.c,v 1.2 2001/03/21 13:42:34 sam Exp $
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 macosx
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"
49 #define DUMMY_WIDTH 16
50 #define DUMMY_HEIGHT 16
51 #define DUMMY_BITS_PER_PLANE 16
52 #define DUMMY_BYTES_PER_PIXEL 2
54 /*****************************************************************************
55 * vout_sys_t: MacOS X video output method descriptor
56 *****************************************************************************
57 * This structure is part of the video output thread descriptor.
58 * It describes the MacOS X specific properties of an output thread.
59 *****************************************************************************/
60 typedef struct vout_sys_s
62 /* MacOS X video memory */
63 byte_t * p_video; /* base adress */
64 size_t i_page_size; /* page size */
68 /*****************************************************************************
70 *****************************************************************************/
71 static int vout_Probe ( probedata_t *p_data );
72 static int vout_Create ( struct vout_thread_s * );
73 static int vout_Init ( struct vout_thread_s * );
74 static void vout_End ( struct vout_thread_s * );
75 static void vout_Destroy ( struct vout_thread_s * );
76 static int vout_Manage ( struct vout_thread_s * );
77 static void vout_Display ( struct vout_thread_s * );
79 /*****************************************************************************
80 * Functions exported as capabilities. They are declared as static so that
81 * we don't pollute the namespace too much.
82 *****************************************************************************/
83 void _M( vout_getfunctions )( function_list_t * p_function_list )
85 p_function_list->pf_probe = vout_Probe;
86 p_function_list->functions.vout.pf_create = vout_Create;
87 p_function_list->functions.vout.pf_init = vout_Init;
88 p_function_list->functions.vout.pf_end = vout_End;
89 p_function_list->functions.vout.pf_destroy = vout_Destroy;
90 p_function_list->functions.vout.pf_manage = vout_Manage;
91 p_function_list->functions.vout.pf_display = vout_Display;
92 p_function_list->functions.vout.pf_setpalette = NULL;
95 /*****************************************************************************
96 * intf_Probe: return a score
97 *****************************************************************************/
98 static int vout_Probe( probedata_t *p_data )
100 if( TestMethod( VOUT_METHOD_VAR, "macosx" ) )
108 /*****************************************************************************
109 * vout_Create: allocates MacOS X video thread output method
110 *****************************************************************************
111 * This function allocates and initializes a MacOS X vout method.
112 *****************************************************************************/
113 static int vout_Create( vout_thread_t *p_vout )
115 /* Allocate structure */
116 p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
117 if( p_vout->p_sys == NULL )
119 intf_ErrMsg("error: %s", strerror(ENOMEM) );
123 p_vout->i_width = DUMMY_WIDTH;
124 p_vout->i_height = DUMMY_HEIGHT;
125 p_vout->i_screen_depth = DUMMY_BITS_PER_PLANE;
126 p_vout->i_bytes_per_pixel = DUMMY_BYTES_PER_PIXEL;
127 p_vout->i_bytes_per_line = DUMMY_WIDTH * DUMMY_BYTES_PER_PIXEL;
129 p_vout->p_sys->i_page_size = DUMMY_WIDTH * DUMMY_HEIGHT
130 * DUMMY_BYTES_PER_PIXEL;
132 /* Map two framebuffers a the very beginning of the fb */
133 p_vout->p_sys->p_video = malloc( 2 * p_vout->p_sys->i_page_size );
134 if( p_vout->p_sys->p_video == NULL )
136 intf_ErrMsg( "vout error: can't map video memory (%s)",
138 free( p_vout->p_sys );
142 /* Set and initialize buffers */
143 vout_SetBuffers( p_vout, p_vout->p_sys->p_video,
144 p_vout->p_sys->p_video + p_vout->p_sys->i_page_size );
149 /*****************************************************************************
150 * vout_Init: initialize video thread output method
151 *****************************************************************************/
152 static int vout_Init( vout_thread_t *p_vout )
157 /*****************************************************************************
158 * vout_End: terminate video thread output method
159 *****************************************************************************/
160 static void vout_End( vout_thread_t *p_vout )
165 /*****************************************************************************
166 * vout_Destroy: destroy video thread output method
167 *****************************************************************************/
168 static void vout_Destroy( vout_thread_t *p_vout )
170 free( p_vout->p_sys->p_video );
171 free( p_vout->p_sys );
174 /*****************************************************************************
175 * vout_Manage: handle events
176 *****************************************************************************
177 * This function should be called regularly by video output thread. It manages
178 * console events. It returns a non null value on error.
179 *****************************************************************************/
180 static int vout_Manage( vout_thread_t *p_vout )
185 /*****************************************************************************
186 * vout_Display: displays previously rendered output
187 *****************************************************************************
188 * This function send the currently rendered image to image, waits until
189 * it is displayed and switch the two rendering buffers, preparing next frame.
190 *****************************************************************************/
191 static void vout_Display( vout_thread_t *p_vout )