Removed CD sound buffer dependency on main sound buffer. Fixes CD audio issues following the last commit.

This commit is contained in:
SarahW 2017-02-01 19:53:24 +00:00
commit c581b018a7
2 changed files with 12 additions and 4 deletions

View file

@ -93,6 +93,7 @@ static int16_t cd_buffer[CD_BUFLEN * 2];
static thread_t *sound_cd_thread_h; static thread_t *sound_cd_thread_h;
static event_t *sound_cd_event; static event_t *sound_cd_event;
static unsigned int cd_vol_l, cd_vol_r; static unsigned int cd_vol_l, cd_vol_r;
static int cd_buf_update = CD_BUFLEN / SOUNDBUFLEN;
void sound_set_cd_volume(unsigned int vol_l, unsigned int vol_r) void sound_set_cd_volume(unsigned int vol_l, unsigned int vol_r)
{ {
@ -207,8 +208,13 @@ void sound_poll(void *priv)
fwrite(buf16,(SOUNDBUFLEN)*2*2,1,soundf);*/ fwrite(buf16,(SOUNDBUFLEN)*2*2,1,soundf);*/
if (soundon) givealbuffer(outbuffer); if (soundon) givealbuffer(outbuffer);
thread_set_event(sound_cd_event); cd_buf_update--;
if (!cd_buf_update)
{
cd_buf_update = (48000 / SOUNDBUFLEN) / (CD_FREQ / CD_BUFLEN);
thread_set_event(sound_cd_event);
}
sound_pos_global = 0; sound_pos_global = 0;
} }

View file

@ -91,7 +91,8 @@ void inital()
#ifdef USE_OPENAL #ifdef USE_OPENAL
int c; int c;
int16_t buf[BUFLEN*2]; int16_t buf[BUFLEN*2];
int16_t cd_buf[CD_BUFLEN*2];
// printf("1\n"); // printf("1\n");
check(); check();
@ -120,12 +121,13 @@ void inital()
check(); check();
memset(buf,0,BUFLEN*4); memset(buf,0,BUFLEN*4);
memset(cd_buf, 0, CD_BUFLEN*4);
// printf("5\n"); // printf("5\n");
for (c = 0; c < 4; c++) for (c = 0; c < 4; c++)
{ {
alBufferData(buffers[c], AL_FORMAT_STEREO16, buf, BUFLEN*2*2, FREQ); alBufferData(buffers[c], AL_FORMAT_STEREO16, buf, BUFLEN*2*2, FREQ);
alBufferData(buffers_cd[c], AL_FORMAT_STEREO16, buf, CD_BUFLEN*2*2, CD_FREQ); alBufferData(buffers_cd[c], AL_FORMAT_STEREO16, cd_buf, CD_BUFLEN*2*2, CD_FREQ);
} }
alSourceQueueBuffers(source[0], 4, buffers); alSourceQueueBuffers(source[0], 4, buffers);