Bug 468260 - Update libsydneyaudio to fix sunaudio malloc error and win32 sound issues - rs=roc

This commit is contained in:
Chris Double 2008-12-15 14:31:57 +13:00
parent 35292415af
commit 587e3fcdf2
2 changed files with 14 additions and 15 deletions

View File

@ -293,11 +293,12 @@ sa_stream_write(sa_stream_t *s, const void *data, size_t nbytes)
*/
result = SA_SUCCESS;
buf = new_buffer(nbytes);
memcpy(buf->data,data, nbytes);
if ( buf == NULL)
if (buf == NULL)
return SA_ERROR_OOM;
memcpy(buf->data,data, nbytes);
pthread_mutex_lock(&s->mutex);
if (!s->bl_head)
s->bl_head = buf;

View File

@ -45,7 +45,7 @@
// FIX ME: block size and block should be determined based on the OggPlay offset
// for audio track
#define BLOCK_SIZE 2560
#define BLOCK_SIZE 1024
#define BLOCK_COUNT 32
#define DEFAULT_DEVICE_NAME "Default WAVE Device"
#define DEFAULT_DEVICE WAVE_MAPPER
@ -203,7 +203,7 @@ int sa_stream_get_write_size(sa_stream_t *s, size_t *size) {
ERROR_IF_NO_INIT(s);
EnterCriticalSection(&(s->waveCriticalSection));
avail = s->waveFreeBlockCount * BLOCK_SIZE;
avail = (s->waveFreeBlockCount-1) * BLOCK_SIZE;
if (s->waveFreeBlockCount != BLOCK_COUNT) {
current = &(s->waveBlocks[s->waveCurrentBlock]);
avail += BLOCK_SIZE - current->dwUser;
@ -490,8 +490,14 @@ int writeAudio(sa_stream_t *s, LPSTR data, int bytes) {
int remain;
current = &(s->waveBlocks[s->waveCurrentBlock]);
while(bytes > 0) {
/*
* wait for a block to become free
*/
while (!(s->waveFreeBlockCount))
WaitForSingleObject(s->callbackEvent, INFINITE);
/* first make sure the header we're going to use is unprepared */
if(current->dwFlags & WHDR_PREPARED) {
status = waveOutUnprepareHeader(s->hWaveOut, current, sizeof(WAVEHDR));
@ -503,7 +509,7 @@ int writeAudio(sa_stream_t *s, LPSTR data, int bytes) {
current->dwUser += bytes;
break;
}
/* remain is even as BLOCK_SIZE and dwUser are even too */
remain = BLOCK_SIZE - current->dwUser;
memcpy(current->lpData + current->dwUser, data, remain);
@ -518,15 +524,7 @@ int writeAudio(sa_stream_t *s, LPSTR data, int bytes) {
EnterCriticalSection(&(s->waveCriticalSection));
s->waveFreeBlockCount--;
LeaveCriticalSection(&(s->waveCriticalSection));
/*
* wait for a block to become free
*/
while (!(s->waveFreeBlockCount)) {
//printf("All audio buffer blocks empty\n");
WaitForSingleObject(s->callbackEvent, INFINITE);
//Sleep(10);
}
/*
* point to the next block
*/