PDA

View Full Version : [SOLVED] Stream audio from iPod touch/iPhone over bluetooth to computer



Ric123
April 28th, 2010, 03:46 AM
Hi, I was wondering if it is currently possible to connect an iPod touch (or iPhone) over bluetooth and have the audio playing on the iPod stream over to the computer.
In Windows, Windows pretends to be a wireless headset and the iPod recognizes the computer as such and streams the audio over. No applications running; it just works in the background
Basically, I want to listen to the music, videos, etc. that are on my iPod synced from iTunes in Windows (DRM music, etc.), which cannot be played otherwise, through my computer speakers/headphones in combination with the sounds of other applications.
I have paired up my iPod with my Ubuntu machine; the Bluetooth Preferences lists it as an audio device and reports it as being connected, but it seems to be just sitting there. PulseAudio/Sound Preferences gives me no options and the iPod doesn't appear to be recognizing the machine as a 'headset' like in Windows but does say it is connected.

Again, just mostly curious. Has anyone tried this?

I'm using Ubuntu 9.10.

megamanexent
June 14th, 2010, 06:11 PM
I really need this too, I have been looking for over a year for a solution. Found this http://nohands.sourceforge.net/config.html
It stand to reason that if one could have a handsfree experience, then audio should come through. Problem is that it will not even configure on Lucid???? :confused:

Bump

jackflap
June 17th, 2010, 11:44 AM
Check this out: http://jprvita.wordpress.com/2009/12/15/1-2-3-4-a2dp-stream/

I haven't tested it yet, but it looks like what we're looking for. Please report back with results.

megamanexent
June 17th, 2010, 08:08 PM
^^ This is exactly what i am looking for! However, I cannot find org.bluez.AudioSource in d-feet and I cannot connect org.bluez.Audio. I think the reason for the failed connections has to do with the way Apple implemented A2DP in the iPhone and iTouch. Does anyone have any ideas to force a connection?

BTW, i am using a Broadcom USB Dongle on Ubuntu 10.04. I have had success in Windows Xp streaming from the iPhone to the computer, so I know the Dongle can do it.

jackflap
June 17th, 2010, 10:21 PM
The missing D-Bus AudioSource address might not because of an issue with the iPhone..

I've been fiddling with this, and I've spotted that adding a semi-colon to the end of the Enable=Source; line will not enable the source, and the AudioSource will appear only if you have added 'Enable=Source' alone.

That may be the issue you're experiencing. Generally on mine, the AudioSource.Connect() method appears under the following address:

/org/bluez/942/hci0/dev_00_17_83_D9_FB_B0 -> Interfaces

megamanexent
June 18th, 2010, 12:01 AM
After some more tinkering, I still cannot get org.bluez.AudioSource to appear. There is no semicolon after Enable=Source. I have restarted bluetoothd several times and even rebooted the computer. Still no dice. What version of bluez do I need? I currently have bluez 4.60 .

jackflap
June 18th, 2010, 09:32 AM
Sounds like you might be right that it's an issue with the iphone (which is a shame since I was going to buy an ipod touch just to stream audio to my sound-server).

I'm on the same version of BlueZ as you are, Ubuntu 10.04, BlueZ 4.60 and I've managed to get it working with an Android phone. But the other phone I tried, a Samsung (Symbian S60v3), could see the AudioSource, but couldn't connect properly.

It might be worth testing with another phone and confirming it's definitely an issue with the iphone. I wouldn't know what to suggest if it is though, perhaps just wait for Ubuntu 10.10 to try again?

Alex

megamanexent
June 18th, 2010, 06:06 PM
Ya, what I think is the iDevice doesn't reveal it supports a2dp unless the remote device is a headset or says its a headset. In windows, that was the only way to stream audio for me. I upgraded bluez to 4.66 to if it will help, but it didn't, now I have to find another phone to see if it will stream. I will report later when i do that. Thanks for your help jackflap!

Ric123
June 25th, 2010, 10:17 PM
It works! Thanks everyone! jackflap's link worked perfectly! http://jprvita.wordpress.com/2009/12...4-a2dp-stream/
I've upgraded to Ubuntu 10.04 by now; I have bluez 4.60 and pulseaudio 0.9.21.
Here's how I did it for my iPod touch (3.1.3) on my Dell Inspiron 1720:
1. I skipped step one, it was already loaded.
2. Add "Enable=Source" right under "#Disable=Control,Source" in the "[General]" section.
3. Restart the computer (to restart all the bluetooth 'stuff')
4. Pair the iPod touch and the computer by clicking the bluetooth icon -> Set up new device -> Forward. Click PIN options and select '1234', Close. Enable bluetooth on the iPod; on the computer select it in the list, Forward. Type the PIN (1234) on the iPod, Connect.
5. Install d-feet (from Synaptic) and run it (Applications -> Programming -> D-Feet). Then File -> Connect to System Bus. Under Bus Name select org.bluez and a tree will appear on the right. Under Object Paths, expand the /org/bluez/1464/hci0/dev's until you find the one with Interfaces that have org.bluez.AudioSource. Expand the AudioSource and double-click on Methods -> Connect(). A dialog will appear; just click Execute. It should say 'This method did not return anything' (I had to do it twice the first time.)
6. Open a terminal (Accessories -> Terminal) and type pacmd and press enter.
6a. Then type list-sources and press enter. Find the one with device.description = "Name of your iPod" then scroll up to where it says 'name: ' (under 'index: ') and copy the name somewhere without the < and >(mine was bluez_source.00_...)
6b. Then type list-sinks and press enter. I only had one (ALSA) and copy the name just as before (mine was alsa.output.pci-000_00...)
6c. Type exit and press enter.
7. Now type 'pactl load-module module-loopback source=YOURSOURCE sink=YOURSINK' (for me, it was pactl load-module module-loopback source=bluez_source.00_... sink=alsa.output.pci-000_00...) and press enter! Viola! Now the iPod should play through the computer as if it were a headset!

Note: Save the number that returns after pactl. When you disconnect your iPod, type pactl unload-module YOURNUMBER and press enter (it changes everytime; for example: pactl unload-module 25)

megamanexent, you have to connect AudioSource, not Audio.

Tell me if it works with the iPhone 4 ;)

megamanexent
June 26th, 2010, 01:30 AM
Thank you thank you Thank you! Ric123, jackflap

It works for me perfectly on iPhone 3G ( no iPhone 4 till july:( ). I moved Enable=Source after [General] and AudioSource appeared, I had it at the very top of audio.conf!

jbeamz
July 15th, 2010, 01:23 AM
Did it and it works for me... thanks!

Now if only I could get it working on my xbmc live!

adityavpratap
August 6th, 2010, 01:31 PM
Hi,
Thanks for such a informative post! However I have a Nokia mobile instead of an Ipod. Will the steps remain the same?
Ric123, I have reached step 5, but am stuck up at step 6.
list-sources in pacmd does not show my mobile.
Any suggestions,
Thanking in advance,

megamanexent
August 6th, 2010, 02:54 PM
The steps should remain the same. Did you list your list-sources while your phone was connected? Look for a source that has the same address as your phone did in d-feet. It should start like bluez_source.xx_xx_xx_xx_xx_xx where the xx are the Bluetooth address for the phone. Some where in that section also there should be device.description = 'xxx' where the xxx is the bluetooth name of the phone. If you never changed it, the name should have Nokia in it.

I hope this helps!

adityavpratap
August 6th, 2010, 03:46 PM
I seem to be missing something. The Nokia mobile is not listed in pacmd. It's mac number is nowhere to be seen in the output of list-sources. Can you share your /etc/bluetooth/audio.conf? I tried these steps in Ubuntu 10.04 aswell as in Linux Mint 8. In Ubuntu, AudioServer itself was missing from d-feet. In Linux Mint 8, I am unable to proceed beyond the 5th step. However audio streaming via bluetooth work in *******.:(

megamanexent
August 6th, 2010, 04:28 PM
I'm currently not in front of my computer, but I will post it once I am able to.

megamanexent
August 6th, 2010, 08:07 PM
I seem to be missing something. The Nokia mobile is not listed in pacmd. It's mac number is nowhere to be seen in the output of list-sources. Can you share your /etc/bluetooth/audio.conf? I tried these steps in Ubuntu 10.04 aswell as in Linux Mint 8. In Ubuntu, AudioServer itself was missing from d-feet. In Linux Mint 8, I am unable to proceed beyond the 5th step. However audio streaming via bluetooth work in *******.:(

Don't get frustrated, I had the same problem, I couldn't find AudioSource in d-feet either. What solved it was to move Enable=Source to right after [General] . I am on Ubuntu 10.04

Heres my audio.conf

# Configuration file for the audio service

# This section contains options which are not specific to any
# particular interface
[General]
Enable=Source
# Switch to master role for incoming connections (defaults to true)
#Master=true

# If we want to disable support for specific services
# Defaults to supporting all implemented services
#Disable=Control,Source

# SCO routing. Either PCM or HCI (in which case audio is routed to/from ALSA)
# Defaults to HCI
#SCORouting=PCM

# Automatically connect both A2DP and HFP/HSP profiles for incoming
# connections. Some headsets that support both profiles will only connect the
# other one automatically so the default setting of true is usually a good
# idea.
AutoConnect=true

# Headset interface specific options (i.e. options which affect how the audio
# service interacts with remote headset devices)
[Headset]

# Set to true to support HFP, false means only HSP is supported
# Defaults to true
HFP=true

# Maximum number of connected HSP/HFP devices per adapter. Defaults to 1
MaxConnected=1

# Just an example of potential config options for the other interfaces
#[A2DP]
#SBCSources=1
#MPEG12Sources=0

adityavpratap
August 7th, 2010, 03:03 PM
Hi!
Thanks for the prompt reply.
My audio.conf is exactly the same as yours. I can find an entry corresponding to my Nokia mobiles bluetooth mac address in d-feet->org.bluez->"Object Path. However, in the corresponding "Interfaces", I fail to see AudioSource. There is only Audio. This is very frustrating!:(

megamanexent
August 7th, 2010, 03:44 PM
I am assuming that you have rebooted your computer or Bluetooth multiple times and if your audio.conf looks like mine then AudioSource should appear. What model Nokia phone do you have? Does it support A2DP? Try repairng the phone to the computer and see what happens.

adityavpratap
August 7th, 2010, 04:45 PM
It is a low end Nokia model - Nokia 2730, audio-streaming over bluetooth works perfectly over Windows so I assume that A2DP is supported. But I don't know how to confirm. I have followed all the steps religiously, but still AudioSource is missing from d-feet.

megamanexent
August 7th, 2010, 06:12 PM
I can confirm that phone has A2DP support. For Linux Mint 8, you might have to upgrade the bluez package to the latest version, however, Ubuntu 10.04 should work out the box. You need at least BlueZ 4.46 but the latest is probably best. I am not sure why you don't see AudioSource.

adityavpratap
August 7th, 2010, 06:17 PM
You have been very patient with a newbie like me. Thanks for that! :-)
One question though, how do I check the version of Bluez?

megamanexent
August 7th, 2010, 06:23 PM
We all were once newbies, I still consider myself a newbie. LOL.
But you can open synaptic and type in BlueZ and see which version is currently installed.

megamanexent
August 8th, 2010, 12:34 AM
For those of you who stumble on this thread and really would like a script to somewhat automate the process of connecting your A2DP device, I created such a script. It uses zenity to add a GUI element so you might have to install it from the repos if it is not installed.While doing that, make sure libqt4-dbus is installed to, but it should be there already. UPDATE: libqt4-dbus is no longer needed as the script now uses 'dbus-send'. Thank you hohlraum!

You still need to add your source and sink from pacmd with list-sources and list-sinks respectively to the script. I left a spot at the top of the script to add them. Leave no space between the '=' and what you type. You can type qdbus --system org.bluez into a terminal to find your device address ( If you do not have the package libqt4-dbus installed, ignore this). It should look like /org/bluez/XXXX/hci0/dev_XX_XX_XX_XX_XX_XX where XX are numbers or letters. You only need to type the dev_XX_XX_XX_XX_XX_XX in the script. Word of cation, this script creates a file in your home directory called .bluetooth_unload, if you have a file with that name, change the script to not overwrite your file. I tried to make the script as portable as possible, but there may be something I missed so use it with discretion!!!!

Make sure the file is executable and your done. You can run the script from console, or add a launcher to your gnome menu to get the full GUI effect. Gnome-Do is also a good launcher too.;)

megamanexent
August 9th, 2010, 05:32 PM
Those of you on Karmic will need to manually load the PulseAudio Bluetooth Module.
This should install it

sudo apt-get install pulseaudio-module-bluetooth
This should load it

pactl load-module module-bluetooth-discover
After you get d-feet to show AudioSource, This should help you find the source while the device is connected

pactl list | grep bluez_source
This can help find the sink, but pacmd and list-sinks will give you all sinks if you have more than one sound card

pactl list | grep alsa_output

Follow Rick123 instructions ( or you could use the script above :D )and you should now have A2DP audio!!
http://ubuntuforums.org/showpost.php?p=9511043&postcount=10

Tylerc230
August 10th, 2010, 07:02 AM
I am able to connect to my ubuntu box and hear audio but it is very crackly and seems to be playing too slowly (like powering down a record player). I'm running a fresh install of ubuntu 10.04 with iPhone 4 ios 4. Any suggestions? I get a similar effect when running an iPad with 3.2 on it. Lots of pitch shifting and echo effect.

megamanexent
August 10th, 2010, 08:51 PM
I noticed this to, but it was off and on. I thought is might be pulseaudio, but looking at this bug report, it might be bluez https://bugs.launchpad.net/ubuntu/+source/bluez/+bug/424215
Any way, there is a suggested fix and im going to try it to see if it helps.

** Update **

Seems to work better yes, but this is with an iPhone 3G.
what I did was from the bug report


sudo hciconfig hci0 lm ACCEPT,MASTER

sudo hciconfig hci0 lp HOLD,SNIFF,PARK

Now just to add it to udev to run at start-up :D

Tylerc230
August 12th, 2010, 07:44 PM
Didn't seem to work for me. There are other post regarding pulseaudio and varying playback speed so I think it has something to do with that. I'll post back if I find a solution.

sancelot
September 23rd, 2010, 11:47 PM
Hi,
I have tried this with maverick , and my phone, everything went well for setting up, but unfortunately no sound in the computer!

megamanexent
September 27th, 2010, 12:52 AM
Hi,
I have tried this with maverick , and my phone, everything went well for setting up, but unfortunately no sound in the computer!

Did you make sure to use the right sink and source when you ran 'pactl load-module module-loopback source=YOURSOURCE sink=YOURSINK'?
Theoretically, it should work on maverick.

TheKent
September 27th, 2010, 09:01 PM
Hello. I have an iPod that I am trying to stream from, but I'm stuck at Ric123's number 6a. I can't find my iPod in 'list-sources'.
There's only 2 sources:

0: device.description = "Monitor of Intern lyd Analog Stereo"
1: device.description = "Intern lyd Analog Stereo"


Managed to get the Audio-Sources in d-feet, and executed the 'connect ()', but still no luck in list-sources. Suggestions, anyone?

megamanexent
September 28th, 2010, 12:00 AM
Hello. I have an iPod that I am trying to stream from, but I'm stuck at Ric123's number 6a. I can't find my iPod in 'list-sources'.
There's only 2 sources:

0: device.description = "Monitor of Intern lyd Analog Stereo"
1: device.description = "Intern lyd Analog Stereo"


Managed to get the Audio-Sources in d-feet, and executed the 'connect ()', but still no luck in list-sources. Suggestions, anyone?

Use
pactl list | grep bluez_source to see if you can find it when your iPod is connected.

How could you have missed this? :lolflag:
http://ubuntuforums.org/showpost.php?p=9698302&postcount=25

Ashen001
October 13th, 2010, 01:18 PM
Even I had the same problem with my iPod touch, but I got it fixed now. Thank you for your help. The steps which you have mentioned are so simple, it does not take much time also. It can be done without any issues. Now I am able to connect my iPod touch over Bluetooth and have the audio playing.

Sultan-mrm
October 15th, 2010, 06:55 PM
It works! Thanks everyone! jackflap's link worked perfectly! http://jprvita.wordpress.com/2009/12...4-a2dp-stream/
I've upgraded to Ubuntu 10.04 by now; I have bluez 4.60 and pulseaudio 0.9.21.
Here's how I did it for my iPod touch (3.1.3) on my Dell Inspiron 1720:
1. I skipped step one, it was already loaded.
2. Add "Enable=Source" right under "#Disable=Control,Source" in the "[General]" section.
3. Restart the computer (to restart all the bluetooth 'stuff')
4. Pair the iPod touch and the computer by clicking the bluetooth icon -> Set up new device -> Forward. Click PIN options and select '1234', Close. Enable bluetooth on the iPod; on the computer select it in the list, Forward. Type the PIN (1234) on the iPod, Connect.
5. Install d-feet (from Synaptic) and run it (Applications -> Programming -> D-Feet). Then File -> Connect to System Bus. Under Bus Name select org.bluez and a tree will appear on the right. Under Object Paths, expand the /org/bluez/1464/hci0/dev's until you find the one with Interfaces that have org.bluez.AudioSource. Expand the AudioSource and double-click on Methods -> Connect(). A dialog will appear; just click Execute. It should say 'This method did not return anything' (I had to do it twice the first time.)
6. Open a terminal (Accessories -> Terminal) and type pacmd and press enter.
6a. Then type list-sources and press enter. Find the one with device.description = "Name of your iPod" then scroll up to where it says 'name: ' (under 'index: ') and copy the name somewhere without the < and >(mine was bluez_source.00_...)
6b. Then type list-sinks and press enter. I only had one (ALSA) and copy the name just as before (mine was alsa.output.pci-000_00...)
6c. Type exit and press enter.
7. Now type 'pactl load-module module-loopback source=YOURSOURCE sink=YOURSINK' (for me, it was pactl load-module module-loopback source=bluez_source.00_... sink=alsa.output.pci-000_00...) and press enter! Viola! Now the iPod should play through the computer as if it were a headset!

Note: Save the number that returns after pactl. When you disconnect your iPod, type pactl unload-module YOURNUMBER and press enter (it changes everytime; for example: pactl unload-module 25)

megamanexent, you have to connect AudioSource, not Audio.

Tell me if it works with the iPhone 4 ;)



Thaaaaaaanks ,,

Its work with Nexus One

Nephilime
October 21st, 2010, 09:48 AM
I'm trying to stream audio from my iPhone 3GS iOS 4.01 to my linux computer via Bluetooth and A2DP.

My setup:
(ArchLinux)
Linux CoreNAS 2.6.34-Custom-Core #10 SMP PREEMPT Thu Aug 5 15:13:53 CEST 2010 i686 Intel(R) Atom(TM) CPU D510 @ 1.66GHz GenuineIntel GNU/Linux

Bluez 4.69

pulseaudio 0.9.21

The stream actually works, but every 1/2 seconds there is a glitch in the audio. Sometimes there are pitches in the audio. The audio is being streamed at 44.1Khz and my phone is in an acceptable range of the bluetooth enabled computer.

Pulseaudio outputs about every 5 seconds:

I: module-loopback.c: Should buffer 36012 bytes, buffered at minimum 92178 bytes
I: module-loopback.c: Old rate 45022 Hz, new rate 45046 Hz
I: module-loopback.c: Loopback overall latency is 63.33 ms + 352.51 ms + 39.51 ms = 455.35 ms

I load the loopback module as follows:

pactl load-module module-loopback source=bluez_source.00_26_B0_8D_6F_39 sink=alsa_output.usb-Native_Instruments_Audio_2_DJ_SN-v42x7kbg-00-Audio2DJ.analog-stereo rate=44100

Does anybody have a clue or direction to solve this issue? Thanks in advance!

hohlraum
December 2nd, 2010, 10:01 PM
For those of you who stumble on this thread and really would like a script to somewhat automate the process of connecting your A2DP device, I created such a script. It uses zenity to add a GUI element so you might have to install it from the repos if it is not installed. While doing that, make sure libqt4-dbus is installed to, but it should be there already.

You still need to add your source and sink from pacmd with list-sources and list-sinks respectively to the script. I left a spot at the top of the script to add them. Leave no space between the '=' and what you type. You can type qdbus --system org.bluez into a terminal to find your device address. It should look like /org/bluez/XXXX/hci0/dev_XX_XX_XX_XX_XX_XX where XX are numbers or letters. You only need to type the dev_XX_XX_XX_XX_XX_XX in the script. Word of cation, this script creates a file in your home directory called .bluetooth_unload, if you have a file with that name, change the script to not overwrite your file. I tried to make the script as portable as possible, but there may be something I missed so use it with discretion!!!!

Make sure the file is executable and your done. You can run the script from console, or add a launcher to your gnome menu to get the full GUI effect. Gnome-Do is also a good launcher too.;)

You mention in your code that it works with 9.10. That is not my experience. The instructions (using qdbus) at the beginning of the code and the code that sets the 'device' variable will not work with ubuntu 9.10. This is because bluez doesn't support introspection in the version included with 9.10.

megamanexent
December 2nd, 2010, 11:56 PM
You mention in your code that it works with 9.10. That is not my experience. The instructions (using qdbus) at the beginning of the code and the code that sets the 'device' variable will not work with ubuntu 9.10. This is because bluez doesn't support introspection in the version included with 9.10.

hohlram- see post(s)
http://ubuntuforums.org/showpost.php?p=9511043&postcount=10
http://ubuntuforums.org/showpost.php?p=9698302&postcount=25

In order to stream audio over bluetooth in Karmic, you have to upgrade the version of bluez from source (unless you find a .deb of the new version)( or use backports?). The new version will have the code for A2DP streaming.

The problem you're seeing is that you need to have module-bluetooth-discover for pulseaudio installed and loaded. As http://jprvita.wordpress.com/2009/12/15/1-2-3-4-a2dp-stream/ states: "If it’s not loaded you can use pactl to load it manually or configure PulseAudio to load it on startup in /etc/pulse/default.pa" The script will not set up A2DP streaming entirely in Karmic, which I did mention. You still have to follow the instructions for the initial set-up, then my script will become useful.

hohlraum
December 3rd, 2010, 05:15 AM
hohlram- see post(s)
http://ubuntuforums.org/showpost.php?p=9511043&postcount=10
http://ubuntuforums.org/showpost.php?p=9698302&postcount=25

In order to stream audio over bluetooth in Karmic, you have to upgrade the version of bluez from source (unless you find a .deb of the new version)( or use backports?). The new version will have the code for A2DP streaming.

The problem you're seeing is that you need to have module-bluetooth-discover for pulseaudio installed and loaded. As http://jprvita.wordpress.com/2009/12/15/1-2-3-4-a2dp-stream/ states: "If it’s not loaded you can use pactl to load it manually or configure PulseAudio to load it on startup in /etc/pulse/default.pa" The script will not set up A2DP streaming entirely in Karmic, which I did mention. You still have to follow the instructions for the initial set-up, then my script will become useful.

I should have explained a bit better. Karmic and your instructions on the first page work just fine with all existing/available packages for Karmic (no upgrading required). Your script works fine as well if a few parts are modified to use dbus-send instead of qdbus.

hohlraum
December 3rd, 2010, 07:21 PM
So now that everyone is awake has anyone figured out a way to control your phone/device from the computer? Normally you've got bt headphones (pause/play, skip forward/reverse, vol up/down) controlling (AVRCP profile) the device but since the computer "is/are" the head phones there must be a way to do it via dbus methods maybe? Didn't see anything obvious using d-peek

megamanexent
December 5th, 2010, 04:54 PM
hohlraum - Ahh! Now I understand, thank you! I'm not to confident in using dbus-send, but I will try to rewrite the script. Sorry about that, I should have personally tested the script on Karmic.



So now that everyone is awake has anyone figured out a way to control your phone/device from the computer? Normally you've got bt headphones (pause/play, skip forward/reverse, vol up/down) controlling (AVRCP profile) the device but since the computer "is/are" the head phones there must be a way to do it via dbus methods maybe? Didn't see anything obvious using d-peek

Using d-feet, I see some control methods under org.bluez.Headset. But I don't think that will help. For now I just use veency with vncviewer !! ;)

Maybe somebody will eventually write something to accomplish this. I would if I knew how.

hohlraum
December 6th, 2010, 01:57 AM
Actually, I'm dumb. There is no reason to use dbus-send (although it would remove the scripts dependancy on qdbus). Your method for retreiving the device path is really the only issue as it uses introspection which bluez under karmic doesn't support. I'll post the fix that doesn't use introspection (its just one extra command to get the bt adapter path).

megamanexent
December 6th, 2010, 02:13 AM
Quick question, is it the bluetooth adapter my script cannot find, or is it the A2DP device?

hohlraum
December 6th, 2010, 06:27 AM
Quick question, is it the bluetooth adapter my script cannot find, or is it the A2DP device?
Bluez won't allow qdbus to just scan and return everything it sees. This is called introspection. Let me post my fix tomorrow before you spend any time on it.

hohlraum
December 6th, 2010, 04:27 PM
The issue:

$ qdbus --system --literal org.bluez
/
Cannot introspect object / at org.bluez:
org.freedesktop.DBus.Error.UnknownInterface (Interface 'org.freedesktop.DBus.Introspectable' was not found)

The fix:

qdbus --system --literal org.bluez / org.bluez.Manager.ListAdapters

for each adapter until we find our phone/device:

qdbus --system --literal org.bluez ADAPTERPATH org.bluez.Adapter.ListDevices

However, your script currently just assumes that the user only has one bluetooth adapter (hci0) in the system so:

qdbus --system --literal org.bluez / org.bluez.Manager.DefaultAdapter
qdbus --system --literal org.bluez <DEFAULTADAPTER> org.bluez.Adapter.ListDevices

Right now your script uses:

device=`qdbus --system org.bluez | grep /hci0/$your_device`

and instead could use:

adapter_device=`qdbus --system --literal org.bluez / org.bluez.Manager.DefaultAdapter | sed -n 's:^[^/]*\([^]]*\)]:\1:p'`
device=`qdbus --system --literal org.bluez $adapter_device org.bluez.Adapter.ListDevices | sed -n 's/^.*Path: \([^]]*\)]}]/\1/p' | grep $your_device`

This will work in all versions of ubuntu regardless of how old their bluez version is as long as they have qdbus.

Anything you can do with qdbus you can do with dbus-send if you want to remove the depency on qdbus. The only issue is that dbus-send returns xml instead of python data structures. The parameters are nearly identical:

qdbus --system --literal org.bluez <everything else is identical>

is the same as:

dbus-send --system --print-reply --dest=org.bluez <everything else is identical>

megamanexent
December 7th, 2010, 05:29 PM
hohlraum - Thank you for your help. I rewritten the script to use dbus-send and included your fix. Hopefully by doing so, other distros besides Ubuntu can use it too.

Right now I don't have access to Karmic, do you mind if you could test the script out to see if the changes work?

petekalo
January 1st, 2011, 09:26 PM
It works! Thanks everyone! jackflap's link worked perfectly! http://jprvita.wordpress.com/2009/12...4-a2dp-stream/
I've upgraded to Ubuntu 10.04 by now; I have bluez 4.60 and pulseaudio 0.9.21.
Here's how I did it for my iPod touch (3.1.3) on my Dell Inspiron 1720:
1. I skipped step one, it was already loaded.
2. Add "Enable=Source" right under "#Disable=Control,Source" in the "[General]" section.
3. Restart the computer (to restart all the bluetooth 'stuff')
4. Pair the iPod touch and the computer by clicking the bluetooth icon -> Set up new device -> Forward. Click PIN options and select '1234', Close. Enable bluetooth on the iPod; on the computer select it in the list, Forward. Type the PIN (1234) on the iPod, Connect.
5. Install d-feet (from Synaptic) and run it (Applications -> Programming -> D-Feet). Then File -> Connect to System Bus. Under Bus Name select org.bluez and a tree will appear on the right. Under Object Paths, expand the /org/bluez/1464/hci0/dev's until you find the one with Interfaces that have org.bluez.AudioSource. Expand the AudioSource and double-click on Methods -> Connect(). A dialog will appear; just click Execute. It should say 'This method did not return anything' (I had to do it twice the first time.)
6. Open a terminal (Accessories -> Terminal) and type pacmd and press enter.
6a. Then type list-sources and press enter. Find the one with device.description = "Name of your iPod" then scroll up to where it says 'name: ' (under 'index: ') and copy the name somewhere without the < and >(mine was bluez_source.00_...)
6b. Then type list-sinks and press enter. I only had one (ALSA) and copy the name just as before (mine was alsa.output.pci-000_00...)
6c. Type exit and press enter.
7. Now type 'pactl load-module module-loopback source=YOURSOURCE sink=YOURSINK' (for me, it was pactl load-module module-loopback source=bluez_source.00_... sink=alsa.output.pci-000_00...) and press enter! Viola! Now the iPod should play through the computer as if it were a headset!

Note: Save the number that returns after pactl. When you disconnect your iPod, type pactl unload-module YOURNUMBER and press enter (it changes everytime; for example: pactl unload-module 25)

megamanexent, you have to connect AudioSource, not Audio.

Tell me if it works with the iPhone 4 ;)


I am trying it with the iphone 4, with a new AZIO bluetooth adapter, and I have been able to get output. However it is essentially unusable because there is an outrageous amount of static, it even slows down the playback speed. Anyone run into this?

Timbo337
January 31st, 2011, 03:13 AM
Thanks for posting this! I have been wanting to set something like this up since I got my Droid, but just now got around to it.

I have it working with Ubuntu 10.04 and Motorola Droid. The biggest problem was just needing to restart instead of 'bluetoothd restart', to get the Audiosource interface... which wasn't much of a problem.

My plan now is to set this up in my car with something running embedded linux, such as a beagleboard. I only have an aux in on my head unit, but want to go wireless (which will also eliminate the ground-loop problem I have when charging the phone and have the phone plugged into the aux in... no more static when charging!)

brianallred
February 11th, 2011, 02:35 AM
I am trying it with the iphone 4, with a new AZIO bluetooth adapter, and I have been able to get output. However it is essentially unusable because there is an outrageous amount of static, it even slows down the playback speed. Anyone run into this?
I am having the exact same issue with 10.10 and my iPhone 4. Haven't yet solved it.

oscrp
February 13th, 2011, 02:25 PM
I am having the exact same issue with 10.10 and my iPhone 4. Haven't yet solved it.

Same here with an iPad, albeit there isn't any problems when streaming from my Nexus one through A2DP.. Hope someone find a reason for this bad behaviour

zansatsu0
February 25th, 2011, 06:57 AM
I figured since this thread got revived, I would share this script I wrote. The script is attached. It wouldn't let me attach the config file, but I'm sure you can do:

sudo gedit /etc/bluetooth/audio.conf

I have not tested this on any other system and I cannot guarantee that it will even work for you, but I figured someone may find it useful. At the worst, it will just error out on you. At the best, it will work. Enjoy. :)

My sources were two users on these forums and they gave me just enough to get this script done. Thanks goes out to the OP of this thread Ric123, especially this post:
http://ubuntuforums.org/showpost.php?p=9511043&postcount=10

And megamanextent at this thread:
http://ubuntuforums.org/showpost.php?p=9698302&postcount=25

I had to edit my /etc/bluetooth/audio.conf to look like this:

# Configuration file for the audio service

# This section contains options which are not specific to any
# particular interface
[General]

# Switch to master role for incoming connections (defaults to true)
Master=true

# If we want to disable support for specific services
# Defaults to supporting all implemented services
#Disable=Control,Source
Enable=Source

# SCO routing. Either PCM or HCI (in which case audio is routed to/from ALSA)
# Defaults to HCI
#SCORouting=PCM

# Automatically connect both A2DP and HFP/HSP profiles for incoming
# connections. Some headsets that support both profiles will only connect the
# other one automatically so the default setting of true is usually a good
# idea.
AutoConnect=true

# Headset interface specific options (i.e. options which affect how the audio
# service interacts with remote headset devices)
[Headset]

# Set to true to support HFP, false means only HSP is supported
# Defaults to true
HFP=true

# Maximum number of connected HSP/HFP devices per adapter. Defaults to 1
MaxConnected=1

# Just an example of potential config options for the other interfaces
#[A2DP]
#SBCSources=1
#MPEG12Sources=0

connectBTAudio.sh

#!/bin/bash
# Credit to Ric123 and megamanextent for the primer material
# found at UbuntuForums.Org
#---------------------------------------------------------------
# Written by Alex Zaballa on 02/24/2011
# Distributed under GPL v.2.
# Use at your own risk. There is no guarantee this will work
# but shouldn't hurt anything.
#---------------------------------------------------------------
# This script is designed to work in Ubuntu Maverick 10.10
# so I can pair my Android to Ubuntu. I have not tested this
# with IPhone in any flavor. Your mileage may vary.
# It requires qdbus and Pulse Audio.
# This also assumes that your audio.conf file in
# /etc/bluetooth is configured properly.

clear

echo "Please pair and connect your device."
read -p "Press any key to initialize audio..." -n 1 garbageVar

# Return Example: /org/bluez/29159/hci0/dev_01_23_45_AB_CD_EF
qPath="$(qdbus --system org.bluez | grep -m 1 "/dev_")"

# Even though the phone says it's connected, it doesn't work
# unless I hard-reset the connection. Also, AudioSource.Disconnect
# won't work reliably in this situation, so I tried the Device.Disconnect
# method which seems to work well for my Gingerbread Hero (Android 2.3).
qdbus --system org.bluez "${qPath}" org.bluez.Device.Disconnect 1> /dev/null
sleep 5
echo "Attempting connection..."
qdbus --system org.bluez "${qPath}" org.bluez.AudioSource.Connect 1> /dev/null


# Return Example: bluez_source.01_23_45_AB_CD_EF
bluezSource="$(pactl list | grep -m 1 "Name: bluez_source" | cut -c 8-)"
echo "Bluez Source: ${bluezSource}"

# Return Example: alsa_output.pci-0000_00_10.1.analog-stereo
alsaSink="$(pactl list | grep -m 1 "Name: alsa_output" | cut -c 8-)"
echo "Alsa Sink: ${alsaSink}"

# Return Example: 25
paID="$(pactl load-module module-loopback source="${bluezSource}" sink="${alsaSink}")"
echo "pactl ID number: ${paID}"

read -p "Press any key to disconnect..." -n 1 garbageVar

pactl unload-module "${paID}"
qdbus --system org.bluez "${qPath}" org.bluez.AudioSource.Disconnect

hero809
March 9th, 2011, 12:04 PM
first timer here but i have managed to follow all the instructions to the best of my ability, everything went as instructed without issues until the last part. pactl load-module module-loopback source=bluez_source.11_22_33_44_55_66 sink=alsa_output.pci-0000_01_00.1.hdmi-stereo the source being my evo 4g and my computer a hp dv8. long story short it says Connection failure: Connection refused. i dont know what i did wrong. i need help. my computer can play music from my phone. i had windows 7 at one point and it worked fin then but i now have ubuntu 10.10 and i dont know my way around this problem. thank you who ever reads this.

hero809
March 9th, 2011, 01:16 PM
i reset pulseaudio and now i get this Failure: Module initalization failed

lothar83fr
March 10th, 2011, 04:03 PM
i reset pulseaudio and now i get this Failure: Module initalization failed

You can see what happened in /var/log/syslog

Some one has resolv the iphone 4 issue? I tried many rate but the song still bad and some times the speed increase.
I use bluez 4.60-0ubuntu8, maybe I should update this...

HeinekenPissr
March 18th, 2011, 01:31 AM
OK so I set it up as described and it works but the audio quality is such crap that I would never bother using this.

I was hoping to be able to watch my movies on my ipad (streaming through airvideo from my linux server) and to be able to get the audio of the movie on my ubuntu 10.10 computer speakers. This presently works...kind of. But the quality is terrible.

Anyone the static /audio quality problems on this yet? Does this work perfectly for anyone? Is there better success with different bluetooth dongles?

sherman
March 18th, 2011, 02:17 AM
I've managed to get my iPhone 4 to connect and play via PulseAudio on Ubuntu 10.10, and I am using a Apple Wireless Keyboard (obviously via bluetooth) and every half second there is an audio interruption that is almost like a lost packet of audio. The audio keeps playing however...

I am assuming this is a combination between something in Bluez, the nondescript bluetooth device I am using and the fact the keyboard is polling the bluetooth stack every half a second at least.

I can't really try this combination in Windows, since this is my work PC and I'm sure they'd fire my *** if I installed Windows myself (not that I want to... *shudders*). Not that it matters... we are getting a fresh install of Windows 7 in a few weeks (cries).

Just thought I'd add my feedback!

HeinekenPissr
March 19th, 2011, 01:32 PM
Ok so now I'm looking for other alternatives for the same objective as this solution is not sufficient due to low quality audio and an audio to video lag of 5 secs when streaming audio over bluetooth. I have 2 more ideas about this.


Objective: Airvideo works perfectly streaming from my media center to my IPAD. However sometimes the audio ouput on the ipad is too low and i wish to have louder better quality sound output. I have another computer in my room with a nice speaker systemwhich i would like to use for audio of the movie.

Option 1: I figure I should be able to access the AirVideo stream through VLC on my desktop so that i could simultaneously play the file on the IPAD and my computer to allow for better sound. To do this i need to know what the URL is of the airvideo server to enter into VLC Network Stream. I have found the port number to be 46631 and my the IP of my server is 192.168.3.10. Any ideas about the full network stream?

Option 2: I could go the more expensive route of using the airport express to hook up my speakers to. Evidently, native to the iPad is the ability to choose your iPad speakers or speakers hooked up to airstream as audio output. However I am running Ubuntu and It is not clear to me if it is required to run iTunes for this to work. However the movie would be streaming from an air video server running on another Ubuntu box and not through iTunes so I don't see why iTunes would need to be installed.

Any thoughts or other ideas?

HeinekenPissr
March 19th, 2011, 05:43 PM
Ok so now I'm looking for other alternatives for the same objective as this solution is not sufficient due to low quality audio and an audio to video lag of 5 secs when streaming audio over bluetooth. I have 2 more ideas about this.


Objective: Airvideo works perfectly streaming from my media center to my IPAD. However sometimes the audio ouput on the ipad is too low and i wish to have louder better quality sound output. I have another computer in my room with a nice speaker systemwhich i would like to use for audio of the movie.

Option 1: I figure I should be able to access the AirVideo stream through VLC on my desktop so that i could simultaneously play the file on the IPAD and my computer to allow for better sound. To do this i need to know what the URL is of the airvideo server to enter into VLC Network Stream. I have found the port number to be 46631 and my the IP of my server is 192.168.3.10. Any ideas about the full network stream?

Option 2: I could go the more expensive route of using the airport express to hook up my speakers to. Evidently, native to the iPad is the ability to choose your iPad speakers or speakers hooked up to airstream as audio output. However I am running Ubuntu and It is not clear to me if it is required to run iTunes for this to work. However the movie would be streaming from an air video server running on another Ubuntu box and not through iTunes so I don't see why iTunes would need to be installed.

Any thoughts or other ideas?

So after some more digging around on the internet and at the airvideo forums it appears that Option1 will not be feasible for technical reasons i'm not prepared to get into.

So possible option 2 or some other idea altogether unless of course someone found a way to get this bluetooth to work perfectly without static but then I would still except an audio lag problem

sofiazara
March 21st, 2011, 03:45 AM
Has anyone looked at their bluetooth and wondered why Apple incorporated it into the iPhone? In my opinion it seems pretty standard to do these days as every handset adopts it, however i have never ever used it on my iPhone. It simply doesn't have any function in the iPhone OS. The most it can do is pair a handset and that is about it. Well here is a list of 5 features I reckon that Apple and developers ought to incorporated in the iPhone and its functions.
1. The transfer of videos, applications and music from iTunes to the iPhone. I realize there may be many issues but i wonder if it was possible to do that. I find myself sometimes in a rush and just want to transfer the app across quickly without having to though my draw and find the sync cable.
2. Use bluetooth to connect a sort of controller to the iPhone unit. I realize many games may not be able to use it however it their start to build add-ons like these, they can greatly increase the amount of buttons available which would make the gaming experience so much better.
3. Use bluetooth to connect the iPhone wirelessly to a set of speakers. Ok! Maybe this is not to best idea when it comes to docking it for the night as would would have to connect it up and charge it. The benefit lies in when you walk in the door and want to play music. Simply just play from the iPhone as it instantly recognizes your bluetooth wireless speakers. It would be great as you walked through different rooms and speakers in each room could pick up on the bluetooth transmission from the iPhone.

krshna_r
April 6th, 2011, 10:39 AM
Hi,
I am trying stream music files from my samsung galaxy to i.Mx51 evalkit which boots Ubuntu.

I successfully followed the steps given by Ric123

i am able to find source as bluez_source.myphonebluetoothaddr and sink as alsa_output.platform-soc-audio.2.analog-stereo

but after giving the cmd 'pactl load-module module-loopback source=MYSOURCE sink=MYSINK and playing the song in my phone i am not able to hear any sound from the speakers connected to eval kit.

whr i am going wrong.
plz reply

livinginx
April 13th, 2011, 09:07 AM
I've tried the steps posted by Ric123 but am having issues.

After I restart and pair my computer to my Nokia phone, my pulseaudio stops working.

If I type 'pacmd' into a terminal, I get 'No PulseAudio daemon running, or not running as session daemon.' or 'Failed to kill PulseAudio daemon'

I am running 10.04 but no luck in getting this to work. Any help?

-gr00ve-
April 29th, 2011, 12:57 PM
Hi,

my Ipod 4G (no jailbreak) connects fine, but i have the same problem with bad quality.
Running Ubuntu 10.10.
The Iphone 3GS and the Ipod Touch is working better ?

Greetings.

gerard187
May 25th, 2011, 04:49 AM
My Motorola Atrix sounds find but the Ipod Touch 2G sounds like crap. This is all under Natty 11.04.

elysion
June 28th, 2011, 02:03 PM
I have been trying to get this working with Kubuntu 11.04 and Nokia N9. I called the Connect method of org.bluez.AudioSource under the object path of the N9 on the Kubuntu laptop, but I just get the following error:

'org.bluez.Error.Failed: Stream setup failed'

Anyone had this issue? Any ideas how to make this work?

elysion
June 28th, 2011, 02:15 PM
Another thing I was wondering was if it would be possible for bluez to provide a org.bluez.AudioSink.Connect() method on the laptop? That way I could connect to the laptop in similar manner as to any bluetooth headset.

kais
August 27th, 2011, 12:28 AM
I have been trying to get this working with Kubuntu 11.04 and Nokia N9. I called the Connect method of org.bluez.AudioSource under the object path of the N9 on the Kubuntu laptop, but I just get the following error:

'org.bluez.Error.Failed: Stream setup failed'

Anyone had this issue? Any ideas how to make this work?


I met the same issue with Android phone and ubuntu 10.4. After numerous tries, I found the following steps would help:

1. unpair the phone with ubuntu and pair again and have a try.

2. if the previous step does not work, make sure when you pair phone with ubuntu, you don't make them connect. you only pair it.

kais
August 27th, 2011, 12:34 AM
i met the same issue ocassionally. seems the deamon crashed.

ps -aef | grep pulse

would yield pulseaudio deamon not there.

reboot the system would work.


I've tried the steps posted by Ric123 but am having issues.

After I restart and pair my computer to my Nokia phone, my pulseaudio stops working.

If I type 'pacmd' into a terminal, I get 'No PulseAudio daemon running, or not running as session daemon.' or 'Failed to kill PulseAudio daemon'

I am running 10.04 but no luck in getting this to work. Any help?

kais
August 27th, 2011, 12:43 AM
I had similar experience with destop ubuntu 10.4. After successfully followed the steps, namely finishing 'pactl load-module module-loopback source=bluez_source.xx.xx.xx.xx.xx sink=..." which seems to suceed, I can't hear any music.

What is more, if I play youtube from safari, I can't hear anything. The interesting thing to note is that the sound control icon on the upper right bar changed shape to dot dot shape.

Any one has similar experience would like to share your solution?


Hi,
I am trying stream music files from my samsung galaxy to i.Mx51 evalkit which boots Ubuntu.

I successfully followed the steps given by Ric123

i am able to find source as bluez_source.myphonebluetoothaddr and sink as alsa_output.platform-soc-audio.2.analog-stereo

but after giving the cmd 'pactl load-module module-loopback source=MYSOURCE sink=MYSINK and playing the song in my phone i am not able to hear any sound from the speakers connected to eval kit.

whr i am going wrong.
plz reply

kais
August 29th, 2011, 06:43 PM
Tried a little bit more.

Open system->preference->sound, click input, I do see the A2DP card as input.
However, as soon as I start to steam audio from the phone, I get a popup window saying "Waiting for sound system to respond" forever.


I had similar experience with destop ubuntu 10.4. After successfully followed the steps, namely finishing 'pactl load-module module-loopback source=bluez_source.xx.xx.xx.xx.xx sink=..." which seems to suceed, I can't hear any music.

What is more, if I play youtube from safari, I can't hear anything. The interesting thing to note is that the sound control icon on the upper right bar changed shape to dot dot shape.

Any one has similar experience would like to share your solution?

drinkmilk
September 15th, 2011, 06:10 PM
It actually seems that a lot of issues were fixed lately since running Ubuntu 11.10 (beta) I can finally get lots of different configurations to work (from different phones to different bluetooth dongles on 3 differents machines) flawlessly. None of these configurations was working (stuttering sound) with 11.04. I would be interested to know which component fixed that if anyone knows: bluez, pulseaudio, the kernel, alsa?

Anyway, that’s a really good news.

jayk_s4
December 1st, 2011, 02:14 AM
This script worked for me in Ubuntu 11.10, streaming music from a gingerbread droid to a rocketfish bt adapter. Very cool!

The only thing I have to do in addition to run the script is open the Sound Settings, select Output, and then select my "Internal Audio Digital Stereo (HDMI)" device, and then click back onto the "Internal Audio Analog Stereo" device. Maybe the script is picking the wrong output device by default?

Second, I want to put this server in my basement out of the way and stream music to it from anywhere in the house. Obviously if I have to walk all the way to the basement and run this script it isn't going to be very convenient. Any ideas on how to automate or make it permanent?

Thanks for the help everybody who is looking for a solution. I hope this includes the ubuntu team and upstream folks...

EDIT : NVM, figured the first problem out. Changed the alsaSink line to be more specific about which output driver to use.
alsaSink="$(pactl list | grep -m 1 "Name: alsa_output.*analog-stereo" | cut -c 8-)"


I figured since this thread got revived, I would share this script I wrote. The script is attached. It wouldn't let me attach the config file, but I'm sure you can do:

sudo gedit /etc/bluetooth/audio.confI have not tested this on any other system and I cannot guarantee that it will even work for you, but I figured someone may find it useful. At the worst, it will just error out on you. At the best, it will work. Enjoy. :)

My sources were two users on these forums and they gave me just enough to get this script done. Thanks goes out to the OP of this thread Ric123, especially this post:
http://ubuntuforums.org/showpost.php?p=9511043&postcount=10

And megamanextent at this thread:
http://ubuntuforums.org/showpost.php?p=9698302&postcount=25

..code clipped...

jamfreak
September 27th, 2012, 10:19 PM
Stupid question... but how do I run this script? Just download it and click on it?



I figured since this thread got revived, I would share this script I wrote. The script is attached. It wouldn't let me attach the config file, but I'm sure you can do:

sudo gedit /etc/bluetooth/audio.confI have not tested this on any other system and I cannot guarantee that it will even work for you, but I figured someone may find it useful. At the worst, it will just error out on you. At the best, it will work. Enjoy. :)

My sources were two users on these forums and they gave me just enough to get this script done. Thanks goes out to the OP of this thread Ric123, especially this post:
http://ubuntuforums.org/showpost.php?p=9511043&postcount=10

And megamanextent at this thread:
http://ubuntuforums.org/showpost.php?p=9698302&postcount=25
Stupid question... but how do I run this script? Just download it and click on it? please help...





I had to edit my /etc/bluetooth/audio.conf to look like this:

# Configuration file for the audio service

# This section contains options which are not specific to any
# particular interface
[General]

# Switch to master role for incoming connections (defaults to true)
Master=true

# If we want to disable support for specific services
# Defaults to supporting all implemented services
#Disable=Control,Source
Enable=Source

# SCO routing. Either PCM or HCI (in which case audio is routed to/from ALSA)
# Defaults to HCI
#SCORouting=PCM

# Automatically connect both A2DP and HFP/HSP profiles for incoming
# connections. Some headsets that support both profiles will only connect the
# other one automatically so the default setting of true is usually a good
# idea.
AutoConnect=true

# Headset interface specific options (i.e. options which affect how the audio
# service interacts with remote headset devices)
[Headset]

# Set to true to support HFP, false means only HSP is supported
# Defaults to true
HFP=true

# Maximum number of connected HSP/HFP devices per adapter. Defaults to 1
MaxConnected=1

# Just an example of potential config options for the other interfaces
#[A2DP]
#SBCSources=1
#MPEG12Sources=0connectBTAudio.sh

#!/bin/bash
# Credit to Ric123 and megamanextent for the primer material
# found at UbuntuForums.Org
#---------------------------------------------------------------
# Written by Alex Zaballa on 02/24/2011
# Distributed under GPL v.2.
# Use at your own risk. There is no guarantee this will work
# but shouldn't hurt anything.
#---------------------------------------------------------------
# This script is designed to work in Ubuntu Maverick 10.10
# so I can pair my Android to Ubuntu. I have not tested this
# with IPhone in any flavor. Your mileage may vary.
# It requires qdbus and Pulse Audio.
# This also assumes that your audio.conf file in
# /etc/bluetooth is configured properly.

clear

echo "Please pair and connect your device."
read -p "Press any key to initialize audio..." -n 1 garbageVar

# Return Example: /org/bluez/29159/hci0/dev_01_23_45_AB_CD_EF
qPath="$(qdbus --system org.bluez | grep -m 1 "/dev_")"

# Even though the phone says it's connected, it doesn't work
# unless I hard-reset the connection. Also, AudioSource.Disconnect
# won't work reliably in this situation, so I tried the Device.Disconnect
# method which seems to work well for my Gingerbread Hero (Android 2.3).
qdbus --system org.bluez "${qPath}" org.bluez.Device.Disconnect 1> /dev/null
sleep 5
echo "Attempting connection..."
qdbus --system org.bluez "${qPath}" org.bluez.AudioSource.Connect 1> /dev/null


# Return Example: bluez_source.01_23_45_AB_CD_EF
bluezSource="$(pactl list | grep -m 1 "Name: bluez_source" | cut -c 8-)"
echo "Bluez Source: ${bluezSource}"

# Return Example: alsa_output.pci-0000_00_10.1.analog-stereo
alsaSink="$(pactl list | grep -m 1 "Name: alsa_output" | cut -c 8-)"
echo "Alsa Sink: ${alsaSink}"

# Return Example: 25
paID="$(pactl load-module module-loopback source="${bluezSource}" sink="${alsaSink}")"
echo "pactl ID number: ${paID}"

read -p "Press any key to disconnect..." -n 1 garbageVar

pactl unload-module "${paID}"
qdbus --system org.bluez "${qPath}" org.bluez.AudioSource.Disconnect

zander1013
January 6th, 2013, 01:59 AM
hi,

i have it working on kubuntu 12.10 with iPhone 4 as a source.

it works okay but it does cut-out sometimes.

i will remark pactl was initially returning
alonzo@eartha:~$ pacmd
Daemon not responding.
i am not sure what happened to get it going. :confused:

also? i am not sure what was meant by "save the number after pactl",,,

here is the output when i ran pactl load-module,,,,

>>> exit
alonzo@eartha:~$ pactl load-module module-loopback source=bluez_source.7C_C5_37_1D_80_88 sink=alsa_output.pci-0000_00_1b.0.analog-stereo
19
alonzo@eartha:~$ pactl
No valid command specified.
alonzo@eartha:~$ pactl


is the number i should make note of 19?

please advise.

thank you for a great thread!

jianyongng
February 8th, 2013, 10:54 AM
why am I getting this?


$ pactl load-module module-loopback source=bluez_source.90_C1_15_7F_F7_58 sink=alsa_card.pci-0000_00_1b.0
Failure: Module initalization failed

salinmooch
February 12th, 2013, 09:26 PM
I see that this post is still active. I recently was struggling through the same thing with my 12.10 - trying to stream audio from my android phone to my workstation which has nice studio speakers on it. I was disappointed the default bluetooth applet did not support this in a nice GUI way - but I found the old standby blueman did. Its a bit ugly but gets the job done with a single right click on the device (my phone) and selecting it the audio source (e.g. A2DT) and you are done.

https://apps.ubuntu.com/cat/applications/precise/blueman/

https://dl.dropbox.com/u/585302/Screenshot%20from%202013-02-12%2013%3A22%3A30.png

ICouldBeAnyone
June 17th, 2013, 01:36 AM
I know this post is old - but for future people wanting a less complicated way of doing this, there is now an application that will let you listen to your iPhone, iPod, or other android device with bluetooth music streaming capability’s. It is aptly named Listen. After paring your device to your computer, open Listen and select the device from the drop down menu. Then check the check box! :D

Listen seems much more easy than going through all these .config files. Then again, I have never tried the methods in this thread...

EDIT:
Before I forget, here is the link to Listen! (apt:pct-listen)

riddelltm
April 27th, 2014, 08:46 PM
Still working in 12.04 LTS with iPhone 5 on iOS 6, one note (may have missed in gloss over trying to get it to work) is that you have to have to go into Sound Settings and under the Input Tab you have to Select the bluetooth device in the "Record Sound from" field, otherwise the audio is not looped through the speakers.

cydewaze
February 22nd, 2015, 02:15 PM
Funny, I got this working just using blueman the other day, and now I can't get it to work again to save my life. When I right click on my phone on the Devices list, I don't get any audio options. When I refresh services, I get this:


Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.

Argh! Any ideas?

EDIT: Turns out I had to do two things.

1) Pull my bluetooth dongle and plug it back in (weird)
2) Update my pulseaudio driver and reloading the module as per this how-to: http://zach-adams.com/2014/07/bluetooth-audio-sink-stream-setup-failed/

FYI, if your sound quality is horrible on the PC speakers, try turning the volume on the phone down and your speakers up instead.