From f707439e8653392919e92baaccd7f6c2a15e9e75 Mon Sep 17 00:00:00 2001 From: Ozkan Sezer Date: Tue, 8 Feb 2011 11:00:29 +0000 Subject: [PATCH] * common.c (FS_fread): fixed coding style. * bgmusic.c: minor updates from uhexen2. git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@406 af15c1b1-3010-417e-b628-4374ebc0bcbd --- Quake/bgmusic.c | 12 ++---------- Quake/bgmusic.h | 3 ++- Quake/common.c | 30 +++++++++++++++--------------- 3 files changed, 19 insertions(+), 26 deletions(-) diff --git a/Quake/bgmusic.c b/Quake/bgmusic.c index 2fcc9517..798aab2a 100644 --- a/Quake/bgmusic.c +++ b/Quake/bgmusic.c @@ -26,14 +26,6 @@ #include "snd_codec.h" #include "bgmusic.h" -/* - * MUSIC FILE DIRECTORIES: - * - * Midi music file have always lived under "midi" directory, we are - * not changing that. Any other music files, including cd-rips, are - * expected under the "music" directory. - */ - #define MUSIC_DIRNAME "music" qboolean bgmloop; @@ -63,15 +55,15 @@ static music_handler_t wanted_handlers[] = { { CODECTYPE_OGG, BGM_STREAMER, -1, ".ogg", MUSIC_DIRNAME, NULL }, { CODECTYPE_MP3, BGM_STREAMER, -1, ".mp3", MUSIC_DIRNAME, NULL }, - { CODECTYPE_WAV, BGM_STREAMER, -1, ".wav", MUSIC_DIRNAME, NULL }, { CODECTYPE_FLAC, BGM_STREAMER, -1, ".flac", MUSIC_DIRNAME, NULL }, + { CODECTYPE_WAV, BGM_STREAMER, -1, ".wav", MUSIC_DIRNAME, NULL }, { CODECTYPE_NONE, BGM_NONE, -1, NULL, NULL, NULL } }; static music_handler_t *music_handlers = NULL; #define ANY_CODECTYPE 0xFFFFFFFF -#define CDRIP_TYPES (CODECTYPE_OGG | CODECTYPE_MP3 | CODECTYPE_WAV) +#define CDRIP_TYPES (CODECTYPE_OGG | CODECTYPE_MP3 | CODECTYPE_FLAC | CODECTYPE_WAV) #define CDRIPTYPE(x) (((x) & CDRIP_TYPES) != 0) static snd_stream_t *bgmstream = NULL; diff --git a/Quake/bgmusic.h b/Quake/bgmusic.h index 013f6019..e6cd69d9 100644 --- a/Quake/bgmusic.h +++ b/Quake/bgmusic.h @@ -34,11 +34,12 @@ qboolean BGM_Init (void); void BGM_Shutdown (void); void BGM_Play (const char *filename); -void BGM_PlayCDtrack (byte track, qboolean looping); void BGM_Stop (void); void BGM_Update (void); void BGM_Pause (void); void BGM_Resume (void); +void BGM_PlayCDtrack (byte track, qboolean looping); + #endif /* _BGMUSIC_H_ */ diff --git a/Quake/common.c b/Quake/common.c index 8284c142..61f554a4 100644 --- a/Quake/common.c +++ b/Quake/common.c @@ -1957,9 +1957,9 @@ void COM_InitFilesystem (void) //johnfitz -- modified based on topaz's tutorial size_t FS_fread(void *ptr, size_t size, size_t nmemb, fshandle_t *fh) { - long byteSize; - long bytesRead; - size_t nMembRead; + long byte_size; + long bytes_read; + size_t nmemb_read; if (!ptr) { @@ -1979,21 +1979,21 @@ size_t FS_fread(void *ptr, size_t size, size_t nmemb, fshandle_t *fh) return 0; } - byteSize = nmemb * size; - if (byteSize > fh->length - fh->pos) /* just read to end */ - byteSize = fh->length - fh->pos; - bytesRead = fread(ptr, 1, byteSize, fh->file); - fh->pos += bytesRead; - - /* return the number of elements read not the number of bytes */ - nMembRead = bytesRead / size; + byte_size = nmemb * size; + if (byte_size > fh->length - fh->pos) /* just read to end */ + byte_size = fh->length - fh->pos; + bytes_read = fread(ptr, 1, byte_size, fh->file); + fh->pos += bytes_read; + /* fread() must return the number of elements read, + * not the total number of bytes. */ + nmemb_read = bytes_read / size; /* even if the last member is only read partially - * it is counted as a whole in the return value */ - if (bytesRead % size) - nMembRead++; + * it is counted as a whole in the return value. */ + if (bytes_read % size) + nmemb_read++; - return nMembRead; + return nmemb_read; } int FS_fseek(fshandle_t *fh, long offset, int whence)