[pulseaudio-discuss] Detecting success/error in cli protocol?

Tanu Kaskinen tanuk at iki.fi
Wed May 23 14:42:24 UTC 2018


On Thu, 2018-05-17 at 08:28 +0200, Tomaž Šolc wrote:
> (apologies for sending an incomplete mail earlier)
> 
> Hi
> 
> is there a way to detect that a CLI command has succeeded or failed when
> using the socket interface offered by module-cli-protocol-unix?
> 
> Specifically I'm currently interested in the "play-file" command (which 
> seems to be only accessible over the CLI interface). If the command 
> fails because the daemon can't read the file, there is no error message 
> returned back through the socket. Any error is only written to syslog.
> 
> In general I don't see any way of getting back the success/error status 
> of a command. pulse-cli-syntax man page does not mention anything in 
> this regard. "pacmd" also does not signal failures through its exit code.
> 
> I see that individual handlers in cli-command.c (including 
> pa_cli_command_play_file) return -1 on error, but this status seems to 
> be lost somewhere down the line. Is see that in line_callback() in cli.c 
> the return value of pa_cli_command_execute_line() is ignored.
> 
> Does anyone have any thoughts on how proper error handling could be 
> implemented in the cli interface? I would be happy to work on a patch to 
> fix this.

Getting an error message from the "play-file" command is just a matter
of printing the error in pa_cli_command_play_file(). It already prints
errors when it detects bad parameters, but if pa_play_file() fails,
that doesn't currently result in any error message. A patch for this
would be welcome.

You asked about "proper" error handling, and in my view that includes
something better than just ad-hoc error messages. The CLI interface is
what it is, and I don't like the idea of trying to make it a proper
programming interface. The native protocol is what applications should
use.

A "play file" command could be added to the native protocol, although
I'm not sure it should. PulseAudio isn't a media player, after all...

-- 
Tanu

https://liberapay.com/tanuk
https://www.patreon.com/tanuk


More information about the pulseaudio-discuss mailing list