Send “Signal” before changing audio output configuration

Hi,

I am trying to use KODI together with snapclient. Snapclient is an audio playback software which directly plays to ALSA. It always plays 2 channel 48.000 (in my case). I am using a Raspberry PI3 with HDMI.

I made a couple of tests and realized the following scenarios:

1. Kodi plays 2 channel 48.000 (e.g. watching a TV channel) -> http://pastebin.com/xFeW9Rnw
In this case, even if snapclient is playing before KODI starts the playback, the KODI playback just blends in, since the audio output configuration is identical to the one already playing. It outputs 2 channels, and my receiver decodes this as PL2, meaning, most sound is coming out of the center box. (speech). Also if KODI playback is already running and then I start snapclient, it blends in as well.

2. Playback of e.g. 6 channel. I have to add that I am not using passthrough, since the PI cannot passthrough HD formats, so KODI decodes everything to 6 channels (I have Denon 5.1. receiver)
a) If snapclient plays first, KODI cannot change the config and this leads to stuttering noise.
b) If KODI plays first, Kodi obviously changes to 6 channel output (my receiver displays MULTI IN). Starting Snapclient afterwards leads to snapclient playing on 2 of the 6 channels blended in. (front left and front right channel). Now, if I stop the KODI playback, the receiver stays in MULTI IN, since Kodi cannot change the sound setting back. When I now start the playback of a 2 channel file or TV channel, the sound is normal, however not decoded any more by the receiver, so that I hear everything from the TV sound out of front left and front right, and no center box any more. -> http://pastebin.com/PUwNQRFT

I tried to change KODI to a fixed output configuration but 1. it has the drawback that I cannot decode PL2 any more, therefore not being able to watch TV naturally, and also, 2 channel sound is just stuttering, so I switched back to Optimized.

I have 2 ideas how this would be solved:

1. Have KODI decode PL2 internally and output it to a 6 channel layout. Is this even possible? Problably not (yet). This way I could always output 6 channels.
2. Have KODI send some kind of signal before it changes the output configuration. This way I could have snapclient release the audio device before KODI changes it. I would even be ok with KODI just killinig snapclient in order to get access to the audio device and change it however KODI wants to change it. I could have snapcast respawn itself afterwards.

Is there a solution for idea number 2 ?? Is it even clear what I want? Smile
Thanks!