List Info

Thread: CR-Client: Support multi-channel playback on Linux using ALSA




CR-Client: Support multi-channel playback on Linux using ALSA
user name
2006-10-26 17:01:17
Daniel Yek wrote:
> Here is the core part of additional changes.
> 
> More comment inline...
> 
> At 05:24 PM 10/24/2006, Daniel Yek wrote:
>> At 11:32 AM 10/24/2006, Greg Wright wrote:
>> <snip>
>>>>   Note that on some mis-configured system,
"plug:surround51" was 
>>>> defined even though
>>>>   the system isn't 5.1 capable. This is
system configuration problem.
>>>>   On such system, ALSA would invoke the
"plug" plugin, which uses 
>>>> "route" plugin to
>>>>   discard surround sound content and
playback in 2-channel mode.
>>>>   On these systems, we really want to have
Helix client "preserve" 
>>>> all channels by
>>>>   down-mixing it to 2 channels.
>>>
>>> So, do we properly handle mis-configured
systems? If not, we should. At
>>> least we should have a pref that will let users
force 2-channel 
>>> playback,
>>> if we don't already.
>>
>> I was/am planning to do just that. I'm working on
that now.
> 
> 
> 
> This is now handled by the
"DisableSurroundSoundPlayback" preference.
> 
> If a system's surround sound playback isn't working,
use:
> ~/.hxplayrc:
> DisableSurroundSoundPlayback=1
> 
> That would force all channels to be merged into 2
channels (stereo).
> 
> I have provided a checkbox in the players' Preference
Dialog box too. 
> (Will be in the player part of the CR.)
> 
> 
>>> -    virtual HX_RESULT _OpenAudio() = 0;
>>> +    virtual HX_RESULT _OpenAudio( const
HXAudioFormat* pFormat ) = 0;
>>>
>>> I am not sure I like changing this in
audUnix.h.
>>
>> I don't have strong preference. It is much easier
for me to not change 
>> the function prototype, but trouble-shooting became
more tricky. You 
>> never know when the format information is set in
the member variables 
>> with so many _CheckFormat() calls that do
_OpenAudio() to test the 
>> ALSA. Those member variables surely sounded like
"global variables".
>>
>> I can do it either way.
> 
> OK, I have changed all Unix-based audio device files to
use this new 
> prototype.

Three of the .diff files attached are empty.

+    UINT32 uPrefForceStereo = 0;
+    if (m_pContext)
+    {
+        if(HXR_OK != ReadPrefUINT32(m_pContext,
"DisableSurroundSoundPlayback", uPrefForceStereo))
+        {
+            // Add "DisableSurroundSoundPlayback"
into the Preference.
+            WritePrefUINT32(m_pContext,
"DisableSurroundSoundPlayback", 0);
+        }
+    }

Generally, if a pref is not present, we do not write one out
like
you do above. We just leave it not present and use default
values.
I think that "DisableMultiChannelPlayback" might
be a clearer name.
Also, the ReadPref*() utils check for null IUnknowns. So,
the above
could just be:

+    UINT32 uPrefForceStereo = 0;
+    ReadPrefUINT32(m_pContext,
"DisableSurroundSoundPlayback", uPrefForceStereo);

If you don't have a context or the pref doesn't exist, then
uPrefForceStereo
will still be zero on exit.


Same thing with:

+            if(HXR_OK != ReadPrefUINT32(m_pContext,
"AlsaVaryingSampleRate",
uPrefSampleRateNoDefault))
              {
-                // Add AlsaVaryingSampleRate into
Preference.
-                IHXBuffer* pBuffer = new CHXBuffer;
-                pBuffer->AddRef();
-                pBuffer->SetSize(2);
-                SafeSprintf((char*)
pBuffer->GetBuffer(),2,"%d", 0); /* Flawfinder:
ignore */
-               
z_pIHXPrefs->WritePref("AlsaVaryingSampleRate",
pBuffer);
-                pBuffer->Release();
+                // Add "AlsaVaryingSampleRate"
into the Preference.
+                WritePrefUINT32(m_pContext,
"AlsaVaryingSampleRate", 0);
              }


The rest looks good.

--greg.








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

about | contact  Other archives ( Real Estate discussion Medical topics )