[xiph-commits] r3827 - libsydneyaudio/trunk/src

doublec at svn.annodex.net doublec at svn.annodex.net
Thu Dec 11 15:45:32 PST 2008


Author: doublec
Date: 2008-12-11 15:45:31 -0800 (Thu, 11 Dec 2008)
New Revision: 3827

Modified:
   libsydneyaudio/trunk/src/sydney_audio_waveapi.c
Log:
Fix ticket #444 - Off by one error in sa_stream_get_write_size

Modified: libsydneyaudio/trunk/src/sydney_audio_waveapi.c
===================================================================
--- libsydneyaudio/trunk/src/sydney_audio_waveapi.c	2008-12-09 12:45:21 UTC (rev 3826)
+++ libsydneyaudio/trunk/src/sydney_audio_waveapi.c	2008-12-11 23:45:31 UTC (rev 3827)
@@ -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 @@
   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 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 @@
       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,16 +524,8 @@
     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
      */
     (s->waveCurrentBlock)++;



More information about the commits mailing list