Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using dsnoop with input.alsa #293

Closed
StudentSA opened this issue Feb 3, 2016 · 10 comments
Closed

Using dsnoop with input.alsa #293

StudentSA opened this issue Feb 3, 2016 · 10 comments

Comments

@StudentSA
Copy link

Hi,

I would like to stream data using input.alsa however I do not want to use the "hw:1,0" device as this causes the device to enter a inaccessible/busy state to other programs.

Alsa has a builtin "dsnoop:1,0" device that allows multiple programs to read the data however liquid soap fails when using dsnoop as device.

This line works fine:

radio_stream = input.alsa(device="hw:1,0",bufferize=true)

but when replaced with this:

radio_stream = input.alsa(device="dsnoop:1,0",bufferize=true)

fails with:

2016/02/03 21:41:12 [input.alsa_4950:3] Using ALSA 1.0.28.
2016/02/03 21:41:12 [xxx:3] Connecting mount xxx for [email protected]...
2016/02/03 21:41:12 [input.alsa_4950:2] Falling back on interleaved S16LE
2016/02/03 21:41:12 [threads:1] Thread "input.alsa_4950" aborts with exception Alsa error: Invalid argument!
Thread 4 killed on uncaught exception Alsa.Invalid_argument

How can I stream from using alsa.input while still being able to use arecord on the command line?

@toots
Copy link
Member

toots commented Feb 6, 2016

Hi,

I can reproduce this. It seems like the dsnoop device doesn't offer any format compatible with liquidsoap's capabilities.

Have you tried using the default device? It seems to be working here and it's supposed to be the one with all the required features/options.

@StudentSA
Copy link
Author

The default device is associated with a specific hw type notation and will function as such. For audio devices that support multiple access to the hardware this will be fine to use however for a USB sound card (cmedia) that supports only one access it becomes problematic as multiple access needs to handled on the software level.

dsnoop is alsa's "software audio bus" and works for other applications like arecord, lame, etc. could this non support possibly just be a bug?

@StudentSA
Copy link
Author

as a workaround I have resorted to
radio_stream = input.external("arecord -f S16_LE -c1 -r44100 -t raw -D dsnoop:1,0 -",channels=1)

@toots
Copy link
Member

toots commented Feb 14, 2016

That's a nice workaround!

Have you tried using "plughw:1,0" ?

@toots
Copy link
Member

toots commented Feb 14, 2016

Otherwise, this should work:

$ cat ~/.asoundrc
liq.dsnoop {
  type dsnoop
  ipc_key 12345
  slave {
    pcm "hw:1,0"
    channels 2
  }
}

liq.input {
  type plug
  slave {
    pcm "liq.dsnoop"
  }
}

@toots
Copy link
Member

toots commented Feb 14, 2016

$ liquidsoap 'output.dummy(fallible=true,input.alsa(device="liq.input"))'

@toots
Copy link
Member

toots commented Feb 14, 2016

And the reason for the failure is that dnsoop doesn't handle conversions such as rate conversions so the format requested by liq was not available. See for instance:

$ arecord -f S16_LE -c2 -r44100 -t raw -D liq.dsnoop /dev/null
Recording raw data '/dev/null' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
Warning: rate is not accurate (requested = 44100Hz, got = 48000Hz)
         please, try the plug plugin (-Dplug:liq.dsnoop)

@StudentSA
Copy link
Author

Thanks Mr Toots,
I am using your .asound configuration solution. The only slight thing to mention is every time I start liquidsoap using the "liq.input alsa" source I get a report of Overrun. This comes up immediately at startup and never again(hopefully).

2016/02/15 20:23:18 [test:3] Connection setup was successful.
2016/02/15 20:23:18 [threads:3] Created thread "wallclock_alsa" (2 total).
2016/02/15 20:23:18 [clock:4] Main phase starts.
2016/02/15 20:23:18 [clock.wallclock_alsa:3] Streaming loop starts, synchronized by active sources.
2016/02/15 20:23:18 [input.alsa_4900:2] Overrun!
2016/02/15 20:23:18 [input.alsa_4900:2] Trying to recover..

@toots
Copy link
Member

toots commented Feb 15, 2016

Yeah, it shouldn't be a big deal..

@toots toots closed this as completed Feb 15, 2016
@hakao32
Copy link

hakao32 commented Jan 20, 2020

Hello toots and everyone,
I made the asound as you told but I recieve

2020/01/20 11:56:48 [/stream(dot)1:3] Connecting mount /stream for [email protected]...
2020/01/20 11:56:51 [/stream(dot)1:2] Connection failed: could not write data to host: No route to host in write()
2020/01/20 11:56:51 [/stream(dot)1:3] Will try again in 3.00 sec.
2020/01/20 11:56:51 [input.alsa_5090:2] Overrun!
2020/01/20 11:56:51 [input.alsa_5090:2] Trying to recover..

It only happens when connection lost with icecast server. I loopback the audio and a hear only "hşşştşshşşs"

When connection established wtih icecast I recieved

2019/12/30 11:42:40 [/stream:3] Closing connection...
2019/12/30 11:42:40 [main:3] Waiting for threads to terminate...
2019/12/30 11:42:40 [main:3] Shutdown started!
2019/12/30 11:42:40 [/club106/mpeg:3] Closing connection...
2019/12/30 11:42:40 [stderr:3] bitsperframe: 5016
2019/12/30 11:42:40 [stderr:3] total bits: 7032 (remainder: 0)
2019/12/30 11:42:40 [stderr:3] data bits: 6741
2019/12/30 11:42:40 [stderr:3] header and sideinfo: 288
2019/12/30 11:42:40 [stderr:3] resv drain (pre) 197984
2019/12/30 11:42:40 [stderr:3] resv drain (post) 3
2019/12/30 11:42:40 [stderr:3] Resvoir size: 4088
2019/12/30 11:42:40 [stderr:3] l3_side->main_data_begin: 204088
2019/12/30 11:42:40 [clock.wallclock_alsa:2] Source /club106/mpeg failed while streaming: Lame.Unknown_error(-1)!
2019/12/30 11:42:40 [stderr:3] This is a fatal error. It has several possible causes:90% LAME compiled with buggy version of gcc using advanced optimizations 9% Your system is overclocked 1% bug in LAME encoding libraryInternal buffer inconsistency. flushbits <> ResvSizebit reservoir error:

how can I fix this issue? There is no error when I use "plughw:1,0" as device but dsnoop make things wrong.

edit:
I also tried

radio_stream = input.external("arecord -f S16_LE -c2 -t raw -D dsnooped",channels=2)

as StudentSA workaround and then I recieved. When I loopback the audio, I hear the audio with breathtakings.

2020/01/20 12:18:32 [STREAM:3] Connecting mount /stream for [email protected]...
2020/01/20 12:18:35 [STREAM:2] Connection failed: could not connect to host: No route to host in connect()
2020/01/20 12:18:35 [STREAM:3] Will try again in 3.00 sec.
2020/01/20 12:18:35 [clock.wallclock_main:2] We must catchup 3.04 seconds!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants