-
Notifications
You must be signed in to change notification settings - Fork 354
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide audio format to pipe output command #4
Provide audio format to pipe output command #4
Conversation
So far, the pipe output of MPD had the problem that the commands in the pipe had no information about the format of the raw audio data sent into the pipe. With this patch mpd sets the environment variables MPDPIPE_BITS, MPDPIPE_CHANNELS, MPDPIPE_RATE to the number of bits per sample, the number of channels, and the sample rate of the raw PCM sent to the pipe, respectively. These variables can then be used in the command or within a script which is started for the pipe.
This is a nicer version to achieve the same as the rejected pull request #3. Thanks for the hint to set environment variables; I was not aware of the rules for the environment of a process started with The code works fine for me (and is indeed much nicer than in #3), an adjustment of the documentation is included. |
This implementation is not acceptable, because it leaks the environment variables to the MPD process as well. The problem is, of course, that |
I cannot see any problem with setting these environment variables for the MPD process itself. |
Your code will not compile on Windows, because Windows has no fork(). |
I wasn't aware that MPD can be used on Windows. I don't have any Windows system and do not know how to find out what is available there. (Have only used cygwin which does have fork().) You didn't mention Windows after commit d1f170e. Does that work on Windows? |
I wrote "This is where you should use |
Use earlier version on Windows because fork() is not available. Add explicit call of wait to Close method to avoid zombies.
Ok, thanks for the hint. |
@@ -84,12 +97,30 @@ PipeOutput::Create(const ConfigBlock &block, Error &error) | |||
return po; | |||
} | |||
|
|||
#define set_MPDPIPE_vars(audio_format) {\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't write preprocessor macros when you can write C++.
It's been 3 months without a reply. Closing for now. |
this fixes listening on the XDG runtime dir socket if binding to the configured tcp port fails. while listen_global_init() does in fact start listening on the XDG runtime dir socket, a failure to listen to the configured port causes all listener fd's, including the perfectly valid unix socket, to be closed: (gdb) bt #0 close (fd=10) at src/unistd/close.c:15 MusicPlayerDaemon#1 0x00005555555b2db7 in FileDescriptor::Close (this=0x7fffec777f80) at ../src/io/FileDescriptor.hxx:201 MusicPlayerDaemon#2 0x0000555555635a51 in SocketEvent::Close (this=0x7fffec777f58) at ../src/event/SocketEvent.cxx:46 MusicPlayerDaemon#3 0x00005555556385a0 in ServerSocket::OneServerSocket::Close (this=0x7fffec777f50) at ../src/event/ServerSocket.cxx:83 MusicPlayerDaemon#4 0x0000555555637777 in ServerSocket::Close (this=0x7fffef911f90) at ../src/event/ServerSocket.cxx:270 MusicPlayerDaemon#5 0x00005555556374d5 in ServerSocket::Open (this=0x7fffef911f90) at ../src/event/ServerSocket.cxx:260 MusicPlayerDaemon#6 0x00005555555bb0a4 in listen_global_init (config=..., listener=...) at ../src/Listen.cxx:139 MusicPlayerDaemon#7 0x0000555555583c9b in MainConfigured (options=..., raw_config=...) at ../src/Main.cxx:355 MusicPlayerDaemon#8 0x000055555558467e in MainOrThrow (argc=3, argv=0x7fffffffe738) at ../src/Main.cxx:663 MusicPlayerDaemon#9 0x00005555555846fa in mpd_main (argc=3, argv=0x7fffffffe738) at ../src/Main.cxx:669 MusicPlayerDaemon#10 0x000055555558475d in main (argc=3, argv=0x7fffffffe738) at ../src/Main.cxx:681 to fix that, consider listeners added by AddFD "good" so that it is kept open even if the tcp listens fail.
So far, the pipe output of MPD had the problem that the commands
in the pipe had no information about the format of the raw audio data
sent into the pipe.
With this patch mpd sets the environment variables
MPDPIPE_BITS,
MPDPIPE_CHANNELS,
MPDPIPE_RATE
to the number of bits per sample,
the number of channels, and the sample rate of the raw PCM sent to the
pipe, respectively. These variables can then be used in the command or
within a script which is started for the pipe.