]> git.sesse.net Git - vlc/blob - plugins/macosx/intf_macosx.c
* Function prototypes for the forthcoming Darwin and MacOS X port.
[vlc] / plugins / macosx / intf_macosx.c
1 /*****************************************************************************
2  * intf_macosx.c: MacOS X interface plugin
3  *****************************************************************************
4  * Copyright (C) 2001 VideoLAN
5  *
6  * Authors: 
7  *
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.
12  * 
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.
17  *
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  *****************************************************************************/
22
23 #define MODULE_NAME macosx
24 #include "modules_inner.h"
25
26 /*****************************************************************************
27  * Preamble
28  *****************************************************************************/
29 #include "defs.h"
30
31 #include <stdlib.h>                                      /* malloc(), free() */
32
33 #include "config.h"
34 #include "common.h"
35 #include "threads.h"
36 #include "mtime.h"
37 #include "tests.h"
38
39 #include "intf_msg.h"
40 #include "interface.h"
41
42 #include "modules.h"
43
44 #include "main.h"
45
46 /*****************************************************************************
47  * intf_sys_t: description and status of the interface
48  *****************************************************************************/
49 typedef struct intf_sys_s
50 {
51
52 } intf_sys_t;
53
54 /*****************************************************************************
55  * Local prototypes.
56  *****************************************************************************/
57 static int  intf_Probe     ( probedata_t *p_data );
58 static int  intf_Open      ( intf_thread_t *p_intf );
59 static void intf_Close     ( intf_thread_t *p_intf );
60 static void intf_Run       ( intf_thread_t *p_intf );
61
62 /*****************************************************************************
63  * Functions exported as capabilities. They are declared as static so that
64  * we don't pollute the namespace too much.
65  *****************************************************************************/
66 void _M( intf_getfunctions )( function_list_t * p_function_list )
67 {
68     p_function_list->pf_probe = intf_Probe;
69     p_function_list->functions.intf.pf_open  = intf_Open;
70     p_function_list->functions.intf.pf_close = intf_Close;
71     p_function_list->functions.intf.pf_run   = intf_Run;
72 }
73
74 /*****************************************************************************
75  * intf_Probe: probe the interface and return a score
76  *****************************************************************************
77  * This function checks the interface can be run and returns a score to the
78  * plugin manager so that it can select the best plugin.
79  *****************************************************************************/
80 static int intf_Probe( probedata_t *p_data )
81 {
82     if( TestMethod( INTF_METHOD_VAR, "macosx" ) )
83     {
84         return( 999 );
85     }
86
87     /* Under MacOS X, this plugin always works */
88     return( 100 );
89 }
90
91 /*****************************************************************************
92  * intf_Open: initialize interface
93  *****************************************************************************/
94 static int intf_Open( intf_thread_t *p_intf )
95 {
96     /* Allocate instance and initialize some members */
97     p_intf->p_sys = malloc( sizeof( intf_sys_t ) );
98     if( p_intf->p_sys == NULL )
99     {
100         return( 1 );
101     };
102
103     return( 0 );
104 }
105
106 /*****************************************************************************
107  * intf_Close: destroy interface
108  *****************************************************************************/
109 static void intf_Close( intf_thread_t *p_intf )
110 {
111     /* Destroy structure */
112     free( p_intf->p_sys );
113 }
114
115
116 /*****************************************************************************
117  * intf_Run: main loop
118  *****************************************************************************/
119 static void intf_Run( intf_thread_t *p_intf )
120 {
121     while( !p_intf->b_die )
122     {
123         /* Manage core vlc functions through the callback */
124         p_intf->pf_manage( p_intf );
125
126         /* Wait a bit */
127         msleep( INTF_IDLE_SLEEP );
128     }
129 }
130