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