Home of the Squeezebox™ & Transporter® network music players.

Go Back   Squeezebox : Community : Forums > Developer Forums > Developers
User Name
Password

Reply
 
Thread Tools Search this Thread Display Modes
  #61  
Old 2008-04-14, 11:53
Triode Triode is offline
Senior Member
 
Join Date: Apr 2005
Posts: 3,724
Triode is on a distinguished road
Default Fast-forward/rewind resign

>> I noticed that the scanner plugin didn't support multiple players - it
>> kept the current scan state in global variables rather than per
>> client.
>> I've just committed a fix for this to 7.1. R18754

>
> Thanks, but can you rework that so it stores the data needed using a
> method in $client? Using a global variable is bad and will lead to
> memory leaks.


Given its in a plugin it should probably use $client->pluginData to store
stuff.

Reply With Quote
  #62  
Old 2008-04-14, 12:23
andyg's Avatar
andyg andyg is offline
Slim Devices Developer
 
Join Date: Jan 2006
Location: Pittsburgh, PA
Posts: 6,329
andyg is on a distinguished road
Send a message via AIM to andyg
Default Fast-forward/rewind resign

On Apr 14, 2008, at 2:53 PM, Triode wrote:
>>> I noticed that the scanner plugin didn't support multiple players
>>> - it
>>> kept the current scan state in global variables rather than per
>>> client.
>>> I've just committed a fix for this to 7.1. R18754

>>
>> Thanks, but can you rework that so it stores the data needed using a
>> method in $client? Using a global variable is bad and will lead to
>> memory leaks.

>
> Given its in a plugin it should probably use $client->pluginData to
> store
> stuff.


Yeah good idea.
Reply With Quote
  #63  
Old 2008-04-14, 14:23
max.spicer's Avatar
max.spicer max.spicer is offline
Senior Member
 
Join Date: Apr 2005
Location: York, United Kingdom
Posts: 1,661
max.spicer is on a distinguished road
Default

Quote:
Originally Posted by andyg View Post
On Apr 14, 2008, at 1:53 PM, max.spicer wrote:
>
> I noticed that the scanner plugin didn't support multiple players - it
> kept the current scan state in global variables rather than per
> client.
> I've just committed a fix for this to 7.1. R18754


Thanks, but can you rework that so it stores the data needed using a
method in $client? Using a global variable is bad and will lead to
memory leaks.
Interesting. The global is exactly what random mix does (or at least did...), so I'll take a look at that at the same time. Any good examples in existing code to copy?

Max
__________________
Some people think the title of this song is irrelevant,
but it's not irrelevant - it's a hippopotamus.
Reply With Quote
  #64  
Old 2008-04-14, 14:29
andyg's Avatar
andyg andyg is offline
Slim Devices Developer
 
Join Date: Jan 2006
Location: Pittsburgh, PA
Posts: 6,329
andyg is on a distinguished road
Send a message via AIM to andyg
Default

It's possible to do global variables like that but you have to be really careful and know when to clean up the data. It's much easier to keep all the data tied to the client object and then it goes away automatically. RandomPlay is probably full of memory leaks as well.
Reply With Quote
  #65  
Old 2008-04-14, 15:10
max.spicer's Avatar
max.spicer max.spicer is offline
Senior Member
 
Join Date: Apr 2005
Location: York, United Kingdom
Posts: 1,661
max.spicer is on a distinguished road
Default

Quote:
Originally Posted by andyg View Post
It's possible to do global variables like that but you have to be really careful and know when to clean up the data. It's much easier to keep all the data tied to the client object and then it goes away automatically. RandomPlay is probably full of memory leaks as well.
A good example of code that puts custom data into the client object would be appreciated - it would save me a good bit of grepping. I'll hopefully have some time to look at this tomorrow.

Cheers,

Max
__________________
Some people think the title of this song is irrelevant,
but it's not irrelevant - it's a hippopotamus.
Reply With Quote
  #66  
Old 2008-04-14, 15:13
max.spicer's Avatar
max.spicer max.spicer is offline
Senior Member
 
Join Date: Apr 2005
Location: York, United Kingdom
Posts: 1,661
max.spicer is on a distinguished road
Default

Quote:
Originally Posted by Triode View Post
>> I noticed that the scanner plugin didn't support multiple players - it
>> kept the current scan state in global variables rather than per
>> client.
>> I've just committed a fix for this to 7.1. R18754

>
> Thanks, but can you rework that so it stores the data needed using a
> method in $client? Using a global variable is bad and will lead to
> memory leaks.


Given its in a plugin it should probably use $client->pluginData to store
stuff.
Missed this reply somehow. Thanks - I'll check that out.

Max
__________________
Some people think the title of this song is irrelevant,
but it's not irrelevant - it's a hippopotamus.
Reply With Quote
  #67  
Old 2008-04-14, 15:18
kdf's Avatar
kdf kdf is offline
NOT a Slim Devices Employee
 
Join Date: Apr 2005
Posts: 9,488
kdf is on a distinguished road
Default Fast-forward/rewind resign

>
> andyg;291487 Wrote:
>> It's possible to do global variables like that but you have to be really
>> careful and know when to clean up the data. It's much easier to keep
>> all the data tied to the client object and then it goes away
>> automatically. RandomPlay is probably full of memory leaks as well.

>
> A good example of code that puts custom data into the client object
> would be appreciated

check out the included scrobbler plugin. That's making extensive use of
pluginData.
-k

Reply With Quote
  #68  
Old 2008-04-15, 06:41
max.spicer's Avatar
max.spicer max.spicer is offline
Senior Member
 
Join Date: Apr 2005
Location: York, United Kingdom
Posts: 1,661
max.spicer is on a distinguished road
Default

I notice that Client:luginData() replaces $client with Sync::masterOrSelf($client). Is this really right? I'd have thought there are many situations where you'd want to treat two clients differently, even if they do happen to be synced.

Max
__________________
Some people think the title of this song is irrelevant,
but it's not irrelevant - it's a hippopotamus.
Reply With Quote
  #69  
Old 2008-04-15, 06:56
andyg's Avatar
andyg andyg is offline
Slim Devices Developer
 
Join Date: Jan 2006
Location: Pittsburgh, PA
Posts: 6,329
andyg is on a distinguished road
Send a message via AIM to andyg
Default Fast-forward/rewind resign

On Apr 15, 2008, at 9:41 AM, max.spicer wrote:
>
> I notice that Client:luginData() replaces $client with
> Sync::masterOrSelf($client). Is this really right? I'd have thought
> there are many situations where you'd want to treat two clients
> differently, even if they do happen to be synced.


That's a good question, for all the plugins I'm using this for now it
seems to be the right thing to do. But I guess if for some reason you
wanted to seek on multiple synced players at the same time you might
have an issue with that.
Reply With Quote
  #70  
Old 2008-04-15, 07:06
Millwood's Avatar
Millwood Millwood is offline
Senior Member
 
Join Date: Jan 2006
Posts: 689
Millwood is on a distinguished road
Default

Certainly when players are synced and you do a seek on any one of them, it must effect them all, or they won't be sync'd anymore.

Have no idea if this is relevant to the code you're asking about.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 07:20.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.