[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Ayttm-commits] CVS: ayttm/src sound.c,1.10,1.11
From: |
Colin Leroy <address@hidden> |
Subject: |
[Ayttm-commits] CVS: ayttm/src sound.c,1.10,1.11 |
Date: |
Fri, 24 Jan 2003 03:23:04 -0500 |
Update of /cvsroot/ayttm/ayttm/src
In directory subversions:/tmp/cvs-serv9509/src
Modified Files:
sound.c
Log Message:
cosmetics
Index: sound.c
===================================================================
RCS file: /cvsroot/ayttm/ayttm/src/sound.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- sound.c 21 Jan 2003 01:11:01 -0000 1.10
+++ sound.c 24 Jan 2003 08:23:02 -0000 1.11
@@ -75,39 +75,39 @@
static int play_audio(gchar *soundfile)
{
- int fd;
- struct stat info;
- char * buf;
- char * audio_device;
-
- fd = open(soundfile,O_RDONLY);
- if (fd <= 0)
- {
+ int fd;
+ struct stat info;
+ char * buf;
+ char * audio_device;
+
+ fd = open(soundfile,O_RDONLY);
+ if (fd <= 0)
+ {
eb_debug(DBG_CORE, "Cannot open file %s\n", soundfile);
return FALSE;
- }
- fstat(fd, &info);
- buf = alloca(info.st_size);
- read(fd,buf,24);
- read(fd,buf,info.st_size-24);
- close(fd);
- eb_debug(DBG_CORE, "File is %ld bytes\n", info.st_size);
-
- audio_device = getenv("AUDIODEV");
- if (audio_device == NULL) {
- /* OK, we're not running on a SunRay */
- audio_device = "/dev/audio";
- }
+ }
+ fstat(fd, &info);
+ buf = alloca(info.st_size);
+ read(fd,buf,24);
+ read(fd,buf,info.st_size-24);
+ close(fd);
+ eb_debug(DBG_CORE, "File is %ld bytes\n", info.st_size);
+
+ audio_device = getenv("AUDIODEV");
+ if (audio_device == NULL) {
+ /* OK, we're not running on a SunRay */
+ audio_device = "/dev/audio";
+ }
- eb_debug(DBG_CORE, "sending to %s\n", audio_device);
-
- fd = open(audio_device, O_WRONLY | O_EXCL);
- if (fd < 0)
+ eb_debug(DBG_CORE, "sending to %s\n", audio_device);
+
+ fd = open(audio_device, O_WRONLY | O_EXCL);
+ if (fd < 0)
return FALSE;
- write(fd, buf, info.st_size-24);
- close(fd);
+ write(fd, buf, info.st_size-24);
+ close(fd);
- return TRUE;
+ return TRUE;
}
static int can_play_audio()
@@ -145,40 +145,43 @@
static unsigned char linear2ulaw(int sample)
{
- static int exp_lut[256] = {0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,
- 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
- 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
- 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
- 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
- 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
- 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
- 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7};
- int sign, exponent, mantissa;
- unsigned char ulawbyte;
-
- /* Get the sample into sign-magnitude. */
- sign = (sample >> 8) & 0x80; /* set aside the sign */
- if (sign != 0) sample = -sample; /* get magnitude */
- if (sample > CLIP) sample = CLIP; /* clip the magnitude */
-
- /* Convert from 16 bit linear to ulaw. */
- sample = sample + BIAS;
- exponent = exp_lut[(sample >> 7) & 0xFF];
- mantissa = (sample >> (exponent + 3)) & 0x0F;
- ulawbyte = ~(sign | (exponent << 4) | mantissa);
+ static int exp_lut[256] = {0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,
+ 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
+ 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
+ 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
+ 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
+ 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
+ 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
+ 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7};
+ int sign, exponent, mantissa;
+ unsigned char ulawbyte;
+
+ /* Get the sample into sign-magnitude. */
+ sign = (sample >> 8) & 0x80; /* set aside the sign */
+ if (sign != 0)
+ sample = -sample; /* get magnitude */
+ if (sample > CLIP)
+ sample = CLIP; /* clip the magnitude */
+
+ /* Convert from 16 bit linear to ulaw. */
+ sample = sample + BIAS;
+ exponent = exp_lut[(sample >> 7) & 0xFF];
+ mantissa = (sample >> (exponent + 3)) & 0x0F;
+ ulawbyte = ~(sign | (exponent << 4) | mantissa);
#ifdef ZEROTRAP
- if (ulawbyte == 0) ulawbyte = 0x02; /* optional CCITT trap */
+ if (ulawbyte == 0)
+ ulawbyte = 0x02; /* optional CCITT trap */
#endif
- return(ulawbyte);
+ return(ulawbyte);
}
#if HAVE_LIBAUDIOFILE
@@ -223,18 +226,16 @@
*/
static int _af_ulaw2linear (unsigned char ulawbyte)
{
- static int exp_lut[8] = {0,132,396,924,1980,4092,8316,16764};
- int sign, exponent, mantissa, sample;
+ static int exp_lut[8] = {0,132,396,924,1980,4092,8316,16764};
+ int sign, exponent, mantissa, sample;
- ulawbyte = ~ulawbyte;
- sign = (ulawbyte & 0x80);
- exponent = (ulawbyte >> 4) & 0x07;
- mantissa = ulawbyte & 0x0F;
- sample = exp_lut[exponent] + (mantissa << (exponent + 3));
- if (sign != 0) sample = -sample;
- {
- return(sample);
- }
+ ulawbyte = ~ulawbyte;
+ sign = (ulawbyte & 0x80);
+ exponent = (ulawbyte >> 4) & 0x07;
+ mantissa = ulawbyte & 0x0F;
+ sample = exp_lut[exponent] + (mantissa << (exponent + 3));
+ if (sign != 0) sample = -sample;
+ return(sample);
}
#endif /* HAVE_LIBAUDIOFILE */
@@ -248,32 +249,28 @@
static int play_esd_file(gchar *soundfile)
{
- int esd_stat;
- esd_stat = esd_play_file(NULL, soundfile, 1);
- if (!esd_stat)
- {
- if (errno == ENOENT)
- {
- eb_debug(DBG_CORE, "Ayttm: File not found - file = \"%s\"\n",
soundfile);
+ int esd_stat;
+ esd_stat = esd_play_file(NULL, soundfile, 1);
+ if (!esd_stat) {
+ if (errno == ENOENT) {
+ eb_debug(DBG_CORE, "Ayttm: File not found - file =
\"%s\"\n", soundfile);
+ } else {
+ eb_debug(DBG_CORE, "Ayttm: Esd play file failed with
code %d\n", errno);
}
- else
- {
- eb_debug(DBG_CORE, "Ayttm: Esd play file failed with code
%d\n", errno);
- }
- }
- return esd_stat;
+ }
+ return esd_stat;
}
#else
static int can_play_esd()
{
- return FALSE;
+ return FALSE;
}
static int play_esd_file(gchar *soundfile)
{
- return FALSE;
+ return FALSE;
}
#endif /* ESD_SOUND */
@@ -284,119 +281,104 @@
static int test_arts()
{
- int err;
- if ((err = arts_init()) != 0)
- {
- eb_debug(DBG_CORE, "WARNING (NO ERROR!):\ncan_play_arts(): arts_init()
failed: %s\nIs artsd running?\n", arts_error_text( err ));
- return FALSE;
- }
- return TRUE;
+ int err;
+ if ((err = arts_init()) != 0) {
+ eb_debug(DBG_CORE, "WARNING (NO ERROR!):\ncan_play_arts():
arts_init() failed: %s\nIs artsd running?\n", arts_error_text( err ));
+ return FALSE;
+ }
+ return TRUE;
}
static int can_play_arts()
{
#ifndef ARTS_FREE_IS_BROKEN
- return test_arts();
+ return test_arts();
#else
- pid_t childpid;
- int childstatus;
- int ret = -1;
-
- childpid = fork();
-
- if(childpid==0)
- {
- /* Child - do test and exit with result */
- exit(test_arts() ? 0 : 1);
- }
- else if(childpid==-1)
- {
- fprintf(stderr,"test_arts(): Failed at fork(), errno=%d\n", errno);
- return FALSE;
- }
- else
- {
- if( (ret=waitpid(-1, &childstatus, 0) == -1)) {
- fprintf(stderr,"test_arts(): Failed at wait(), errno=%d\n", errno);
- perror("waitpid");
- return FALSE;
- }
+ pid_t childpid;
+ int childstatus;
+ int ret = -1;
+
+ childpid = fork();
+
+ if(childpid==0)
+ /* Child - do test and exit with result */
+ exit(test_arts() ? 0 : 1);
+ else if(childpid==-1) {
+ fprintf(stderr,"test_arts(): Failed at fork(), errno=%d\n",
errno);
+ return FALSE;
+ } else {
+ if( (ret=waitpid(-1, &childstatus, 0) == -1)) {
+ fprintf(stderr,"test_arts(): Failed at wait(),
errno=%d\n", errno);
+ perror("waitpid");
+ return FALSE;
+ }
- if( WEXITSTATUS(childstatus)==0 ) {
- return TRUE;
- }
- }
- return FALSE;
+ if( WEXITSTATUS(childstatus)==0 ) {
+ return TRUE;
+ }
+ }
+ return FALSE;
#endif
}
static void arts_shutdown()
{
- arts_free();
+ arts_free();
}
static int play_arts_file(gchar *soundfile)
{
- AFfilehandle fd;
- AFframecount frameCount, count;
- arts_stream_t artsStream;
- int frameSize, channelCount, sampleFormat, sampleWidth, err, susperr;
- double sampleRate;
- char * buf;
+ AFfilehandle fd;
+ AFframecount frameCount, count;
+ arts_stream_t artsStream;
+ int frameSize, channelCount, sampleFormat, sampleWidth, err, susperr;
+ double sampleRate;
+ char * buf;
#ifdef ARTS_FREE_IS_BROKEN
- /* We have to init every time */
- if ((err = arts_init()) != 0)
- {
- eb_debug(DBG_CORE, "WARNING (NO ERROR!):\ncan_play_arts(): arts_init()
failed: %s\nIs artsd running?\n", arts_error_text( err ));
- return FALSE;
- }
+ /* We have to init every time */
+ if ((err = arts_init()) != 0) {
+ eb_debug(DBG_CORE, "WARNING (NO ERROR!):\ncan_play_arts():
arts_init() failed: %s\nIs artsd running?\n", arts_error_text( err ));
+ return FALSE;
+ }
#endif
- fd = afOpenFile( soundfile, "r", NULL );
- if (fd == AF_NULL_FILEHANDLE)
- {
+ fd = afOpenFile( soundfile, "r", NULL );
+ if (fd == AF_NULL_FILEHANDLE) {
eb_debug(DBG_CORE, "play_arts_file(): Cannot open file %s\n",
soundfile);
return FALSE;
- }
- frameCount = afGetFrameCount( fd, AF_DEFAULT_TRACK );
- frameSize = afGetFrameSize( fd, AF_DEFAULT_TRACK, 1 );
- channelCount = afGetChannels( fd, AF_DEFAULT_TRACK );
- sampleRate = afGetRate( fd, AF_DEFAULT_TRACK );
- afGetSampleFormat( fd, AF_DEFAULT_TRACK, &sampleFormat, &sampleWidth );
- eb_debug(DBG_CORE, "play_arts_file(): frameCount: %d\nframeSize:
%i\nchannelCount: %i\nsampleRate: %.2f\n", (int) frameCount, frameSize,
channelCount, sampleRate );
-
- artsStream = arts_play_stream( sampleRate, sampleWidth, channelCount,
"EVERYBUDDY" );
- buf = (char *) malloc( BUFFERED_FRAME_COUNT * frameSize );
- count = afReadFrames( fd, AF_DEFAULT_TRACK, buf, BUFFERED_FRAME_COUNT );
- do
- {
- err = arts_write( artsStream, buf, count * frameSize );
- eb_debug(DBG_CORE, "count = %d\n", (int) count);
- eb_debug(DBG_CORE, "play_arts_file(): written bytes in artsStream:
%i\n", err );
- if(err < 0)
- {
- eb_debug(DBG_CORE, "arts_write error: %s\n", arts_error_text( err )
);
}
- }
- while ((count = afReadFrames( fd, AF_DEFAULT_TRACK, buf,
BUFFERED_FRAME_COUNT)) && (err >= 0));
- free( buf );
- arts_close_stream( artsStream );
-
- afCloseFile( fd );
- susperr = arts_suspend();
- if(susperr < 0)
- {
- eb_debug(DBG_CORE, "arts_suspend error: %s\n", arts_error_text( err )
);
- }
-
- return (err<0?FALSE:TRUE);
+ frameCount = afGetFrameCount( fd, AF_DEFAULT_TRACK );
+ frameSize = afGetFrameSize( fd, AF_DEFAULT_TRACK, 1 );
+ channelCount = afGetChannels( fd, AF_DEFAULT_TRACK );
+ sampleRate = afGetRate( fd, AF_DEFAULT_TRACK );
+ afGetSampleFormat( fd, AF_DEFAULT_TRACK, &sampleFormat, &sampleWidth );
+ eb_debug(DBG_CORE, "play_arts_file(): frameCount: %d\nframeSize:
%i\nchannelCount: %i\nsampleRate: %.2f\n", (int) frameCount, frameSize,
channelCount, sampleRate );
+
+ artsStream = arts_play_stream( sampleRate, sampleWidth, channelCount,
"EVERYBUDDY" );
+ buf = (char *) malloc( BUFFERED_FRAME_COUNT * frameSize );
+ count = afReadFrames( fd, AF_DEFAULT_TRACK, buf, BUFFERED_FRAME_COUNT );
+ do {
+ err = arts_write( artsStream, buf, count * frameSize );
+ eb_debug(DBG_CORE, "count = %d\n", (int) count);
+ eb_debug(DBG_CORE, "play_arts_file(): written bytes in
artsStream: %i\n", err );
+ if(err < 0)
+ eb_debug(DBG_CORE, "arts_write error: %s\n",
arts_error_text( err ) );
+ } while ((count = afReadFrames( fd, AF_DEFAULT_TRACK, buf,
BUFFERED_FRAME_COUNT)) && (err >= 0));
+ free( buf );
+ arts_close_stream( artsStream );
+
+ afCloseFile( fd );
+ susperr = arts_suspend();
+ if(susperr < 0)
+ eb_debug(DBG_CORE, "arts_suspend error: %s\n", arts_error_text(
err ) );
+ return (err>=0);
}
#else
static int can_play_arts()
{
- return FALSE;
+ return FALSE;
}
static void arts_shutdown()
@@ -405,7 +387,7 @@
static int play_arts_file(gchar *soundfile)
{
- return FALSE;
+ return FALSE;
}
#endif /* ARTS_SOUND */
@@ -441,22 +423,19 @@
if (scaling == 0.0)
return(infile); /* save time */
- if ((fd_in = fopen(infile, "rb")) == NULL)
- {
+ if ((fd_in = fopen(infile, "rb")) == NULL) {
fprintf(stderr,"Failed opening infile %s, errno=%d\n",infile,
errno);
return(infile);
}
/* see if this is .au file, if not then get out */
- if ((io_bytes = fread((guchar *)&auheader, sizeof(guchar),
sizeof(auheader), fd_in)) != 28)
- {
+ if ((io_bytes = fread((guchar *)&auheader, sizeof(guchar),
sizeof(auheader), fd_in)) != 28) {
fclose(fd_in);
fprintf(stderr,"Auscale - header read failed\n");
return(infile);
}
- if (strncmp(auheader.magic,".snd",4))
- {
+ if (strncmp(auheader.magic,".snd",4)) {
eb_debug(DBG_CORE, "Not .au file,file
type=%X%X%X%X\n",auheader.magic[0],auheader.magic[1],auheader.magic[2],auheader.magic[3]);
fclose(fd_in);
return(infile);
@@ -464,8 +443,7 @@
x = GUINT32_FROM_BE(auheader.dataformat);
- if (x!=1) /* only want ulaw-8 format files */
- {
+ if (x!=1) /* only want ulaw-8 format files */ {
eb_debug(DBG_CORE, "Not .au file,file
type=%X%X%X%X\n",auheader.magic[0],auheader.magic[1],auheader.magic[2],auheader.magic[3]);
fclose(fd_in);
return(infile);
@@ -475,8 +453,7 @@
/* file is right type, reset to start */
rewind(fd_in);
- if ((fd_out = fopen(outfile, "w+b")) == NULL)
- {
+ if ((fd_out = fopen(outfile, "w+b")) == NULL) {
fprintf(stderr,"Failed opening outfile %s, errno=%d\n",outfile,
errno);
fclose(fd_in);
return(infile);
@@ -486,28 +463,23 @@
scaling = pow(10.0,scaling/20.0);
/* Build mapping */
- for (x=0; x<mapLen ; x++)
+ for (x=0; x<mapLen ; x++)
map[x]=linear2ulaw(scaling*_af_ulaw2linear(x));
- /* Shift the .au header */
- /* copy the .au header */
- /* Note: There are unusual situations when the 'info' field is VERY
- * large and the start of data can therefore be larger than buf2.
- * The following 'while' statement takes care of that problem. */
- while(header_size >= (guint32)sizeof(buf2))
- {
- if ((io_bytes = fread(buf2, sizeof(guchar), sizeof(buf2),
fd_in)) == sizeof(buf2))
- {
- if ((io_bytes = fwrite(buf2, sizeof(guchar),
sizeof(buf2), fd_out)) != sizeof(buf2))
- {
+ /* Shift the .au header
+ * copy the .au header
+ * Note: There are unusual situations when the 'info' field is VERY
+ * large and the start of data can therefore be larger than buf2.
+ * The following 'while' statement takes care of that problem. */
+ while(header_size >= (guint32)sizeof(buf2)) {
+ if ((io_bytes = fread(buf2, sizeof(guchar), sizeof(buf2),
fd_in)) == sizeof(buf2)) {
+ if ((io_bytes = fwrite(buf2, sizeof(guchar),
sizeof(buf2), fd_out)) != sizeof(buf2)) {
eb_debug(DBG_CORE, "error copying au file");
fclose(fd_out);
fclose(fd_in);
return (infile);
}
- }
- else
- {
+ } else {
eb_debug(DBG_CORE, "error copying au file");
fclose(fd_in);
fclose(fd_out);
@@ -519,35 +491,29 @@
}
/* copy rest of header (or in most cases - all of it) */
- if ((io_bytes = fread(buf2, sizeof(guchar), header_size, fd_in)) ==
header_size)
- {
- if ((io_bytes = fwrite(buf2, sizeof(guchar), header_size,
fd_out)) != header_size)
- {
+ if ((io_bytes = fread(buf2, sizeof(guchar), header_size, fd_in)) ==
header_size) {
+ if ((io_bytes = fwrite(buf2, sizeof(guchar), header_size,
fd_out)) != header_size) {
eb_debug(DBG_CORE, "error copying au file");
fclose(fd_out);
fclose(fd_in);
return (infile);
}
- }
- else
- {
+ } else {
eb_debug(DBG_CORE, "error copying au file");
fclose(fd_in);
fclose(fd_out);
return(infile);
}
- /* Write the mapped data out */
+ /* Write the mapped data out */
while((bytes_read = fread( &buf, sizeof(guchar), 1, fd_in)) > 0)
- {
fwrite(map+buf, sizeof(guchar), 1, fd_out);
- }
fclose(fd_in);
fclose(fd_out);
#endif
- return outfile;
+ return outfile;
}
@@ -566,33 +532,24 @@
static gboolean file_ok(gchar *soundfile)
{
- gchar message[1024];
+ gchar message[1024];
- if (access(soundfile, R_OK) == -1) /* use 'access' rather than
- * 'stat', so we also get access
- * results
- */
- {
+ if (access(soundfile, R_OK) == -1) {
/* find and report the error */
- switch (errno)
- {
- case ENOENT:
- g_snprintf(message, 1024, "Sound file \'%s\', Not Found", soundfile);
- break;
-
- case EACCES:
- g_snprintf(message, 1024, "Sound file \'%s\', Access Not Allowed",
soundfile);
- break;
-
- default:
- g_snprintf(message, 1024, "Error in opening sound file \'%s\', error
code = %d", soundfile, errno);
- break;
- }
-
- do_error_dialog(message, "Ayttm-WARNING");
- return FALSE;
- }
- return TRUE;
+ switch (errno) {
+ case ENOENT:
+ g_snprintf(message, 1024, "Sound file \'%s\', Not
Found", soundfile);
+ break;
+ case EACCES:
+ g_snprintf(message, 1024, "Sound file \'%s\', Access
Not Allowed", soundfile);
+ break;
+ default:
+ g_snprintf(message, 1024, "Error in opening sound file
\'%s\', error code = %d", soundfile, errno);
+ }
+ do_error_dialog(message, "Ayttm-WARNING");
+ return FALSE;
+ }
+ return TRUE;
}
@@ -613,53 +570,41 @@
gint pid;
if(!play_soundfile)
- return;
+ return;
if (!file_ok(soundfile))
return;
pid = fork();
- if (pid < 0)
- {
+ if (pid < 0) {
fprintf(stderr, "in playsoundfile(), fork failed!\n");
return;
- }
- else if (pid == 0)
- {
- /* we're the child process, play the sound... */
- if(fGetLocalPref("SoundVolume") != 0.0)
- {
- gchar tmp_soundfile[9] = "ebXXXXXX";
+ } else if (pid == 0) {
+ /* we're the child process, play the sound... */
+ if(fGetLocalPref("SoundVolume") != 0.0) {
+ gchar tmp_soundfile[9] = "ebXXXXXX";
- if (mkstemp(tmp_soundfile) == -1) /* create name for auscale */
- {
- fprintf(stderr, "in playsoundfile(), mkstemp failed!\n");
- return;
- }
-
- soundfile =
auscale(soundfile,tmp_soundfile,fGetLocalPref("SoundVolume"));
-
- play_soundfile(soundfile);
-
- if (unlink(tmp_soundfile))
- fprintf(stderr,
- "in playsoundfile(), unlink failed!\n");
- }
- else
- {
- play_soundfile(soundfile);
- }
+ if (mkstemp(tmp_soundfile) == -1) /* create name for
auscale */ {
+ fprintf(stderr, "in playsoundfile(), mkstemp
failed!\n");
+ return;
+ }
- _exit(0);
-
- }
- else
- {
+ soundfile =
auscale(soundfile,tmp_soundfile,fGetLocalPref("SoundVolume"));
+
+ play_soundfile(soundfile);
+
+ if (unlink(tmp_soundfile))
+ fprintf(stderr, "in playsoundfile(), unlink
failed!\n");
+ } else {
+ play_soundfile(soundfile);
+ }
+
+ _exit(0);
+ } else {
/* We're the parent process... */
eb_timeout_add(100, clean_pid, NULL);
}
#endif
-
}
@@ -667,80 +612,57 @@
void play_sound(int sound)
{
if ( iGetLocalPref("do_no_sound_when_away") && is_away )
- return;
+ return;
- switch(sound)
- {
- case BUDDY_AWAY:
- {
- playsoundfile(cGetLocalPref("BuddyAwayFilename"));
- }
+ switch(sound) {
+ case BUDDY_AWAY:
+ playsoundfile(cGetLocalPref("BuddyAwayFilename"));
break;
- case BUDDY_ARRIVE:
- {
- playsoundfile(cGetLocalPref("BuddyArriveFilename"));
- }
+ case BUDDY_ARRIVE:
+ playsoundfile(cGetLocalPref("BuddyArriveFilename"));
break;
- case BUDDY_LEAVE:
- {
- playsoundfile(cGetLocalPref("BuddyLeaveFilename"));
- }
+ case BUDDY_LEAVE:
+ playsoundfile(cGetLocalPref("BuddyLeaveFilename"));
break;
- case SEND:
- {
- playsoundfile(cGetLocalPref("SendFilename"));
- }
+ case SEND:
+ playsoundfile(cGetLocalPref("SendFilename"));
break;
- case RECEIVE:
- {
- playsoundfile(cGetLocalPref("ReceiveFilename"));
- break;
- }
- case FIRSTMSG:
- {
- playsoundfile(cGetLocalPref("FirstMsgFilename"));
- break;
- }
- default:
- return;
- }
+ case RECEIVE:
+ playsoundfile(cGetLocalPref("ReceiveFilename"));
+ break;
+ case FIRSTMSG:
+ playsoundfile(cGetLocalPref("FirstMsgFilename"));
+ break;
+ }
}
void sound_init()
{
- /* Determine which sound module will be used to play sounds */
-
-
- if(can_play_arts())
- {
- eb_debug(DBG_CORE,"Using arts sound\n");
- play_soundfile = play_arts_file;
- shutdown_sounddrv = arts_shutdown;
- }
- else if(can_play_esd())
- {
- eb_debug(DBG_CORE,"Using esd sound\n");
- play_soundfile = play_esd_file;
- shutdown_sounddrv = NULL;
- }
- /* handle sound direct to /dev/audio */
- else if (can_play_audio())
- {
- eb_debug(DBG_CORE,"Using raw audio\n");
- play_soundfile = play_audio;
- shutdown_sounddrv = NULL;
- }
- else
- {
- eb_debug(DBG_CORE,"Sound not available\n");
- play_soundfile = NULL;
- shutdown_sounddrv = NULL;
- }
+ if(can_play_arts()) {
+ eb_debug(DBG_CORE,"Using arts sound\n");
+ play_soundfile = play_arts_file;
+ shutdown_sounddrv = arts_shutdown;
+ }
+ else if(can_play_esd()) {
+ eb_debug(DBG_CORE,"Using esd sound\n");
+ play_soundfile = play_esd_file;
+ shutdown_sounddrv = NULL;
+ }
+ /* handle sound direct to /dev/audio */
+ else if (can_play_audio()) {
+ eb_debug(DBG_CORE,"Using raw audio\n");
+ play_soundfile = play_audio;
+ shutdown_sounddrv = NULL;
+ }
+ else {
+ eb_debug(DBG_CORE,"Sound not available\n");
+ play_soundfile = NULL;
+ shutdown_sounddrv = NULL;
+ }
}
void sound_shutdown()
{
- if(shutdown_sounddrv != NULL) {
- shutdown_sounddrv();
- }
+ if(shutdown_sounddrv != NULL)
+ shutdown_sounddrv();
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Ayttm-commits] CVS: ayttm/src sound.c,1.10,1.11,
Colin Leroy <address@hidden> <=
- Prev by Date:
[Ayttm-commits] CVS: ayttm ChangeLog,1.192,1.193 configure.in,1.188,1.189
- Next by Date:
[Ayttm-commits] CVS: ayttm CODING_STYLE,NONE,1.1
- Previous by thread:
[Ayttm-commits] CVS: ayttm ChangeLog,1.192,1.193 configure.in,1.188,1.189
- Next by thread:
[Ayttm-commits] CVS: ayttm CODING_STYLE,NONE,1.1
- Index(es):