Working around a buggy sound card

02 Dec 2014 23:34

I found the laptop I bought recently has a weird thing with its soundcard. It plays music OK, it also allows you to change the mixer levels, nothing special, but when you try changing mixer setting while the music is playing the music starts getting choppy and the process handling the mixer tend to freeze. Also you cannot pause the music, sometimes it repeats the same sample over and over and it gets very annoying.

My approach to this issue was to use PulseAudio software mixer capabilities, so the hardware mixer is never adjusted (other than for the initial setup).

Step 1. Getting PulseAudio to use the software mixer

I found no good documentation on this other than PulseAudio uses paths to convert the desired volume to the hardware mixer settings and if it lacks the ability to do so it would turn the volume up/down using software. Reading between the lines I realized if I remove the paths I will get what I want. Just do this and restart pulseaudio and you'll have PulseAudio doing all the mixing in software:

sudo mv /usr/share/pulseaudio/alsa-mixer/paths /usr/share/pulseaudio/alsa-mixer/paths.bak

Verifying it works

Open two terminal windows. In each of them open alsamixer. Both should display very simple controls and say Card: PulseAudio. Use F6 to switch to the real card in one of the windows. Usually the cards have plethora of controls, so should yours.

Now change the output volume in the alsamixer still saying "Card: PulseAudio". If the volume reported by the other alsamixer does not change, it works as expected!

If you now rename the paths directory back and restart the pulseaudio process, updating the PulseAudio volume should update the real device volume as well.

Step 2. Integrating this with XFCE (or other DE)

The way xfce4 handles the volume is two-fold:

  • There's a xfce4-volumed daemon. It only controls the key bindings. It binds volume up, volume down and mute keys to control the real device controls
  • There's a panel applet called "Audio Mixer" that shows the current volume level and lets you change the volume as well.

Both component are optional and both seem to not work with PulseAudio (even through PulseAudio ALSA emulation which tricks alsamixer for instance).

We're going to overcome this problem by replacing these components with two other programs.

pa-applet

pa-applet will replace the "Audio Mixer" applet. The difference is the pa-applet docks to the systray, so is not XFCE-specific. The downside is we don't have control over the specific position of the icon, all we know is it will appear in the systray (so don't forget to have the systray applet added to the panel).

In order to install this software you need to clone the source, and run ./autogen.sh, ./configure, make, sudo make install. You will get information about deps missing, for instance:

configure: error: Package requirements (glib-2.0) were not met:

No package 'glib-2.0' found

You need to find the proper *-dev package for each unmet dependency (for this one it will be libglib2.0-dev).

I came across one additional problem. The software seems not updated after some GTK+ 3 updates and it uses a deprecated function. Because the code is configured in a way that every warning stops the compilation, it wouldn't let you compile the code unless you open the src/Makefile file and then find and remove the -Werror flag from it.

xfce4-volumed-pulse

This part will take care of binding the media keys to the pulse audio controls (rather than to the sound card controls).

You need to download the tar package, untar it, ./configure, make, sudo make install. It also requires quite a few libs to be installed, but I didn't found any issues when compiling.

Hooking this up together

Since I didn't need the original xfce4-volume anymore I decided to remove it:

apt-get remove xfce4-volumed

But because XFCE will try to launch this anyway on each start, I decided to take advantage of it and replace it with a script:

#!/bin/bash

/usr/local/bin/xfce4-volumed-pulse
/usr/local/bin/pa-applet

Add the executable bit, restart the laptop and all should be working correctly at this moment.

Setting the hw mixer controls

Since PulseAudio won't update the hw controls after you follow up this little howto, it's quite important to set all the important channels to 100% (or other number up to your taste). The way to update the hw controls was described before.

Open the terminal, type alsamixer and hit F6. This will give the list of ALSA devices besides the PulseAudio emulation, your real sound cards should display as well. Choose the right one and you should be given access to tweak the real card controls.

Note if you removed the PulseAudio paths, the PulseAudio controls wouldn't update when you tweak the hw controls.

Comments: 0

Accessing HTTPS Over HTTP

01 Nov 2014 16:47

For one my internal projects, I needed a HTTP-to-HTTPS proxy in a way that a client connects to HTTP network inside the trusted network and the server connects through the Internet to the service via HTTPS.

I quickly set this up using Apache. Here's the virtual host file:

<VirtualHost *:8371>
        ServerName              localhost
        ProxyPreserveHost       Off
        SSLProxyEngine          On
        Header                  edit Set-Cookie secure;.HttpOnly HttpOnly
        RewriteEngine           On
        RewriteRule             ^/(.*) https://remote-server.com/$1 [P,L]
        ProxyPassReverse        / https://remote-server.com/
</VirtualHost>

You need to enable the following modules for that: proxy, proxy_http, rewrite, headers

Note, above I also mangle the Set-Cookie response headers in a way, that every http-only secure cookie (this means a cookie is transmitted to the server only over a secure transport and is not available on the client side) is converted to a http-only but non-secure.

The rule I produced (convert regexp "secure;.HttpOnly" to just "HttpOnly") may not work for you because I targeted one particular service and the construction of such cookies may be different for the one you want to proxy.

The second note is that, the service you're proxying might actually check the protocol on the client side as well, which we cannot mock on the server-level. I was lucky my service didn't have such checks.

Comments: 0

Cups And Easy Printer Sharing

22 Apr 2014 20:53

Today I decided I want to share an USB printer via CUPS. This has always been fun and easy thing to do.

After spending some time figuring out why this doesn't work out of the box, I learned most of the tutorials are not right about one thing. They claim to share the network in the same (sub)network you don't need any special configuration on the client. That's wrong. You need to install cups-browsed package on the client:

sudo apt-get install cups-browsed

Then you just wait 30 seconds and you're remote printers should appear in http://localhost:631/printers

If you want to print from a different network (or your stupid router doesn't bridge Wifi and Ethernet networks) you may need to add a line like that:

BrowsePoll server-name

to the /etc/cups/cups-browsed.conf file.

An update: actually BrowsePoll server-name doesn't seem to work. I needed to replace the server name with the server IP address.

Comments: 0

Flash I Silverlight

16 Mar 2014 20:18

Z Flashem do niedawna było całkiem nieźle. Wsparcie dla Linuksa było. Paczki w apcie były. W miarę działało. Silverlight był gorszy. Niby był moonlight, ale nigdy nie działał akurat z tymi stronami co się chciało.

Teraz Flash na Linuksa dostępny jest tylko w wersji 11. Jak chcesz wersję 12, to musisz mieć Chrome'a. Można jakimś hakiem wyciągnąć z Chrome'a samą wtyczkę i wrzucić do Chromium, ale to już trochę bez sensu.

Natomiast o Moonlighcie to już chyba wszyscy zapomnieli. Przekierowanie ze strony Microsoftu (gdzie kierują strony "brak wtyczki) prowadzi do 404-ki, w apcie susza, w sumie nie wiadomo co robić.

Ale dzisiaj odkryłem rozwiązanie obu problemów. Nazywa się ono pipelight. Jest to sprytna biblioteka instalująca Windowsowe wtyczki do przeglądarek jako wtyczki do przeglądarek na Linuksie, np. Firefoksa. Korzysta to z wine'a i sprawdziłem, że działa. Zarówno Silverlight jak i Flash 12 odtąd działa elegancko. Przynajmniej do oglądania filmów i transmisji na żywo. Obsługa kamerki w tej "wersji" Flasha nie działa.

Comments: 0

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License