[3569] | 1 | //beep.c: |
---|
| 2 | |
---|
| 3 | /* |
---|
[5381] | 4 | * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2012 |
---|
[3569] | 5 | * |
---|
| 6 | * This file is part of libroar 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 | * libroar 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 | * NOTE for everyone want's to change something and send patches: |
---|
| 25 | * read README and HACKING! There a addition information on |
---|
| 26 | * the license of this document you need to read before you send |
---|
| 27 | * any patches. |
---|
| 28 | * |
---|
| 29 | * NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc |
---|
| 30 | * or libpulse*: |
---|
| 31 | * The libs libroaresd, libroararts and libroarpulse link this lib |
---|
| 32 | * and are therefore GPL. Because of this it may be illigal to use |
---|
| 33 | * them with any software that uses libesd, libartsc or libpulse*. |
---|
| 34 | */ |
---|
| 35 | |
---|
| 36 | #include "libroar.h" |
---|
| 37 | |
---|
[3570] | 38 | int roar_beep(struct roar_connection * con, const struct roar_beep * beep) { |
---|
| 39 | struct roar_message m; |
---|
| 40 | int16_t * data = (int16_t*)m.data; |
---|
| 41 | |
---|
[5145] | 42 | if ( con == NULL ) { |
---|
| 43 | roar_err_set(ROAR_ERROR_FAULT); |
---|
[3570] | 44 | return -1; |
---|
[5145] | 45 | } |
---|
[3570] | 46 | |
---|
| 47 | memset(&m, 0, sizeof(m)); |
---|
| 48 | |
---|
| 49 | m.cmd = ROAR_CMD_BEEP; |
---|
| 50 | |
---|
| 51 | if ( beep == NULL ) { |
---|
| 52 | m.datalen = 0; |
---|
| 53 | } else { |
---|
| 54 | m.datalen = 8*2; |
---|
| 55 | data[0] = ROAR_HOST2NET16(0); // version |
---|
| 56 | data[1] = ROAR_HOST2NET16(beep->vol); |
---|
| 57 | data[2] = ROAR_HOST2NET16(beep->time); |
---|
| 58 | data[3] = ROAR_HOST2NET16(beep->freq); |
---|
| 59 | data[4] = ROAR_HOST2NET16(beep->type); |
---|
| 60 | data[5] = ROAR_HOST2NET16(beep->x); |
---|
| 61 | data[6] = ROAR_HOST2NET16(beep->y); |
---|
| 62 | data[7] = ROAR_HOST2NET16(beep->z); |
---|
| 63 | } |
---|
| 64 | |
---|
[5146] | 65 | if ( roar_req3(con, &m, NULL) != 0 ) |
---|
[3570] | 66 | return -1; |
---|
| 67 | |
---|
| 68 | if ( m.cmd != ROAR_CMD_OK ) |
---|
| 69 | return -1; |
---|
| 70 | |
---|
| 71 | return m.stream; |
---|
| 72 | } |
---|
| 73 | |
---|
[3569] | 74 | //ll |
---|