source: roaraudio/roard/hwmixer_dstr.c @ 4364:7c2f27407e46

Last change on this file since 4364:7c2f27407e46 was 4364:7c2f27407e46, checked in by phi, 14 years ago

wrote dstr mixer

File size: 2.8 KB
Line 
1//hwmixer_dstr.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
28int hwmixer_dstr_open(struct hwmixer_stream * stream, char * drv, char * dev, int fh, char * basename, struct roar_keyval * subnames, size_t subnamelen) {
29 struct roar_vio_calls * vio = roar_mm_malloc(sizeof(struct roar_vio_calls));
30 struct roar_vio_defaults def;
31 struct roar_stream_server * ss;
32
33 if ( vio == NULL )
34  return -1;
35
36 if ( fh == -1 ) {
37  if ( dev == NULL ) {
38   roar_mm_free(vio);
39   return -1;
40  }
41
42  if ( roar_vio_dstr_init_defaults(&def, ROAR_VIO_DEF_TYPE_NONE, O_WRONLY|O_CREAT|O_TRUNC, 0644) == -1 ) {
43   roar_mm_free(vio);
44   return -1;
45  }
46
47  if ( roar_vio_open_dstr(vio, dev, &def, 1) == -1 ) {
48   roar_mm_free(vio);
49   return -1;
50  }
51 } else {
52  if ( roar_vio_open_fh(vio, fh) == -1 ) {
53   roar_mm_free(vio);
54   return -1;
55  }
56 }
57
58 stream->baseud = vio;
59
60 roar_vio_printf(vio, "No data yet.\n");
61 roar_vio_lseek(vio, 0, SEEK_SET);
62 roar_vio_sync(vio);
63
64 if (streams_get(stream->basestream, &ss) != -1) {
65  ROAR_STREAM(ss)->info.channels = 2;
66 } else {
67  ROAR_WARN("hwmixer_dstr_open(*): can not get object for basestream %i", stream->basestream);
68 }
69
70 return 0;
71}
72
73int hwmixer_dstr_close(struct hwmixer_stream * stream) {
74 roar_vio_close(stream->baseud);
75 roar_mm_free(stream->baseud);
76 return 0;
77}
78
79int hwmixer_dstr_set_vol(struct hwmixer_stream * stream, int channels, int mode, struct roar_mixer_settings * settings) {
80 struct roar_vio_calls * vio = stream->baseud;
81 int i;
82
83 roar_vio_printf(vio, "[Stream %i of basestream %i]\n", stream->stream, stream->basestream);
84 roar_vio_printf(vio, "Channels: %i\n", channels);
85 roar_vio_printf(vio, "Mode: %i\n", mode);
86 roar_vio_printf(vio, "Scale: %i\n", (int)settings->scale);
87 roar_vio_printf(vio, "RPG: %i/%i\n", (int)settings->rpg_mul, (int)settings->rpg_div);
88
89 for (i = 0; i < channels; i++) {
90  roar_vio_printf(vio, "Channel[%i]: %i\n", i, (int)settings->mixer[i]);
91 }
92
93 roar_vio_lseek(vio, 0, SEEK_SET);
94 roar_vio_sync(vio);
95 return 0;
96}
97
98//ll
Note: See TracBrowser for help on using the repository browser.