[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 option_index = 0;
|
||||||
int c = 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) {
|
switch(c) {
|
||||||
case 'f':
|
case 'f':
|
||||||
gl_screen.flags |= OPENGL_FULLSCREEN;
|
gl_screen.flags |= OPENGL_FULLSCREEN;
|
||||||
|
@ -148,7 +148,7 @@ void takeoff(void) {
|
|||||||
if(!landed) return;
|
if(!landed) return;
|
||||||
|
|
||||||
music_load(MUSIC_TAKEOFF);
|
music_load(MUSIC_TAKEOFF);
|
||||||
music_play();
|
//music_play();
|
||||||
|
|
||||||
int sw, sh;
|
int sw, sh;
|
||||||
sw = planet->gfx_space->w;
|
sw = planet->gfx_space->w;
|
||||||
|
@ -111,7 +111,7 @@ int main(int argc, char** argv) {
|
|||||||
// OpenAL sound.
|
// OpenAL sound.
|
||||||
if(sound_init()) WARN("Problem setting up sound!");
|
if(sound_init()) WARN("Problem setting up sound!");
|
||||||
music_load("Machina");
|
music_load("Machina");
|
||||||
//music_play();
|
music_play();
|
||||||
|
|
||||||
// Input.
|
// Input.
|
||||||
if((indjoystick >= 0) || (namjoystick != NULL)) {
|
if((indjoystick >= 0) || (namjoystick != NULL)) {
|
||||||
|
43
src/music.c
43
src/music.c
@ -75,25 +75,30 @@ int music_thread(void* unused) {
|
|||||||
// Main loop.
|
// Main loop.
|
||||||
while(!music_is(MUSIC_KILL)) {
|
while(!music_is(MUSIC_KILL)) {
|
||||||
if(music_is(MUSIC_PLAYING)) {
|
if(music_is(MUSIC_PLAYING)) {
|
||||||
music_rm(MUSIC_STOPPED);
|
if(music_vorbis.file.end == 0)
|
||||||
SDL_mutexP(music_vorbis_lock); // Lock the mutex.
|
music_rm(MUSIC_PLAYING);
|
||||||
SDL_mutexP(sound_lock);
|
else {
|
||||||
|
music_rm(MUSIC_STOPPED);
|
||||||
|
|
||||||
// Start playing current song.
|
SDL_mutexP(music_vorbis_lock); // Lock the mutex.
|
||||||
active = 0; // Load first buffer.
|
SDL_mutexP(sound_lock);
|
||||||
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 current song.
|
||||||
alSourcePlay(music_source);
|
active = 0; // Load first buffer.
|
||||||
|
if(stream_loadBuffer(music_buffer[active])) music_rm(MUSIC_PLAYING);
|
||||||
|
alSourceQueueBuffers(music_source, 1, &music_buffer[active]);
|
||||||
|
|
||||||
active = 1; // Load second buffer.
|
// Start playing with buffer laoaded.
|
||||||
if(stream_loadBuffer(music_buffer[active])) music_rm(MUSIC_PLAYING);
|
alSourcePlay(music_source);
|
||||||
alSourceQueueBuffers(music_source, 1, &music_buffer[active]);
|
|
||||||
|
|
||||||
SDL_mutexV(sound_lock);
|
active = 1; // Load the second buffer.
|
||||||
|
if(stream_loadBuffer(music_buffer[active])) music_rm(MUSIC_PLAYING);
|
||||||
|
alSourceQueueBuffers(music_source, 1, &music_buffer[active]);
|
||||||
|
|
||||||
active = 0; // dive into the loop.
|
SDL_mutexV(sound_lock);
|
||||||
|
|
||||||
|
active = 0;
|
||||||
|
}
|
||||||
while(music_is(MUSIC_PLAYING)) {
|
while(music_is(MUSIC_PLAYING)) {
|
||||||
SDL_mutexP(sound_lock);
|
SDL_mutexP(sound_lock);
|
||||||
|
|
||||||
@ -141,15 +146,19 @@ static int stream_loadBuffer(ALuint buffer) {
|
|||||||
§ion); // Current bitstream.
|
§ion); // Current bitstream.
|
||||||
|
|
||||||
if(result == 0) return 1;
|
if(result == 0) return 1;
|
||||||
else if(result == OV_HOLE)
|
else if(result == OV_HOLE) {
|
||||||
WARN("OGG: Vorbis hole detected in music!");
|
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!");
|
WARN("OGG: Invalid stream section or corrupt link in music!");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
size += result;
|
size += result;
|
||||||
if(size == BUFFER_SIZE) break; // Buffer is full.
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user