Hello all.

I am happy to announce that I think I have fully resolved the issue of
sound mixing on my R3000Z, running a *64-bit* 2.6.14 kernel.  That
includes skype (albeit with some trouble).  Yes, I can be listening to
my favorite jazz station on my 64-bit Amarok and when skype "rings," 
announcing an incoming call, I can hear the two sounds mixed and/or if I
visit a web site with flash (using Firefox running 32-bit so it can
invoke flashplayer), the sound of flashplayer is MIXED with the other
sounds.  So, I decided to share my configuration because it may help
many others.  Since my configuration uses ALSA devices in addition to
the ones mentioned in Håkan's wiki page, if others test my configuration
successfully, maybe Håkan's wiki can be amended with these new findings.

I am running 64-bit SuSE 10.   The breakthrough came when, after
repeated googling and surfing through the not-so-well-documented ALSA
project, I ran into the following two URLs (highly recommended):

http://www.novell.com/coolsolutions/feature/16675.html
http://gentoo-wiki.com/HOWTO_ALSA_sound_mixer_aka_dmix

The first URL discusses SuSE's recommendation on how to get skype to
share the sound card; it does not seem to work very well, at least not
on my 64-bit system, but it provides very useful information about ALSA
devices nonetheless.  The second URL above is from Gentoo; it provides
some more information about the ALSA devices mentioned on the SuSE URL.

The gist of my solution is this:  More devices, not mentioned in Håkan's
wiki, are needed in the '/etc/asound.conf' and/or '~/.asoundrc' file
--these files may be different, depending on your distribution-- than
merely the 'dmix' device.  Namely, the device types 'asym' and 'dsnoop'
seem to solve the problem of sound mixing very nicely.  The 'dsnoop'
device type handles the microphone input.  Of course, the appropriate
modules need to be loaded for these devices to work properly and also
for AOSS (ALSA's "wrapper," which intercepts sound calls of
ALSA-agnostic programs that would otherwise "monopolize" the sound card,
and redirects them to the ALSA mixing system) to deal with programs
written for the older OSS.  Below I provide my '/etc/asound.conf' and
'/etc/modprobe.conf.local' files for reference.  The '/etc/asound.conf'
file contains a lot of commented lines because I am still experimenting
and I can change configurations on the fly by editing this file and
running 'rcalsasound stop' and then 'rcalsasound start' (in
distributions other than SuSE one would probably have to run something
like '/etc/rc.d/alsasound ...' as the soft link to
'/usr/sbin/rcalsasound' probably does not exist in distributions other
than SuSE).

Now to skype.  I followed SuSE's advice  in the very first URL above and
used aoss.  It worked for a minute or so, but then the sound became
"crackling" and the fans started running at high speed.  'powersave -rT'
confirmed that the CPU speed governor had "pushed the pedal to the
metal" and my 64-bit CPU was running at full 2.2 GHz.  'top' confirmed
that skype sapped all that CPU power.  Clearly, something was wrong. The
results were the same even when I used 'linux32 aoss skype &', 'aoss
linux32 skype &' and 'linux32 aoss linux32 skype &'.  I decided to draw
on my previous experience handling skype.

My solution to getting the recalcitrant skype to share the sound card? 
You may not like it, but here it is anyway: 'artsdsp'!  Yes, I do know
that arTs (Audio Real Time Synthesizer) is on its way out, but it works
the best here.  It is no longer supported and, in fact, KDE no longer
depends on it; also, the newer versions of MPlayer no longer support
arTs output.  Here is what I do to accommodate skype:  First, I start
artsd with 'artsd -a alsa -D asymed -F 1024 -S 512 -l 3 -s 4' (the
'asymed' alsa device has been declared in my '/etc/asound.conf' file;
you may run 'artsd -h' to see what these options mean); then, when I
want to start skype, I run 'linux32 artsdsp skype &'.  I get a bunch of
errors about unloadable libraries, but the thing runs!  'artsd' blends
nicely with ALSA mixing.  After a couple of pick-up, talk, hang-up
cycles, errors creep up and I have to shut down and restart skype.  It
is not perfect, but in the typical scenario when I am listening to music
and want to take an incoming call, this scheme works very well.  I can
converse on skype while I am still listening to music on, say, Amarok. 
I just shut down and restart skype after finishing a conversation.

I found out  I cannot declare period and buffer sizes for 'dmix' or
'dsnoop' at will in my '/etc/asound.conf' file because for certain
settings skype gave me device-busy error.  This probably has to do with
memory mapping.  The settings I show below work fine for me.  I am
looking into alternatives to skype, by the way, but I find their rates
hard to beat.  Of all the SIP clients only one seems to be
ALSA-compliant: ekiga (check http://ekiga.org/ ; it claims to be
ALSA-compliant, but I have not tried it).  Project Gizmo (check
http://www.gizmoproject.com) is a SIP client but it is closed-source and
still has problems; the dialpad does not work and I don't think the
outgoing sound works, either, at least not with ALSA.  So, I think I
will be stuck with skype for a while.  (Note: the kphone SIP client is
no longer supported and has a bug which garbles the outgoing sound;
otherwise, it is ALSA compliant.  There is a patch for that bug, but I
am hesitant to use a program which is no longer supported.)

Speaking of Amarok, I use the xine engine with ALSA output and the
'asymed' device for mono and stereo output ('asymed' has been declared
in my '/etc/asound.conf' file).  I have never been able to get gstreamer
to work.

And now the configuration of MPlayer.  I run a 32-bit MPlayer which I
installed as an rpm from the Packman site.  As you probably know, there
are two ways to declare the audio output for MPlayer: (1) In the
'/etc/mplayer/mplayer.conf' file with a line like
'ao=alsa:device=asymed'; (2)by invoking MPlayer with the '-ao
alsa:device=asymed' option, which will take precedence over the entry
--or lack thereof-- in the '/etc/mplayer/mplayer.conf' file.  Older
versions of MPlayer may require 'alsa9' instead of 'alsa'.

With the audio configuration above, I observed an inexplicable behavior
in MPlayer: The video played faster than the audio, probably at around
2X speed!  I was able to resynchronize them (momentarily) by jumping
ahead or backwards, but after that the video still came out at about 2X
speed!  I don't know why.  I solved the problem by declaring 'default'
(also declared in my '/etc/asound.conf' file) instead of 'asymed' above.

If you use the gaim all-in-one messenger (handling ICQ, AIM, yahoo, MSN,
jabber...), you may declare '/usr/bin/aplay %s' for sound output in
gaim's sound settings to make use of ALSA mixing.  The kopete all-in-one
messenger seems to be ALSA ready; I did not have to do anything to get
it to work with ALSA mixing.

Firefox, at least as installed from the SuSE rpms (as I said, 32-bit, in
order to be able to invoke the 32-bit closed-source plugins flashplayer
and realplayer) starts through a startup script which invokes Firefox
via AOSS.  I surmise that it is because of that flashplayer sounds are
mixed properly. (I have also installed 32-bit java and the 32-bit java
ALSA compatibility; there is no detriment when an ALSA-compliant program
is invoked via AOSS.)

I hope this puts the sound mixing issues on the R3000Z and perhaps other
laptops to rest.  My '/etc/asound.conf' and '/etc/modprobe.conf.local'
files follow.

Gus Fantanas

#  /etc/asound.conf for nVidia nForce3
 pcm.snd_card {
     type hw
     card 0
     device 0
  }

 ctl.snd_card {
        type hw
        card 0
  }


pcm.asymed {
         type asym
         playback.pcm "dmix"
         capture.pcm "dsnoop"
 }

 pcm.!default {
         type plug
         slave.pcm "asymed"
 }

pcm.!dmix {
        type dmix
        ipc_key 1024
#       ipc_perm 0660
        ipc_key_add_uid yes
        slave {
            pcm "hw:0,0"
            period_time 0
            period_size 512
            buffer_size 16384
           rate 48000
#           rate 44100
        }
        bindings {
            0 0
            1 1
          }
}

# dsnoop is used for the microphone input
pcm.!dsnoop {
         type dsnoop
#        ipc_key 5778293
         ipc_key 2048
         ipc_key_add_uid yes
         slave {
                 pcm "hw:0,0"
                 period_time 0
                 period_size 128
#               period_size 512
                buffer_size 1024
#                buffer_size 2048
                 format S16_LE
                 rate 48000
#                rate 44100
         }
 }

# ctl.mixer0 {
#    type hw
#    card 0
#  }

# Jack devices are used for experimentation;
# they are not needed for plain vanilla ALSA
 pcm.jackplug {
                type plug
                slave { pcm "jack" }
        }

 pcm.jack {
                type jack
                playback_ports {
                       0 alsa_pcm:playback_1
                       1 alsa_pcm:playback_2
               }
                capture_ports {
                       0 alsa_pcm:capture_1
                        1 alsa_pcm:capture_2
                }
          }


pcm.dsp0 {
     type plug
     slave.pcm "asymed"
 }

# pcm.dsp1 {
#     type plug
#     slave.pcm "asymed"
# }

#   -----End of /etc/asound.conf

#  /etc/modprobe.conf.local
# please add local extensions to this file
#
options nvidia NVreg_Mobile=1
options nvidia NVreg_EnableAGPSBA=1
options nvidia NVreg_EnableAGPFW=1



# This sets up the ALSA and OSS portion
alias char-major-116 snd
alias char-major-14 soundcore

# Replace "driver" with the driver for you soundcard
alias snd-card-0 snd_intel8x0
alias sound-slot-0 snd-card-0

# The modem counts as second sound card
alias snd-card-1 snd_intel8x0m
alias sound-slot-1 snd-card-1

# Configure the OSS emulation layer
alias sound-service-0-0 snd-mixer-oss
alias sound-service-0-1 snd-seq-oss
alias sound-service-0-3 snd-pcm-oss
alias sound-service-0-8 snd-seq-oss
alias sound-service-0-12 snd-pcm-oss

alias /dev/mixer snd-mixer-oss
alias /dev/dsp snd-pcm-oss
alias /dev/dsp0 snd-pcm-oss
alias /dev/dsp1 snd-pcm-oss
alias /dev/dsp-1 snd-pcm-oss
alias /dev/midi snd-seq-oss

# For /dev/dsp-1
alias sound-service-1-0 snd-mixer-oss
alias sound-service-1-3 snd-pcm-oss
alias sound-service-1-12 snd-pcm-oss

# If you have more than 1 card, set this number to the correct value
# The modem is considered a second sound card
options snd cards_limit=2
options snd-pcm-oss nonblock_open=1

alias wlan0 driverloader

# ----- End of /etc/modprobe.conf.local

-- 
Running 64-bit Linux on AMD64


_______________________________________________
LinuxR3000 mailing list
[email protected]
http://lists.pcxperience.com/cgi-bin/mailman/listinfo/linuxr3000
Wiki at http://prinsig.se/weekee/

Reply via email to