[1561] | 1 | //volume.c: |
---|
[1559] | 2 | |
---|
| 3 | /* |
---|
| 4 | * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009 |
---|
| 5 | * The code (may) include prototypes and comments (and maybe |
---|
| 6 | * other code fragements) from EsounD. |
---|
| 7 | * They are mostly copyrighted by Eric B. Mitchell (aka 'Ricdude) |
---|
| 8 | * <ericmit@ix.netcom.com>. For more information see AUTHORS.esd. |
---|
| 9 | * |
---|
| 10 | * This file is part of libroaresd a part of RoarAudio, |
---|
| 11 | * a cross-platform sound system for both, home and professional use. |
---|
| 12 | * See README for details. |
---|
| 13 | * |
---|
| 14 | * This file is free software; you can redistribute it and/or modify |
---|
| 15 | * it under the terms of the GNU General Public License version 3 |
---|
| 16 | * as published by the Free Software Foundation. |
---|
| 17 | * |
---|
| 18 | * RoarAudio is distributed in the hope that it will be useful, |
---|
| 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 21 | * GNU General Public License for more details. |
---|
| 22 | * |
---|
| 23 | * You should have received a copy of the GNU General Public License |
---|
| 24 | * along with this software; see the file COPYING. If not, write to |
---|
| 25 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
---|
| 26 | * |
---|
| 27 | * NOTE for everyone want's to change something and send patches: |
---|
| 28 | * read README and HACKING! There a addition information on |
---|
| 29 | * the license of this document you need to read before you send |
---|
| 30 | * any patches. |
---|
| 31 | */ |
---|
| 32 | |
---|
[1571] | 33 | #define ROAR_USE_OWN_SNDIO_HDL |
---|
[1559] | 34 | #include "libroarsndio.h" |
---|
| 35 | |
---|
[1561] | 36 | int sio_setvol (struct sio_hdl * hdl, unsigned vol) { |
---|
[1575] | 37 | struct roar_mixer_settings mixer; |
---|
| 38 | int i; |
---|
| 39 | |
---|
| 40 | if ( hdl == NULL ) |
---|
| 41 | return 0; |
---|
| 42 | |
---|
| 43 | if ( vol > SIO_MAXVOL ) |
---|
| 44 | return 0; |
---|
| 45 | |
---|
[1579] | 46 | mixer.scale = 65535; |
---|
[1575] | 47 | mixer.rpg_mul = 1; |
---|
| 48 | mixer.rpg_div = 1; |
---|
| 49 | |
---|
| 50 | for (i = 0; i < hdl->info.channels; i++) |
---|
[1579] | 51 | mixer.mixer[i] = vol*65535/SIO_MAXVOL; |
---|
[1575] | 52 | |
---|
| 53 | if ( roar_set_vol(&(hdl->con), roar_stream_get_id(&(hdl->stream)), &mixer, hdl->info.channels) == -1 ) |
---|
| 54 | return 0; |
---|
| 55 | |
---|
| 56 | if ( hdl->on_vol != NULL ) |
---|
| 57 | hdl->on_vol(hdl->on_vol_arg, vol); |
---|
| 58 | |
---|
| 59 | return 1; |
---|
[1561] | 60 | } |
---|
| 61 | |
---|
[1711] | 62 | void sio_onvol (struct sio_hdl * hdl, void (*cb)(void * arg, unsigned vol), void * arg) { |
---|
| 63 | if ( hdl == NULL ) |
---|
| 64 | return; |
---|
| 65 | |
---|
| 66 | hdl->on_vol = cb; |
---|
| 67 | hdl->on_vol_arg = arg; |
---|
| 68 | } |
---|
| 69 | |
---|
[1559] | 70 | //ll |
---|