1 /*****************************************************************************
2 * vout_macosx.c: MacOS X video output plugin
3 *****************************************************************************
4 * Copyright (C) 2001 VideoLAN
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 #define MODULE_NAME macosx
24 #include "modules_inner.h"
26 /*****************************************************************************
28 *****************************************************************************/
31 #include <errno.h> /* ENOMEM */
32 #include <stdlib.h> /* free() */
33 #include <string.h> /* strerror() */
42 #include "video_output.h"
48 #define DUMMY_WIDTH 16
49 #define DUMMY_HEIGHT 16
50 #define DUMMY_BITS_PER_PLANE 16
51 #define DUMMY_BYTES_PER_PIXEL 2
53 /*****************************************************************************
54 * vout_sys_t: MacOS X video output method descriptor
55 *****************************************************************************
56 * This structure is part of the video output thread descriptor.
57 * It describes the MacOS X specific properties of an output thread.
58 *****************************************************************************/
59 typedef struct vout_sys_s
61 /* MacOS X video memory */
62 byte_t * p_video; /* base adress */
63 size_t i_page_size; /* page size */
67 /*****************************************************************************
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 * );
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 )
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;
94 /*****************************************************************************
95 * intf_Probe: return a score
96 *****************************************************************************/
97 static int vout_Probe( probedata_t *p_data )
99 if( TestMethod( VOUT_METHOD_VAR, "macosx" ) )
107 /*****************************************************************************
108 * vout_Create: allocates MacOS X video thread output method
109 *****************************************************************************
110 * This function allocates and initializes a MacOS X vout method.
111 *****************************************************************************/
112 static int vout_Create( vout_thread_t *p_vout )
114 /* Allocate structure */
115 p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
116 if( p_vout->p_sys == NULL )
118 intf_ErrMsg("error: %s", strerror(ENOMEM) );
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;
128 p_vout->p_sys->i_page_size = DUMMY_WIDTH * DUMMY_HEIGHT
129 * DUMMY_BYTES_PER_PIXEL;
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 )
135 intf_ErrMsg( "vout error: can't map video memory (%s)",
137 free( p_vout->p_sys );
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 );
148 /*****************************************************************************
149 * vout_Init: initialize video thread output method
150 *****************************************************************************/
151 static int vout_Init( vout_thread_t *p_vout )
156 /*****************************************************************************
157 * vout_End: terminate video thread output method
158 *****************************************************************************/
159 static void vout_End( vout_thread_t *p_vout )
164 /*****************************************************************************
165 * vout_Destroy: destroy video thread output method
166 *****************************************************************************/
167 static void vout_Destroy( vout_thread_t *p_vout )
169 free( p_vout->p_sys->p_video );
170 free( p_vout->p_sys );
173 /*****************************************************************************
174 * vout_Manage: handle events
175 *****************************************************************************
176 * This function should be called regularly by video output thread. It manages
177 * console events. It returns a non null value on error.
178 *****************************************************************************/
179 static int vout_Manage( vout_thread_t *p_vout )
184 /*****************************************************************************
185 * vout_Display: displays previously rendered output
186 *****************************************************************************
187 * This function send the currently rendered image to image, waits until
188 * it is displayed and switch the two rendering buffers, preparing next frame.
189 *****************************************************************************/
190 static void vout_Display( vout_thread_t *p_vout )