source: roaraudio/roard/hwmixer_dstr.c @ 5012:b263759832f1

Last change on this file since 5012:b263759832f1 was 4752:42cd1d189fa2, checked in by phi, 13 years ago

corrected c&p error

File size: 3.4 KB
Line 
1//hwmixer_dstr.c:
2
3/*
4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2011
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
28#ifndef ROAR_WITHOUT_DCOMP_MIXER
29
30//#define TEST_HWMIXER_SUBSTREAMS
31
32int hwmixer_dstr_open(struct hwmixer_stream * stream, char * drv, char * dev, int fh, char * basename, struct roar_keyval * subnames, size_t subnamelen) {
33 struct roar_vio_calls * vio = roar_mm_malloc(sizeof(struct roar_vio_calls));
34 struct roar_vio_defaults def;
35 struct roar_stream_server * ss;
36
37 if ( vio == NULL )
38  return -1;
39
40 if ( fh == -1 ) {
41  if ( dev == NULL ) {
42   roar_mm_free(vio);
43   return -1;
44  }
45
46  if ( roar_vio_dstr_init_defaults(&def, ROAR_VIO_DEF_TYPE_NONE, O_WRONLY|O_CREAT|O_TRUNC, 0644) == -1 ) {
47   roar_mm_free(vio);
48   return -1;
49  }
50
51  if ( roar_vio_open_dstr(vio, dev, &def, 1) == -1 ) {
52   roar_mm_free(vio);
53   return -1;
54  }
55 } else {
56  if ( roar_vio_open_fh(vio, fh) == -1 ) {
57   roar_mm_free(vio);
58   return -1;
59  }
60 }
61
62 stream->baseud = vio;
63
64 roar_vio_printf(vio, "No data yet.\n");
65 roar_vio_lseek(vio, 0, SEEK_SET);
66 roar_vio_sync(vio);
67
68 if (streams_get(stream->basestream, &ss) != -1) {
69  ROAR_STREAM(ss)->info.channels = 2;
70 } else {
71  ROAR_WARN("hwmixer_dstr_open(*): can not get object for basestream %i", stream->basestream);
72 }
73
74#ifdef TEST_HWMIXER_SUBSTREAMS
75 stream = hwmixer_substream_new(stream);
76 if ( stream == NULL ) {
77  ROAR_WARN("hwmixer_dstr_open(*): can not create substream");
78 } else {
79  if (streams_get(stream->stream, &ss) != -1) {
80   ROAR_STREAM(ss)->info.channels = 2;
81  } else {
82   ROAR_WARN("hwmixer_dstr_open(*): can not get object for stream %i", stream->stream);
83  }
84 }
85#endif
86
87 return 0;
88}
89
90int hwmixer_dstr_close(struct hwmixer_stream * stream) {
91 // are we a substream? if yes we do not clean up anything.
92 // streams_delete() will do all our work.
93 if ( stream->stream != stream->basestream )
94  return 0;
95
96 roar_vio_close(stream->baseud);
97 roar_mm_free(stream->baseud);
98 return 0;
99}
100
101int hwmixer_dstr_set_vol(struct hwmixer_stream * stream, int channels, int mode, struct roar_mixer_settings * settings) {
102 struct roar_vio_calls * vio = stream->baseud;
103 int i;
104
105 roar_vio_printf(vio, "[Stream %2i of basestream %2i]\n", stream->stream, stream->basestream);
106 roar_vio_printf(vio, "Channels: %2i\n", channels);
107 roar_vio_printf(vio, "Mode: %1i\n", mode);
108 roar_vio_printf(vio, "Scale: %5i\n", (int)settings->scale);
109 roar_vio_printf(vio, "RPG: %5i/%5i\n", (int)settings->rpg_mul, (int)settings->rpg_div);
110
111 for (i = 0; i < channels; i++) {
112  roar_vio_printf(vio, "Channel[%2i]: %5i\n", i, (int)settings->mixer[i]);
113 }
114
115 roar_vio_lseek(vio, 0, SEEK_SET);
116 roar_vio_sync(vio);
117 return 0;
118}
119
120#endif
121
122//ll
Note: See TracBrowser for help on using the repository browser.