We have moved to a new Sailfish OS Forum. Please start new discussions there.
12

An app to manually switch audio output from Headphones to speaker?

asked 2014-09-19 12:31:07 +0200

Munim Zahid gravatar image

updated 2014-09-20 12:19:26 +0200

Hello! The main reason behind my silly request is: I bought a 50$ Skull Candy headphones they worked pretty good for some time and then suddenly jolla stopped recognizing them. At this point other phones like s3, iphone 5s and lumia 1020 were recognizing them. Then i started using the headphones which came with Lumia 1020 on Jolla. They also worked awesome until one day when Jolla stopped recognizing these headphones too. 5-10 attempts of plugging in and out and jolla will recognise both the headphones but i think this in and out might damage my phone.

This either tell me a command to manually switch between audio outputs or someone should make an app for this? Maybe jolla should. We had such an app for MeeGo.

here's the link to that meego app, https://bitbucket.org/IlyaSkriblovsky/headphonefix

Regards. Munim.

edit retag flag offensive close delete

Comments

4

try to execute pactl set-sink-port sink.primary output-speaker

coderus ( 2014-09-21 08:53:37 +0200 )edit

worked^ :)))

Munim Zahid ( 2014-09-21 21:02:32 +0200 )edit

4 Answers

Sort by » oldest newest most voted
5

answered 2014-09-21 17:50:33 +0200

dthierbach gravatar image

The meego app works by writing directly to /dev/input/jack. On the Jolla, the sound codec ("sitar") jack events are delivered via the input subsystem, and the device is /dev/input/by-path/platform-soc-audio.0-event (which links to /dev/input/event6).

Doing cat /dev/input/event6 | hexdump -C while plugging the headphone shows that the normal event format (struct input_event) is emitted, with type = 0x05 (EV_SW), code = 0x02 and a value of 0 or 1.

So you can change the meego app (switcher.cpp) accordingly, compile, and see if it works. If I do it myself, I will probably end up having to support it. :-(

This whole thing works by basically simulating the plugin/plugout events on the lowest level, if the hardware is so broken it can't generate the events any more reliably. In principle that can also be done from the commandline, but I suppose you have to come up with a valid timestamp somehow.

I also tested the suggested

pactl set-sink-port sink.primary output-speaker

and that also works, but I'm not sure how well it interacts with the system settings (it only changes the Pulseaudio settings). Maybe someone knows details?

The command to select the headset is

pactl set-sink-port sink.primary output-wired_headset
edit flag offensive delete publish link more

Comments

The command is working fine for me, thus i take it as an answer.

though your part about app above was far from my little knowledge.

I hope one day someone will make such an app.

thanks :)

Munim Zahid ( 2014-09-21 21:02:07 +0200 )edit

If you happen to get a call after using this command, please tell us if the phone switches back to the original output, or keeps this output setting. Just to satisfy my curiousity. :-)

dthierbach ( 2014-09-21 21:45:14 +0200 )edit

yep, incoming call switches the output back to original.

Munim Zahid ( 2014-10-31 13:40:26 +0200 )edit
1

Works on Xperia X as well. My headphone jack seems broken. It doesn't recognize plugs any longer, I guess it is a hardware problem. I'll try the warranty with Sailfish X. Don't want to downgrade to Android. Also I couldn't find a friendly instruction to do so.

1chb ( 2017-11-16 09:28:29 +0200 )edit
1

answered 2014-09-19 13:52:29 +0200

Hi,

I totally support your view. Also if the jack sensors start acting up at any point (as mine did after a fall on the N9), you can just use the App. Somebody should port that to Sailfish.

br, N

edit flag offensive delete publish link more
1

answered 2014-09-21 02:59:08 +0200

midnightoil gravatar image

updated 2014-09-21 20:36:50 +0200

Maybe you should ask the author (jklingen) of the USB Switch app in the Jolla store? It'd seem like a logical thing to add to it? 1 app for 2 things instead of 2 separate ones.

edit flag offensive delete publish link more
0

answered 2016-08-13 22:15:26 +0200

jdrescher2006 gravatar image

I have a question related to this thread. I am using a HP Touchpad with Sailfish ported to it. Problem (among others) is that the headphone jack does not work.

I figured out that I have a device /dev/input/by-path/platform-soc-audio-event which points to /dev/input/event5.
If do cat /dev/input/event5 | hexdump -C, and then plug in a headphone I get:
00000000 25 05 00 00 51 72 0b 00 05 00 02 00 00 00 00 00 |%...Qr..........|
00000010 25 05 00 00 8e 72 0b 00 00 00 00 00 00 00 00 00 |%....r..........|
If I unplug the headphone I get:
00000020 29 05 00 00 2d ea 0a 00 05 00 02 00 01 00 00 00 |)...-...........|
00000030 29 05 00 00 f9 8d 0b 00 00 00 00 00 00 00 00 00 |)...............|

Finally also the command pactl set-sink-port sink.primary output-wired_headset works like it should.

Could I write some sort of script which looks for events on /dev/input/event5 and switches headphone mode on/off?

edit flag offensive delete publish link more
Login/Signup to Answer

Question tools

Follow
3 followers

Stats

Asked: 2014-09-19 12:31:07 +0200

Seen: 2,189 times

Last updated: Aug 13 '16