LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Linux more than 1 multimedia application sharing sound (https://www.linuxquestions.org/questions/linux-newbie-8/linux-more-than-1-multimedia-application-sharing-sound-605022/)

afa_linux 12-06-2007 03:32 PM

Linux more than 1 multimedia application sharing sound
 
Hey,
In Linux, does anyone know how to enable multiple applications like realplayer and other mp3 player to play sound at the same time?
Current I think when I started realplayer, it totally grabs the sound card. And I started xmms(another multimedia player) afterwards, it has no sound produced at all...(unless I closed realplayer application first, then start it)
Is this a common problem in Linux?
Sorry that I don't know how to explain this problem in a precisely technical way. Thanks in advance.

matthewg42 12-06-2007 03:45 PM

Realplayer uses the OSS sound driver, and on sound cards with only one channel this can grab the whole card until the application releases it (or usually, terminates).

You can call realplayer using a program called aoss (which in Ubuntu is part of the alsa-oss package). This channels the OSS driver calls though ALSA, which knows how to share the sound card with other ALSA apps. Most apps are ALSA these days, with a few OSS apps still remaining, and being a pain in the butt. Some programs allow you to choose which one to use - ALSA or OSS (e.g. Skype).

What I did was to create a wrapper script called realplay which I put in my PATH before the existing realplay launcher. This script contains the following:
Code:

#!/bin/bash

pgrep realplay > /dev/null
if [ $? -eq 0 ]; then
        aoss /opt/real/realplay -r "$@"
else
        aoss /opt/real/realplay "$@"
fi

As you an see I installed realplayer to /opt/real, and this is called from my wrapper script. My wrapper script has another function - if an instance of realplayer is already running it opens the requested media in that instance of the program rather than opening a second window.

I put this in a directory called bin in my HOME directory, which I added to the PATH in my .bashrc file by adding a line to the end of the file:
Code:

export PATH="$PATH:$HOME/bin"
To make this effective for all apps I had to log out and back in again.


All times are GMT -5. The time now is 07:47 AM.