1 |
pcg |
1.1 |
package sound; |
2 |
|
|
|
3 |
pcg |
1.3 |
use KGS::Constants; |
4 |
|
|
|
5 |
pcg |
1.1 |
my %sound; |
6 |
|
|
$SIG{CHLD} = 'IGNORE'; |
7 |
|
|
|
8 |
root |
1.7 |
for (qw(alarm warning info move pass ring connect user_unknown gamestart resign outoftime)) { |
9 |
pcg |
1.4 |
my $path = KGS::Constants::findfile "KGS/kgsueme/sounds/$_"; |
10 |
|
|
|
11 |
|
|
open my $snd, "<", $path |
12 |
|
|
or die "$path: $!"; |
13 |
pcg |
1.1 |
binmode $snd; |
14 |
|
|
|
15 |
|
|
$sound{$_} = new Audio::Data; |
16 |
pcg |
1.4 |
$sound{$_}->Load ($snd); |
17 |
pcg |
1.1 |
} |
18 |
|
|
|
19 |
|
|
sub play { |
20 |
|
|
my ($annoyancy, $sound) = @_; |
21 |
|
|
# annoyany 1 => important, annoyance 2 => useful, annoyancy 3 => not useful |
22 |
|
|
if (fork == 0) { |
23 |
root |
1.8 |
eval { |
24 |
|
|
if (my $audioserver = new Audio::Play (1)) { |
25 |
|
|
$audioserver->play ($sound{$sound}); |
26 |
|
|
$audioserver->flush; |
27 |
|
|
undef $audioserver; |
28 |
|
|
} |
29 |
root |
1.9 |
}; |
30 |
root |
1.10 |
exit(0); |
31 |
pcg |
1.1 |
} |
32 |
|
|
} |
33 |
|
|
|
34 |
|
|
1; |