1 | //ssynth.c: |
---|
2 | |
---|
3 | /* |
---|
4 | * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009 |
---|
5 | * |
---|
6 | * This file is part of roard a part of RoarAudio, |
---|
7 | * a cross-platform sound system for both, home and professional use. |
---|
8 | * See README for details. |
---|
9 | * |
---|
10 | * This file is free software; you can redistribute it and/or modify |
---|
11 | * it under the terms of the GNU General Public License version 3 |
---|
12 | * as published by the Free Software Foundation. |
---|
13 | * |
---|
14 | * RoarAudio 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 software; see the file COPYING. If not, write to |
---|
21 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
---|
22 | * |
---|
23 | */ |
---|
24 | |
---|
25 | #include "roard.h" |
---|
26 | |
---|
27 | int ssynth_init_config(void) { |
---|
28 | memset(&ssynth_conf, 0, sizeof(ssynth_conf)); |
---|
29 | |
---|
30 | return 0; |
---|
31 | } |
---|
32 | |
---|
33 | #define _err() streams_delete(sid); return -1 |
---|
34 | int ssynth_init (void) { |
---|
35 | struct roar_stream_server * ss; |
---|
36 | struct roar_stream * s; |
---|
37 | int sid; |
---|
38 | |
---|
39 | if ( !ssynth_conf.enable ) |
---|
40 | return 0; |
---|
41 | |
---|
42 | memset(&g_ssynth, 0, sizeof(g_ssynth)); |
---|
43 | g_ssynth.stream = -1; |
---|
44 | |
---|
45 | if ( (sid = streams_new()) == -1 ) |
---|
46 | return -1; |
---|
47 | |
---|
48 | if ( streams_set_client(sid, g_self_client) == -1 ) { |
---|
49 | _err(); |
---|
50 | } |
---|
51 | |
---|
52 | if ( streams_set_dir(sid, ROAR_DIR_BRIDGE, 1) == -1 ) { |
---|
53 | _err(); |
---|
54 | } |
---|
55 | |
---|
56 | if ( streams_set_flag(sid, ROAR_FLAG_PRIMARY) == -1 ) { |
---|
57 | _err(); |
---|
58 | } |
---|
59 | |
---|
60 | if ( streams_set_name(sid, "Simple Synthesizer") == -1 ) { |
---|
61 | _err(); |
---|
62 | } |
---|
63 | |
---|
64 | if ( streams_get(sid, &ss) == -1 ) { |
---|
65 | _err(); |
---|
66 | } |
---|
67 | |
---|
68 | s = ROAR_STREAM(ss); |
---|
69 | |
---|
70 | memcpy(&(s->info), g_sa, sizeof(struct roar_audio_info)); |
---|
71 | |
---|
72 | s->info.channels = 1; |
---|
73 | s->info.codec = ROAR_CODEC_DEFAULT; |
---|
74 | |
---|
75 | g_ssynth.stream = sid; |
---|
76 | |
---|
77 | return 0; |
---|
78 | } |
---|
79 | |
---|
80 | int ssynth_free (void) { |
---|
81 | if ( !ssynth_conf.enable ) |
---|
82 | return 0; |
---|
83 | |
---|
84 | return streams_delete(g_ssynth.stream); |
---|
85 | } |
---|
86 | |
---|
87 | //ll |
---|