Initial revision
[ahxm.git] / output.c
blob9bbdcb6b87498cc7a2982ed847ef57459bfa3914
1 /*
3 output.c
5 Copyright (C) 2003 Angel Ortega <angel@triptico.com>
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; either version 2
10 of the License, or (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 http://www.triptico.com
25 #include <stdio.h>
26 #include <string.h>
27 #include "output.h"
29 /* output drivers */
30 #include "out_raw.h"
31 #include "out_wav.h"
32 #include "out_pipe.h"
33 #include "out_oss.h"
35 static struct
37 char * name;
38 int (* open)(char *);
39 int (* write)(int, int);
40 int (* close)(void);
41 } _drivers[]={
42 { "raw", _out_open_raw, _out_write_raw, _out_close_raw },
43 { "wav", _out_open_wav, _out_write_wav, _out_close_wav },
44 { "pipe", _out_open_pipe, _out_write_pipe, _out_close_pipe },
45 #ifdef LINUX_OSS
46 { "oss", _out_open_oss, _out_write_oss, _out_close_oss },
47 #endif
48 { NULL, NULL, NULL, NULL }
51 /* driver in use */
52 static int _driver=-1;
54 int output_open(char * name, char * filename)
56 int n;
58 if(_driver != -1)
59 return(-1);
61 for(n=0;;n++)
63 if(strcmp(name, _drivers[n].name)==0)
64 break;
66 if(_drivers[n].name == NULL)
67 return(-2);
70 _driver=n;
72 return(_drivers[_driver].open(filename));
76 int output_write(int lsample, int rsample)
78 return(_drivers[_driver].write(lsample, rsample));
82 int output_close(void)
84 int r;
86 r=_drivers[_driver].close();
87 _driver=-1;
89 return(r);