Synopsis:
Multiple changes for porting Atlas for Windows Mobile 5.0

Overview:

- Dont make use of DirectSound for WINCE platforms
- make use of hlxclib includes. 
- Volume apis are now supported in WINCE
- issue pause on device reset - needed for the wm50 device being used.

Files Added:

auddevlib_wince-500-ppc-arm.pcf

Files Modified:
audio/device/auddevlib_win.pcf
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:
None 

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, hxclient_3_1_0_atlas

Files Attached:
audio_device.diff.txt
auddevlib_wince-500-ppc-arm.pcf

Thanks & Regards
Anshuman
Index: auddevlib_win.pcf
===================================================================
RCS file: /cvsroot/audio/device/auddevlib_win.pcf,v
retrieving revision 1.6
diff -u -r1.6 auddevlib_win.pcf
--- auddevlib_win.pcf   26 Jan 2006 15:40:03 -0000      1.6
+++ auddevlib_win.pcf   17 Aug 2007 07:43:35 -0000
@@ -39,7 +39,7 @@
 
 
 if project.IsDefined("HELIX_CONFIG_MINIMIZE_SIZE"):
-    if "HELIX_FEATURE_DIRECT_SOUND" in project.defines:
+    if "HELIX_FEATURE_DIRECT_SOUND" in project.defines and not 'wince' in 
sysinfo.family_list:
         project.AddIncludes(GetSDKPath("dxsdk") + "/include")
         project.AddSources("platform/win/hxaudevds.cpp")
         project.AddModuleIncludes("common/system/pub/platform/win")
Index: platform/win/winaudio.cpp
===================================================================
RCS file: /cvsroot/audio/device/platform/win/winaudio.cpp,v
retrieving revision 1.10
diff -u -r1.10 winaudio.cpp
--- platform/win/winaudio.cpp   6 Jul 2007 20:21:17 -0000       1.10
+++ platform/win/winaudio.cpp   17 Aug 2007 07:43:35 -0000
@@ -55,18 +55,22 @@
 #include <stdio.h>
 
 #ifdef _TESTING
-#include <fcntl.h>
+#include "hlxclib/fcntl.h"
+#if !defined(_WINCE)
 #include <sys/types.h>
 #include <sys/stat.h>
+#endif
 
-#if defined (_WINDOWS) || defined (_WIN32)
 
+#if defined (_WINDOWS) || defined (_WIN32)
+#if !defined(_WINCE)
 #include <io.h>
 
 #endif
 
 #endif
 
+#endif // _TESTING
 #include "hxresult.h"
 
 #include "hxcom.h"
@@ -99,9 +103,13 @@
 #define        OFFSET_THIS             0
 
 #ifdef _TESTING
+#if defined (_WINCE)
+FILE* m_audfile = NULL;
+#else
 int m_audfile = -1;
 #endif
 
+#endif // _TESTING
 HXBOOL CAudioOutWindows::zm_bVolSupport = FALSE;
 HXBOOL CAudioOutWindows::zm_bLRVolSupport = FALSE;
 WORD   CAudioOutWindows::zm_uMaxVolume = 100;
@@ -144,11 +152,14 @@
 #if defined(_WIN32)
     , m_ulOriginalThreadId(0)
 #endif /*_WIN32*/
+#ifdef DONT_WRITE_WHILE_PAUSE_AT_RESET
+    , m_bPausedAtReset(FALSE)
+#endif //DONT_WRITE_WHILE_PAUSE_AT_RESET
 {
     zm_bClosed = TRUE;    
     zm_pCurrentAudioDevice = this;
 
-#if defined(_WIN32) && !defined(_WINCE)
+#if defined(_WIN32)
     m_hMixer = NULL;  
     memset(&m_VolumeControlDetails, 0 , sizeof(MIXERCONTROLDETAILS));
 #endif // _WIN32
@@ -170,7 +181,7 @@
     // We might as well consider the device closed!
     zm_bClosed = TRUE;
 
-#if defined(_WIN32) && !defined(_WINCE)
+#if defined(_WIN32)
 
     /* This sleep is added to fix a hang bug that ONLY happens on
      * Darren's machine if you adjust audio volume. His machine
@@ -210,7 +221,7 @@
     DWORD dwVol            = 0;                          
     HXBOOL bSuccess   = FALSE;
 
-#if defined(_WIN32) && !defined(_WINCE)
+#if defined(_WIN32)
     if (!zm_bMixerVolSupportChecked)
     {
        CheckForVolumeSupport();
@@ -276,14 +287,7 @@
         return HXR_OK;
     }
 
-#if defined(_WINCE) && (_WIN32_WCE >= 400) && defined(_X86_)
-       //Windows CE 4.2 Emulator (testing platform) does not seem to support 
waveOut
-       //set volume functionality (on speakers). In some sense it does but 
only the
-       //high volume value work, other values just mute the speakers
-       dwVol = (DWORD) 0xFFFF;
-#else
     dwVol = (DWORD)uVolume * 0xFFFF / zm_uMaxVolume;
-#endif
 
     // Here we are avoiding rounding error
     if(dwVol * zm_uMaxVolume / 0xFFFF < uVolume)
@@ -294,7 +298,7 @@
        goto noMixer;
     }
 
-#if defined(_WIN32) && !defined(_WINCE)
+#if defined(_WIN32)
     if (!zm_bMixerVolSupportChecked)
     {
        CheckForVolumeSupport();
@@ -353,10 +357,12 @@
         * always set the volume on NULL device. 
         * Needed to attach volume control on win98 SE, Creative SB Live! Value 
sound card.
         */
+#ifndef _WINCE
        if (m_hWave != NULL)
        {
             hResult2 = waveOutSetVolume(NULL, dwLRVol);
        }
+#endif
 
        if (hResult != MMSYSERR_NOERROR && hResult2 != MMSYSERR_NOERROR)
        {
@@ -372,14 +378,14 @@
     MMRESULT wSuccess;
     WAVEOUTCAPS auxcap; 
 
-#if defined(_WIN32) && !defined(_WINCE)
+#if defined(_WIN32)
     if (!zm_bMixerVolSupportChecked)
     {
        CheckForVolumeSupport();
     }
 #endif
 
-#if defined(_WIN32) || defined(_WINCE)
+#if defined(_WIN32)
 
        // Gonna have to make VolSupport static  
     if ( zm_bVolSupport )
@@ -435,8 +441,12 @@
     }
        
 #ifdef _TESTING
+#if defined (_WINCE)
+    m_audfile =  fopen("\\auddev.raw", "wt");
+#else
     m_audfile =  open("\\auddev.raw", O_WRONLY | O_CREAT);
 #endif
+#endif //_TESTING
 
     m_WaveFormat.SetFormat(pFormat->ulSamplesPerSec, pFormat->uChannels, 
pFormat->uBitsPerSample);
     // Get the Windows style wave format!
@@ -466,7 +476,7 @@
        case WAVERR_SYNC:           theErr = HXR_AUDIO_DRIVER;  break;
        default:                    theErr = HXR_OUTOFMEMORY;   break;
     }
-#if defined(_WIN32) && !defined(_WINCE)
+#if defined(_WIN32)
        if ( !theErr )
        {
            if (!zm_bMixerVolSupportChecked)
@@ -483,11 +493,17 @@
 HX_RESULT CAudioOutWindows::_Imp_Close()
 {
 #ifdef _TESTING
+#if defined (_WINCE)
+       if ( m_audfile != NULL ) 
+               fclose(m_audfile);
+       m_audfile = NULL;
+#else
        if ( m_audfile > 0 ) 
                close(m_audfile);
        m_audfile = -1;
 #endif
 
+#endif //_TESTING
  zm_bClosed = TRUE;
     if (m_hWave) 
     {
@@ -573,6 +589,14 @@
     MMRESULT       res;
     ULONG32        ulBufLen = 0;
     UCHAR*         pBuffer = 0;
+
+#ifdef DONT_WRITE_WHILE_PAUSE_AT_RESET
+    if (m_bPausedAtReset) 
+    {
+        return HXR_WOULD_BLOCK; // ignore the write until Restart is called. 
Do NOT return HXR_OK here!
+    }
+#endif //DONT_WRITE_WHILE_PAUSE_AT_RESET
+
     if (pAudioOutHdr->pData)
     {
        pBuffer  = pAudioOutHdr->pData->GetBuffer();
@@ -597,10 +621,17 @@
     }
 
 #ifdef _TESTING
+
+#if defined (_WINCE)
+    if ( m_audfile )
+        fwrite(pBuffer, ulBufLen, 1, m_audfile); 
+#else
     if ( m_audfile > 0 )
         write(m_audfile, pBuffer,ulBufLen); 
 #endif
 
+#endif //_TESTING
+
     UINT32 ulBytesToCopy = ulBufLen;
     HX_ASSERT(ulBytesToCopy <= pWaveHeader->m_WAVEHDR.dwBufferLength);
     if (ulBytesToCopy > pWaveHeader->m_WAVEHDR.dwBufferLength)
@@ -669,10 +700,18 @@
     if (m_hWave) 
     {
 //     OutputDebugString("BEFORE CALL TO:waveOutReset\r\n");
+#ifdef DONT_WRITE_WHILE_PAUSE_AT_RESET
+        if (!m_bPausedAtReset)
+        {
+            m_bPausedAtReset = TRUE;
+        }
+#endif //DONT_WRITE_WHILE_PAUSE_AT_RESET
        res = waveOutReset(m_hWave);
        // Need to be turned on after RC2000 XXXRA
        // commenting it out for safety reasons.
-       //_Imp_Pause();
+#ifdef PAUSE_ON_RESET
+        _Imp_Pause();
+#endif //PAUSE_ON_RESET
        //OutputDebugString("AFTER CALL TO:waveOutReset\r\n");
        m_bIsFirstPacket        = TRUE;
 
@@ -1200,7 +1239,7 @@
     return unRemaining;
 }
 
-#if defined(_WIN32) && !defined(_WINCE)
+#if defined(_WIN32)
 void
 CAudioOutWindows::CheckForVolumeSupport()
 {
@@ -1309,8 +1348,12 @@
        if (!m_hInst)
        {
 #ifdef _DEBUG
+#ifdef _WINCE
+       HX_TRACE( "Don't have a valid handle\r\n" );
+#else
        MessageBox(NULL, _T("Don't have a valid handle"), NULL, MB_OK);
 #endif
+#endif // _DEBUG
        return HXR_OUTOFMEMORY;
        }
 
@@ -1343,8 +1386,12 @@
        #endif /* _WIN16 */    
                {
        #ifdef _DEBUG
+       #ifdef _WINCE
+               HX_TRACE( "Could Not register class\r\n" );
+       #else
                MessageBox(NULL, _T("Could Not register class"), NULL, MB_OK);
-       #endif
+       #endif  
+       #endif // _DEBUG
                return(HXR_OUTOFMEMORY);
                }
                m_bClassRegistered = TRUE;
@@ -1362,8 +1409,12 @@
     if (!m_hWnd)
     {
 #ifdef _DEBUG
+#ifdef _WINCE
+       HX_TRACE( "Could Not create messageWindow\r\n" );
+#else
        MessageBox(NULL, _T("Could Not create messageWindow"), NULL, MB_OK);
 #endif
+#endif
        return HXR_OUTOFMEMORY;
     }
 
Index: pub/platform/win/winaudio.h
===================================================================
RCS file: /cvsroot/audio/device/pub/platform/win/winaudio.h,v
retrieving revision 1.6
diff -u -r1.6 winaudio.h
--- pub/platform/win/winaudio.h 16 Feb 2006 23:04:51 -0000      1.6
+++ pub/platform/win/winaudio.h 17 Aug 2007 07:43:36 -0000
@@ -267,6 +267,9 @@
        IHXMutex*           m_pMutex;
        
        HXBOOL              m_bIsFirstPacket;
+#ifdef DONT_WRITE_WHILE_PAUSE_AT_RESET
+       HXBOOL              m_bPausedAtReset;
+#endif //DONT_WRITE_WHILE_PAUSE_AT_RESET
 
        HXBOOL              AllocateBuffers(UINT16 unNumBuffers, UINT16 
unBufSize);
 
@@ -277,12 +280,12 @@
        UINT32              m_ulOriginalThreadId;
 #endif
 
-#if !defined(_WINCE) && ( !defined(_WINDOWS) || defined(_WIN32) ) 
+#if defined(_WIN32)
        void                CheckForVolumeSupport(void);
 
         HMIXER               m_hMixer;
         MIXERCONTROLDETAILS  m_VolumeControlDetails;
-#endif // !defined(_WINDOWS) || defined(_WIN32) 
+#endif 
 
        HX_RESULT           Register();
        void                UnRegister();

Attachment: auddevlib_wince-500-ppc-arm.pcf
Description: Binary data

_______________________________________________
Audio-dev mailing list
[email protected]
http://lists.helixcommunity.org/mailman/listinfo/audio-dev

Reply via email to