source: roaraudio/roard/beep.c @ 3577:4c63ef992347

Last change on this file since 3577:4c63ef992347 was 3577:4c63ef992347, checked in by phi, 14 years ago

set name for beep streams

File size: 2.0 KB
Line 
1//beep.c:
2
3/*
4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010
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, 51 Franklin Street, Fifth Floor,
22 *  Boston, MA 02110-1301, USA.
23 *
24 */
25
26#include "roard.h"
27
28int beep_start (int client, struct roar_beep * beep) {
29 struct roar_stream_server * ss;
30 struct roar_stream        *  s;
31 int stream;
32
33 if ( beep->vol  == 0 )
34  beep->vol  = ROAR_BEEP_MAX_VOL;
35
36 if ( beep->time == 0 )
37  beep->time = 512; // 512ms
38
39 if ( beep->freq == 0 )
40  beep->freq = 440;
41
42 if ( beep->type == 0 )
43  beep->type = ROAR_BEEP_TYPE_DEFAULT;
44
45 // x, y, z location '0' is allready centered.
46
47 // TODO: remove the following lions as soon as we support non zero values
48 if ( beep->z != 0 )
49  return -1;
50
51 if ( beep->y != 0 )
52  return -1;
53
54 if ( beep->x != 0 )
55  return -1;
56
57 if ((stream = streams_new()) == -1 )
58  return -1;
59
60 if ( client_stream_add(client, stream) == -1 ) {
61  streams_delete(stream);
62  return -1;
63 }
64
65 if ( streams_set_name(stream, "Beep Source") == -1 ) {
66  streams_delete(stream);
67  return -1;
68 }
69
70 if ( streams_get(stream, &ss) == -1 ) {
71  streams_delete(stream);
72  return -1;
73 }
74
75 s = ROAR_STREAM(ss);
76
77 memcpy(&(s->info), g_sa, sizeof(s->info));
78
79 s->info.channels = 1;
80
81 if ( streams_set_dir(stream, ROAR_DIR_PLAY, 1) == -1 ) {
82  streams_delete(stream);
83  return -1;
84 }
85
86 return stream;
87}
88
89//ll
Note: See TracBrowser for help on using the repository browser.