[mythtv] I'm working on UNICABLE improvment - help needed

Warpme warpme at o2.pl
Tue Aug 27 08:21:23 UTC 2013


On 8/26/13 10:21 PM, Torbjörn Jansson wrote:
>>
>> 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....
>>
> If your variable is accessed by multiple threads don't forget about thread
> synchronization and do proper locking.
>
>
> _______________________________________________
> mythtv-dev mailing list
> mythtv-dev at mythtv.org
> http://www.mythtv.org/mailman/listinfo/mythtv-dev
>
Of course. Coordinating concurrent writes is very important.

However currently I stuck with much simpler problem:
To illustrate it, in test, I add in dvbchannel tune method printing (and 
only printing; no any other operations) value of var.
What is strange for me that every instance of dvbchannel prints 
different value of var.
My var is QDateTime type and it looks like value of var printed by every 
instance is very near to time of initiating this object instance.
It pretends like var is somehow "touched" when object instance is 
initiated. Why this when var is declared as static and initiated once 
only at file scope?

test code is following:

dvbchannel.h:

class DVBChannel : public DTVChannel
{
........
   private:
     static QDateTime  last_tuning;
........



dvbchannel.cpp:

QDateTime DVBChannel::last_tuning;

bool DVBChannel::Tune(const DTVMultiplex &tuning,
                       uint inputid,
                       bool force_reset,
                       bool same_input)
{

...........

LOG(VB_GENERAL, LOG_INFO, LOC +
QString("Begin tuning\nlast_tuning: %1 
").arg(last_tuning.toString("hh:mm:ss.zzz")) +
QString("\ncurrent_time: 
%1").arg(QDateTime::currentDateTime().toString("hh:mm:ss.zzz")));

.........

LOG(VB_GENERAL, LOG_INFO, LOC +
QString("End tuning\nlast_tuning: %1 
").arg(last_tuning.toString("hh:mm:ss.zzz")) +
QString("\ncurrent_time: 
%1").arg(QDateTime::currentDateTime().toString("hh:mm:ss.zzz")));

}


Output is following:

2013-08-21 10:45:37.406931 I DVBChan[1](/dev/dvb/adapter10/frontend0): 
Begin tuning
last_tuning:  10:45:37.098
current_time: 10:45:37.406
2013-08-21 10:45:37.406969 I DVBChan[1](/dev/dvb/adapter10/frontend0): 
End tuning
last_tuning:  10:45:37.098
current_time: 10:45:37.406
2013-08-21 10:45:45.549762 I DVBChan[21](/dev/dvb/adapter11/frontend0): 
Begin tuning
last_tuning:  10:45:45.321
current_time: 10:45:45.549
2013-08-21 10:45:45.549796 I DVBChan[21](/dev/dvb/adapter11/frontend0): 
End tuning
last_tuning:  10:45:45.321
current_time: 10:45:45.549

Why this ?



More information about the mythtv-dev mailing list