mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2024-11-10 07:21:58 +00:00
* 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
This commit is contained in:
parent
dd4c96d3c2
commit
f707439e86
3 changed files with 19 additions and 26 deletions
|
@ -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;
|
||||
|
|
|
@ -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_ */
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue