Setting up C-Media USB Headphone Set in mixer mode

I’ve recently purchased a C-Media USB Headphone Set USB sound card. And am able to play MPD through it. I can’t however play a second sound when mopidy is playing a stream. If a play a file with aplay I get the following error:

aplay: main:722: audio open error: Device or resource busy

How can I configure Mopidy so that it uses mixing and doesn’t ‘claim’ the device? I’m relatively new to Raspbian. And I’m using raspbian Jessie latest release.

Much obliged

p.s. Thanx for creating this great music player. I already used Pi MusicBox for a long time. But decided to try Mopidy without Wouter’s add ons.

You probably need to configure an alsa dmix device. Impossible to stream another sound when mpd is used (Device or resource busy)

Thank you. I’ll give it a try

The link you’ve provided helped me out a lot. But I had to add some permissions (ipc_perm). So for anyone who comes across the same problem. Here’s my /etc/asound.conf

pcm.dmixed {
type dmix
ipc_key 1024
ipc_key_add_uid 0
ipc_perm 0666
slave.pcm “hw:1,0”
pcm.dsnooped {
type dsnoop
ipc_key 1025
slave.pcm “hw:0,0”

pcm.duplex {
type asym
playback.pcm "dmixed"
capture.pcm “dsnooped”

pcm.!default {
type plug
slave.pcm “duplex”

ctl.!default {
type hw
card 1

My [audio] config section in /etc/mopidy/mopidy.conf is the following:

mixer_volume = 100
output = alsasink device=dmixed

These config work for me. I’m running mopidy on raspberry jessie with mopidy installed as service.

This week I received a mini Hifiberry. And a hard time getting it to work with ALSA. The previous config worked perfectly for a cheap USB sound card. But the hifiberry mini also needs a soft volume. After searching around I came accross this simple asound.conf which works perfect and is much more simple.

pcm.!default {
type plug
slave.pcm “softvol” #make use of softvol

pcm.softvol {
type softvol
slave {
pcm “dmix” #redirect the output to dmix (instead of “hw:0,0”)
control {
name “PCM” #override the PCM slider to set the softvol volume level globally
card 0

Configuring Mopidy is also much more simple.

mixer = alsamixer
output = autoaudiosink

card = 0
control = PCM

Just in case someone runs into the same problem