ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/kgsueme/kgsueme/sound.pl
Revision: 1.9
Committed: Wed Jun 2 05:30:15 2004 UTC (20 years ago) by root
Content type: text/plain
Branch: MAIN
Changes since 1.8: +1 -1 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
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 pcg 1.1 use POSIX ();
31     POSIX::_exit(0);
32     }
33     }
34    
35     1;