1 /* $Id$ */
2 /* Copyright (c) 2014 Pierre Pronchery <khorben@defora.org> */
3 /* This file is part of DeforaOS Desktop Phone */
4 /* This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, version 3 of the License.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>. */
15
16
17
18 #include <unistd.h>
19 #include <stdio.h>
20 #include "../src/plugins/oss.c"
21
22
23 /* private */
24 /* prototypes */
25 static int _oss(char const * filename);
26
27 static int _usage(void);
28
29
30 /* functions */
31 /* plugins */
32 static char const * _oss_config_get(Phone * phone, char const * section,
33 char const * variable);
34 static int _oss_error(Phone * phone, char const * message, int ret);
35
_oss(char const * filename)36 static int _oss(char const * filename)
37 {
38 OSS * oss;
39 PhonePluginHelper helper;
40 PhoneEvent event;
41
42 memset(&helper, 0, sizeof(helper));
43 helper.config_get = _oss_config_get;
44 helper.error = _oss_error;
45 if((oss = _oss_init(&helper)) == NULL)
46 return 2;
47 event.type = PHONE_EVENT_TYPE_AUDIO_PLAY;
48 event.audio_play.sample = filename;
49 _oss_event(oss, &event);
50 _oss_destroy(oss);
51 return 0;
52 }
53
_oss_config_get(Phone * phone,char const * section,char const * variable)54 static char const * _oss_config_get(Phone * phone, char const * section,
55 char const * variable)
56 {
57 return NULL;
58 }
59
_oss_error(Phone * phone,char const * message,int ret)60 static int _oss_error(Phone * phone, char const * message, int ret)
61 {
62 fprintf(stderr, "oss: %s\n", message);
63 return ret;
64 }
65
66
67 /* usage */
_usage(void)68 static int _usage(void)
69 {
70 fputs("Usage: oss sample...\n", stderr);
71 return 1;
72 }
73
74
75 /* public */
76 /* functions */
77 /* main */
main(int argc,char * argv[])78 int main(int argc, char * argv[])
79 {
80 int ret = 0;
81 int o;
82
83 while((o = getopt(argc, argv, "")) != -1)
84 switch(o)
85 {
86 default:
87 return _usage();
88 }
89 if(optind == argc)
90 return _usage();
91 while(optind < argc)
92 if(_oss(argv[optind++]) != 0)
93 ret = 2;
94 return ret;
95 }
96