Ticket #10323: 0001-TV-Automatically-select-a-free-card-when-changing-ch.patch
File 0001-TV-Automatically-select-a-free-card-when-changing-ch.patch, 8.4 KB (added by , 12 years ago) |
---|
-
mythtv/libs/libmythtv/tv_play.cpp
From 26d96e7db5123ba45c4a0251ee91e93bf88a3191 Mon Sep 17 00:00:00 2001 From: Lawrence Rust <lvr@softsystem.co.uk> Date: Wed, 8 Feb 2012 18:53:57 +0100 Subject: [PATCH] TV: Automatically select a free card when changing channel This patch fixes a shortcoming in TV::ChangeChannel which presently doesn't detect when the new channel is unavialable on the current card due to a current recording or other other LiveTV access. When the channel change is sent to the backend it detects the conflict and selects a different channel to view even when there are cards availab le that could receive the requested channel. This patch checks the current card for conflicts and switches to the next available card that can receive the channel. It has most utility in systems with multiple tuners. Signed-off-by: Lawrence Rust <lvr@softsystem.co.uk> --- mythtv/libs/libmythtv/tv_play.cpp | 48 ++++++++++++-------------- mythtv/libs/libmythtv/tvremoteutil.cpp | 60 ++++++++++++++++++++++++++++++++ mythtv/libs/libmythtv/tvremoteutil.h | 2 + 3 files changed, 84 insertions(+), 26 deletions(-) diff --git a/mythtv/libs/libmythtv/tv_play.cpp b/mythtv/libs/libmythtv/tv_play.cpp index 5a9f8d1..e63fe22 100644
a b void TV::HandleStateChange(PlayerContext *mctx, PlayerContext *ctx) 2163 2163 bool getit = ctx->recorder->ShouldSwitchToAnotherCard( 2164 2164 QString::number(chanid)); 2165 2165 2166 if ( getit)2167 reclist = ChannelUtil::GetValidRecorderList(chanid, channum);2166 if (!getit) 2167 getit = !RemoteIsTuneable(ctx->GetCardID(), chanid); 2168 2168 2169 if ( reclist.size())2169 if (getit) 2170 2170 { 2171 RemoteEncoder *testrec = NULL; 2172 testrec = RemoteRequestFreeRecorderFromList(reclist); 2171 RemoteEncoder *testrec = RemoteRequestFreeRecorder(chanid); 2173 2172 if (testrec && testrec->IsValidRecorder()) 2174 2173 { 2175 2174 ctx->SetRecorder(testrec); 2176 2175 ctx->recorder->Setup(); 2177 2176 } 2177 else 2178 chanid = 0; 2178 2179 } 2179 else if (getit)2180 chanid = 0;2181 2180 } 2182 2181 2183 2182 LOG(VB_GENERAL, LOG_NOTICE, LOC + "Spawning LiveTV Recorder -- begin"); … … void TV::SwitchCards(PlayerContext *ctx, 6472 6471 } 6473 6472 6474 6473 uint input_cardid = 0; 6475 QStringList reclist;6476 6474 if (inputid) 6477 6475 { 6478 6476 // If we are switching to a specific input.. 6479 6477 input_cardid = CardUtil::GetCardID(inputid); 6478 QStringList reclist; 6480 6479 if (input_cardid) 6480 { 6481 6481 reclist.push_back(QString::number(input_cardid)); 6482 testrec = RemoteRequestFreeRecorderFromList(reclist); 6483 } 6482 6484 } 6483 6485 else if (!channum.isEmpty()) 6484 6486 { 6485 6487 // If we are switching to a channel not on the current recorder 6486 6488 // we need to find the next free recorder with that channel. 6487 reclist = ChannelUtil::GetValidRecorderList(chanid, channum);6489 testrec = RemoteRequestFreeRecorder(chanid, channum); 6488 6490 } 6489 6491 6490 if (!reclist.empty())6491 testrec = RemoteRequestFreeRecorderFromList(reclist);6492 6493 6492 if (testrec && testrec->IsValidRecorder()) 6494 6493 { 6495 6494 uint cardid = testrec->GetRecorderNumber(); … … void TV::ChangeChannel(PlayerContext *ctx, uint chanid, const QString &chan) 7012 7011 return; 7013 7012 7014 7013 QString channum = chan; 7015 QStringList reclist;7016 7014 7017 7015 QString oldinputname = ctx->recorder->GetInput(); 7018 7016 … … void TV::ChangeChannel(PlayerContext *ctx, uint chanid, const QString &chan) 7021 7019 channum = ChannelUtil::GetChanNum(chanid); 7022 7020 } 7023 7021 7024 bool getit = false; 7025 if (ctx->recorder) 7022 bool getit = true; 7023 if (ctx->pseudoLiveTVState == kPseudoRecording) 7024 ; 7025 else if (ctx->recorder) 7026 7026 { 7027 if (ctx->pseudoLiveTVState == kPseudoRecording) 7028 { 7029 getit = true; 7030 } 7031 else if (chanid) 7027 if (chanid) 7032 7028 { 7033 7029 getit = ctx->recorder->ShouldSwitchToAnotherCard( 7034 7030 QString::number(chanid)); … … void TV::ChangeChannel(PlayerContext *ctx, uint chanid, const QString &chan) 7039 7035 uint pref_cardid; 7040 7036 uint cardid = ctx->GetCardID(); 7041 7037 bool dummy; 7042 7043 7038 ctx->recorder->CheckChannelPrefix(chan, pref_cardid, 7044 7039 dummy, needed_spacer); 7045 7040 … … void TV::ChangeChannel(PlayerContext *ctx, uint chanid, const QString &chan) 7047 7042 getit = (pref_cardid != cardid); 7048 7043 } 7049 7044 7050 if (getit) 7051 reclist = ChannelUtil::GetValidRecorderList(chanid, channum); 7045 // If the channel is available on the current card then check for 7046 // conflicts in case a common input group restricts tuning 7047 if (!getit) 7048 getit = !RemoteIsTuneable(ctx->GetCardID(), chanid, channum); 7052 7049 } 7053 7050 7054 if ( reclist.size())7051 if (getit) 7055 7052 { 7056 RemoteEncoder *testrec = NULL; 7057 testrec = RemoteRequestFreeRecorderFromList(reclist); 7053 RemoteEncoder *testrec = RemoteRequestFreeRecorder(chanid, channum); 7058 7054 if (!testrec || !testrec->IsValidRecorder()) 7059 7055 { 7060 7056 ClearInputQueues(ctx, true); -
mythtv/libs/libmythtv/tvremoteutil.cpp
diff --git a/mythtv/libs/libmythtv/tvremoteutil.cpp b/mythtv/libs/libmythtv/tvremoteutil.cpp index d348d64..3e25c72 100644
a b 4 4 5 5 #include "tvremoteutil.h" 6 6 #include "cardutil.h" 7 #include "channelutil.h" 7 8 #include "inputinfo.h" 8 9 #include "programinfo.h" 9 10 #include "mythcorecontext.h" … … bool RemoteGetRecordingStatus( 371 372 return isRecording; 372 373 } 373 374 375 bool RemoteIsTuneable(uint cardid, uint chanid, const QString &channum) 376 { 377 if (!chanid) 378 { 379 vector<uint> c = ChannelUtil::GetConflicting(channum); 380 if (c.size() == 0) 381 return false; 382 chanid = c[0]; 383 } 384 385 const uint mplexid = ChannelUtil::GetMplexID(chanid); 386 const uint sourceid = ChannelUtil::GetSourceIDForChannel(chanid); 387 QStringList const inputs = CardUtil::GetInputNames(cardid, sourceid); 388 if (inputs.size() == 0) 389 return false; 390 const uint inputid = CardUtil::GetInputID(cardid, inputs[0]); 391 392 // Enumerate cards with the same inputgroup 393 vector<uint> const cards = CardUtil::GetConflictingCards(inputid, cardid); 394 for (vector<uint>::const_iterator it = cards.begin(); 395 it != cards.end(); ++it) 396 { 397 // Check if card is busy 398 TunedInputInfo busy_input; 399 if (!RemoteIsBusy(*it, busy_input)) 400 continue; 401 402 // Check for conflicting source and multiplex IDs 403 if (busy_input.mplexid != mplexid || busy_input.sourceid != sourceid) 404 return false; 405 } 406 407 return true; 408 } 409 410 RemoteEncoder *RemoteRequestFreeRecorder(uint chanid, const QString &channum) 411 { 412 QStringList strlist( "GET_FREE_RECORDER_LIST" ); 413 414 if (!gCoreContext->SendReceiveStringList(strlist, true)) 415 return NULL; 416 417 QStringList reclist = ChannelUtil::GetValidRecorderList(chanid, channum); 418 for (QStringList::const_iterator recIter = reclist.begin(); 419 recIter != reclist.end(); ++recIter) 420 { 421 if (strlist.contains(*recIter)) 422 { 423 RemoteEncoder *rec = RemoteGetExistingRecorder((*recIter).toInt()); 424 if (rec && RemoteIsTuneable(rec->GetRecorderNumber(), chanid, channum)) 425 return rec; 426 427 delete rec; 428 } 429 } 430 // didn't find anything. just return NULL. 431 return NULL; 432 } 433 374 434 /* vim: set expandtab tabstop=4 shiftwidth=4: */ -
mythtv/libs/libmythtv/tvremoteutil.h
diff --git a/mythtv/libs/libmythtv/tvremoteutil.h b/mythtv/libs/libmythtv/tvremoteutil.h index cc2d9e5..b0a3aca 100644
a b MTV_PUBLIC vector<InputInfo> RemoteRequestFreeInputList( 46 46 uint cardid, const vector<uint> &excluded_cardids); 47 47 MTV_PUBLIC InputInfo RemoteRequestBusyInputID(uint cardid); 48 48 MTV_PUBLIC bool RemoteIsBusy(uint cardid, TunedInputInfo &busy_input); 49 MTV_PUBLIC bool RemoteIsTuneable(uint cardid, uint chanid, const QString &channum = QString()); 50 MTV_PUBLIC RemoteEncoder *RemoteRequestFreeRecorder(uint chanid, const QString &channum = QString()); 49 51 50 52 MTV_PUBLIC bool RemoteGetRecordingStatus( 51 53 vector<TunerStatus> *tunerList, bool list_inactive);