Code cleanup and unsuccessfully trying to fix alSourcePlay issues

This commit is contained in:
tudnai 2020-05-17 13:48:35 -07:00
parent 8d570eb0f3
commit 0e1f7be961
2 changed files with 34 additions and 29 deletions

View File

@ -1932,8 +1932,8 @@
endingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807"
startingLineNumber = "122" startingLineNumber = "122"
endingLineNumber = "122" endingLineNumber = "122"
landmarkName = "unknown" landmarkName = "spkr_exit()"
landmarkType = "0"> landmarkType = "9">
</BreakpointContent> </BreakpointContent>
</BreakpointProxy> </BreakpointProxy>
<BreakpointProxy <BreakpointProxy
@ -1964,7 +1964,7 @@
endingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807"
startingLineNumber = "202" startingLineNumber = "202"
endingLineNumber = "202" endingLineNumber = "202"
landmarkName = "spkr_playUpd()" landmarkName = "spkr_update()"
landmarkType = "9"> landmarkType = "9">
</BreakpointContent> </BreakpointContent>
</BreakpointProxy> </BreakpointProxy>
@ -1980,7 +1980,7 @@
endingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807"
startingLineNumber = "222" startingLineNumber = "222"
endingLineNumber = "222" endingLineNumber = "222"
landmarkName = "spkr_playUpd()" landmarkName = "spkr_update()"
landmarkType = "9"> landmarkType = "9">
</BreakpointContent> </BreakpointContent>
</BreakpointProxy> </BreakpointProxy>
@ -1996,7 +1996,7 @@
endingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807"
startingLineNumber = "230" startingLineNumber = "230"
endingLineNumber = "230" endingLineNumber = "230"
landmarkName = "spkr_playUpd()" landmarkName = "spkr_update()"
landmarkType = "9"> landmarkType = "9">
</BreakpointContent> </BreakpointContent>
</BreakpointProxy> </BreakpointProxy>
@ -2092,7 +2092,7 @@
endingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807"
startingLineNumber = "238" startingLineNumber = "238"
endingLineNumber = "238" endingLineNumber = "238"
landmarkName = "spkr_playUpd()" landmarkName = "spkr_update()"
landmarkType = "9"> landmarkType = "9">
</BreakpointContent> </BreakpointContent>
</BreakpointProxy> </BreakpointProxy>
@ -2108,8 +2108,8 @@
endingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807"
startingLineNumber = "262" startingLineNumber = "262"
endingLineNumber = "262" endingLineNumber = "262"
landmarkName = "spkr_playUpd()" landmarkName = "unknown"
landmarkType = "9"> landmarkType = "0">
</BreakpointContent> </BreakpointContent>
</BreakpointProxy> </BreakpointProxy>
</Breakpoints> </Breakpoints>

View File

@ -64,7 +64,7 @@ const int spkr_seconds = 1;
const unsigned spkr_sample_rate = 44100; const unsigned spkr_sample_rate = 44100;
unsigned spkr_extra_buf = 13; // TODO: Should it be a dynamic value calculated by how many bytes we overshot by the edge curve generator? unsigned spkr_extra_buf = 13; // TODO: Should it be a dynamic value calculated by how many bytes we overshot by the edge curve generator?
const unsigned spkr_buf_size = spkr_seconds * spkr_sample_rate / spkr_fps; const unsigned spkr_buf_size = spkr_seconds * spkr_sample_rate / spkr_fps;
char spkr_samples [ spkr_buf_size * spkr_fps * 100]; // 1s of sound char spkr_samples [ spkr_buf_size * spkr_fps * 2]; // 1s of sound
unsigned spkr_sample_idx = 0; unsigned spkr_sample_idx = 0;
@ -96,10 +96,15 @@ void spkr_init() {
al_check_error(); al_check_error();
alSourcei(spkr_src, AL_LOOPING, AL_FALSE); alSourcei(spkr_src, AL_LOOPING, AL_FALSE);
al_check_error(); al_check_error();
alSourcef(spkr_src, AL_ROLLOFF_FACTOR, 0);
al_check_error();
alSource3f(spkr_src, AL_POSITION, 0.0, 8.0, 0.0);
al_check_error();
alListener3f(AL_POSITION, 0.0, 0.0, 0.0); alListener3f(AL_POSITION, 0.0, 0.0, 0.0);
al_check_error(); al_check_error();
alListener3f(AL_ORIENTATION, 0.0, -16.0, 0.0);
al_check_error();
// start from the beginning // start from the beginning
spkr_sample_idx = 0; spkr_sample_idx = 0;
@ -237,21 +242,21 @@ void spkr_update() {
} }
void spkr_Update() { //void spkr_Update() {
if ( spkr_src && spkr_buf ) { // if ( spkr_src && spkr_buf ) {
if ( spkr_src ) { // if ( spkr_src ) {
alSourcePause(spkr_src); // alSourcePause(spkr_src);
al_check_error(); // al_check_error();
alSourcei(spkr_src, AL_BUFFER, 0); // alSourcei(spkr_src, AL_BUFFER, 0);
al_check_error(); // al_check_error();
} // }
//
// Download buffer to OpenAL // // Download buffer to OpenAL
alBufferData(spkr_buf, AL_FORMAT_MONO8, spkr_samples, spkr_buf_size, spkr_sample_rate); // alBufferData(spkr_buf, AL_FORMAT_MONO8, spkr_samples, spkr_buf_size, spkr_sample_rate);
al_check_error(); // al_check_error();
//
alSourcei( spkr_src, AL_BYTE_OFFSET, 0 ); // alSourcei( spkr_src, AL_BYTE_OFFSET, 0 );
al_check_error(); // al_check_error();
alSourcePlay(spkr_src); // alSourcePlay(spkr_src);
} // }
} //}