Hey,

Le sam. 12 janv. 2019 à 04:38, Bob Stern via Savonet-users <
savonet-users@lists.sourceforge.net> a écrit :
>
> Per Romain’s advice, I am successfully using pulseaudio to receive music
from a virtual audio device.  The virtual audio device is capturing (like
Jack) audio from a music player that can alternate between play and pause
modes.
>
> QUESTION:  Is there a way to call a handler when the audio stream from
the virtual audio device starts after having been paused?
>
> My attempts to use the on_connect & on_start callback functions in
input.pulseaudio and output.icecast were unsuccessful.  In both cases each
of the functions was called as soon as liquidsoap launched, but were never
called again regardless of my switching the music player between pause and
play modes.
>
> The pause->play transition should have been detectable by liquidsoap
because icecast server did detect it.  When the music player paused,
icecast dropped the connection to liquidsoap and its mountpoint, and then
liquidsoap would log the errors:
>         Error while sending data: could not write data to host: Broken
pipe in write()!
>         Closing connection...
>         Will try to reconnect in 3.00 seconds.
>
> icecast promptly reinstated its connection to liquidsoap and its
mountpoint when the music player resumed play mode, but the on_connect &
on_start functions were not called.
>
> Do I need to use on_blank()  instead of on_start()?  If so, can you
please provide the code?  It’s unclear to me how the source argument and
source result of on_blank() should should be associated with
input.pulseaudio() in the following command:
>
> output.icecast(%ogg(%flac(compression=5)),
> input.pulseaudio(device="4", fallible=true, on_start=pulse_start(),
on_start=pulse_start()),
> fallible=true, host="localhost", port=8000, password="sourcepwd",
mount="mystream", format="audio/ogg”,
> on_connect=on_connect(), on_start=on_start())
>
> Each callback function was as follows except for the function name and
echo’d text:
> def pulse_start()
>      system ('echo "pulse" >>
/usr/local/hqp_liquidsoap/log/on_start_on_connect_LOG.log')
>      {()}
> end

There is a mistake in the callback code here. You are passing pulse_start()
as the callback, which is the evaluation of the function pulse_start
defined above. In turn, this means that the system() call is executed when
evaluating the function and the callback eventually returned is {()}, which
is a dummy function that does nothing.

Instead, it should be:

def pulse_start()
      system ('echo "pulse" >>
/usr/local/hqp_liquidsoap/log/on_start_on_connect_LOG.log')
end

and:

output.icecast(%ogg(%flac(compression=5)),
  input.pulseaudio(device="4", fallible=true),
  fallible=true,
  host="localhost",
  port=8000,
  password="sourcepwd",
  mount="mystream",
  format="audio/ogg”,
  on_connect=on_connect,
  on_start=on_start)

By the way: there was a bug in input.pulseaudio showing two on_start
parameters, I just fixed it.

Romain
_______________________________________________
Savonet-users mailing list
Savonet-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/savonet-users

Reply via email to