Synopsis:
This change Fixes the bug for WM 5.0 devices audio driver gets hung if the
queue is full
Overview:
Need to clear the queue for this by seeing whether WOM_DONEs are received or not
Files Added:
None
Files Modified:
audio/device/platform/win/winaudio.cpp
audio/device/pub/platform/win/winaudio.h
Image Size and Heap Use impact (Client -Only):
None.
Platforms and Profiles Affected:
platform : wince-500-ppc-arm
profile : helix-client-wince-wm50
Distribution Libraries Affected:
None
Distribution library impact and planned action:
None
Platforms and Profiles Build Verified:
BIF branch -> helix_restricted
Target(s) -> wince_wm50_play(new target)
Profile -> helix-client-wince-wm50(new profile)
SYSTEM_ID-> wince-500-ppc-arm
Branch:
HEAD, atlas310
Files Attached:
winaudio_cpp.diff.txt
winaudio_h.diff.txt
Thanks & Regards,
Lovish
Index: winaudio.h
===================================================================
RCS file: /cvsroot/audio/device/pub/platform/win/winaudio.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- winaudio.h 21 Aug 2007 04:47:12 -0000 1.8
+++ winaudio.h 2 Nov 2007 09:28:09 -0000 1.9
@@ -238,6 +238,9 @@
HX_RESULT _Imp_GetCurrentTime( ULONG32& ulCurrentTime);
INT16 _Imp_GetAudioFd(void) {return 0;};
UINT16 _NumberOfBlocksRemainingToPlay(void);
+#ifdef DONT_WRITE_WHILE_PAUSE_AT_RESET
+ UINT16 _NumberOfBlocksPlaying(void);
+#endif
HXBOOL _IsWaveOutDevice(void) { return TRUE; };
private:
@@ -269,6 +272,7 @@
HXBOOL m_bIsFirstPacket;
#ifdef DONT_WRITE_WHILE_PAUSE_AT_RESET
HXBOOL m_bPausedAtReset;
+ HXBOOL m_bPausedForRestart;
#endif //DONT_WRITE_WHILE_PAUSE_AT_RESET
HXBOOL AllocateBuffers(UINT16 unNumBuffers, UINT16
unBufSize);
Index: winaudio.cpp
===================================================================
RCS file: /cvsroot/audio/device/platform/win/winaudio.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- winaudio.cpp 3 Oct 2007 05:01:33 -0000 1.12
+++ winaudio.cpp 2 Nov 2007 09:28:07 -0000 1.13
@@ -153,6 +153,7 @@
, m_ulOriginalThreadId(0)
#endif /*_WIN32*/
#ifdef DONT_WRITE_WHILE_PAUSE_AT_RESET
+ , m_bPausedForRestart(FALSE)
, m_bPausedAtReset(FALSE)
#endif //DONT_WRITE_WHILE_PAUSE_AT_RESET
{
@@ -580,6 +581,35 @@
return HXR_OK;
}
+#ifdef DONT_WRITE_WHILE_PAUSE_AT_RESET
+UINT16 CAudioOutWindows::_NumberOfBlocksPlaying(void)
+{
+ m_pMutex->Lock();
+
+ UINT16 unQueued = m_UsedBuffersList.GetCount(), unPlaying = 0;
+
+ /* There may be some buffers for which we have not receoved WOM_DONEs
+ * but they have already been played
+ */
+ if (unQueued > 0)
+ {
+ LISTPOSITION ndxUsed = m_UsedBuffersList.GetHeadPosition();
+ while (ndxUsed != NULL)
+ {
+ CWaveHeader* pWaveHeader =
+ (CWaveHeader*)
m_UsedBuffersList.GetNext(ndxUsed);
+ if (pWaveHeader->m_WAVEHDR.dwFlags & WHDR_INQUEUE)
+ {
+ unPlaying++;
+ }
+ }
+ }
+
+ m_pMutex->Unlock();
+
+ return unPlaying;
+}
+#endif
HX_RESULT CAudioOutWindows::_Imp_Write
(
@@ -661,6 +691,32 @@
HX_UNLOCK(m_pMutex);
//OutputDebugString("AFTER CALL TO:waveOutWrite\r\n");
+#ifdef DONT_WRITE_WHILE_PAUSE_AT_RESET
+ // BUG FIX: on some WM2005 devices audio driver gets hung for some
reason if the queue is full
+
+ // We need to return the unused buffers to the available queue
+ UINT16 unRemaining = _NumberOfBlocksRemainingToPlay();
+ UINT16 unPlaying = _NumberOfBlocksPlaying();
+
+ if (unRemaining == 0 && unPlaying == 0)
+ {
+ ::SetThreadPriority( ::GetCurrentThread(), ::GetThreadPriority(
::GetCurrentThread() ) + 1 );
+
+ // Lets reset the audio device. Will this help?
+ m_bPausedForRestart = TRUE;
+
+ _Imp_Pause();
+ }
+ else if (m_bPausedForRestart)
+ {
+ _Imp_Resume();
+
+ m_bPausedForRestart = FALSE;
+
+ ::SetThreadPriority( ::GetCurrentThread(), ::GetThreadPriority(
::GetCurrentThread() ) - 1 );
+ }
+
+#endif //DONT_WRITE_WHILE_PAUSE_AT_RESET
return HXR_OK;
}
_______________________________________________
Audio-dev mailing list
[email protected]
http://lists.helixcommunity.org/mailman/listinfo/audio-dev