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

doublec at svn.annodex.net doublec at svn.annodex.net
Thu Mar 26 15:16:14 PDT 2009


Author: doublec
Date: 2009-03-26 15:16:14 -0700 (Thu, 26 Mar 2009)
New Revision: 3895

Modified:
   libsydneyaudio/trunk/src/sydney_audio_waveapi.c
Log:
Ticket 426. Cleanup closeAudio implementation in win32 backend

Modified: libsydneyaudio/trunk/src/sydney_audio_waveapi.c
===================================================================
--- libsydneyaudio/trunk/src/sydney_audio_waveapi.c	2009-03-26 22:10:50 UTC (rev 3894)
+++ libsydneyaudio/trunk/src/sydney_audio_waveapi.c	2009-03-26 22:16:14 UTC (rev 3895)
@@ -449,33 +449,42 @@
  * \return - completion status
  */
 int closeAudio(sa_stream_t * s) {
-  int status, i;
+  int status, i, result;
   
+  result = SA_SUCCESS;
+
   // reseting audio device and flushing buffers
   status = waveOutReset(s->hWaveOut);    
-  HANDLE_WAVE_ERROR(status, "resetting audio device");
+  if (status != MMSYSERR_NOERROR) {
+    result = getSAErrorCode(status);
+  }
   
   /* wait for all blocks to complete */  
-  while(s->waveFreeBlockCount < BLOCK_COUNT)
-	  Sleep(10);
+  while(s->waveFreeBlockCount < BLOCK_COUNT) {
+    Sleep(10);
+  }
 
   /* unprepare any blocks that are still prepared */  
   for(i = 0; i < s->waveFreeBlockCount; i++) {
     if(s->waveBlocks[i].dwFlags & WHDR_PREPARED) {
-	    status = waveOutUnprepareHeader(s->hWaveOut, &(s->waveBlocks[i]), sizeof(WAVEHDR));
-      HANDLE_WAVE_ERROR(status, "closing audio device");
+      status = waveOutUnprepareHeader(s->hWaveOut, &(s->waveBlocks[i]), sizeof(WAVEHDR));
+      if (status != MMSYSERR_NOERROR) {
+        result = getSAErrorCode(status);
+      }
     }
   }    
 
   freeBlocks(s->waveBlocks);  
   status = waveOutClose(s->hWaveOut);    
-  HANDLE_WAVE_ERROR(status, "closing audio device");
+  if (status != MMSYSERR_NOERROR) {
+    result = getSAErrorCode(status);
+  }
 
   DeleteCriticalSection(&(s->waveCriticalSection));
   CloseHandle(s->callbackEvent);
   printf("[audio] audio resources cleanup completed\n");
   
-  return SA_SUCCESS;
+  return result;
 }
 /**
  * \brief - writes PCM audio samples to audio device



More information about the commits mailing list