]> git.sesse.net Git - vlc/blob - plugins/macosx/vout_macosx.c
* Header cleaning: filled all empty authors fields, added CVS $Id stuff.
[vlc] / plugins / macosx / vout_macosx.c
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 $
6  *
7  * Authors: 
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 macosx
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
49 #define DUMMY_WIDTH 16
50 #define DUMMY_HEIGHT 16
51 #define DUMMY_BITS_PER_PLANE 16
52 #define DUMMY_BYTES_PER_PIXEL 2
53
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
61 {
62     /* MacOS X video memory */
63     byte_t *                    p_video;                      /* base adress */
64     size_t                      i_page_size;                    /* page size */
65
66 } vout_sys_t;
67
68 /*****************************************************************************
69  * Local prototypes
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 * );
78
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 )
84 {
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;
93 }
94
95 /*****************************************************************************
96  * intf_Probe: return a score
97  *****************************************************************************/
98 static int vout_Probe( probedata_t *p_data )
99 {
100     if( TestMethod( VOUT_METHOD_VAR, "macosx" ) )
101     {
102         return( 999 );
103     }
104
105     return( 100 );
106 }
107
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 )
114 {
115     /* Allocate structure */
116     p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
117     if( p_vout->p_sys == NULL )
118     {
119         intf_ErrMsg("error: %s", strerror(ENOMEM) );
120         return( 1 );
121     }
122
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;
128
129     p_vout->p_sys->i_page_size = DUMMY_WIDTH * DUMMY_HEIGHT
130                                   * DUMMY_BYTES_PER_PIXEL;
131
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 )
135     {
136         intf_ErrMsg( "vout error: can't map video memory (%s)",
137                      strerror(errno) );
138         free( p_vout->p_sys );
139         return( 1 );
140     }
141
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 );
145
146     return( 0 );
147 }
148
149 /*****************************************************************************
150  * vout_Init: initialize video thread output method
151  *****************************************************************************/
152 static int vout_Init( vout_thread_t *p_vout )
153 {
154     return( 0 );
155 }
156
157 /*****************************************************************************
158  * vout_End: terminate video thread output method
159  *****************************************************************************/
160 static void vout_End( vout_thread_t *p_vout )
161 {
162     ;
163 }
164
165 /*****************************************************************************
166  * vout_Destroy: destroy video thread output method
167  *****************************************************************************/
168 static void vout_Destroy( vout_thread_t *p_vout )
169 {
170     free( p_vout->p_sys->p_video );
171     free( p_vout->p_sys );
172 }
173
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 )
181 {
182     return( 0 );
183 }
184
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 )
192 {
193     ;
194 }
195