OpenAL fixes
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@161 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -27,12 +27,12 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <vorbis/codec.h>
|
||||||
|
#include <vorbis/vorbisfile.h>
|
||||||
#include "decoder.h"
|
#include "decoder.h"
|
||||||
#include "wav.h"
|
#include "wav.h"
|
||||||
#include "libs/sound/sound_common.h"
|
#include "libs/sound/sound_common.h"
|
||||||
#include "mikmod/mikmod.h"
|
#include "mikmod/mikmod.h"
|
||||||
#include "vorbis/codec.h"
|
|
||||||
#include "vorbis/vorbisfile.h"
|
|
||||||
|
|
||||||
MIKMODAPI extern struct MDRIVER drv_openal;
|
MIKMODAPI extern struct MDRIVER drv_openal;
|
||||||
|
|
||||||
@@ -225,7 +225,7 @@ TFB_SoundDecoder* SoundDecoder_Load (char *filename, ALuint buffer_size)
|
|||||||
vinfo = ov_info (vf, -1);
|
vinfo = ov_info (vf, -1);
|
||||||
if (!vinfo)
|
if (!vinfo)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "SoundDecoder_Load(): failed to retrieve ogg bitstream info\n");
|
fprintf (stderr, "SoundDecoder_Load(): failed to retrieve ogg bitstream info for %s\n", filename);
|
||||||
ov_clear (vf);
|
ov_clear (vf);
|
||||||
free (vf);
|
free (vf);
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -276,13 +276,13 @@ ALuint SoundDecoder_Decode (TFB_SoundDecoder *decoder)
|
|||||||
{
|
{
|
||||||
if (decoder->looping)
|
if (decoder->looping)
|
||||||
{
|
{
|
||||||
//fprintf (stderr, "SoundDecoder_Decode(): looping %s\n", decoder->filename);
|
fprintf (stderr, "SoundDecoder_Decode(): looping %s\n", decoder->filename);
|
||||||
Player_SetPosition (0);
|
Player_SetPosition (0);
|
||||||
Player_Start (mod);
|
Player_Start (mod);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//fprintf (stderr, "SoundDecoder_Decode(): eof for %s\n", decoder->filename);
|
fprintf (stderr, "SoundDecoder_Decode(): eof for %s\n", decoder->filename);
|
||||||
decoder->error = SOUNDDECODER_EOF;
|
decoder->error = SOUNDDECODER_EOF;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -312,19 +312,20 @@ ALuint SoundDecoder_Decode (TFB_SoundDecoder *decoder)
|
|||||||
{
|
{
|
||||||
if (decoder->looping)
|
if (decoder->looping)
|
||||||
{
|
{
|
||||||
if (ov_raw_seek (vf, 0) != 0)
|
int err;
|
||||||
|
if ((err = ov_raw_seek (vf, 0)) != 0)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "SoundDecoder_Decode(): tried to loop %s but couldn't rewind\n", decoder->filename);
|
fprintf (stderr, "SoundDecoder_Decode(): tried to loop %s but couldn't rewind, error code %d\n", decoder->filename, err);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//fprintf (stderr, "SoundDecoder_Decode(): looping %s\n", decoder->filename);
|
fprintf (stderr, "SoundDecoder_Decode(): looping %s\n", decoder->filename);
|
||||||
count++;
|
count++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//fprintf (stderr, "SoundDecoder_Decode(): eof for %s\n", decoder->filename);
|
fprintf (stderr, "SoundDecoder_Decode(): eof for %s\n", decoder->filename);
|
||||||
decoder->error = SOUNDDECODER_EOF;
|
decoder->error = SOUNDDECODER_EOF;
|
||||||
return decoded_bytes;
|
return decoded_bytes;
|
||||||
}
|
}
|
||||||
@@ -402,19 +403,20 @@ void SoundDecoder_Rewind (TFB_SoundDecoder *decoder)
|
|||||||
MODULE *mod = (MODULE *)decoder->data;
|
MODULE *mod = (MODULE *)decoder->data;
|
||||||
Player_Start (mod);
|
Player_Start (mod);
|
||||||
Player_SetPosition (0);
|
Player_SetPosition (0);
|
||||||
//fprintf (stderr, "SoundDecoder_Rewind(): rewinded %s\n", decoder->filename);
|
fprintf (stderr, "SoundDecoder_Rewind(): rewinded %s\n", decoder->filename);
|
||||||
decoder->error = SOUNDDECODER_OK;
|
decoder->error = SOUNDDECODER_OK;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case SOUNDDECODER_OGG:
|
case SOUNDDECODER_OGG:
|
||||||
{
|
{
|
||||||
|
int err;
|
||||||
OggVorbis_File *vf = (OggVorbis_File *) decoder->data;
|
OggVorbis_File *vf = (OggVorbis_File *) decoder->data;
|
||||||
if (ov_raw_seek (vf, 0) != 0)
|
if ((err = ov_raw_seek (vf, 0)) != 0)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "SoundDecoder_Rewind(): couldn't rewind %s\n", decoder->filename);
|
fprintf (stderr, "SoundDecoder_Rewind(): couldn't rewind %s, error code %d\n", decoder->filename, err);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//fprintf (stderr, "SoundDecoder_Rewind(): rewinded %s\n", decoder->filename);
|
fprintf (stderr, "SoundDecoder_Rewind(): rewinded %s\n", decoder->filename);
|
||||||
decoder->error = SOUNDDECODER_OK;
|
decoder->error = SOUNDDECODER_OK;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,7 +119,6 @@ StreamDecoderTaskFunc (void *data)
|
|||||||
{
|
{
|
||||||
ALuint processed, queued;
|
ALuint processed, queued;
|
||||||
ALint state;
|
ALint state;
|
||||||
ALboolean finished = AL_FALSE;
|
|
||||||
ALboolean do_speech_advancetrack = AL_FALSE;
|
ALboolean do_speech_advancetrack = AL_FALSE;
|
||||||
|
|
||||||
LockMutex (soundSource[i].stream_mutex);
|
LockMutex (soundSource[i].stream_mutex);
|
||||||
@@ -134,13 +133,16 @@ StreamDecoderTaskFunc (void *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
alGetSourcei (soundSource[i].handle, AL_BUFFERS_PROCESSED, &processed);
|
alGetSourcei (soundSource[i].handle, AL_BUFFERS_PROCESSED, &processed);
|
||||||
|
alGetSourcei (soundSource[i].handle, AL_BUFFERS_QUEUED, &queued);
|
||||||
|
|
||||||
if (processed == 0)
|
if (processed == 0)
|
||||||
{
|
{
|
||||||
alGetSourcei (soundSource[i].handle, AL_SOURCE_STATE, &state);
|
alGetSourcei (soundSource[i].handle, AL_SOURCE_STATE, &state);
|
||||||
if (state != AL_PLAYING)
|
if (state != AL_PLAYING)
|
||||||
{
|
{
|
||||||
if (soundSource[i].sample->decoder->error == SOUNDDECODER_EOF)
|
if (queued == 0 && soundSource[i].sample->decoder->error == SOUNDDECODER_EOF)
|
||||||
{
|
{
|
||||||
|
fprintf (stderr, "StreamDecoderTaskFunc(): finished playing %s, source %d\n", soundSource[i].sample->decoder->filename, i);
|
||||||
soundSource[i].stream_should_be_playing = FALSE;
|
soundSource[i].stream_should_be_playing = FALSE;
|
||||||
if (i == SPEECH_SOURCE && speech_advancetrack)
|
if (i == SPEECH_SOURCE && speech_advancetrack)
|
||||||
{
|
{
|
||||||
@@ -155,10 +157,9 @@ StreamDecoderTaskFunc (void *data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
alGetSourcei (soundSource[i].handle, AL_BUFFERS_QUEUED, &queued);
|
|
||||||
//fprintf (stderr, "StreamDecoderTaskFunc(): source %d, processed %d queued %d\n", i, processed, queued);
|
//fprintf (stderr, "StreamDecoderTaskFunc(): source %d, processed %d queued %d\n", i, processed, queued);
|
||||||
|
|
||||||
while (processed && !finished)
|
while (processed)
|
||||||
{
|
{
|
||||||
ALenum error;
|
ALenum error;
|
||||||
ALuint buffer;
|
ALuint buffer;
|
||||||
@@ -205,7 +206,6 @@ StreamDecoderTaskFunc (void *data)
|
|||||||
{
|
{
|
||||||
fprintf (stderr, "StreamDecoderTaskFunc(): OpenAL error after alBufferData: %x, file %s, source %d, decoded_bytes %d\n",
|
fprintf (stderr, "StreamDecoderTaskFunc(): OpenAL error after alBufferData: %x, file %s, source %d, decoded_bytes %d\n",
|
||||||
error, soundSource[i].sample->decoder->filename, i, decoded_bytes);
|
error, soundSource[i].sample->decoder->filename, i, decoded_bytes);
|
||||||
finished = AL_TRUE;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -215,7 +215,6 @@ StreamDecoderTaskFunc (void *data)
|
|||||||
{
|
{
|
||||||
fprintf (stderr, "StreamDecoderTaskFunc(): OpenAL error after alSourceQueueBuffers: %x, file %s, source %d, decoded_bytes %d\n",
|
fprintf (stderr, "StreamDecoderTaskFunc(): OpenAL error after alSourceQueueBuffers: %x, file %s, source %d, decoded_bytes %d\n",
|
||||||
error, i, soundSource[i].sample->decoder->filename, decoded_bytes);
|
error, i, soundSource[i].sample->decoder->filename, decoded_bytes);
|
||||||
finished = AL_TRUE;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user