source: roaraudio/libroarsndio/volume.c @ 4038:5e7b9cca7dd2

Last change on this file since 4038:5e7b9cca7dd2 was 4038:5e7b9cca7dd2, checked in by phi, 14 years ago

some cleanup

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