ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/kgsueme/kgsueme/sound.pl
Revision: 1.6
Committed: Sun May 30 03:24:47 2004 UTC (20 years ago) by pcg
Content type: text/plain
Branch: MAIN
Changes since 1.5: +1 -1 lines
Log Message:
*** empty log message ***

File Contents

# Content
1 package sound;
2
3 use KGS::Constants;
4
5 my %sound;
6 $SIG{CHLD} = 'IGNORE';
7
8 for (qw(alarm warning 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 if (my $audioserver = new Audio::Play (1)) {
24 $audioserver->play ($sound{$sound});
25 $audioserver->flush;
26 undef $audioserver;
27 }
28 use POSIX ();
29 POSIX::_exit(0);
30 }
31 }
32
33 1;