Razer Megalodon USB Headsets and Fedora (or Ubuntu)

Over my break, I picked up a bunch of new Razer peripherals for my machines — they make remarkably good wired mice and the odd piece of keyboard brilliance, so while I was at it, I thought about getting some headsets.

I settled on the Razer Megalodon after finding the other candidates had smaller inner ear cups (and as someone with boney ears, wearing over-ear cans that don’t fit for more than a few hours tends to hurt a bit) — the fact it had it’s own DSP was nice and the microphone did a good job at filtering the noise in the store where I bought it, so $more-than-I-wanted-to-spend later, I unboxed it and threw it at my two primary workstations.

Now, we’ve not had a lot of luck with headsets around here — i’m usually the guy that buys them, breaks them in the first Jabber discussion and then either a) returns them, for another type or b) hacks on various settings, throws things in a PPA or generally gives people enough fodder to say “Try another one”.

Having tried 3 types of Turtle Beach as well as an Astro A40 and having them all returned for one reason or another before christmas, the first outing started no better for the Razer’s.

First off, my Ubuntu 12.10 installation, as well as 12.04, as well as Fedora 18, loads usb-storage (as well as usb-audio) for them, which hampers the ability for the Sound Control on my GNOME 3.x based desktops to see them as an Output device (and there’s nothing worse than getting the input to work through the microphone, but nothing coming out the ears).

Often, we could fix this by doing a “pulseaudio -k” from a terminal, but only having “modprobe -f usb-storage” first (which is dangerous, especially for those of you with other devices plugged in when you’re trying to use the headset).

Second, all of them provide this error, streamed through dmesg(8),

cannot submit datapipe for urb 0, error -28: not enough bandwidth

Regardless of if the headset is plugged into a USB2 or USB3 port, even if it’s the only device on the bus.

Thirdly, The output is always muted on first plug-in, if I unmute it once (from alsamixer or from the PulseAudio control panel) it stays unmuted until I either power the machine off, or I plug it into a different port.

… and finally, the sound crackles once it does work, no worse than any of the other models we tried, but quite badly, especially if the DSP functions on the control configuration aren’t turned up to “just the right amount”

[Frustration!]

After a little Googling, turns out 3) can be fixed a multitude of ways, the easiest fix was here

Luckily, 1) & 2) have also been handled rather ingeniously by a couple of clever people with USB headsets, involving relaunching pulseaudio from udev — which only require little modifications to get working with the Megalodon.

The original post is here and there’s a guy who’s tweaked it further to run from a single file here

If you’re using the latter of the two versions with the Megalodon, you’ll want to make the following changes:

First, save a copy of the script, or ‘git clone’ it somewhere.

Second, change line 10 and 11 to the Input and Output sources of the Megalodon, which are:

OUTPUT="alsa_output.usb-Razer_Razer_Megalodon-00-Megalodon.analog-surround-71"
INPUT="alsa_input.usb-Razer_Razer_Megalodon-00-Megalodon.analog-mono"

Lastly, change the udev line on line 48 to the following, in order to make the control of the script more fine-grained, from:

#KERNEL=="card?", SUBSYSTEM=="sound", ATTR{id}=="Everyman", ACTION=="add", 
RUN+="/path/to/this/script/usb-headset --fork"

to:

#KERNEL=="card?", SUBSYSTEM=="usb", ATTR{idVendor}=="1532", ATTR{idProduct}=="000e", 
ATTR{product}=="Razer Megalodon", ACTION=="add", 
RUN+="/path/to/this/script/usb-headset --fork"

Now save the script somewhere, change it’s permissions to 0750 and follow the instructions accordingly — at this point you’ll have working Razer Megalodon hardware, but the sound will be a bit choppy and you may experience hangs on suspend, or audio dropouts when making calls with Empathy, which are evidenced by the URB error we saw above.

These problems are fixed by tweaking the way PulseAudio works with USB hardware and, if you have Intel HD Audio hardware, the power-saving functions on the codec and controller, which appear to be a little too overzealous in Fedora 18 and Ubuntu 12.04.1 or 12.10.

To fix them, as root, first make a file in /etc/modprobe.d called “usb-audio.conf” and add the following line:

options snd-hda-intel power_save=0 power_save_controller=N

(Yes, that’s a capital N at the end of the line.)

Then, we need to change the scheduling used by PulseAudio from the “new” style back to the older timer-based style, which seems to fix the bandwidth problems caused by the DSP in this particular card — to do this, we open /etc/pulse/system.pa as root and change line:

load-module module-udev-detect

to:

load-module module-udev-detect tsched=0

Save the file and either do a pulseaudio -k as your user or reboot the system to make the entire set of changes take effect.

… and finally, after much tweaking — you should have a working Razer Megalodon card on your Linux installation that runs just as well as it does under other operating systems out-of-the-box.

note: This post also fixes Ubuntu bug 658915 — which is not necessarily fixed, but is certainly not completely broken anymore.