]> git.sesse.net Git - vlc/blob - plugins/dummy/aout_dummy.c
34cd387a928d411b38dd1aeb61624834ea8b3bed
[vlc] / plugins / dummy / aout_dummy.c
1 /*****************************************************************************
2  * aout_dummy.c : dummy audio output plugin
3  *****************************************************************************
4  * Copyright (C) 2000, 2001 VideoLAN
5  *
6  * Authors: Samuel Hocevar <sam@zoy.org>
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 /*****************************************************************************
24  * Preamble
25  *****************************************************************************/
26 #include "defs.h"
27
28 #include "config.h"
29 #include "common.h"                                     /* boolean_t, byte_t */
30 #include "threads.h"
31 #include "mtime.h"
32 #include "tests.h"
33
34 #include "audio_output.h"                                   /* aout_thread_t */
35
36 #include "main.h"
37
38 #include "modules.h"
39
40 /*****************************************************************************
41  * vout_dummy_t: dummy video output method descriptor
42  *****************************************************************************
43  * This structure is part of the video output thread descriptor.
44  * It describes the dummy specific properties of an output thread.
45  *****************************************************************************/
46 typedef struct aout_sys_s
47 {
48
49 } aout_sys_t;
50
51 /*****************************************************************************
52  * Local prototypes.
53  *****************************************************************************/
54 static int     aout_Probe       ( probedata_t *p_data );
55 static int     aout_Open        ( aout_thread_t *p_aout );
56 static int     aout_SetFormat   ( aout_thread_t *p_aout );
57 static long    aout_GetBufInfo  ( aout_thread_t *p_aout, long l_buffer_info );
58 static void    aout_Play        ( aout_thread_t *p_aout,
59                                   byte_t *buffer, int i_size );
60 static void    aout_Close       ( aout_thread_t *p_aout );
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 aout_getfunctions( function_list_t * p_function_list )
67 {
68     p_function_list->pf_probe = aout_Probe;
69     p_function_list->functions.aout.pf_open = aout_Open;
70     p_function_list->functions.aout.pf_setformat = aout_SetFormat;
71     p_function_list->functions.aout.pf_getbufinfo = aout_GetBufInfo;
72     p_function_list->functions.aout.pf_play = aout_Play;
73     p_function_list->functions.aout.pf_close = aout_Close;
74 }
75
76 /*****************************************************************************
77  * aout_Probe: probe the audio device and return a score
78  *****************************************************************************/
79 static int aout_Probe( probedata_t *p_data )
80 {
81     if( TestMethod( AOUT_METHOD_VAR, "dummy" ) )
82     {
83         return( 999 );
84     }
85
86     /* The dummy plugin always works but give it the lower possible score */
87     return( 1 );
88 }
89
90 /*****************************************************************************
91  * aout_Open: opens a dummy audio device
92  *****************************************************************************/
93 static int aout_Open( aout_thread_t *p_aout )
94 {
95     /* Initialize some variables */
96     p_aout->i_format = AOUT_FORMAT_DEFAULT;
97     p_aout->i_channels = 1 + main_GetIntVariable( AOUT_STEREO_VAR,
98                                                   AOUT_STEREO_DEFAULT );
99     p_aout->l_rate     =     main_GetIntVariable( AOUT_RATE_VAR,
100                                                   AOUT_RATE_DEFAULT );
101
102     return( 0 );
103 }
104
105 /*****************************************************************************
106  * aout_SetFormat: pretends to set the dsp output format
107  *****************************************************************************/
108 static int aout_SetFormat( aout_thread_t *p_aout )
109 {
110     return( 0 );
111 }
112
113 /*****************************************************************************
114  * aout_GetBufInfo: returns available bytes in buffer
115  *****************************************************************************/
116 static long aout_GetBufInfo( aout_thread_t *p_aout, long l_buffer_limit )
117 {
118     return( sizeof(s16) * l_buffer_limit + 1 ); /* value big enough to sleep */
119 }
120
121 /*****************************************************************************
122  * aout_Play: pretends to play a sound
123  *****************************************************************************/
124 static void aout_Play( aout_thread_t *p_aout, byte_t *buffer, int i_size )
125 {
126     ;
127 }
128
129 /*****************************************************************************
130  * aout_Close: closes the dummy audio device
131  *****************************************************************************/
132 static void aout_Close( aout_thread_t *p_aout )
133 {
134     ;
135 }
136