Record line-in audio from two applications using Alsa

1

1

Im currently working on an small application which runs on a cubieboard (ARMv7, rasp-pi-like).

What I really need to do is, accessing and recording the line-in audio-signal from two different applications.

The first is PyAudio and the second an Darkice Media Streamer. The Soundcard uses the kernel driver sun4i-CODEC from the developers of the cubieboard. The Audio Layer is currently provided by ALSA Audio.

Currently both applications record from hw:0,0 and they intefere. So if I start the Darkice Client, my Python Script has no access and vice verca.

The Ouput from my arecord -L:

null
Discard all samples (playback) or generate zero samples (capture)
default
sysdefault:CARD=sun4icodec
    sun4i-CODEC, sun4i PCM
    Default Audio Device
dmix:CARD=sun4icodec,DEV=0
    sun4i-CODEC, sun4i PCM
    Direct sample mixing device
dsnoop:CARD=sun4icodec,DEV=0
    sun4i-CODEC, sun4i PCM
    Direct sample snooping device
hw:CARD=sun4icodec,DEV=0
    sun4i-CODEC, sun4i PCM
    Direct hardware device without any conversions
plughw:CARD=sun4icodec,DEV=0
    sun4i-CODEC, sun4i PCM
    Hardware device with all software conversions

This is my amixerOutput:

imple mixer control 'Master',0
  Capabilities: pvolume pvolume-joined penum
  Playback channels: Mono
  Limits: Playback 0 - 63
  Mono: Playback 63 [100%]
Simple mixer control 'LineL',0
  Capabilities: pswitch pswitch-joined penum
  Playback channels: Mono
  Mono: Playback [off]
Simple mixer control 'LineR',0
  Capabilities: pswitch pswitch-joined penum
  Playback channels: Mono
  Mono: Playback [off]
Simple mixer control 'Mic Input Mux',0
  Capabilities: volume volume-joined penum
  Playback channels: Mono
  Capture channels: Mono
  Limits: 0 - 15
  Mono: 15 [100%]
Simple mixer control 'MicL',0
  Capabilities: volume volume-joined penum
  Playback channels: Mono
  Capture channels: Mono
  Limits: 0 - 3
  Mono: 1 [33%]
Simple mixer control 'MicR',0
  Capabilities: volume volume-joined penum
  Playback channels: Mono
  Capture channels: Mono
  Limits: 0 - 3
  Mono: 3 [100%]
Simple mixer control 'Playback',0
  Capabilities: pswitch pswitch-joined penum
  Playback channels: Mono
  Mono: Playback [off]
Simple mixer control 'Capture',0
  Capabilities: cvolume cvolume-joined penum
  Capture channels: Mono
  Limits: Capture 0 - 7
  Mono: Capture 7 [100%]
Simple mixer control 'ADC Input Mux',0
  Capabilities: volume volume-joined penum
  Playback channels: Mono
  Capture channels: Mono
  Limits: 0 - 7
  Mono: 7 [100%]
Simple mixer control 'Fm',0
  Capabilities: volume volume-joined penum
  Playback channels: Mono
  Capture channels: Mono
  Limits: 0 - 7
  Mono: 7 [100%]
Simple mixer control 'FmL',0
  Capabilities: pswitch pswitch-joined penum
  Playback channels: Mono
  Mono: Playback [off]
Simple mixer control 'FmR',0
  Capabilities: pswitch pswitch-joined penum
  Playback channels: Mono
  Mono: Playback [off]
Simple mixer control 'Ldac Left Mixer',0
  Capabilities: pswitch pswitch-joined penum
  Playback channels: Mono
  Mono: Playback [off]
Simple mixer control 'Ldac Right Mixer',0
  Capabilities: pswitch pswitch-joined penum
  Playback channels: Mono
  Mono: Playback [off]
Simple mixer control 'Rdac Right Mixer',0
  Capabilities: pswitch pswitch-joined penum
  Playback channels: Mono
  Mono: Playback [off]

So whats the best solution to solve this problem? Splitting the stereo-input in two different decices? Use another audio-layer? I don't know!

Thank you in advance,

~MxAgent

Micronax

Posted 2013-07-12T15:43:56.507

Reputation: 111

Try dsnoop instead of hw. – CL. – 2013-07-12T19:28:16.923

This gives me an IOError: [Errno Input overflowed] -9981 Error while starting PyAudio.. – Micronax – 2013-07-13T13:35:18.790

Does it work with two arecord instances or other programs? – CL. – 2013-07-13T17:31:18.830

Is it possible, that this is caused by performance issues on that small ARM CPU? – Micronax – 2013-07-13T21:05:38.917

That might be possible. How much CPU load do you have when recording? – CL. – 2013-07-14T09:05:22.370

Darkice produces about 90% load - So that might be the reason why python throws an input-overflow. BUT: I also tried another icecast client called ices. This client causes about 18% CPU-Usage and python also fails with the same error. The python-script produces abput 10% cpu-load. Mysterious.. – Micronax – 2013-07-14T12:08:17.147

No answers