[3571] | 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 | |
---|
[3573] | 28 | int beep_start (int client, struct roar_beep * beep) { |
---|
[3576] | 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_get(stream, &ss) == -1 ) { |
---|
| 66 | streams_delete(stream); |
---|
| 67 | return -1; |
---|
| 68 | } |
---|
| 69 | |
---|
| 70 | s = ROAR_STREAM(ss); |
---|
| 71 | |
---|
| 72 | memcpy(&(s->info), g_sa, sizeof(s->info)); |
---|
| 73 | |
---|
| 74 | s->info.channels = 1; |
---|
| 75 | |
---|
| 76 | if ( streams_set_dir(stream, ROAR_DIR_PLAY, 1) == -1 ) { |
---|
| 77 | streams_delete(stream); |
---|
| 78 | return -1; |
---|
| 79 | } |
---|
| 80 | |
---|
| 81 | return stream; |
---|
[3573] | 82 | } |
---|
| 83 | |
---|
[3571] | 84 | //ll |
---|