Ticket #820: dvbswitchto.patch
File dvbswitchto.patch, 5.2 KB (added by , 20 years ago) |
---|
-
libs/libmythtv/dvbchannel.h
63 63 64 64 // Commands 65 65 bool SwitchToInput(const QString &inputname, const QString &chan); 66 bool SwitchToInput(int newcapchannel, bool setstarting) 67 { (void)newcapchannel; (void)setstarting; return false; } 66 bool SwitchToInput(int newcapchannel, bool setstarting); 68 67 bool Tune(const dvb_channel_t& channel, bool force_reset=false); 69 68 70 69 // Set/Get/Command just for SIScan/ScanWizardScanner … … 113 112 int currentTID; ///< Stores mplexid from database 114 113 115 114 bool first_tune; ///< Used to force hardware reset 115 116 int nextcapchannel; ///< Signal an input change 116 117 }; 117 118 118 119 #endif -
libs/libmythtv/dvbchannel.cpp
132 132 { 133 133 channelnames.clear(); 134 134 inputChannel.clear(); 135 inputTuneTo.clear(); 135 136 136 137 MSqlQuery query(MSqlQuery::InitCon()); 137 138 query.prepare( 138 139 "SELECT cardinputid, inputname, " 140 " if (tunechan='', 'Undefined', tunechan), " 139 141 " if (startchan, startchan, '') " 140 142 "FROM cardinput " 141 143 "WHERE cardid = :CARDID"); … … 159 161 { 160 162 int inputNum = query.value(0).toInt(); 161 163 channelnames[inputNum] = query.value(1).toString(); 162 inputChannel[inputNum] = query.value(2).toString(); 164 inputTuneTo[inputNum] = query.value(2).toString(); 165 inputChannel[inputNum] = query.value(3).toString(); 163 166 } 164 167 165 168 // print em … … 170 173 .arg(it.key()).arg(*it) 171 174 .arg(inputChannel[it.key()])); 172 175 } 176 currentcapchannel = nextcapchannel = -1; 173 177 } 174 178 175 179 bool DVBChannel::Open() … … 284 288 CHANNEL(QString("Tuned to frequency for channel %1.").arg(chan)); 285 289 286 290 currentcapchannel = chan_opts.input_id; 291 nextcapchannel = currentcapchannel; 287 292 inputChannel[currentcapchannel] = curchannelname; 288 293 289 294 return true; … … 300 305 301 306 bool DVBChannel::SwitchToInput(const QString &input, const QString &chan) 302 307 { 303 (void)input; 304 // TODO We should be switching the input even if chan exists on 305 // the current input, currently this will only work correctly if 306 // channum's are unique across inputs. -- dtk Dec 15, 2005 308 if (input != channelnames[currentcapchannel]) 309 { 310 nextcapchannel = GetInputByName(input); 311 if (nextcapchannel == -1) 312 { 313 VERBOSE(VB_IMPORTANT, QString("Failed to locate input %1"). 314 arg(input)); 315 nextcapchannel = currentcapchannel; 316 } 317 } 307 318 return SetChannelByString(chan); 308 319 } 309 320 bool DVBChannel::SwitchToInput(int newcapchannel, bool setstarting) 321 { 322 (void)setstarting; 323 if(inputChannel[newcapchannel] != "") 324 { 325 nextcapchannel = newcapchannel; 326 return SetChannelByString(inputChannel[newcapchannel]); 327 } 328 return false; 329 } 310 330 /** \fn DVBChannel::GetChannelOptions(const QString&) 311 331 * \brief This function called when tuning to a specific stream. 312 332 */ … … 317 337 int cardid = GetCardID(); 318 338 319 339 // Reset Channel data 320 inputChannel[currentcapchannel] = "";321 340 currentATSCMajorChannel = currentATSCMinorChannel = -1; 322 341 currentProgramNum = -1; 323 342 chan_opts.serviceID = 0; 324 343 325 344 QString thequery = 326 QString("SELECT chanid, serviceid, mplexid, atscsrcid "345 QString("SELECT chanid, serviceid, mplexid, atscsrcid, cardinputid " 327 346 "FROM channel, cardinput, capturecard " 328 347 "WHERE channel.channum='%1' AND " 329 348 " cardinput.sourceid = channel.sourceid AND " … … 340 359 return false; 341 360 } 342 361 343 if (query.next()) 362 bool found = false; 363 int mplexid; 364 while (query.next()) 344 365 { 345 // TODO: Fix structs to be more useful to new DB structure 346 currentProgramNum = chan_opts.serviceID = query.value(1).toInt(); 347 if (query.value(3).toInt() > 256) 366 int this_inputid = query.value(4).toInt(); 367 if (! found || this_inputid == nextcapchannel) 348 368 { 349 currentATSCMajorChannel = query.value(3).toInt() >> 8; 350 currentATSCMinorChannel = query.value(3).toInt() & 0xff; 351 currentProgramNum = -1; 369 found = true; 370 mplexid = query.value(2).toInt(); 371 // TODO: Fix structs to be more useful to new DB structure 372 currentProgramNum = chan_opts.serviceID = query.value(1).toInt(); 373 if (query.value(3).toInt() > 256) 374 { 375 currentATSCMajorChannel = query.value(3).toInt() >> 8; 376 currentATSCMinorChannel = query.value(3).toInt() & 0xff; 377 currentProgramNum = -1; 378 } 379 352 380 } 353 381 } 354 else382 if (! found) 355 383 { 356 384 ERROR("Unable to find channel in database."); 357 385 return false; 358 386 } 359 387 360 int mplexid = query.value(2).toInt();361 362 388 if (!GetTransportOptions(mplexid)) 363 389 return false; 364 390