[Fix] Flakyness removed. :D
This commit is contained in:
parent
b165e7b263
commit
15599909a0
@ -208,7 +208,7 @@ void conf_parseCLI(int argc, char** argv) {
|
||||
int option_index = 0;
|
||||
int c = 0;
|
||||
|
||||
while((c = getopt_long(argc, argv, "fF:d:J:j:sm:V:hv", long_options, &option_index)) != -1) {
|
||||
while((c = getopt_long(argc, argv, "fF:d:J:j:s:m:V:hv", long_options, &option_index)) != -1) {
|
||||
switch(c) {
|
||||
case 'f':
|
||||
gl_screen.flags |= OPENGL_FULLSCREEN;
|
||||
|
@ -148,7 +148,7 @@ void takeoff(void) {
|
||||
if(!landed) return;
|
||||
|
||||
music_load(MUSIC_TAKEOFF);
|
||||
music_play();
|
||||
//music_play();
|
||||
|
||||
int sw, sh;
|
||||
sw = planet->gfx_space->w;
|
||||
|
@ -111,7 +111,7 @@ int main(int argc, char** argv) {
|
||||
// OpenAL sound.
|
||||
if(sound_init()) WARN("Problem setting up sound!");
|
||||
music_load("Machina");
|
||||
//music_play();
|
||||
music_play();
|
||||
|
||||
// Input.
|
||||
if((indjoystick >= 0) || (namjoystick != NULL)) {
|
||||
|
21
src/music.c
21
src/music.c
@ -75,7 +75,11 @@ int music_thread(void* unused) {
|
||||
// Main loop.
|
||||
while(!music_is(MUSIC_KILL)) {
|
||||
if(music_is(MUSIC_PLAYING)) {
|
||||
if(music_vorbis.file.end == 0)
|
||||
music_rm(MUSIC_PLAYING);
|
||||
else {
|
||||
music_rm(MUSIC_STOPPED);
|
||||
|
||||
SDL_mutexP(music_vorbis_lock); // Lock the mutex.
|
||||
SDL_mutexP(sound_lock);
|
||||
|
||||
@ -84,16 +88,17 @@ int music_thread(void* unused) {
|
||||
if(stream_loadBuffer(music_buffer[active])) music_rm(MUSIC_PLAYING);
|
||||
alSourceQueueBuffers(music_source, 1, &music_buffer[active]);
|
||||
|
||||
// Start playing with the buffer loaded.
|
||||
// Start playing with buffer laoaded.
|
||||
alSourcePlay(music_source);
|
||||
|
||||
active = 1; // Load second buffer.
|
||||
active = 1; // Load the second buffer.
|
||||
if(stream_loadBuffer(music_buffer[active])) music_rm(MUSIC_PLAYING);
|
||||
alSourceQueueBuffers(music_source, 1, &music_buffer[active]);
|
||||
|
||||
SDL_mutexV(sound_lock);
|
||||
|
||||
active = 0; // dive into the loop.
|
||||
active = 0;
|
||||
}
|
||||
while(music_is(MUSIC_PLAYING)) {
|
||||
SDL_mutexP(sound_lock);
|
||||
|
||||
@ -141,15 +146,19 @@ static int stream_loadBuffer(ALuint buffer) {
|
||||
§ion); // Current bitstream.
|
||||
|
||||
if(result == 0) return 1;
|
||||
else if(result == OV_HOLE)
|
||||
else if(result == OV_HOLE) {
|
||||
WARN("OGG: Vorbis hole detected in music!");
|
||||
else if(result == OV_EBADLINK)
|
||||
return 0;
|
||||
}
|
||||
else if(result == OV_EBADLINK) {
|
||||
WARN("OGG: Invalid stream section or corrupt link in music!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
size += result;
|
||||
if(size == BUFFER_SIZE) break; // Buffer is full.
|
||||
}
|
||||
alBufferData(buffer, AL_FORMAT_STEREO16, data, size, music_vorbis.info->rate);
|
||||
alBufferData(buffer, AL_FORMAT_STEREO16, data, BUFFER_SIZE, music_vorbis.info->rate);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user