mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2025-02-02 22:11:22 +00:00
snd_flac.c, snd_mpg123.c: fix incorrect usage of decoder function
return value in RewindStream procedures. bgmusic.c (BGM_UpdateStream): print msg if stream rewinding fails. git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@1169 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
parent
ea65ff0c6d
commit
6ddd983eb8
3 changed files with 11 additions and 14 deletions
|
@ -144,7 +144,7 @@ qboolean BGM_Init (void)
|
|||
switch (wanted_handlers[i].player)
|
||||
{
|
||||
case BGM_MIDIDRV:
|
||||
/* not supported in quake */
|
||||
/* not supported in quake */
|
||||
break;
|
||||
case BGM_STREAMER:
|
||||
wanted_handlers[i].is_available =
|
||||
|
@ -203,7 +203,7 @@ static void BGM_Play_noext (const char *filename, unsigned int allowed_types)
|
|||
switch (handler->player)
|
||||
{
|
||||
case BGM_MIDIDRV:
|
||||
/* not supported in quake */
|
||||
/* not supported in quake */
|
||||
break;
|
||||
case BGM_STREAMER:
|
||||
bgmstream = S_CodecOpenStreamType(tmp, handler->type);
|
||||
|
@ -261,7 +261,7 @@ void BGM_Play (const char *filename)
|
|||
switch (handler->player)
|
||||
{
|
||||
case BGM_MIDIDRV:
|
||||
/* not supported in quake */
|
||||
/* not supported in quake */
|
||||
break;
|
||||
case BGM_STREAMER:
|
||||
bgmstream = S_CodecOpenStreamType(tmp, handler->type);
|
||||
|
@ -420,8 +420,10 @@ static void BGM_UpdateStream (void)
|
|||
{
|
||||
if (bgmloop)
|
||||
{
|
||||
if (S_CodecRewindStream(bgmstream) < 0)
|
||||
res = S_CodecRewindStream(bgmstream);
|
||||
if (res != 0)
|
||||
{
|
||||
Con_Printf("Stream seek error (%i), stopping.\n", res);
|
||||
BGM_Stop();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -146,16 +146,12 @@ flac_write_func (const FLAC__StreamDecoder *decoder,
|
|||
flacfile_t *ff = (flacfile_t *) client_data;
|
||||
|
||||
if (!ff->buffer) {
|
||||
#if 1 /*!defined(CODECS_USE_ZONE)*/
|
||||
ff->buffer = (byte *) malloc (ff->info->blocksize * ff->info->channels * ff->info->width);
|
||||
if (!ff->buffer) {
|
||||
ff->error = -1; /* needn't set this here, but... */
|
||||
Con_Printf("Insufficient memory for fLaC audio\n");
|
||||
return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
|
||||
}
|
||||
#else
|
||||
ff->buffer = (byte *) Z_Malloc (ff->info->blocksize * ff->info->channels * ff->info->width);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (ff->info->channels == 1)
|
||||
|
@ -359,11 +355,7 @@ static void S_FLAC_CodecCloseStream (snd_stream_t *stream)
|
|||
FLAC__stream_decoder_delete (ff->decoder);
|
||||
|
||||
if (ff->buffer)
|
||||
#if 0 /*defined(CODECS_USE_ZONE)*/
|
||||
Z_Free(ff->buffer);
|
||||
#else
|
||||
free(ff->buffer);
|
||||
#endif
|
||||
Z_Free(ff);
|
||||
|
||||
S_CodecUtilClose(&stream);
|
||||
|
@ -374,7 +366,8 @@ static int S_FLAC_CodecRewindStream (snd_stream_t *stream)
|
|||
flacfile_t *ff = (flacfile_t *) stream->priv;
|
||||
|
||||
ff->pos = ff->size = 0;
|
||||
return FLAC__stream_decoder_seek_absolute (ff->decoder, 0);
|
||||
if (FLAC__stream_decoder_seek_absolute(ff->decoder, 0)) return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
snd_codec_t flac_codec =
|
||||
|
|
|
@ -203,7 +203,9 @@ static void S_MP3_CodecCloseStream (snd_stream_t *stream)
|
|||
static int S_MP3_CodecRewindStream (snd_stream_t *stream)
|
||||
{
|
||||
mp3_priv_t *priv = (mp3_priv_t *) stream->priv;
|
||||
return (int) mpg123_seek(priv->handle, 0, SEEK_SET);
|
||||
off_t res = mpg123_seek(priv->handle, 0, SEEK_SET);
|
||||
if (res >= 0) return (0);
|
||||
return res;
|
||||
}
|
||||
|
||||
snd_codec_t mp3_codec =
|
||||
|
|
Loading…
Reference in a new issue