Thanks a lot for the warning, start_playback looks good.
There is already a workaround in Audio._setup_preferences with the TODO comment in commit https://github.com/mopidy/mopidy/commit/fd9100a5f330db4d98d32abe4d7dbb62330e21f2#diff-41786cf21d61f8d773107bc83320f891R304 . I would prefer being able to insert a piece of code (or extend, or any other way to run custom code before actual playback starts).
However, each backend should have a way to override the default enable_output behaviour. I will have AnalogInputBackend and SPDIFInputBackend, which will not play anything through gstreamer, just reconfigure the input switch (for AnalogInputBackend) or the soundcard controls (for SPDIFInputBackend). These backends will publish their own playlists with their own uri_schemes. When one of their tracks is selected to play, the backend should switch the inputs or reconfigure the soundcard accordingly. That way any MPD/web client can control hardware facilities of the appliance.
My idea was to catch the to-be-played uri in my set_uri(uri) “hacked” method and act as relevant for the actual uri_scheme. I am not sure the Audio.start_playback() or potential mixer.enable_output() would have this key information available. Unless the potential method was overridable in individual backends, that would be perfect solution.
But AFAIU I can provide my own audio class for these nonstandard backends so that should be doable with existing API.
I very much appreciate your opinion.