View Full Version : outMod member of the In_Module struct - question.
viulian
2nd August 2007, 20:16
Hi guys!
I want to make an input plug in for WinAMP that starts to play a file (raw encoding, assumed existing on the hard disk) as soon as WinAMP starts.
Basically I have set up my input plug in, and decided to use the init() method to start up the raw decode thread [which sends the chunks to the output module].
However, it seems that the In_Module::outMod member (in the call mod.outMod->Write(...) ) fails as outMod is still NULL. My guess is that WinAMP probably populates this member when the user presses Play..
Is there a way for an input plugin to actually write data to the selected output plugin without the user intervention ?
Thanks for your answers..
DrO
2nd August 2007, 21:57
outMod is only ever guaranteed to be valid when in the playing state (since that can be changed when stopped/after a restart). the system as i understand it is only designed for use when the user has instructed playback and not the other way.
-daz
viulian
3rd August 2007, 03:49
Thanks for the reply.
What I wanted in the end is to make a streaming plugin.. I double click on an MP3 on my laptop, and another WinAMP that sits on the desktop [connected to the sound system] will start play without any other intervention.
I find it hard to always have to upload the file on desktop, connect remotely and play it there. Or other combinations with streaming servers + controlling WinAMP remotely and make it play.
Later edit:
What about writing a file on a temporary directory and make the desktop WinAMP play the .mp3 that gets uploaded while it is uploaded.
Can I issue a fake PLAY command (via SendMessage) and give it the name of the temporary file ?
viulian
3rd August 2007, 04:07
My algorithm is this one:
Laptop WinAMP:
a) connect to the Desktop WinAMP via TCP/IP.
b) send metadata informations related to the .mp3 (name, time to play, etc)
c) start sending the file.
Desktop WinAMP:
a) accept connection via TCP/IP.
b) receives metadata informations (to be able to answer WinAMP's GetFileInfo questions.
c) starts a thread that saves the remote file locally.
d) issues a fake PLAY command to WinAMP with the temp file as parameter. Only the input plugin will recognise the temporary extension and will run normally.
Does this seem doable :) ?
It seems a lot of work to do it in C (as compared to doing it in Java for example) so I am asking to save myself a lot of frustration if something is not possible :D
Thanks!
viulian
4th August 2007, 19:17
I made it :)
Right now I'm streaming from Netbeans (Java's TCP/IP is far more easier to make it run and simulate the future output plugin) to an WinAMP on a different machine, running an input plugin written in Mingw.
I start WinAMP on Desktop, and on a single button press on the laptop music starts to hear.
The issues were these ones:
a) Windows's scheduling played tricks on me; the decode thread sometime got a heluva lot more CPU time than the IO thread that was receiving the file from laptop.
b) I could not make WinAMP to populate the outMod member on my plugin. So I had to come up with a workaround: have two threads on the input plugin, one receiving a file from laptop and one decoding the file as it is downloaded.
As WinAMP is very controlling asking a lot of questions about the file - there's a need to send some metadata informations to the plugin - so it knows what to answer (as the file hasn't arrived yet locally).
Also, as soon as some data arrives, plugin has to enqueue the temporary file in the playlist, and issue a PLAY message:
SendMessage(mod.hMainWindow,WM_WA_IPC,&file,IPC_ENQUEUEFILE);
...
SendMessage(mod.hMainWindow, WM_COMMAND, WINAMP_BUTTON2, 0);
c) As the plugins are init-ed, network support isn't yet available. I need to do WSAStartup in the input plugin.
vBulletin® v3.8.6, Copyright ©2000-2013, Jelsoft Enterprises Ltd.