Re: [mpg123-users] Win32/64 remote control
Brought to you by:
sobukus
From: Myles <smp...@gm...> - 2015-12-30 05:26:04
|
I tried launching independently and just writing to it. No dice. I spent a few hours looking at Ruby's win32-pipe gem. I can get their Hello World working. I checked the mpg123 source code. Do you guys prepend \\.pipe\ to the name? That's what the Ruby win32-pipe code does. See here: https://msdn.microsoft.com/en-us/library/windows/desktop/aa365588(v=vs.85).aspx LPTSTR lpszPipename = TEXT("\\\\.\\pipe\\mynamedpipe"); And in the Ruby gem: https://github.com/djberg96/win32-pipe/blob/ffi/lib/win32/pipe.rb # Abstract initializer for base class. This handles automatic prepending # of '\\.\pipe\' to each named pipe so that you don't have to. Don't # use this directly. Add the full implementation in subclasses. # # The default pipe mode is PIPE_WAIT. # # The default open mode is FILE_ATTRIBUTE_NORMAL | FILE_FLAG_WRITE_THROUGH. # def initialize(name, pipe_mode = DEFAULT_PIPE_MODE, open_mode = DEFAULT_OPEN_MODE, pipe_buffer_size = DEFAULT_PIPE_BUFFER_SIZE) @name = "\\\\.\\pipe\\" + name And in the server sub-class: https://github.com/djberg96/win32-pipe/blob/ffi/lib/win32/pipe/server.rb def initialize(name, pipe_mode = 0, open_mode = Pipe::ACCESS_DUPLEX, pipe_buffer_size = DEFAULT_PIPE_BUFFER_SIZE) super(name, pipe_mode, open_mode, pipe_buffer_size) @pipe = CreateNamedPipe( @name, @open_mode, @pipe_mode, PIPE_UNLIMITED_INSTANCES, pipe_buffer_size, pipe_buffer_size, PIPE_TIMEOUT, nil ) mpg123 code: int win32_fifo_mkfifo(const char *path) { HANDLE ret; win32_fifo_close(); #ifdef WANT_WIN32_UNICODE wchar_t *str; if(win32_utf8_wide(path,&str,NULL) == 0) { fprintf(stderr,"Cannot get FIFO name, likely out of memory\n"); return -1; } #if (DEBUG == 1) fwprintf(stderr,L"CreateNamedPipeW %ws\n", str); #endif ret = CreateNamedPipeW(str,PIPE_ACCESS_DUPLEX|FILE_FLAG_OVERLAPPED,PIPE_TYPE_BYTE,1,255,255,0,NULL); free(str); #else #if (DEBUG == 1) fprintf(stderr,"CreateNamedPipeA %s\n", path); #endif ret = CreateNamedPipeA(path,PIPE_ACCESS_DUPLEX|FILE_FLAG_OVERLAPPED,PIPE_TYPE_BYTE,1,255,255,0,NULL); #endif /* WANT_WIN32_UNICODE */ if(ret == INVALID_HANDLE_VALUE) return -1; fifohandle = ret; /* Wait for client */ ConnectNamedPipe(fifohandle,&ov1); WaitForSingleObjectEx(fifohandle,INFINITE,TRUE); return 0; } #endif /* WANT_WIN32_FIFO */ On Tue, Dec 29, 2015 at 5:30 PM Myles <smp...@gm...> wrote: > I had already visited the MSDN site at that link thinking just like you > (nothing is ever as it seems [it should be] in Windows). I'm running the > script like so in a cmd window: > > ruby remote_control_test.rb > > My naive expectation is that audio will just start playing (remember, just > giving 'mpg123 file.mp3' works on the command line). I also tried launching > with rubyw.exe. That didn't work either. > > You know, I bet you're right. I bet I need to empty (and keep emptying) > the stdout pipe to let mpg123 progress. I'm out of time today. I'll try > that when I'm back in the saddle again. And if it doesn't work, I'll also > try independent launch/write. > > > On Tue, Dec 29, 2015 at 5:24 PM Thomas Orgis <tho...@or...> > wrote: > >> Am Tue, 29 Dec 2015 23:06:19 +0000 >> schrieb Myles <smp...@gm...>: >> >> > Open3.pipeline_rw('mpg123.exe -R --fifo mpg123.control') do |stdin, >> stdout, >> > wait_threads| >> > sleep 1 >> > cmd_term = "\r\n" >> > File.open('mpg123.control', 'w+') do |fh| >> >> Are you listening on the standard output of mpg123? You're opening a >> 3-way pipe, yes? Mpg123 could get stuck writing where noone is listing. >> >> Can you just start mpg123 independently and just open the FIFO in your >> program? I have the suspicion that you need to access the FIFO / named >> pipe differently: >> >> >> https://msdn.microsoft.com/en-us/library/windows/desktop/aa365590%28v=vs.85%29.aspx >> >> Under Unix, it's just like opening a regular file, not so on Windows. >> >> >> Alrighty then, >> >> Thomas >> > |