| 3431 | } |
| 3432 | |
| 3433 | void AL_UpdateRawSamples() |
| 3434 | { |
| 3435 | ALuint buffer; |
| 3436 | ALint size; |
| 3437 | ALint processed; |
| 3438 | ALint state; |
| 3439 | int i,j,src; |
| 3440 | |
| 3441 | #ifdef _DEBUG |
| 3442 | // Clear Open AL Error |
| 3443 | alGetError(); |
| 3444 | #endif |
| 3445 | |
| 3446 | S_UpdateBackgroundTrack(); |
| 3447 | |
| 3448 | // Find out how many buffers have been processed (played) by the Source |
| 3449 | alGetSourcei(s_channels[0].alSource, AL_BUFFERS_PROCESSED, &processed); |
| 3450 | |
| 3451 | while (processed) |
| 3452 | { |
| 3453 | // Unqueue each buffer, determine the length of the buffer, and then delete it |
| 3454 | alSourceUnqueueBuffers(s_channels[0].alSource, 1, &buffer); |
| 3455 | alGetBufferi(buffer, AL_SIZE, &size); |
| 3456 | alDeleteBuffers(1, &buffer); |
| 3457 | |
| 3458 | // Update sg.soundtime (+= number of samples played (number of bytes / 4)) |
| 3459 | s_soundtime += (size >> 2); |
| 3460 | |
| 3461 | processed--; |
| 3462 | } |
| 3463 | |
| 3464 | // Add new data to a new Buffer and queue it on the Source |
| 3465 | if (s_rawend > s_paintedtime) |
| 3466 | { |
| 3467 | size = (s_rawend - s_paintedtime)<<2; |
| 3468 | if (size > (MAX_RAW_SAMPLES<<2)) |
| 3469 | { |
| 3470 | OutputDebugString("UpdateRawSamples :- Raw Sample buffer has overflowed !!!\n"); |
| 3471 | size = MAX_RAW_SAMPLES<<2; |
| 3472 | s_paintedtime = s_rawend - MAX_RAW_SAMPLES; |
| 3473 | } |
| 3474 | |
| 3475 | // Copy samples from RawSamples to audio buffer (sg.rawdata) |
| 3476 | for (i = s_paintedtime, j = 0; i < s_rawend; i++, j+=2) |
| 3477 | { |
| 3478 | src = i & (MAX_RAW_SAMPLES - 1); |
| 3479 | s_rawdata[j] = (short)(s_rawsamples[src].left>>8); |
| 3480 | s_rawdata[j+1] = (short)(s_rawsamples[src].right>>8); |
| 3481 | } |
| 3482 | |
| 3483 | // Need to generate more than 1 buffer for music playback |
| 3484 | // iterations = 0; |
| 3485 | // largestBufferSize = (MAX_RAW_SAMPLES / 4) * 4 |
| 3486 | // while (size) |
| 3487 | // generate a buffer |
| 3488 | // if size > largestBufferSize |
| 3489 | // copy sg.rawdata + ((iterations * largestBufferSize)>>1) to buffer |
| 3490 | // size -= largestBufferSize |
no test coverage detected