[xiph-commits] r3086 - liboggplay/trunk/plugin/audio

laser13 at svn.annodex.net laser13 at svn.annodex.net
Tue Jun 26 22:40:24 PDT 2007


Author: laser13
Date: 2007-06-26 22:40:24 -0700 (Tue, 26 Jun 2007)
New Revision: 3086

Modified:
   liboggplay/trunk/plugin/audio/sydney_audio_waveapi.c
Log:
Win32 audio pointer arithmetic fixed.

Modified: liboggplay/trunk/plugin/audio/sydney_audio_waveapi.c
===================================================================
--- liboggplay/trunk/plugin/audio/sydney_audio_waveapi.c	2007-06-27 05:22:03 UTC (rev 3085)
+++ liboggplay/trunk/plugin/audio/sydney_audio_waveapi.c	2007-06-27 05:40:24 UTC (rev 3086)
@@ -238,8 +238,8 @@
   // request playback progress in bytes
   mm.wType = TIME_BYTES;		
 	status = waveOutGetPosition(s->hWaveOut, &mm, sizeof(MMTIME));
-  HANDLE_WAVE_ERROR(status, "reading audio buffer position");
-  *pos = (int64_t)mm.u.cb;
+  HANDLE_WAVE_ERROR(status, "reading audio buffer position");  
+  *pos = (int64_t)mm.u.cb;  
 
 	return SA_SUCCESS;
 }
@@ -398,8 +398,8 @@
     }
   }
   // reseting audio device and flushing buffers
-  // status = waveOutReset(s->hWaveOut);    
-  // HANDLE_WAVE_ERROR(status, "resetting audio device");
+  status = waveOutReset(s->hWaveOut);    
+  HANDLE_WAVE_ERROR(status, "resetting audio device");
 
   freeBlocks(s->waveBlocks);
   status = waveOutClose(s->hWaveOut);    
@@ -421,37 +421,33 @@
   UINT status;
   WAVEHDR* current;	  
   int remain;
-  //printf("API write audio 1 bytes to write: %d\n", bytes);
+  
   current = &(s->waveBlocks[s->waveCurrentBlock]);
-  //printf("API write audio 2\n");
-  while(bytes > 0) {
-    //printf("API write audio 3 bytes to write: %d\n", bytes);
+  
+  while(bytes > 0) {  
     /* first make sure the header we're going to use is unprepared */
     if(current->dwFlags & WHDR_PREPARED) {      
         status = waveOutUnprepareHeader(s->hWaveOut, current, sizeof(WAVEHDR));         
-        HANDLE_WAVE_ERROR(status, "preparing audio headers for writing");
-        //printf("API write audio 3.1\n");
+        HANDLE_WAVE_ERROR(status, "preparing audio headers for writing");        
     }
 		
-    if(bytes < (int)(BLOCK_SIZE - current->dwUser)) {							  	    
-      //printf("API write audio 3.2\n");
-		  memcpy(current->lpData + current->dwUser, data, bytes);
-      //printf("API write audio 3.3\n");
+    if(bytes < (int)(BLOCK_SIZE - current->dwUser)) {							  	          
+		  memcpy(current->lpData + current->dwUser, data, bytes);      
       current->dwUser += bytes;
       break;
     }
 	
     /* remain is even as BLOCK_SIZE and dwUser are even too */
-    remain = BLOCK_SIZE - current->dwUser;      
-    printf("API write audio 3.4 samples pointer <%p>, remains [%d]\n", data, remain);
-  	memcpy(current->lpData + current->dwUser, data, remain);
-    printf("API write audio 3.5\n");
+    remain = BLOCK_SIZE - current->dwUser;          
+  	memcpy(current->lpData + current->dwUser, data, remain);    
     bytes -= remain;
-    data += bytes;
+    data += remain;
 	  current->dwBufferLength = BLOCK_SIZE;
 	  /* write to audio device */
     waveOutPrepareHeader(s->hWaveOut, current, sizeof(WAVEHDR));
+    printf("Before writing to audio dev\n");
 	  status = waveOutWrite(s->hWaveOut, current, sizeof(WAVEHDR));      
+    printf("After writing to audio dev\n");
     HANDLE_WAVE_ERROR(status, "writing audio to audio device");
       
     EnterCriticalSection(&(s->waveCriticalSection));
@@ -460,8 +456,7 @@
     /*
      * wait for a block to become free
      */
-    if (!(s->waveFreeBlockCount)) {
-      printf("All audio buffer blocks empty\n");        
+    if (!(s->waveFreeBlockCount)) {      
       WaitForSingleObject(s->callbackEvent, INFINITE);
         //Sleep(10);
     }		  
@@ -474,8 +469,7 @@
 
     current = &(s->waveBlocks[s->waveCurrentBlock]);
     current->dwUser = 0;
-  }
-  printf("API write audio 4 bytes to write: %d\n", bytes);
+  }  
   return SA_SUCCESS;
 }
 



More information about the commits mailing list