[mythtv] I'm working on UNICABLE improvment - help needed
warpme at o2.pl
Mon Aug 26 19:55:59 UTC 2013
On 8/26/13 5:37 PM, Jean-Yves Avenard wrote:
> On 26 August 2013 21:06, warpme <warpme at o2.pl> wrote:
>> Forgive me maybe lame question, but c++ isn't thing I know enough.
>> I want to share&use global variable between all instances of dvbchannel
>> My idea was to declare this variable as static in dvbchannel.h.
>> class DVBChannel : public DTVChannel
>> static QDateTime last_tuning;
>> It compiles, but unfortunately linker returns:
>> ../../libs/libmythtv/libmythtv-0.27.so: undefined reference to
>> So what is best way to declare global, shared variable used by all instances
>> of dvbchannel ?
> if you define a static variable, it can't be just defined in the header.
> so in your cpp add something like:
> QDataTime DVBChannel::last_tuning;
> mythtv-dev mailing list
> mythtv-dev at mythtv.org
Thx You found time to respond.
Indeed it should be initialized out of class level to allocate memory.
Now compiles OK :-)
But I'm surprised by results: it looks like variable is still not global
across all dvbchannel instances but seems to be still instance specific.
What I want to achieve is an semi-serialization on SCR(unicable) bus.
Currently all dvbchannels objects are living in parallel with full
isolation with relation: phy tuner<->dvbchannel object(instance).
This is OK as phy tuners are physically separate.
Unicable however has shared SCR bus and in proper design multiple tuners
access to this bus should be coordinated.
During last year I solved this by predictably delaying event processing
in recorders - so I can easy setup system with starting 16 concurrent
recordings and it works without issues.
Price in this solution is delayed start of recordings. For 20 tuners
system delay might be even 10s.
Now I want to change solution to little more sophisticated.
Going back to our topic: using static variable gives me following situation:
time t1: tuner1 dvbchannel instance sets var=t1
time t2: tuner2 dvbchannel instance reads var and var=t2, not t1
So it looks like I'm still missing something here....
More information about the mythtv-dev