1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
##################################################
#
# GiantDisc mp3 Jukebox
#
# © 2003, Rolf Brugger
#
##################################################
package gdsoundcard;
#
# soundcard drivers to control volume etc
#
#
#
#use lib '/usr/local/bin';
use strict;
############################################################
### Constants & global variables
############################################################
sub sndc_init{
### initialize
# actually not used yet
my ($playertype, $playerhost, $sounddevice) = @_;
if ($playertype == 0){ # local oss soundcard
;
}
elsif ($playertype == 20){ # exstreamer
;
}
else{
print "Warning: unknown player type $playertype\n";
}
}
############################################################
### Volume routines
# 0 <= volume <= 100
sub sndc_set_volume{
### Set volume
my ($playertype, $playerhost, $sounddevice, $volume) = @_;
if ($playertype == 0){ # local oss soundcard
system "aumix -v$volume";
}
elsif ($playertype == 20){ # exstreamer
use integer;
my $cmd = "v=".($volume/5)."\n";
gdgentools::exstreamer_command($playerhost, $cmd);
}
else{
print "Warning: unknown player type $playertype\n";
}
}
sub sndc_get_volume{
### Get volume
# returns the currently set volume.
my ($playertype, $playerhost, $sounddevice) = @_;
my $volume = 0;
if ($playertype == 0){ # local oss soundcard
my ($shcommand) = @_;
my ($res, $resline, @reslines);
$res = `aumix -vq`;
@reslines = split /\n/, $res;
$resline = shift (@reslines);
if ($resline =~ m/\D*(\d+).*/){
$volume = $1;
}
else{print "Warning: Get volume - can't match aumix output\n";}
}
elsif ($playertype == 20){ # exstreamer
my $cmd = "v=\n"; # cmd get volume
my $res = gdgentools::exstreamer_command_res($playerhost, $cmd);
if ($res =~ m/\<.*\>(\d+)\<.*\>/){
$volume = ($1)*5;
}
else{
$volume = 50;
}
}
else{
print "Warning: unknown player type $playertype\n";
}
return $volume;
}
sub sndc_save_volume{
### Save default volume
my ($playertype, $playerhost, $sounddevice, $volume) = @_;
if ($playertype == 0){ # local oss soundcard
system "aumix -S";
}
elsif ($playertype == 20){ # exstreamer
# the exstreamer always saves the volume setting in its flash rom
;
}
else{
print "Warning: unknown player type $playertype\n";
}
}
############################################################
sub sndc_inc_volume{
### Increases volume by 5%
my ($playertype, $playerhost, $sounddevice) = @_;
my $volume = sndc_get_volume($playertype, $playerhost, $sounddevice);
$volume += 5;
if ($volume>100){$volume=100;}
sndc_set_volume($playertype, $playerhost, $sounddevice, $volume);
}
sub sndc_dec_volume{
### decreases volume by 5%
my ($playertype, $playerhost, $sounddevice) = @_;
my $volume = sndc_get_volume($playertype, $playerhost, $sounddevice);
$volume -= 5;
if ($volume<0){$volume=0;}
sndc_set_volume($playertype, $playerhost, $sounddevice, $volume);
}
############################################################
1;
#
|