stratagus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Stratagus-CVS] stratagus/src/sound arts_audio.c cdaudio.c cdda...


From: Jimmy Salmon
Subject: [Stratagus-CVS] stratagus/src/sound arts_audio.c cdaudio.c cdda...
Date: Wed, 01 Oct 2003 13:52:41 -0400

CVSROOT:        /cvsroot/stratagus
Module name:    stratagus
Branch:         
Changes by:     Jimmy Salmon <address@hidden>   03/10/01 13:52:41

Modified files:
        src/sound      : arts_audio.c cdaudio.c cdda.c flac.c 

Log message:
        Cleanup

Patches:
Index: stratagus/src/sound/arts_audio.c
diff -u stratagus/src/sound/arts_audio.c:1.6 
stratagus/src/sound/arts_audio.c:1.7
--- stratagus/src/sound/arts_audio.c:1.6        Fri Jul 11 10:35:33 2003
+++ stratagus/src/sound/arts_audio.c    Wed Oct  1 13:52:40 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: arts_audio.c,v 1.6 2003/07/11 14:35:33 n0body Exp $
+//     $Id: arts_audio.c,v 1.7 2003/10/01 17:52:40 jsalmon3 Exp $
 
 //@{
 
@@ -92,16 +92,16 @@
 
     switch (freq) {
        case 11025:
-           frags = ((8<<16) |  8);   // 8 Buffers of  256 Bytes
+           frags = ((8 << 16) |  8);   // 8 Buffers of  256 Bytes
            break;
        case 22050:
-           frags = ((8<<16) |  9);   // 8 Buffers of  512 Bytes
+           frags = ((8 << 16) |  9);   // 8 Buffers of  512 Bytes
            break;
        default:
            DebugLevel0Fn("Unexpected sample frequency %d\n" _C_ freq);
            // FALL THROUGH
        case 44100:
-           frags = ((8<<16) | 10);   // 8 Buffers of 1024 Bytes
+           frags = ((8 << 16) | 10);   // 8 Buffers of 1024 Bytes
            break;
     }
     if (size == 16) {                  //  8 bit
@@ -139,7 +139,7 @@
 */
 global int WriteArtsSound(void* data,int len)
 {
-       return arts_write(stream, data, len);
+    return arts_write(stream, data, len);
 }
 
 /**
@@ -149,7 +149,7 @@
 */
 global int ArtsGetSpace(void)
 {
-       return arts_stream_get(stream, ARTS_P_BUFFER_SPACE);
+    return arts_stream_get(stream, ARTS_P_BUFFER_SPACE);
 }
 
 #endif // } WITH_ARTSC
Index: stratagus/src/sound/cdaudio.c
diff -u stratagus/src/sound/cdaudio.c:1.12 stratagus/src/sound/cdaudio.c:1.13
--- stratagus/src/sound/cdaudio.c:1.12  Fri Jul 11 10:35:33 2003
+++ stratagus/src/sound/cdaudio.c       Wed Oct  1 13:52:40 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: cdaudio.c,v 1.12 2003/07/11 14:35:33 n0body Exp $
+//     $Id: cdaudio.c,v 1.13 2003/10/01 17:52:40 jsalmon3 Exp $
 
 //@{
 
@@ -67,7 +67,7 @@
 global int NumCDTracks;                        /// Number of tracks on the cd
 
 #if defined(USE_SDLCD) 
-local SDL_CD *CDRom;                   /// SDL cdrom device
+local SDL_CD* CDRom;                   /// SDL cdrom device
 #elif defined(USE_CDDA) 
 global int CDDrive;                    /// CDRom device
 global struct cdrom_tocentry CDtocentry[64];   /// TOC track header struct
@@ -105,7 +105,7 @@
 global int PlayCDTrack(int track)
 {
     CDTrack = track;
-    return SDL_CDPlayTracks(CDRom, track-1, 0, 0, 0);
+    return SDL_CDPlayTracks(CDRom, track - 1, 0, 0, 0);
 }
 
 /**
@@ -249,6 +249,7 @@
 global int GetCDVolume(void)
 {
     int vol;
+
     cd_get_volume(&vol, &vol);
     return vol;
 }
@@ -258,7 +259,6 @@
 */
 global void SetCDVolume(int vol)
 {
-    vol = vol;
     cd_set_volume(vol, vol);
 }
 
@@ -307,7 +307,7 @@
 */
 global int PlayCDTrack(int track)
 {
-    Sample *sample;
+    Sample* sample;
 
     sample = LoadCD(NULL, track);
     CDTrack = track;
@@ -339,7 +339,7 @@
 */
 global int IsAudioTrack(track)
 {
-    return !(CDtocentry[track].cdte_ctrl&CDROM_DATA_TRACK);
+    return !(CDtocentry[track].cdte_ctrl & CDROM_DATA_TRACK);
 }
 
 /**
@@ -380,10 +380,10 @@
 ** 
 **      Perodic called from the main loop. 
 */
-global int CDRomCheck(void *unused __attribute__ ((unused)))
+global int CDRomCheck(void* unused __attribute__ ((unused)))
 {
-    if (CDMode != CDModeOff && CDMode != CDModeStopped
-           && !IsCDPlaying() && CDMode != CDModeDefined) {
+    if (CDMode != CDModeOff && CDMode != CDModeStopped &&
+           !IsCDPlaying() && CDMode != CDModeDefined) {
         DebugLevel0Fn("Playing new track\n");
         PlayCDRom(CDMode);
     }
Index: stratagus/src/sound/cdda.c
diff -u stratagus/src/sound/cdda.c:1.19 stratagus/src/sound/cdda.c:1.20
--- stratagus/src/sound/cdda.c:1.19     Fri Jul 11 10:35:33 2003
+++ stratagus/src/sound/cdda.c  Wed Oct  1 13:52:40 2003
@@ -72,10 +72,9 @@
 **
 **     @return             Number of bytes read
 */
-local int CDRead(Sample *sample, void *buf, int len)
+local int CDRead(Sample* sample, void* buf, int len)
 {
-    CddaData *data;
-
+    CddaData* data;
     int n;
 
     data = (CddaData*)sample->User;
@@ -84,9 +83,10 @@
     data->Readdata.addr_format = CDROM_LBA;
 
     // end of track
-    if (FRAME_SIZE * (CDtocentry[CDTrack+1].cdte_addr.lba - 
+    if (FRAME_SIZE * (CDtocentry[CDTrack + 1].cdte_addr.lba - 
            CDtocentry[CDTrack].cdte_addr.lba) - data->PosInCd < len) {
-       len = FRAME_SIZE * (CDtocentry[CDTrack+1].cdte_addr.lba - 
CDtocentry[CDTrack].cdte_addr.lba) - data->PosInCd;
+       len = FRAME_SIZE * (CDtocentry[CDTrack+1].cdte_addr.lba -
+           CDtocentry[CDTrack].cdte_addr.lba) - data->PosInCd;
        data->PosInCd = 0;
     }
 
@@ -98,12 +98,12 @@
 
        n = CDDA_BUFFER_SIZE - sample->Length;
 
-       data->Readdata.nframes = n/FRAME_SIZE;
+       data->Readdata.nframes = n / FRAME_SIZE;
        data->Readdata.buf = data->PointerInBuffer + sample->Length;
        ioctl(CDDrive, CDROMREADAUDIO, &data->Readdata);
 
-       sample->Length += data->Readdata.nframes*FRAME_SIZE;
-       data->PosInCd += data->Readdata.nframes*FRAME_SIZE;
+       sample->Length += data->Readdata.nframes * FRAME_SIZE;
+       data->PosInCd += data->Readdata.nframes * FRAME_SIZE;
     }
 
     memcpy(buf, data->PointerInBuffer, len);
@@ -116,7 +116,7 @@
 **
 **     @param sample       Sample to free
 */
-local void CDFree(Sample *sample)
+local void CDFree(Sample* sample)
 {
     free(sample);
 }
Index: stratagus/src/sound/flac.c
diff -u stratagus/src/sound/flac.c:1.33 stratagus/src/sound/flac.c:1.34
--- stratagus/src/sound/flac.c:1.33     Thu Aug 21 03:12:03 2003
+++ stratagus/src/sound/flac.c  Wed Oct  1 13:52:40 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: flac.c,v 1.33 2003/08/21 07:12:03 n0body Exp $
+//     $Id: flac.c,v 1.34 2003/10/01 17:52:40 jsalmon3 Exp $
 
 //@{
 
@@ -78,9 +78,9 @@
 **     @param user     User data.
 */
 local void FLAC_error_callback(
-       const FLAC__StreamDecoder * stream __attribute__((unused)),
-       FLAC__StreamDecoderErrorStatus status __attribute__((unused)),
-       void *user __attribute__((unused)))
+    const FLAC__StreamDecoder* stream __attribute__((unused)),
+    FLAC__StreamDecoderErrorStatus status __attribute__((unused)),
+    void* user __attribute__((unused)))
 {
     DebugLevel0Fn(" %s\n" _C_ FLAC__StreamDecoderErrorStatusString[status]);
 }
@@ -96,12 +96,12 @@
 **     @return         Error status.
 */
 local FLAC__StreamDecoderReadStatus FLAC_read_callback(
-       const FLAC__StreamDecoder * stream __attribute__((unused)),
-       FLAC__byte buffer[], unsigned int *bytes, void *user)
+    const FLAC__StreamDecoder * stream __attribute__((unused)),
+    FLAC__byte buffer[], unsigned int *bytes, void *user)
 {
     unsigned i;
-    CLFile *f;
-    FlacData *data;
+    CLFile* f;
+    FlacData* data;
 
     DebugLevel3Fn("Read callback %d\n" _C_ *bytes);
 
@@ -125,10 +125,10 @@
 **     @param user     User data.
 */
 local void FLAC_metadata_callback(
-       const FLAC__StreamDecoder * stream __attribute__((unused)),
-       const FLAC__StreamMetadata * metadata, void *user)
+    const FLAC__StreamDecoder* stream __attribute__((unused)),
+    const FLAC__StreamMetadata* metadata, void *user)
 {
-    Sample *sample;
+    Sample* sample;
     int rate;
 
     if (metadata->type == FLAC__METADATA_TYPE_STREAMINFO) {
@@ -140,12 +140,12 @@
 
        rate = 44100 / sample->Frequency;
        // will overbuffer, so double the amount to allocate
-       sample = realloc(sample, sizeof(*sample) + 2*rate*FLAC_BUFFER_SIZE);
+       sample = realloc(sample, sizeof(*sample) + 2 * rate * FLAC_BUFFER_SIZE);
        ((FlacData*)(sample->User))->Sample = sample;
        ((FlacData*)(sample->User))->PointerInBuffer = sample->Data;
 
        DebugLevel3Fn("Stream %d Channels, %d frequency, %d bits\n" _C_
-               sample->Channels _C_ sample->Frequency _C_ sample->SampleSize);
+           sample->Channels _C_ sample->Frequency _C_ sample->SampleSize);
     }
 }
 
@@ -159,15 +159,15 @@
 **
 **     @return         Error status.
 */
-local FLAC__StreamDecoderWriteStatus FLAC_write_callback(const
-    FLAC__StreamDecoder * stream __attribute__((unused)),
-    const FLAC__Frame * frame, const FLAC__int32 * const buffer[], void *user)
+local FLAC__StreamDecoderWriteStatus FLAC_write_callback(
+    const FLAC__StreamDecoder* stream __attribute__((unused)),
+    const FLAC__Frame* frame, const FLAC__int32* const buffer[], void* user)
 {
-    FlacData *data;
-    Sample *sample;
+    FlacData* data;
+    Sample* sample;
     unsigned i;
     unsigned channel;
-    void *p;
+    void* p;
     int rate;
     int y;
 
@@ -187,7 +187,7 @@
 
     if (sample->Type == &FlacSampleType) {
        // not streaming
-       sample = realloc(sample, sizeof(*sample) + sample->Length + i*rate);
+       sample = realloc(sample, sizeof(*sample) + sample->Length + i * rate);
        if (!sample) {
            fprintf(stderr, "Out of memory!\n");
            CLclose(data->FlacFile);
@@ -198,15 +198,15 @@
     }
 
     p = sample->Data + sample->Length;
-    sample->Length += i*rate;
-    data->Bytes -= i*rate;
+    sample->Length += i * rate;
+    data->Bytes -= i * rate;
 
     switch (sample->SampleSize) {
        case 8:
            for (i = 0; i < frame->header.blocksize; ++i) {
                for (y = 0; y < rate; ++y) {
                    for (channel = 0; channel < frame->header.channels; 
channel++) {
-                       *((unsigned char *)p)++ = buffer[channel][i] + 128;
+                       *((unsigned char*)p)++ = buffer[channel][i] + 128;
                    }
                }
            }
@@ -215,7 +215,7 @@
            for (i = 0; i < frame->header.blocksize; ++i) {
                for (y = 0; y < rate; ++y) {
                    for (channel = 0; channel < frame->header.channels; 
channel++) {
-                       *((short *)p)++ = buffer[channel][i];
+                       *((short*)p)++ = buffer[channel][i];
                    }
                }
            }
@@ -240,7 +240,7 @@
 */
 local int FlacRead(Sample* sample, void* buf, int len)
 {
-    char *pos;
+    char* pos;
 
     pos = ((FlacData*)sample->User)->PointerInBuffer;
 
@@ -262,7 +262,9 @@
 */
 local void FlacFree(Sample* sample)
 {
-    IfDebug( AllocatedSoundMemory -= sample->Length; );
+#ifdef DEBUG
+    AllocatedSoundMemory -= sample->Length;
+#endif
 
     free(sample);
 }
@@ -288,7 +290,7 @@
 {
     FlacData* data;
 
-    data = (FlacData*) sample->User;
+    data = (FlacData*)sample->User;
 
     while (FLAC__stream_decoder_get_state(data->Stream) != 
FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC) {
        // read metadata
@@ -324,9 +326,11 @@
 */
 local void FlacStreamFree(Sample* sample)
 {
-    FlacData *data;
+    FlacData* data;
 
-    IfDebug( AllocatedSoundMemory -= sizeof(*sample) + FLAC_BUFFER_SIZE);
+#ifdef DEBUG
+    AllocatedSoundMemory -= sizeof(*sample) + FLAC_BUFFER_SIZE;
+#endif
 
     data = (FlacData*)sample->User;
     CLclose(data->FlacFile);
@@ -358,9 +362,9 @@
     Sample* sample;
     unsigned int magic[1];
     FLAC__StreamDecoder* stream;
-    FlacData *data;
+    FlacData* data;
 
-    if (!(f = CLopen(name,CL_OPEN_READ))) {
+    if (!(f = CLopen(name, CL_OPEN_READ))) {
        fprintf(stderr, "Can't open file `%s'\n", name);
        return NULL;
     }
@@ -385,7 +389,7 @@
        return NULL;
     }
 
-    sample = malloc(sizeof(*sample) + 2*FLAC_BUFFER_SIZE);
+    sample = malloc(sizeof(*sample) + 2 * FLAC_BUFFER_SIZE);
 
     data = malloc(sizeof(FlacData));
     data->FlacFile = f;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]