]> git.sesse.net Git - vlc/blob - plugins/alsa/alsa.c
Added : alsa support
[vlc] / plugins / alsa / alsa.c
1 /*****************************************************************************
2  * dsp.c : OSS /dev/dsp plugin for vlc
3  *****************************************************************************
4  * Copyright (C) 2000 VideoLAN
5  *
6  * Authors:
7  *  Henri Fallon <henri@videolan.org>
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 #include "defs.h"
25
26 #include <sys/types.h>
27 #include <sys/stat.h>
28 #include <sys/asoundlib.h>                                    /* for alsa :) */
29 #include <fcntl.h>
30 #include <stdlib.h>                                      /* malloc(), free() */
31 // #include <unistd.h>                                            /* close() */
32
33 #include "config.h"
34 #include "common.h"                                     /* boolean_t, byte_t */
35 #include "threads.h"
36 #include "mtime.h"
37 #include "tests.h"
38 #include "plugins.h"
39
40 #include "interface.h"
41 #include "audio_output.h"
42 #include "video.h"
43 #include "video_output.h"
44
45 #include "main.h"
46
47
48 /*****************************************************************************
49  * Exported prototypes
50  *****************************************************************************/
51 static void aout_GetPlugin( p_aout_thread_t p_aout );
52
53 /* Audio output */
54 int     aout_AlsaOpen         ( aout_thread_t *p_aout );
55 int     aout_AlsaReset        ( aout_thread_t *p_aout );
56 int     aout_AlsaSetFormat    ( aout_thread_t *p_aout );
57 int     aout_AlsaSetChannels  ( aout_thread_t *p_aout );
58 int     aout_AlsaSetRate      ( aout_thread_t *p_aout );
59 long    aout_AlsaGetBufInfo   ( aout_thread_t *p_aout, long l_buffer_info );
60 void    aout_AlsaPlaySamples  ( aout_thread_t *p_aout, byte_t *buffer,
61                                int i_size );
62 void    aout_AlsaClose        ( aout_thread_t *p_aout );
63
64 /*****************************************************************************
65  * GetConfig: get the plugin structure and configuration
66  *****************************************************************************/
67 plugin_info_t * GetConfig( void )
68 {
69     int i_fd;
70     plugin_info_t * p_info = (plugin_info_t *) malloc( sizeof(plugin_info_t) );
71
72     p_info->psz_name    = "Alsa plugin";
73     p_info->psz_version = VERSION;
74     p_info->psz_author  = "the VideoLAN team <vlc@videolan.org>";
75
76     p_info->aout_GetPlugin = aout_GetPlugin;
77     p_info->vout_GetPlugin = NULL;
78     p_info->intf_GetPlugin = NULL;
79     p_info->yuv_GetPlugin  = NULL;
80
81
82     /* TODO : test if alsa is available */
83     p_info->i_score = 0x100;
84
85     /* If this plugin was requested, score it higher */
86     if( TestMethod( AOUT_METHOD_VAR, "alsa" ) )
87     {
88         p_info->i_score += 0x200;
89     }
90
91     return( p_info );
92 }
93
94 /*****************************************************************************
95  * Following functions are only called through the p_info structure
96  *****************************************************************************/
97
98 static void aout_GetPlugin( p_aout_thread_t p_aout )
99 {
100     p_aout->p_sys_open        = aout_AlsaOpen;
101     p_aout->p_sys_reset       = aout_AlsaReset;
102     p_aout->p_sys_setformat   = aout_AlsaSetFormat;
103     p_aout->p_sys_setchannels = aout_AlsaSetChannels;
104     p_aout->p_sys_setrate     = aout_AlsaSetRate;
105     p_aout->p_sys_getbufinfo  = aout_AlsaGetBufInfo;
106     p_aout->p_sys_playsamples = aout_AlsaPlaySamples;
107     p_aout->p_sys_close       = aout_AlsaClose;
108 }