PDA

View Full Version : Completely lost with Plugin devlopment/SlimServer source/Perl



Jim
2005-05-16, 11:45
First off let me explain I don't know Perl, but I do know VB, COBOL & some C.

What I'm trying to do I don't think is hard, but cannot get anywhere due to my extreme Perl/Slimserver Dev noobishness. I cannot even get the HelloWorld example plugin working - I presume because it is old v5 code?

Anyhow, I've modified the convert.conf file to include a extra parameter (BLAH) in the FLAC transcoding as follows:



flc wav * *
[flac] $BLAH$ -dcs --force-raw-format --endian=little --sign=signed --skip=$START$ --until=$END$ -- $FILE$


I've even written a fake flac.exe to check that this variable is being passed - it is (but is empty).

My problem is where/how do I populate this variable within the Slimserver code, or indeed via a plugin? At the moment I don't care which so a hardcoded line in the code would suit me at the moment.

I think once I understand a few basic things I should be well on my way, but the problem is on the Wiki etc... I cannot find them :(

Thanks in advance

kdf
2005-05-16, 12:07
Look in Slim/Player/Source.pm for tokenizeConvertCommand

That is where the substitution is done. I don't believe there are any hooks for
doing this via a plugin. AlienBBC does make use of a #PIPE# token, but I
think that might be passed to their socketwrapper as oppsed to being translated
during the conversion.

-kdf

Triode
2005-05-16, 12:18
> Look in Slim/Player/Source.pm for tokenizeConvertCommand
>
> That is where the substitution is done. I don't believe there are any hooks for
> doing this via a plugin. AlienBBC does make use of a #PIPE# token, but I
> think that might be passed to their socketwrapper as oppsed to being translated
> during the conversion.

Yes this is passed to socketwrapper and hence is not looked at by the server.

Could you explain what you are trying to do? [It may be that a plugin could alter the command line stored in memory after parsing
convert.conf. I wouldn't recommend it though!]

Adrian

Jim
2005-05-16, 12:57
Thanks all for your replies.

What I am trying to do is set $BLAH$ to one of the following 3 variables, which will hopefully be able to be changed via the remote & the web interface.

'' (nothing)

'--apply-replaygain-which-is-not-lossless=a ' (ReplayGain - album mode)

'--apply-replaygain-which-is-not-lossless=t ' (ReplayGain - track/radio mode)

Yes, it's a ReplayGain hack - but I am sick of having to modify the convert file manually and restart the server when I switch from playing compilations/mixed up playlists to full albums etc...

Yes, it won't work with SB2 native FLAC support either, but I've got a SB1.

Jim
2005-05-16, 15:10
I'm trying to follow some Perl tutorials and put them into action with Slimserver.

For instance, if I put this in some code (that I know is ran) why do I get no output in the console window:



print 'BLAH BLAH BLAH';


I've even looked into the debug routines, and tried this and got no results:



print STDERR 'BLAH BLAH BLAH';

kdf
2005-05-16, 15:19
Quoting Jim <Jim.1p5auz (AT) no-mx (DOT) forums.slimdevices.com>:

>
> I'm trying to follow some Perl tutorials and put them into action with
> Slimserver.

how are you running slimserver?

a simple print statement should work.
as should Slim::Utils::Misc::msg("some debug message\n");
The latter would include a timestamp.

-kdf

Jim
2005-05-16, 16:53
No wonder I've been having problems.

You guys are gonna love this - yes a good laugh (at my expense). I couldn've kept this quiet, but in the interests of preserving my stupidity in case someone else repeats it (as if!?) I will reveal all in this post.

As I said in post #1, I know sod-all about Perl. People are always talking about Perl scripting etc... and before I came to use Slimserver I alwas associated Perl with web-development and script files.

Also I hate reading tutorials, but do skim over them if I am stuck. If worse gets to worse I will ask a question. Obviously things were bad for me today then.

All I've noticed in the past was that I can download a .pl plugin for example and it runs/works with SlimServer. Must be intereperated somewhere by whatever happens in slim.exe...right?

So I presumed I change one of SlimServer's .pl files and it has immediate changes (once I shutdown/restart the server), just like back in the days on my Amstrad CPC464 with it's interperated BASIC.

DOH !

Whenever I heard talk of "builds" I just presumed it meant throwing all the .pl sources together and generating the installation stuff - not actually COMPILING Perl code !

So all this time I've been running slim.exe I've just been running slim.exe as it was last compiled - slim.exe wasn't interperating the modified .pl files as I thought, it only does that trick with plugins.

Now I've actually downloaded ActivePerl I am actually seeing changes !

Right, now on with my learning....must get all those enhancement requests on the BugZilla done by Friday :p

kdf
2005-05-16, 20:58
On 16-May-05, at 4:53 PM, Jim wrote:
>
> Right, now on with my learning....must get all those enhancement
> requests on the BugZilla done by Friday :p
>
best way to learn! now aim for the deep part and jump...
-k

Jim
2005-05-16, 21:18
Thanks for your help KDF, I didn't say which Friday :P

I've got what I wanted to do working at a basic level - for now I have added a prefs option where you type in the mode, e.g. "--apply-replaygain-which-is-not-lossless=a" and it all hangs together nicely in a horrible kind of way (?). Well, it suits me, but is no way near presentable to the world.

What I'm gonna aim for tomorrow is just 1 line of code changed in the actual slimserver codebase and everything else put into a plugin. Obvioulsy if the plugin wasn't installed my code will be smart enough not to break anything.

Realistically what are the chances of a change to the actual slimserver code (to support a Plugin) being allowed to be submitted and going through to the v6.x live branch?

I'm a bit puzzled as to why nobody else has tackled this ReplayGain thing - I'm only interested in FLAC myself so will keep my "hack" version running live on my server regardless.

A few more questions I have if anyone can help:

I've started using CVS, but noticed if I run the code from that location all the cache/prefs files are created there - how can I prevent my CVS folder from getting contaminated with run-time files ? Do I have to have to run the source from another location as I am at the moment ? Is there some way of ensuring that if ever Slim had the misfortune to recieve a checkin from me that I wouldn't send them these useless files?

How easy is it to compile the source on a Windoze system?

I am looking forward to not having to download big nightly releases and want to set up my own batches to grab the latest CVS branch and compile it myself.

kdf
2005-05-16, 22:08
On 16-May-05, at 9:18 PM, Jim wrote:
>
>
> Realistically what are the chances of a change to the actual slimserver
> code (to support a Plugin) being allowed to be submitted and going
> through to the v6.x live branch?

plugin specific code is a no-no, but code that creates a feature to
support the requirement of a plugin might. its a fine line, mostly it
comes down to how you write it. You can't know what's going to go in
until a diff is presented and the reason why it needs to be there.
>
> I'm a bit puzzled as to why nobody else has tackled this ReplayGain
> thing - I'm only interested in FLAC myself so will keep my "hack"
> version running live on my server regardless.

I'm not. It may seem cynical and harsh, but a lot more people are
willing to vote than to actually try writing the code. The insane
hours I've lost trying to fix what on the outset seemed to need just a
few lines of code has given me a real appreciation for what might only
'appear' simple. I also have a lot more tolerance for a minor nuisance
because i can see that it is really easier to work with it than to hack
it away.

>
> A few more questions I have if anyone can help:
>
> I've started using CVS, but noticed if I run the code from that
> location all the cache/prefs files are created there - how can I
> prevent my CVS folder from getting contaminated with run-time files ?
> Do I have to have to run the source from another location as I am at
> the moment ?

the prefs file location is a tricky one, but the cachedir, and
playlistdir can be set via the prefs file. That way you can at least
have that somewhere else. You could also consider creating a .BAT file
that makes use of the --prefsfile command option to relocate your
prefs. Using subversion, however, as long as you dont 'add' the file,
they are ignored when comparing and updating.

>
> How easy is it to compile the source on a Windoze system?

i've never tried, since the dev kit is a fair bit of money for
something I don't consider useful. Spend the money on UltraEdit
instead.

>
> I am looking forward to not having to download big nightly releases and
> want to set up my own batches to grab the latest CVS branch and compile
> it myself.
>

if you are updating the source, why do you even need to compile? The
way I have always seen it, the installer is the only thing that is
useful (for ease of setup). Once you make the step to use source, I
just dont see the point. if you want it as a service, download
firedaemon and use that. The windows web GUI is such an old version if
EI that it is also just a nuisance.

-kdf

Jim
2005-05-17, 07:28
Thanks again for your answers, I hope once I'm a bit more experienced to have a stab at updating the wiki as it seems to me maybe some are put off having a go due to the lack of info for people who are new to Perl/Slimserver/Open Source coding. I shall of course use anything useful I see in these forums.



plugin specific code is a no-no, but code that creates a feature to support the requirement of a plugin might. its a fine line, mostly it comes down to how you write it. You can't know what's going to go in until a diff is presented and the reason why it needs to be there.


Well, for example would the following pseudo-code cross that line:



If this is a FLAC file
If ReplayGain variable is defined
Pass it to command string
Else
Do nothing with it
Endif
Endif


Obvioulsy only the plugin defines that variable if it is installed & activated.



if you are updating the source, why do you even need to compile?

Well, I naturally presumed that compiling the source would make it faster. I've not done any comparisons as I'm deving on a different machine with a lower spec than my live server.

Is this another incorrect assumption I've made?

kdf
2005-05-17, 09:56
Quoting Jim <Jim.1p6jzz (AT) no-mx (DOT) forums.slimdevices.com>:


> Well, for example would the following pseudo-code cross that line:

I dont know offhand why the different replaygain commands are needed, but you
could probably even simplify that to not bother detectign FLAC. call the
variable $GAIN$ or something similar, and it could possibly be an applicable
place to put other gain-adjusting terms for other formats. There is nothing
horrible about the pseudo-code, so anything is possible, since it could be
close to only 2 lines of code wedged into an existing translation subroutine.
Ultimately, the decision falls to those with an @slimdevices email addy :)

> Well, I naturally presumed that compiling the source would make it
> faster.

The exe isn't so much compiled, as simply bundled with the interpreter as an
exe. So, it should run just about the exact same speed. My personal
experience, it felt to me like the EXE was actually a bit slower. No
explanation why, maybe the extra bulk due to the GUI.
-kdf

-kdf