shithub: choc

Download patch

ref: 5673503ff3524db56ae73cbe29ad0a2571beb657
parent: d2c5206b1489770c37504426c6d7e9448287479e
author: Simon Howard <[email protected]>
date: Sat Aug 6 13:05:51 EDT 2005

Remove debug messages, send error messages to stderr
Fix overflow when playing large sound files

Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 43

--- a/src/i_sound.c
+++ b/src/i_sound.c
@@ -1,7 +1,7 @@
 // Emacs style mode select   -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id: i_sound.c 42 2005-08-05 17:53:07Z fraggle $
+// $Id: i_sound.c 43 2005-08-06 17:05:51Z fraggle $
 //
 // Copyright(C) 1993-1996 Id Software, Inc.
 // Copyright(C) 2005 Simon Howard
@@ -22,6 +22,10 @@
 // 02111-1307, USA.
 //
 // $Log$
+// Revision 1.8  2005/08/06 17:05:51  fraggle
+// Remove debug messages, send error messages to stderr
+// Fix overflow when playing large sound files
+//
 // Revision 1.7  2005/08/05 17:53:07  fraggle
 // More sensible defaults
 //
@@ -51,7 +55,7 @@
 //-----------------------------------------------------------------------------
 
 static const char
-rcsid[] = "$Id: i_sound.c 42 2005-08-05 17:53:07Z fraggle $";
+rcsid[] = "$Id: i_sound.c 43 2005-08-06 17:05:51Z fraggle $";
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -129,7 +133,7 @@
 
         sound_chunks[sound].allocated = 1;
         sound_chunks[sound].abuf = expand_sound_data(data + 8, samplerate, length);
-        sound_chunks[sound].alen = (length * 2 * 22050) / samplerate;
+        sound_chunks[sound].alen = (length * 2)  * (22050 / samplerate);
         sound_chunks[sound].volume = 32;
     }
 
@@ -294,13 +298,13 @@
 { 
     if (SDL_Init(SDL_INIT_AUDIO) < 0)
     {
-        printf("Unable to set up sound.\n");
+        fprintf(stderr, "Unable to set up sound.\n");
         return;
     }
 
     if (Mix_OpenAudio(22050, AUDIO_U8, 2, 1024) < 0)
     {
-        printf("Error initialising SDL_mixer: %s\n", SDL_GetError());
+        fprintf(stderr, "Error initialising SDL_mixer: %s\n", SDL_GetError());
     }
 
     Mix_AllocateChannels(16);
@@ -308,8 +312,6 @@
     sound_initialised = 1;
 
     SDL_PauseAudio(0);
-
-    printf("sound started.\n");
 }