source: roaraudio/libroarsndio/volume.c @ 3640:021567ce5448

Last change on this file since 3640:021567ce5448 was 3640:021567ce5448, checked in by phi, 14 years ago

added -Wextra

File size: 2.1 KB
Line 
1//volume.c:
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, 51 Franklin Street, Fifth Floor,
26 *  Boston, MA 02110-1301, USA.
27 *
28 *  NOTE for everyone want's to change something and send patches:
29 *  read README and HACKING! There a addition information on
30 *  the license of this document you need to read before you send
31 *  any patches.
32 */
33
34#define ROAR_USE_OWN_SNDIO_HDL
35#include "libroarsndio.h"
36
37int    sio_setvol (struct sio_hdl * hdl, unsigned vol) {
38 struct roar_mixer_settings mixer;
39 unsigned int i;
40
41 if ( hdl == NULL )
42  return 0;
43
44 if ( vol > SIO_MAXVOL )
45  return 0;
46
47 mixer.scale   = SIO_MAXVOL;
48 mixer.rpg_mul = 1;
49 mixer.rpg_div = 1;
50
51 for (i = 0; i < hdl->info.channels; i++)
52  mixer.mixer[i] = vol;
53
54 if ( roar_set_vol(&(hdl->con), roar_stream_get_id(&(hdl->stream)), &mixer, hdl->info.channels) == -1 )
55  return 0;
56
57 if ( hdl->on_vol != NULL )
58  hdl->on_vol(hdl->on_vol_arg, vol);
59
60 return 1;
61}
62
63void   sio_onvol  (struct sio_hdl * hdl, void (*cb)(void * arg, unsigned vol), void * arg) {
64 if ( hdl == NULL )
65  return;
66
67 hdl->on_vol     = cb;
68 hdl->on_vol_arg = arg;
69}
70
71//ll
Note: See TracBrowser for help on using the repository browser.