Many Linux users enjoy listening

Document Sample
Many Linux users enjoy listening Powered By Docstoc
					COVER STORY                      Bluetooth Headsets




Configuring Linux for a Bluetooth stereo headset



BLUE SOUND


We’ll show you how to set up support for a Bluetooth stereo headset.

BY MARCEL HILZINGER




M
          any Linux users enjoy listening    tion, see the Bluetooth ALSA project             SCO typically uses mono sound quality.
          to music through audio players     page [2].                                        The SCO profile lets users send and re-
          such as XMMS, Amarok, and                                                           ceive sound at the same time. In contrast
Kaffeine. These players typically output     Mono or Stereo                                   to this, the A2DP profile is designed for
sound to speakers or headphones at-          Bluetooth supports two profiles for              high-quality stereo sound. To achieve
tached directly to the computer. If you      transmitting audio signals: Synchronous          this higher quality, A2DP uses a unidi-
prefer the headphone option, and if you      Connection Oriented (SCO) and Ad-                rectional connection with high latency
are the kind of listener who needs room      vanced Audio Distribution Profile                (slow response).
to dance, you might want to consider         (A2DP). The SCO profile defines a bidi-            A Bluetooth headset might support
using a wireless Bluetooth headset.          rectional connection with fast response          only SCO, only A2DP, or both profiles.
   Low-fidelity wireless headsets for two-   (low latency) for voice transmissions.           Single-ear headsets of the type common
way radios and telephones have been on
the market for years, but Bluetooth-
based wireless stereo is a more recent
phenomenon. Many operating systems
do not provide built-in support for Blue-
tooth stereo, relying instead on third-
party tools. Linux, on the other hand,
really does let you directly configure
your system to support a Bluetooth
stereo headset.
   This article is based on the excellent
HOWTO for Ubuntu [1], although the in-
structions will work with any distribu-
tion that has a recent kernel and a Blue-    Figure 1: The Bluetooth headsets by Jabra (left) and Logitech (right) both support stereo
tooth stack. For more detailed informa-      sound. The Jabra headset also supports the mono SCO profile.




38        ISSUE 80 JULY 2007                    W W W. L I N U X - M A G A Z I N E . C O M
                                                                                                 Bluetooth Headsets                 COVER STORY




                                                                                                        The Old Method
                                                                    If the approach that uses the A2DP              btsco v0.42
                                                                    daemon does not work properly, you              Device is 1:0
                                                                    might want to try the old method based
                                                                    on the snd-bt-sco kernel module. This           Voice setting: 0x0060
                                                                    said, I didn’t experience a single case in      RFCOMM channel 1 connected
                                                                    which snd-bt-sco worked but the A2DP
                                                                                                                    Using interface hci0
                                                                    daemon didn’t.
                                                                                                                    Now, pop up a second console and enter
                                                                    To create the snd-bt-sco.ko kernel mod-
                                                                                                                    the following command to start the out-
                                                                    ule, download the CVS code for btsco
                                                                                                                    put:
                                                                    and sbc, build and install as described
                                                                    above, then change directory to btsco/          mpg123 --au - <I>file.mp3<I> | U
                                                                    kernel and run the make command. Be-            a2play <I>Bt-address<I>
                                                                    come root, and copy the module to /lib/         For playback, you need to replace file.
                                                                    modules/Kernelversion/kernel/drivers/           mp3 with the name of any MP3 file and
                                                                    bluetooth. Typing uname -a gives you            Bt-address with the Bluetooth address
                                                                    your Kernelversion.                             for your headset. If you then see the
                                                                    If all of this works, you can load the mod-     messages
                                                                    ule by typing modprobe snd-bt-sco.
                                                                                                                    Listen thread running
                                                                    The next step is to associate with the
                                                                    Bluetooth headset. To do so, you need to        read 2C00C0 2873 times / sec.
                                                                    make sure the headset is in pairing             read 30ABC0 1197 times / sec.
                                                                    mode. Enter the command line:
                                                                                                                    read 3061C0 1198 times / sec.
                                                                    btsco -r -v <I>Bt-address<I>
                                                                                                                    read 2FF0C0 1120 times / sec.
                                                                    Making sure to replace Bt-address with
                                                                                                                    read 3052C0 1154 times / sec.
                                                                    the Bluetooth address for your headset.
                                                                                                                    you can be sure that playback is running.
                                         Herbert Matern, Fotolia




                                                                    If you see the error message
                                                                                                                    The kernel module approach has a cou-
                                                                    btsco v0.42
                                                                                                                    ple of major disadvantages compared
                                                                    Error: control open (hw:1): U                   with the A2DP daemon. For example,
                                                                    No such device                                  to play a track, you need to enter com-
                                                                                                                    mands at the command line – playlists
                                                                    Error: Can't find device. Bail
                                                                                                                    are not supported – and whenever you
                                                                    either your headset is not supported by         update the kernel, you will need to install
                                                                    the module, or the kernel module might          a new module. In addition, playback did
for mobile telephony typically support
                                                                    not be loaded. If everything works out,         not work at all on the Logitech headset
just the SCO profile, whereas stereo
                                                                    you should see the following message:           because it does not support SCO.
headsets often support both. In our lab,
I tested the BT620s stereo headset by
Jabra and the Wireless Headphones for                              You can refer to the box called “The Old         ./bootstrap
PC by Logitech (Figure 1). The Jabra de-                           Method” for instructions on the more             ./configure --prefix=/usr
vice supports both SCO and A2DP. The                               complicated setup for a SCO connection.          make
LED flash sequence tells you which                                 This can be interesting if you would like        sudo make install
mode the headset is working in. The                                to use a headset for phoning (via Skype,
Logitech headset only supports A2DP. In                            for example).                                   Depending on your distribution, you will
fact, the Logitech headset is not officially                         For the A2DP daemon, you need the             need to enter either the root password
a Bluetooth device: Logitech sells it with                         sbc library and the Bluetooth-ALSA tool         (SUSE, Fedora), or your user password
a USB dongle as a normal wireless solu-                            btsco. See the box titled “Downloading          (Ubuntu) to install with a sudo com-
tion, although the set does have Blue-                             Code from CVS” for details.                     mand. When you are done, change di-
tooth capabilities.                                                  After unpacking or downloading the            rectory to plugz and enter the same com-
   This article will be concentrating on                           source code, change to the sbc directory        mands here, adding the --sysconfdir=
stereo output via the a2dpd daemon.                                and enter the following commands:               /etc option to the ./configure command:

                                                                   Downloading Code from CVS
 After logging in, you’re prompted to enter your password. Just press Enter.
 cvs -d:pserver:anonymous@sbc.cvs.sourceforge.net:/cvsroot/sbc login
 cvs -d:pserver:anonymous@sbc.cvs.sourceforge.net:/cvsroot/sbc co sbc
 cvs -d:pserver:anonymous@bluetooth-alsa.cvs.sourceforge.net:/cvsroot/bluetooth-alsa login
 cvs -d:pserver:anonymous@bluetooth-alsa.cvs.sourceforge.net:/cvsroot/bluetooth-alsa co plugz




                                                                      W W W. L I N U X - M A G A Z I N E . C O M              ISSUE 80 JULY 2007            39
COVER STORY                      Bluetooth Headsets




 ./bootstrap                                 fails to find a Bluetooth device, either        will then see the following message in
 ./configure --prefix=U                      your computer’s Bluetooth dongle is not         the terminal window with the a2dpd
 /usr --sysconfdir=/etc                      working or the headset is not in pairing        command:
 make                                        mode. To find out whether Linux has
 sudo make install                           detected the dongle, give the hcitool dev        DEBUG: a2dp_transfer_raw: U
                                             command. It should display the Blue-             Bandwith: 27250 (212 kbps) 32
This completes the installation. The next    tooth address for the dongle.
step is to configure the A2DP daemon.                                                        Instead of XMMS, you could just as eas-
                                             Let’s Rock                                      ily use Amarok or Kaffeine for sound
Configuration Files                          If you have created the two configura-          output. To do so in Amarok, select Set-
For playback, you need to tell the dae-      tion files for the ALSA configuration and       tings | Configure Amarok | Audio output,
mon which headset to use, and you need       the A2DP daemon, you can launch the             and set the Output module to Alsa. After
a .asoundrc file to create a matching        daemon at the command line by typing            clicking on Apply, enter the a2dpd de-
ALSA device. If you do not have a            a2dpd. You don’t need to be root to do          vice in both the Mono and Stereo boxes
.asoundrc file in your home directory,       this. The following two lines should            (Figure 2).
create a new file like so:                   appear as output:                                  In Kaffeine, select Settings | Xine En-
                                                                                             gine Parameters | Audio, click the Expert
 pcm.a2dpd {                                  avrcp: Accepting U                             Options tab, and scroll down until you
        type a2dpd                            incoming connection                            see device.alsa_front_device device used
 }                                            avdtp: Accepting U                             for stereo output. Instead of default,
                                              incoming connection                            enter a2dpd here.
If the file already exists, add the three
preceding lines at the end of the file. To   If you see an error message stating Can-          Pros and Cons
configure the A2DP daemon, copy the          not open /dev/input/uinput: No such file          One of the biggest advantages of the
sample.a2dprc file called .a2dprc from       or directory, you can just ignore it.             Bluetooth approach compared with leg-
the plugz/also-plugins directory to your        Leaving the terminal window open,              acy wireless headsets is that you can use
home directory. Note that both files start   launch XMMS and press Ctrl+P to open              a Bluetooth headset to send commands
with a dot. Then open the .a2dprc file,      the configuration dialog. As your Output          to your Linux computer. For example,
remove the pound sign (#) in line 48 to      Plugin, select ALSA [libALSA.so] and              you can stop the player, move to the next
enable the entry #address=00:08:             then click on Configure. In the Audio             track, or backtrack.
F4:30:07:64, and replace the Bluetooth       device box, manually enter a2dpd (you                The .a2dprc file specifies which com-
address in this entry with the address for   can’t select the device from the list), and       mands the A2DP daemon receives when
your dongle. To find the address, refer to   then click OK twice to apply the settings.        you press a button. In the # AVRCP Com-
the next section.                               When you start
                                             to play back in
Bluetooth Basics                             XMMS, a dialog
To play music on your headset, you need      box appears,
to connect it to your PC. To allow this to   prompting you to
happen, you need to make sure your           pair the device.
headset is visible. If you have a Jabra      The headset must
headset, press the pads on both ear-         be in pairing mode
phones for about five seconds. You can       for this.
tell that the headset is in pairing mode        On SUSE Linux,
because the LEDs will alternately flash      the pairing dialog
red, blue, and green.                        appears in the
   If you have the Logitech headset, hold    KDE Bluetooth
down the button at the center of the left    framework; on
earphone until the LED starts to flash       Ubuntu, you will
quickly. Now enter hcitool scan at the       see a Gnome
command line, and you should see the         Bluetooth dialog
Bluetooth address and name of the head-      box, assuming
sets – for example:                          you have installed
                                             the bluez-passkey-
 marcel@kim:~> hcitool scan                  gnome package on
 Scanning ...                                Edgy.
 00:13:17:70:44:5A Jabra BT620s                 If pairing works
                                             as intended, the
Now enter this address in the .a2dprc file   player should start      Figure 2: To be able to play music via the A2DP daemon, you need to
in your home directory. If the command       to play back. You        set up a2dpd as an ALSA device in Amarok.




40        ISSUE 80 JULY 2007                    W W W. L I N U X - M A G A Z I N E . C O M
                                                                       Bluetooth Headsets                  COVER STORY




mands to run section, you need to en-        though the sound provided by the A2DP        player takes about a second to react;
ter commands for XMMS. If you prefer         profile was far superior to that of the      however, this is not a genuine issue. The
to use Amarok, replace, for example,         SCO connection, which is designed            solution is not currently recommended
cmdplay=xmms --play with cmdplay=            for voice only, some background noise        for video playback: With some video,
amarok -p, enter amarok --previous for       clouded what was otherwise a very            I only heard the voices, and the sound-
cmdprev=, and so on. In the a2dpd            positive impression.                         track was distorted or nonexistent.
window, you will see which commands             Some latency issues occurred with
the daemon sends.                            some versions of the daemon. For exam-       Conclusions
   The same file is used to set the trans-   ple, the daemon stopped playing back in      Now you can enjoy wireless fun with
mission bandwidth. By default, a2dpd         an early version from November 7, 2006,      stereo sound via Bluetooth. It is worth
uses a maximum of 256Kbps. If you            if the headset was out of range, and then    mentioning that Linux is a pioneer in
want to increase the bandwidth, change       it played the notes it had missed at dou-    this field. Mac OS-X Bluetooth versions
the value for sbcbitpool from 32 to 64.      ble or triple speed once the headset was     only support the SCO profile; Apple
In our lab, I experienced some dropouts      back in range.                               plans to introduce A2DP sound with its
doing so. Assessing the value of 16             After applying a patch by Fréderic Dal-   future “Leopard” OS-X release.
reduces the maximum bandwidth to             leau, who is currently continuing the de-      Windows XP is also behind on tools
128Kbps; however, the sound quality          velopment of Bluetooth-Alsa in coopera-      for playing stereo sound with Bluetooth.
is inferior at this bit rate.                tion with Brad Migley, this problem dis-     Vista needs to resort to a third-party
   Because the Bluetooth headset auto-       appeared. However, the latency prob-         vendor for an A2DP profile. ■
matically contacts the A2DP server, you      lems occurred in a CVS version from
can develop a configuration to transmit      November 15.                                                   INFO
the stream from one computer to an-             This time, the speed wowed and flut-
                                                                                           [1] Ubuntu Bluetooth Audio HOWTO:
other with some tinkering; this might be     tered after short periods of dropout dur-
                                                                                               https://help.ubuntu.com/community/
useful if you want to cover the whole of     ing playback. If you remember the days            BluetoothAudio
a large building, for example.               of vinyl, you can probably imagine what
                                                                                           [2] Bluetooth ALSA Project homepage:
   I wasn’t entirely happy with the sound    that sounds like. Because of the slow re-
                                                                                               http://bluetooth-alsa.sourceforge.net
quality of the Bluetooth solution. Al-       sponse of the A2DP connection, the



                                                          Advertisement

				
DOCUMENT INFO
Shared By:
Categories:
Stats:
views:88
posted:2/23/2010
language:English
pages:4