Hi,

2015-06-05 11:34 GMT-05:00 Wayne Merricks <[email protected]>:
> I've put together a little streaming box, the important bit being Error
> LEDs light up when no audio is playing or it has switched to a local
> fallback source (directory full of mp3s).
>
> This worked fine until I added a fallback of local files and then my
> error LEDs never triggered.  So I tried to make a fallback transition
> that would do the following:
>
> 1. Stop playing the dead live stream
> 2. Call a function that would do some system commands so that the right
> LEDs would light up
> 3. Carry on playing local files
>
> Then do the reverse when the stream came back:
> 1. Call a function to put LEDs to normal state
> 2. Switch to live stream (track_sensitive=true)
>
>
>
> Much more detail below...
>
> I have functions defined like:
>
> def playbackStopped()
>    system("/home/thevoiceasia/scripts/sendAudioStopped.sh")
> end
>
> I have two sources (one live, one local):
>
> liveStream = (input.http(id="thevoiceasia",HTTPSTREAM):source(2,0,0))
> emergency = playlist(DIRECTORY)
>
> Then I have an output straight to ALSA:
>
> output.alsa(fallible=true,on_start=playbackStarted,on_stop=playbackStopped,liveStream)
>
> This worked fine, red or green LEDs lit as expected.
>
> So I tried adding the fallback:
>
> liveStream = fallback(track_sensitive=true,[liveStream,emergency])
>
> But the error lights never turn on (because audio is always playing).
> So I googled a lot and found someone
> (http://sourceforge.net/p/savonet/mailman/message/21412775/) explaining
> defining a custom transition which confused me but I ended up with
> another function and an altered liveStream:
>
> def fallbackActive(a,b)
>    system("/home/thevoiceasia/scripts/sendFallbackActive.sh")
>    sequence([a,b])
> end
>
> liveStream =
> fallback(track_sensitive=false,transitions=[fallbackActive,fallbackActive],[liveStream,emergency])
>
> The error led does come on but it never goes off as on_start is never
> called.  So I added another fallbackInActive (the reverse light
> sequence) but now I've lost the error led again.
>
> Can anyone point out where I've screwed up?

I think your problem is simply that you call the same callback on each
transition. If I remember well, transitions are matched in the same
order as the target source so something like this:

fallback(track_sensitive=false,transitions=[goingToLiveStream,
goingToEmergency],[liveStream,emergency])

And so, you should have a function goingToLiveStream that looks like this:
def goingToLiveStream(a,b)
   system("/home/thevoiceasia/scripts/turnErrorLEDoff.sh")
   sequence([a,b])
end

And, conversely:
def goingEmergency(a,b)
   system("/home/thevoiceasia/scripts/turnErrorLEDon.sh")
   sequence([a,b])
end

Hope that helps,
Romain

------------------------------------------------------------------------------
_______________________________________________
Savonet-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/savonet-users

Reply via email to