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