ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/kgsueme/kgsueme/sound.pl
Revision: 1.5
Committed: Sun Mar 28 21:22:16 2004 UTC (20 years, 2 months ago) by pcg
Content type: text/plain
Branch: MAIN
Changes since 1.4: +2 -0 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 pcg 1.4 for (qw(alarm warning move pass ring connect user_unknown gamestart resign)) {
9     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 pcg 1.4 if (my $audioserver = new Audio::Play (1)) {
24 pcg 1.1 $audioserver->play ($sound{$sound});
25 pcg 1.5 $audioserver->flush;
26     undef $audioserver;
27 pcg 1.1 }
28     use POSIX ();
29     POSIX::_exit(0);
30     }
31     }
32    
33     1;