I'll be checking this in later this afternoon if there is no comment.

Modified by: [email protected]
Date: 12/4/2009
Project: RealPlayer for Netbook

Synopsis:
Fixed PulseAudio PlaybackMultiChannelAsStereo support & refine ALSA's
implementation.

Overview:
PlaybackMultiChannelAsStereo support code belongs in the:
CAudioOutLinux*::_CheckFormat( const HXAudioFormat* pFormat )
method.

On ALSA, _CheckFormat() also calls _OpenAudio().
As a result, the PlaybackMultiChannelAsStereo support code
was accidentally implemented in _OpenAudio() instead,
which worked for ALSA,
but when the implementation was copied to PulseAudio,
it didn't work as expected.

This change fixed PulseAudio's PlaybackMultiChannelAsStereo support and
refined ALSA's implementation by moving it to _CheckFormat()
to avoid further confusion.


Files Modified:
audio/device/platform/unix/audlinux_alsa.cpp
audio/device/platform/unix/audlinux_pulseaudio.cpp

Image Size and Heap Use impact (Client -Only):
None.

Platforms and Profiles Affected:
Linux

Distribution Libraries Affected:
None.

Distribution library impact and planned action:
None.

Platforms and Profiles Build Verified:
Profile: helix_client_moblin
Platform: linux-2.2-libc6-gcc32-i586

Platforms and Profiles Functionality verified:
Profile: helix_client_moblin
Platform: linux-2.2-libc6-gcc32-i586

Branch: 310Atlas, 3_4_10Atlas.
Also 347Atlas for the ALSA change.

Copyright assignment: I am a RealNetworks employee.

-- 
Daniel Yek.

Index: audio/device/platform/unix/audlinux_pulseaudio.cpp
===================================================================
RCS file: /cvsroot/audio/device/platform/unix/audlinux_pulseaudio.cpp,v
retrieving revision 1.1.2.4
diff -u -w -r1.1.2.4 audlinux_pulseaudio.cpp
--- audio/device/platform/unix/audlinux_pulseaudio.cpp	20 Nov 2009 00:12:34 -0000	1.1.2.4
+++ audio/device/platform/unix/audlinux_pulseaudio.cpp	4 Dec 2009 19:02:50 -0000
@@ -979,21 +979,6 @@
     HXLOGL4 (HXLOG_ADEV, "CAudioOutLinuxPA::_OpenAudio() rate = %i, channels = %i, bits/sample = %i", 
             pFormat->ulSamplesPerSec, pFormat->uChannels, pFormat->uBitsPerSample);
 
-    // "PlaybackMultiChannelAsStereo" preference is used to workaround playback problem where
-    // surround sound content is missing from some stereo setup.
-    // Setting "PlaybackMultiChannelAsStereo" preference forces playing back of surround sound
-    // channels in stereo speakers.
-    UINT32 uPrefPlaybackMultiChannelAsStereo = 0; 
-    ReadPrefUINT32(m_pContext, "PlaybackMultiChannelAsStereo", uPrefPlaybackMultiChannelAsStereo);
-
-    if (uPrefPlaybackMultiChannelAsStereo && pFormat->uChannels > 2)
-    {
-        HXLOGL2 (HXLOG_ADEV, "CAudioOutLinuxPA::_OpenAudio(): Disabled multichannel playback!"); 
-
-        // Forces Helix to not use surround sound modes.
-        return RA_AOE_NOTENABLED;
-    }
-
     if (m_bUsePulseAudioSimpleAPI)
     {
         int pa_err = PA_OK;
@@ -1100,6 +1085,7 @@
     }
 
 Exit:
+    m_wLastError = wLastError;
     return wLastError;
 }
 
@@ -1140,7 +1126,7 @@
 
         if (!m_pa_context)
         {
-            goto Exit;
+            goto Error;
         }
 
         HX_LOCK(m_pPulseAudioMainloopLock);
@@ -1167,7 +1153,7 @@
             wLastError = RA_AOE_DEVBUSY;    // Unexpected!
             HXLOGL1 (HXLOG_ADEV, "CAudioOutLinuxPA::_CloseAudio(): Timed out waiting for context_drained_callback()!");
 
-            goto Exit;
+            goto Error;
         }
 
         if (m_pa_mainloop)
@@ -1191,7 +1177,9 @@
 
     }
 Exit:
+    return wLastError;
 
+Error:
     HXLOGL2 (HXLOG_ADEV, "CAudioOutLinuxPA::_CloseAudio(): Failed to clean up PulseAudio thread!");
 
     return wLastError;
@@ -1580,9 +1568,27 @@
 {
     HXLOGL4 (HXLOG_ADEV, "CAudioOutLinuxPA::_CheckFormat().");
 
+    // "PlaybackMultiChannelAsStereo" preference is used to workaround playback problem where
+    // surround sound content is missing from some stereo setup.
+    // Setting "PlaybackMultiChannelAsStereo" preference forces playing back of surround sound
+    // channels in stereo speakers.
+
+    UINT32 uPrefPlaybackMultiChannelAsStereo = 0; 
+    ReadPrefUINT32(m_pContext, "PlaybackMultiChannelAsStereo", uPrefPlaybackMultiChannelAsStereo);
+
+    if (uPrefPlaybackMultiChannelAsStereo && pFormat->uChannels > 2)
+    {
+        HXLOGL2 (HXLOG_ADEV, "CAudioOutLinuxPA::_OpenAudio(): Disabled multichannel playback!"); 
+
+        // Forces Helix to not use surround sound modes.
+        return RA_AOE_NOTENABLED;
+    }
+
+
     // PulseAudio supports all kind of formats.
     // If any format is found to be not handled by PulseAudio, 
     // this can be implemented.
+
     return RA_AOE_NOERR;
 }
 
Index: audio/device/platform/unix/audlinux_alsa.cpp
===================================================================
RCS file: /cvsroot/audio/device/platform/unix/audlinux_alsa.cpp,v
retrieving revision 1.9.2.10
diff -u -w -r1.9.2.10 audlinux_alsa.cpp
--- audio/device/platform/unix/audlinux_alsa.cpp	23 Jul 2009 20:30:26 -0000	1.9.2.10
+++ audio/device/platform/unix/audlinux_alsa.cpp	4 Dec 2009 19:02:50 -0000
@@ -181,24 +181,8 @@
         m_unSampleRate = pFormat->ulSamplesPerSec;
     }
 
-    // "PlaybackMultiChannelAsStereo" preference is used to workaround playback problem where
-    // surround sound content is missing from some stereo setup.
-    // Setting "PlaybackMultiChannelAsStereo" preference forces playing back of surround sound
-    // channels in stereo speakers.
-    UINT32 uPrefPlaybackMultiChannelAsStereo = 0; 
-    ReadPrefUINT32(m_pContext, "PlaybackMultiChannelAsStereo", uPrefPlaybackMultiChannelAsStereo);
-
-    if (uPrefPlaybackMultiChannelAsStereo && m_unNumChannels > 2)
-    {
-        // Forces Helix to not use surround sound modes.
-        m_wLastError = wLastError = RA_AOE_BADOPEN;
-        return wLastError; 
-    }
-
     if(z_pIHXPrefs)
     {
-
-
         HX_RELEASE(m_pPCMDeviceName);
         // We provide only 2 PCM-Device preferences for 2 channels and 5.1 channels.
         // The rest of the surround sound modes can simply be set to hardcoded default 
@@ -1021,7 +1005,7 @@
 
 #ifdef _DEBUG
         printf("ALSA Device Configured:\n");
-        printf("     Start threshold: %d\n",  start_threshold);
+        printf("     Start threshold: %d\n",  (int) start_threshold);
 #endif
     }
     else
@@ -1824,6 +1808,20 @@
     m_bCheckFormat = TRUE;
     m_unNumChannels = pFormat->uChannels; // Needed to open the right ALSA PCM.
 
+    // "PlaybackMultiChannelAsStereo" preference is used to workaround playback problem where
+    // surround sound content is missing from some stereo setup.
+    // Setting "PlaybackMultiChannelAsStereo" preference forces playing back of surround sound
+    // channels in stereo speakers.
+    UINT32 uPrefPlaybackMultiChannelAsStereo = 0; 
+    ReadPrefUINT32(m_pContext, "PlaybackMultiChannelAsStereo", uPrefPlaybackMultiChannelAsStereo);
+
+    if (uPrefPlaybackMultiChannelAsStereo && m_unNumChannels > 2)
+    {
+        // Forces Helix to not use surround sound modes.
+        m_wLastError = wLastError = RA_AOE_NOTENABLED;
+        return wLastError; 
+    }
+
     wLastError = _OpenAudio( pFormat );
     if(wLastError != RA_AOE_NOERR)
     {
_______________________________________________
Audio-dev mailing list
[email protected]
http://lists.helixcommunity.org/mailman/listinfo/audio-dev

Reply via email to