diff --git a/mythtv/programs/mythbackend/encoderlink.cpp b/mythtv/programs/mythbackend/encoderlink.cpp
index 2c7bc76..24113fa 100644
|
a
|
b
|
EncoderLink::EncoderLink(int capturecardnum, PlaybackSock *lsock,
|
| 41 | 41 | QString lhostname) |
| 42 | 42 | : m_capturecardnum(capturecardnum), sock(lsock), hostname(lhostname), |
| 43 | 43 | freeDiskSpaceKB(-1), tv(NULL), local(false), locked(false), |
| | 44 | disconnected(false), |
| 44 | 45 | sleepStatus(sStatus_Undefined), chanid(0) |
| 45 | 46 | { |
| 46 | 47 | endRecordingTime = MythDate::current().addDays(-2); |
| … |
… |
EncoderLink::EncoderLink(int capturecardnum, PlaybackSock *lsock,
|
| 50 | 51 | lastSleepTime = MythDate::current(); |
| 51 | 52 | lastWakeTime = MythDate::current(); |
| 52 | 53 | |
| | 54 | QMutexLocker locker(&sockLock); |
| 53 | 55 | if (sock) |
| 54 | 56 | sock->IncrRef(); |
| 55 | 57 | } |
| … |
… |
EncoderLink::EncoderLink(int capturecardnum, PlaybackSock *lsock,
|
| 60 | 62 | EncoderLink::EncoderLink(int capturecardnum, TVRec *ltv) |
| 61 | 63 | : m_capturecardnum(capturecardnum), sock(NULL), |
| 62 | 64 | freeDiskSpaceKB(-1), tv(ltv), local(true), locked(false), |
| | 65 | disconnected(false), |
| 63 | 66 | sleepStatus(sStatus_Undefined), chanid(0) |
| 64 | 67 | { |
| 65 | 68 | endRecordingTime = MythDate::current().addDays(-2); |
| … |
… |
EncoderLink::~EncoderLink(void)
|
| 81 | 84 | delete tv; |
| 82 | 85 | tv = NULL; |
| 83 | 86 | } |
| | 87 | disconnected = true; |
| 84 | 88 | } |
| 85 | 89 | |
| 86 | 90 | /** \fn EncoderLink::SetSocket(PlaybackSock *lsock) |
| … |
… |
EncoderLink::~EncoderLink(void)
|
| 90 | 94 | */ |
| 91 | 95 | void EncoderLink::SetSocket(PlaybackSock *lsock) |
| 92 | 96 | { |
| | 97 | QMutexLocker locker(&sockLock); |
| 93 | 98 | if (lsock) |
| 94 | 99 | { |
| 95 | 100 | lsock->IncrRef(); |
| … |
… |
void EncoderLink::SetSocket(PlaybackSock *lsock)
|
| 99 | 104 | else |
| 100 | 105 | SetSleepStatus(sStatus_Awake); |
| 101 | 106 | } |
| 102 | | else |
| 103 | | { |
| 104 | | if (IsFallingAsleep()) |
| 105 | | SetSleepStatus(sStatus_Asleep); |
| 106 | | else |
| 107 | | SetSleepStatus(sStatus_Undefined); |
| 108 | | } |
| 109 | | |
| 110 | | if (sock) |
| 111 | | sock->DecrRef(); |
| 112 | 107 | sock = lsock; |
| | 108 | disconnected = false; |
| | 109 | } |
| | 110 | |
| | 111 | void EncoderLink::Disconnect() |
| | 112 | { |
| | 113 | disconnected = true; |
| | 114 | if (IsFallingAsleep()) |
| | 115 | SetSleepStatus(sStatus_Asleep); |
| | 116 | else |
| | 117 | SetSleepStatus(sStatus_Undefined); |
| | 118 | |
| | 119 | if (sock) |
| | 120 | sock->DecrRef(); |
| 113 | 121 | } |
| 114 | 122 | |
| 115 | 123 | /** \fn EncoderLink::SetSleepStatus(SleepStatus) |
| … |
… |
void EncoderLink::SetSleepStatus(SleepStatus newStatus)
|
| 128 | 136 | */ |
| 129 | 137 | bool EncoderLink::IsBusy(TunedInputInfo *busy_input, int time_buffer) |
| 130 | 138 | { |
| | 139 | if (disconnected) |
| | 140 | return false; |
| | 141 | |
| 131 | 142 | if (local) |
| 132 | 143 | return tv->IsBusy(busy_input, time_buffer); |
| 133 | 144 | |
| | 145 | QMutexLocker locker(&sockLock); |
| 134 | 146 | if (sock) |
| 135 | 147 | return sock->IsBusy(m_capturecardnum, busy_input, time_buffer); |
| 136 | 148 | |
| … |
… |
bool EncoderLink::IsBusyRecording(void)
|
| 149 | 161 | { |
| 150 | 162 | bool retval = false; |
| 151 | 163 | |
| | 164 | if (disconnected) |
| | 165 | return false; |
| | 166 | |
| 152 | 167 | TVState state = GetState(); |
| 153 | 168 | |
| 154 | 169 | if (state == kState_RecordingOnly || state == kState_WatchingRecording || |
| … |
… |
TVState EncoderLink::GetState(void)
|
| 174 | 189 | if (local) |
| 175 | 190 | retval = tv->GetState(); |
| 176 | 191 | else if (sock) |
| 177 | | retval = (TVState)sock->GetEncoderState(m_capturecardnum); |
| | 192 | { |
| | 193 | QMutexLocker locker(&sockLock); |
| | 194 | if (sock) |
| | 195 | retval = (TVState)sock->GetEncoderState(m_capturecardnum); |
| | 196 | } |
| 178 | 197 | else |
| 179 | 198 | LOG(VB_GENERAL, LOG_ERR, QString("Broken for card: %1") |
| 180 | 199 | .arg(m_capturecardnum)); |
| … |
… |
TVState EncoderLink::GetState(void)
|
| 186 | 205 | * \brief Returns the flag state of the recorder. |
| 187 | 206 | * \sa TVRec::GetFlags(void) const, \ref recorder_subsystem |
| 188 | 207 | */ |
| 189 | | uint EncoderLink::GetFlags(void) const |
| | 208 | uint EncoderLink::GetFlags(void) |
| 190 | 209 | { |
| 191 | 210 | uint retval = 0; |
| 192 | 211 | |
| 193 | | if (!IsConnected()) |
| | 212 | if (disconnected) |
| 194 | 213 | return retval; |
| 195 | 214 | |
| 196 | 215 | if (local) |
| 197 | 216 | retval = tv->GetFlags(); |
| 198 | 217 | else if (sock) |
| 199 | | retval = sock->GetEncoderState(m_capturecardnum); |
| | 218 | { |
| | 219 | QMutexLocker locker(&sockLock); |
| | 220 | if (sock) |
| | 221 | retval = sock->GetEncoderState(m_capturecardnum); |
| | 222 | } |
| 200 | 223 | else |
| 201 | 224 | LOG(VB_GENERAL, LOG_ERR, LOC + "GetFlags failed"); |
| 202 | 225 | |
| … |
… |
uint EncoderLink::GetFlags(void) const
|
| 210 | 233 | */ |
| 211 | 234 | bool EncoderLink::IsRecording(const ProgramInfo *rec) |
| 212 | 235 | { |
| | 236 | if (disconnected) |
| | 237 | return false; |
| 213 | 238 | return (rec->GetChanID() == chanid && |
| 214 | 239 | rec->GetRecordingStartTime() == startRecordingTime); |
| 215 | 240 | } |
| … |
… |
bool EncoderLink::MatchesRecording(const ProgramInfo *rec)
|
| 227 | 252 | bool retval = false; |
| 228 | 253 | ProgramInfo *tvrec = NULL; |
| 229 | 254 | |
| | 255 | if (disconnected) |
| | 256 | return false; |
| | 257 | |
| 230 | 258 | if (local) |
| 231 | 259 | { |
| 232 | 260 | while (kState_ChangingState == GetState()) |
| … |
… |
bool EncoderLink::MatchesRecording(const ProgramInfo *rec)
|
| 243 | 271 | } |
| 244 | 272 | else |
| 245 | 273 | { |
| | 274 | QMutexLocker locker(&sockLock); |
| 246 | 275 | if (sock) |
| 247 | 276 | retval = sock->EncoderIsRecording(m_capturecardnum, rec); |
| 248 | 277 | } |
| … |
… |
bool EncoderLink::MatchesRecording(const ProgramInfo *rec)
|
| 261 | 290 | void EncoderLink::RecordPending(const ProgramInfo *rec, int secsleft, |
| 262 | 291 | bool hasLater) |
| 263 | 292 | { |
| | 293 | if (disconnected) |
| | 294 | return; |
| | 295 | |
| 264 | 296 | if (local) |
| 265 | 297 | tv->RecordPending(rec, secsleft, hasLater); |
| 266 | | else if (sock) |
| 267 | | sock->RecordPending(m_capturecardnum, rec, secsleft, hasLater); |
| | 298 | else |
| | 299 | { |
| | 300 | QMutexLocker locker(&sockLock); |
| | 301 | if (sock) |
| | 302 | sock->RecordPending(m_capturecardnum, rec, secsleft, hasLater); |
| | 303 | } |
| 268 | 304 | } |
| 269 | 305 | |
| 270 | 306 | /** \fn EncoderLink::WouldConflict(const ProgramInfo*) |
| … |
… |
bool EncoderLink::WouldConflict(const ProgramInfo *rec)
|
| 286 | 322 | /// Checks if program is stored locally |
| 287 | 323 | bool EncoderLink::CheckFile(ProgramInfo *pginfo) |
| 288 | 324 | { |
| | 325 | if (disconnected) |
| | 326 | return false; |
| | 327 | |
| | 328 | QMutexLocker locker(&sockLock); |
| 289 | 329 | if (sock) |
| 290 | 330 | return sock->CheckFile(pginfo); |
| 291 | 331 | |
| … |
… |
bool EncoderLink::CheckFile(ProgramInfo *pginfo)
|
| 300 | 340 | */ |
| 301 | 341 | void EncoderLink::GetDiskSpace(QStringList &o_strlist) |
| 302 | 342 | { |
| | 343 | if (disconnected) |
| | 344 | return; |
| | 345 | |
| | 346 | QMutexLocker locker(&sockLock); |
| 303 | 347 | if (sock) |
| 304 | 348 | sock->GetDiskSpace(o_strlist); |
| 305 | 349 | } |
| … |
… |
void EncoderLink::GetDiskSpace(QStringList &o_strlist)
|
| 312 | 356 | */ |
| 313 | 357 | long long EncoderLink::GetMaxBitrate() |
| 314 | 358 | { |
| | 359 | if (disconnected) |
| | 360 | return -1; |
| | 361 | |
| 315 | 362 | if (local) |
| 316 | 363 | return tv->GetMaxBitrate(); |
| 317 | | else if (sock) |
| 318 | | return sock->GetMaxBitrate(m_capturecardnum); |
| 319 | | |
| | 364 | else |
| | 365 | { |
| | 366 | QMutexLocker locker(&sockLock); |
| | 367 | if (sock) |
| | 368 | return sock->GetMaxBitrate(m_capturecardnum); |
| | 369 | } |
| 320 | 370 | return -1; |
| 321 | 371 | } |
| 322 | 372 | |
| … |
… |
int EncoderLink::SetSignalMonitoringRate(int rate, int notifyFrontend)
|
| 338 | 388 | { |
| 339 | 389 | if (local) |
| 340 | 390 | return tv->SetSignalMonitoringRate(rate, notifyFrontend); |
| 341 | | else if (sock) |
| 342 | | return sock->SetSignalMonitoringRate(m_capturecardnum, rate, |
| 343 | | notifyFrontend); |
| | 391 | else |
| | 392 | { |
| | 393 | QMutexLocker locker(&sockLock); |
| | 394 | if (sock) |
| | 395 | return sock->SetSignalMonitoringRate(m_capturecardnum, rate, |
| | 396 | notifyFrontend); |
| | 397 | } |
| 344 | 398 | return -1; |
| 345 | 399 | } |
| 346 | 400 | |
| … |
… |
int EncoderLink::SetSignalMonitoringRate(int rate, int notifyFrontend)
|
| 348 | 402 | */ |
| 349 | 403 | bool EncoderLink::GoToSleep(void) |
| 350 | 404 | { |
| 351 | | if (IsLocal() || !sock) |
| | 405 | if (disconnected) |
| 352 | 406 | return false; |
| 353 | 407 | |
| | 408 | if (IsLocal()) |
| | 409 | return false; |
| | 410 | |
| | 411 | QMutexLocker locker(&sockLock); |
| | 412 | if (!sock) |
| | 413 | return false; |
| | 414 | |
| | 415 | if (sock->getBlockShutdown()) |
| | 416 | { |
| | 417 | LOG(VB_GENERAL, LOG_NOTICE, |
| | 418 | QString("EncoderLink::GoToSleep() Socket shutdown is currently blocked!")); |
| | 419 | return false; |
| | 420 | } |
| | 421 | |
| 354 | 422 | lastSleepTime = MythDate::current(); |
| 355 | 423 | |
| 356 | 424 | return sock->GoToSleep(); |
| … |
… |
bool EncoderLink::GoToSleep(void)
|
| 362 | 430 | */ |
| 363 | 431 | int EncoderLink::LockTuner() |
| 364 | 432 | { |
| | 433 | if (disconnected) |
| | 434 | return -2; |
| | 435 | |
| 365 | 436 | if (locked) |
| 366 | 437 | return -2; |
| 367 | 438 | |
| … |
… |
RecStatusType EncoderLink::StartRecording(const ProgramInfo *rec)
|
| 380 | 451 | { |
| 381 | 452 | RecStatusType retval = rsAborted; |
| 382 | 453 | |
| | 454 | if (disconnected) |
| | 455 | return retval; |
| | 456 | |
| 383 | 457 | endRecordingTime = rec->GetRecordingEndTime(); |
| 384 | 458 | startRecordingTime = rec->GetRecordingStartTime(); |
| 385 | 459 | chanid = rec->GetChanID(); |
| 386 | 460 | |
| 387 | 461 | if (local) |
| 388 | 462 | retval = tv->StartRecording(rec); |
| 389 | | else if (sock) |
| 390 | | retval = sock->StartRecording(m_capturecardnum, rec); |
| 391 | 463 | else |
| 392 | | LOG(VB_GENERAL, LOG_ERR, |
| 393 | | QString("Wanted to start recording on recorder %1,\n\t\t\t" |
| 394 | | "but the backend is not there anymore\n") |
| 395 | | .arg(m_capturecardnum)); |
| | 464 | { |
| | 465 | QMutexLocker locker(&sockLock); |
| | 466 | if (sock) |
| | 467 | retval = sock->StartRecording(m_capturecardnum, rec); |
| | 468 | else |
| | 469 | LOG(VB_GENERAL, LOG_ERR, |
| | 470 | QString("Wanted to start recording on recorder %1,\n\t\t\t" |
| | 471 | "but the backend is not there anymore\n") |
| | 472 | .arg(m_capturecardnum)); |
| | 473 | } |
| 396 | 474 | |
| 397 | 475 | if (retval != rsRecording && retval != rsTuning) |
| 398 | 476 | { |
| … |
… |
RecStatusType EncoderLink::GetRecordingStatus(void)
|
| 408 | 486 | { |
| 409 | 487 | RecStatusType retval = rsAborted; |
| 410 | 488 | |
| | 489 | if (disconnected) |
| | 490 | return retval; |
| | 491 | |
| 411 | 492 | if (local) |
| 412 | 493 | retval = tv->GetRecordingStatus(); |
| 413 | | else if (sock) |
| 414 | | retval = sock->GetRecordingStatus(m_capturecardnum); |
| 415 | 494 | else |
| 416 | | LOG(VB_GENERAL, LOG_ERR, |
| 417 | | QString("Wanted to get status on recorder %1,\n\t\t\t" |
| 418 | | "but the backend is not there anymore\n") |
| 419 | | .arg(m_capturecardnum)); |
| | 495 | { |
| | 496 | QMutexLocker locker(&sockLock); |
| | 497 | if (sock) |
| | 498 | retval = sock->GetRecordingStatus(m_capturecardnum); |
| | 499 | else |
| | 500 | LOG(VB_GENERAL, LOG_ERR, |
| | 501 | QString("Wanted to get status on recorder %1,\n\t\t\t" |
| | 502 | "but the backend is not there anymore\n") |
| | 503 | .arg(m_capturecardnum)); |
| | 504 | } |
| 420 | 505 | |
| 421 | 506 | if (retval != rsRecording && retval != rsTuning) |
| 422 | 507 | { |
| … |
… |
ProgramInfo *EncoderLink::GetRecording(void)
|
| 438 | 523 | { |
| 439 | 524 | ProgramInfo *info = NULL; |
| 440 | 525 | |
| | 526 | if (disconnected) |
| | 527 | return info; |
| | 528 | |
| 441 | 529 | if (local) |
| 442 | 530 | info = tv->GetRecording(); |
| 443 | | else if (sock) |
| 444 | | info = sock->GetRecording(m_capturecardnum); |
| | 531 | else |
| | 532 | { |
| | 533 | QMutexLocker locker(&sockLock); |
| | 534 | if (sock) |
| | 535 | info = sock->GetRecording(m_capturecardnum); |
| | 536 | } |
| 445 | 537 | |
| 446 | 538 | return info; |
| 447 | 539 | } |
| … |
… |
ProgramInfo *EncoderLink::GetRecording(void)
|
| 453 | 545 | */ |
| 454 | 546 | void EncoderLink::StopRecording(bool killFile) |
| 455 | 547 | { |
| | 548 | if (disconnected) |
| | 549 | return; |
| | 550 | |
| 456 | 551 | endRecordingTime = MythDate::current().addDays(-2); |
| 457 | 552 | startRecordingTime = endRecordingTime; |
| 458 | 553 | chanid = 0; |
| … |
… |
void EncoderLink::StopRecording(bool killFile)
|
| 471 | 566 | */ |
| 472 | 567 | void EncoderLink::FinishRecording(void) |
| 473 | 568 | { |
| | 569 | if (disconnected) |
| | 570 | return; |
| | 571 | |
| 474 | 572 | if (local) |
| 475 | 573 | { |
| 476 | 574 | tv->FinishRecording(); |
| … |
… |
bool EncoderLink::IsReallyRecording(void)
|
| 505 | 603 | */ |
| 506 | 604 | float EncoderLink::GetFramerate(void) |
| 507 | 605 | { |
| | 606 | if (disconnected) |
| | 607 | return -1; |
| | 608 | |
| 508 | 609 | if (local) |
| 509 | 610 | return tv->GetFramerate(); |
| 510 | 611 | |
| … |
… |
float EncoderLink::GetFramerate(void)
|
| 521 | 622 | */ |
| 522 | 623 | long long EncoderLink::GetFramesWritten(void) |
| 523 | 624 | { |
| | 625 | if (disconnected) |
| | 626 | return -1; |
| | 627 | |
| 524 | 628 | if (local) |
| 525 | 629 | return tv->GetFramesWritten(); |
| 526 | 630 | |
| … |
… |
long long EncoderLink::GetFramesWritten(void)
|
| 536 | 640 | */ |
| 537 | 641 | long long EncoderLink::GetFilePosition(void) |
| 538 | 642 | { |
| | 643 | if (disconnected) |
| | 644 | return -1; |
| | 645 | |
| 539 | 646 | if (local) |
| 540 | 647 | return tv->GetFilePosition(); |
| 541 | 648 | |
| … |
… |
long long EncoderLink::GetFilePosition(void)
|
| 551 | 658 | */ |
| 552 | 659 | int64_t EncoderLink::GetKeyframePosition(uint64_t desired) |
| 553 | 660 | { |
| | 661 | if (disconnected) |
| | 662 | return -1; |
| | 663 | |
| 554 | 664 | if (local) |
| 555 | 665 | return tv->GetKeyframePosition(desired); |
| 556 | 666 | |
| … |
… |
int64_t EncoderLink::GetKeyframePosition(uint64_t desired)
|
| 561 | 671 | bool EncoderLink::GetKeyframePositions( |
| 562 | 672 | int64_t start, int64_t end, frm_pos_map_t &map) |
| 563 | 673 | { |
| | 674 | if (disconnected) |
| | 675 | return false; |
| | 676 | |
| 564 | 677 | if (!local) |
| 565 | 678 | { |
| 566 | 679 | LOG(VB_GENERAL, LOG_ERR, |
| … |
… |
bool EncoderLink::GetKeyframePositions(
|
| 578 | 691 | */ |
| 579 | 692 | void EncoderLink::FrontendReady(void) |
| 580 | 693 | { |
| | 694 | if (disconnected) |
| | 695 | return; |
| | 696 | |
| 581 | 697 | if (local) |
| 582 | 698 | tv->FrontendReady(); |
| 583 | 699 | else |
| … |
… |
void EncoderLink::FrontendReady(void)
|
| 594 | 710 | */ |
| 595 | 711 | void EncoderLink::CancelNextRecording(bool cancel) |
| 596 | 712 | { |
| | 713 | if (disconnected) |
| | 714 | return; |
| | 715 | |
| 597 | 716 | if (local) |
| 598 | 717 | tv->CancelNextRecording(cancel); |
| 599 | 718 | else |
| 600 | | sock->CancelNextRecording(m_capturecardnum, cancel); |
| | 719 | { |
| | 720 | QMutexLocker locker(&sockLock); |
| | 721 | if (sock) |
| | 722 | sock->CancelNextRecording(m_capturecardnum, cancel); |
| | 723 | } |
| 601 | 724 | } |
| 602 | 725 | |
| 603 | 726 | /** \fn EncoderLink::SpawnLiveTV(LiveTVChain*, bool, QString) |
| … |
… |
void EncoderLink::CancelNextRecording(bool cancel)
|
| 613 | 736 | */ |
| 614 | 737 | void EncoderLink::SpawnLiveTV(LiveTVChain *chain, bool pip, QString startchan) |
| 615 | 738 | { |
| | 739 | if (disconnected) |
| | 740 | return; |
| | 741 | |
| 616 | 742 | if (local) |
| 617 | 743 | tv->SpawnLiveTV(chain, pip, startchan); |
| 618 | 744 | else |
| … |
… |
void EncoderLink::SpawnLiveTV(LiveTVChain *chain, bool pip, QString startchan)
|
| 624 | 750 | */ |
| 625 | 751 | QString EncoderLink::GetChainID(void) |
| 626 | 752 | { |
| | 753 | if (disconnected) |
| | 754 | return ""; |
| | 755 | |
| 627 | 756 | if (local) |
| 628 | 757 | return tv->GetChainID(); |
| 629 | 758 | |
| … |
… |
QString EncoderLink::GetChainID(void)
|
| 638 | 767 | */ |
| 639 | 768 | void EncoderLink::StopLiveTV(void) |
| 640 | 769 | { |
| | 770 | if (disconnected) |
| | 771 | return; |
| | 772 | |
| 641 | 773 | if (local) |
| 642 | 774 | tv->StopLiveTV(); |
| 643 | 775 | else |
| … |
… |
void EncoderLink::StopLiveTV(void)
|
| 652 | 784 | */ |
| 653 | 785 | void EncoderLink::PauseRecorder(void) |
| 654 | 786 | { |
| | 787 | if (disconnected) |
| | 788 | return; |
| | 789 | |
| 655 | 790 | if (local) |
| 656 | 791 | tv->PauseRecorder(); |
| 657 | 792 | else |
| … |
… |
void EncoderLink::PauseRecorder(void)
|
| 665 | 800 | */ |
| 666 | 801 | void EncoderLink::SetLiveRecording(int recording) |
| 667 | 802 | { |
| | 803 | if (disconnected) |
| | 804 | return; |
| | 805 | |
| 668 | 806 | if (local) |
| 669 | 807 | tv->SetLiveRecording(recording); |
| 670 | 808 | else |
| … |
… |
void EncoderLink::SetLiveRecording(int recording)
|
| 677 | 815 | */ |
| 678 | 816 | void EncoderLink::SetNextLiveTVDir(QString dir) |
| 679 | 817 | { |
| | 818 | if (disconnected) |
| | 819 | return; |
| | 820 | |
| 680 | 821 | if (local) |
| 681 | 822 | tv->SetNextLiveTVDir(dir); |
| 682 | 823 | else |
| 683 | | sock->SetNextLiveTVDir(m_capturecardnum, dir); |
| | 824 | { |
| | 825 | QMutexLocker locker(&sockLock); |
| | 826 | if (sock) |
| | 827 | sock->SetNextLiveTVDir(m_capturecardnum, dir); |
| | 828 | } |
| 684 | 829 | } |
| 685 | 830 | |
| 686 | 831 | /** \fn EncoderLink::GetFreeInputs(const vector<uint>&) const |
| … |
… |
void EncoderLink::SetNextLiveTVDir(QString dir)
|
| 689 | 834 | * \sa TVRec::GetFreeInputs(const vector<uint>&) const |
| 690 | 835 | */ |
| 691 | 836 | vector<InputInfo> EncoderLink::GetFreeInputs( |
| 692 | | const vector<uint> &excluded_cardids) const |
| | 837 | const vector<uint> &excluded_cardids) |
| 693 | 838 | { |
| 694 | 839 | vector<InputInfo> list; |
| 695 | 840 | |
| | 841 | if (disconnected) |
| | 842 | return list; |
| | 843 | |
| 696 | 844 | if (local) |
| 697 | 845 | list = tv->GetFreeInputs(excluded_cardids); |
| 698 | 846 | else |
| 699 | | list = sock->GetFreeInputs(m_capturecardnum, excluded_cardids); |
| | 847 | { |
| | 848 | QMutexLocker locker(&sockLock); |
| | 849 | if (sock) |
| | 850 | list = sock->GetFreeInputs(m_capturecardnum, excluded_cardids); |
| | 851 | } |
| 700 | 852 | |
| 701 | 853 | return list; |
| 702 | 854 | } |
| … |
… |
vector<InputInfo> EncoderLink::GetFreeInputs(
|
| 709 | 861 | */ |
| 710 | 862 | QString EncoderLink::GetInput(void) const |
| 711 | 863 | { |
| | 864 | if (disconnected) |
| | 865 | return QString(); |
| | 866 | |
| 712 | 867 | if (local) |
| 713 | 868 | return tv->GetInput(); |
| 714 | 869 | |
| … |
… |
QString EncoderLink::GetInput(void) const
|
| 728 | 883 | */ |
| 729 | 884 | QString EncoderLink::SetInput(QString input) |
| 730 | 885 | { |
| | 886 | if (disconnected) |
| | 887 | return QString(); |
| | 888 | |
| 731 | 889 | if (local) |
| 732 | 890 | return tv->SetInput(input); |
| 733 | 891 | |
| … |
… |
QString EncoderLink::SetInput(QString input)
|
| 742 | 900 | */ |
| 743 | 901 | void EncoderLink::ToggleChannelFavorite(QString changroup) |
| 744 | 902 | { |
| | 903 | if (disconnected) |
| | 904 | return; |
| | 905 | |
| 745 | 906 | if (local) |
| 746 | 907 | tv->ToggleChannelFavorite(changroup); |
| 747 | 908 | else |
| … |
… |
void EncoderLink::ToggleChannelFavorite(QString changroup)
|
| 757 | 918 | */ |
| 758 | 919 | void EncoderLink::ChangeChannel(ChannelChangeDirection channeldirection) |
| 759 | 920 | { |
| | 921 | if (disconnected) |
| | 922 | return; |
| | 923 | |
| 760 | 924 | if (local) |
| 761 | 925 | tv->ChangeChannel(channeldirection); |
| 762 | 926 | else |
| … |
… |
void EncoderLink::ChangeChannel(ChannelChangeDirection channeldirection)
|
| 772 | 936 | */ |
| 773 | 937 | void EncoderLink::SetChannel(const QString &name) |
| 774 | 938 | { |
| | 939 | if (disconnected) |
| | 940 | return; |
| | 941 | |
| 775 | 942 | if (local) |
| 776 | 943 | tv->SetChannel(name); |
| 777 | 944 | else |
| … |
… |
void EncoderLink::SetChannel(const QString &name)
|
| 788 | 955 | */ |
| 789 | 956 | int EncoderLink::GetPictureAttribute(PictureAttribute attr) |
| 790 | 957 | { |
| | 958 | if (disconnected) |
| | 959 | return -1; |
| | 960 | |
| 791 | 961 | if (!local) |
| 792 | 962 | { |
| 793 | 963 | LOG(VB_GENERAL, LOG_ERR, |
| … |
… |
int EncoderLink::ChangePictureAttribute(PictureAdjustType type,
|
| 810 | 980 | PictureAttribute attr, |
| 811 | 981 | bool direction) |
| 812 | 982 | { |
| | 983 | if (disconnected) |
| | 984 | return -1; |
| | 985 | |
| 813 | 986 | if (!local) |
| 814 | 987 | { |
| 815 | 988 | LOG(VB_GENERAL, LOG_ERR, |
| … |
… |
int EncoderLink::ChangePictureAttribute(PictureAdjustType type,
|
| 831 | 1004 | */ |
| 832 | 1005 | bool EncoderLink::CheckChannel(const QString &name) |
| 833 | 1006 | { |
| | 1007 | if (disconnected) |
| | 1008 | return false; |
| | 1009 | |
| 834 | 1010 | if (local) |
| 835 | 1011 | return tv->CheckChannel(name); |
| 836 | 1012 | |
| … |
… |
bool EncoderLink::CheckChannel(const QString &name)
|
| 849 | 1025 | */ |
| 850 | 1026 | bool EncoderLink::ShouldSwitchToAnotherCard(const QString &channelid) |
| 851 | 1027 | { |
| | 1028 | if (disconnected) |
| | 1029 | return false; |
| | 1030 | |
| 852 | 1031 | if (local) |
| 853 | 1032 | return tv->ShouldSwitchToAnotherCard(channelid); |
| 854 | 1033 | |
| … |
… |
bool EncoderLink::CheckChannelPrefix(
|
| 870 | 1049 | bool &is_extra_char_useful, |
| 871 | 1050 | QString &needed_spacer) |
| 872 | 1051 | { |
| | 1052 | if (disconnected) |
| | 1053 | return false; |
| | 1054 | |
| 873 | 1055 | if (local) |
| 874 | 1056 | { |
| 875 | 1057 | return tv->CheckChannelPrefix( |
| … |
… |
void EncoderLink::GetNextProgram(BrowseDirection direction,
|
| 897 | 1079 | QString &channelname, uint &_chanid, |
| 898 | 1080 | QString &seriesid, QString &programid) |
| 899 | 1081 | { |
| | 1082 | if (disconnected) |
| | 1083 | return; |
| | 1084 | |
| 900 | 1085 | if (local) |
| 901 | 1086 | { |
| 902 | 1087 | tv->GetNextProgram(direction, |
| … |
… |
bool EncoderLink::GetChannelInfo(uint &chanid, uint &sourceid,
|
| 912 | 1097 | QString &callsign, QString &channum, |
| 913 | 1098 | QString &channame, QString &xmltv) const |
| 914 | 1099 | { |
| | 1100 | if (disconnected) |
| | 1101 | return false; |
| | 1102 | |
| 915 | 1103 | if (!local) |
| 916 | 1104 | { |
| 917 | 1105 | LOG(VB_GENERAL, LOG_ERR, "Should be local only query: GetChannelInfo"); |
| … |
… |
bool EncoderLink::SetChannelInfo(uint chanid, uint sourceid,
|
| 927 | 1115 | QString callsign, QString channum, |
| 928 | 1116 | QString channame, QString xmltv) |
| 929 | 1117 | { |
| | 1118 | if (disconnected) |
| | 1119 | return false; |
| | 1120 | |
| 930 | 1121 | if (!local) |
| 931 | 1122 | { |
| 932 | 1123 | LOG(VB_GENERAL, LOG_ERR, "Should be local only query: SetChannelInfo"); |
diff --git a/mythtv/programs/mythbackend/encoderlink.h b/mythtv/programs/mythbackend/encoderlink.h
index 09eaae1..2729eee 100644
|
a
|
b
|
|
| 3 | 3 | |
| 4 | 4 | #include <QString> |
| 5 | 5 | #include <QMap> |
| | 6 | #include <QMutex> |
| 6 | 7 | |
| 7 | 8 | #include "tv.h" |
| 8 | 9 | #include "programinfo.h" |
| … |
… |
class EncoderLink
|
| 23 | 24 | |
| 24 | 25 | /// \brief Used to set the socket for a non-local EncoderLink. |
| 25 | 26 | void SetSocket(PlaybackSock *lsock); |
| | 27 | |
| | 28 | void Disconnect(); |
| | 29 | |
| 26 | 30 | /// \brief Returns the socket, if set, for a non-local EncoderLink. |
| 27 | 31 | PlaybackSock *GetSocket(void) { return sock; } |
| 28 | 32 | |
| … |
… |
class EncoderLink
|
| 42 | 46 | /// \brief Returns true for a local EncoderLink. |
| 43 | 47 | bool IsLocal(void) const { return local; } |
| 44 | 48 | /// \brief Returns true if the EncoderLink instance is usable. |
| 45 | | bool IsConnected(void) const { return (IsLocal() || sock!=NULL); } |
| | 49 | bool IsConnected(void) { bool value; |
| | 50 | if (disconnected) |
| | 51 | return false; |
| | 52 | value = IsLocal(); |
| | 53 | if (value) |
| | 54 | return value; |
| | 55 | if (sock) |
| | 56 | return true; |
| | 57 | return false; |
| | 58 | } |
| 46 | 59 | /// \brief Returns true if the encoder is awake. |
| 47 | 60 | bool IsAwake(void) const { return (sleepStatus == sStatus_Awake); } |
| 48 | 61 | /// \brief Returns true if the encoder is asleep. |
| … |
… |
class EncoderLink
|
| 82 | 95 | bool IsBusyRecording(void); |
| 83 | 96 | |
| 84 | 97 | TVState GetState(); |
| 85 | | uint GetFlags(void) const; |
| | 98 | uint GetFlags(void); |
| 86 | 99 | bool IsRecording(const ProgramInfo *rec); // scheduler call only. |
| 87 | 100 | |
| 88 | 101 | bool MatchesRecording(const ProgramInfo *rec); |
| … |
… |
class EncoderLink
|
| 108 | 121 | void PauseRecorder(void); |
| 109 | 122 | void SetLiveRecording(int); |
| 110 | 123 | void SetNextLiveTVDir(QString dir); |
| 111 | | vector<InputInfo> GetFreeInputs(const vector<uint> &excluded_cards) const; |
| | 124 | vector<InputInfo> GetFreeInputs(const vector<uint> &excluded_cards); |
| 112 | 125 | QString GetInput(void) const; |
| 113 | 126 | QString SetInput(QString); |
| 114 | 127 | void ToggleChannelFavorite(QString); |
| … |
… |
class EncoderLink
|
| 138 | 151 | private: |
| 139 | 152 | int m_capturecardnum; |
| 140 | 153 | |
| | 154 | QMutex sockLock; |
| | 155 | |
| 141 | 156 | PlaybackSock *sock; |
| | 157 | |
| 142 | 158 | QString hostname; |
| 143 | 159 | |
| 144 | 160 | long long freeDiskSpaceKB; |
| … |
… |
class EncoderLink
|
| 147 | 163 | |
| 148 | 164 | bool local; |
| 149 | 165 | bool locked; |
| | 166 | bool disconnected; |
| 150 | 167 | |
| 151 | 168 | SleepStatus sleepStatus; |
| 152 | 169 | QDateTime sleepStatusTime; |
diff --git a/mythtv/programs/mythbackend/mainserver.cpp b/mythtv/programs/mythbackend/mainserver.cpp
index ba1fbc5..e4c5fd2 100644
|
a
|
b
|
void MainServer::connectionClosed(MythSocket *socket)
|
| 5749 | 5749 | if (!elink->IsFallingAsleep()) |
| 5750 | 5750 | isFallingAsleep = false; |
| 5751 | 5751 | |
| 5752 | | elink->SetSocket(NULL); |
| | 5752 | // elink->SetSocket(NULL); |
| | 5753 | elink->Disconnect(); |
| 5753 | 5754 | if (m_sched) |
| 5754 | 5755 | disconnectedSlaves.push_back(elink->GetCardID()); |
| 5755 | 5756 | } |
diff --git a/mythtv/programs/mythbackend/playbacksock.cpp b/mythtv/programs/mythbackend/playbacksock.cpp
index 30b76063..a116e25 100644
|
a
|
b
|
using namespace std;
|
| 17 | 17 | PlaybackSock::PlaybackSock( |
| 18 | 18 | MainServer *parent, MythSocket *lsock, |
| 19 | 19 | QString lhostname, PlaybackSockEventsMode eventsMode) : |
| 20 | | ReferenceCounter("PlaybackSock") |
| | 20 | ReferenceCounter("PlaybackSock"), |
| | 21 | sockLock(QMutex::Recursive) |
| 21 | 22 | { |
| 22 | 23 | m_parent = parent; |
| 23 | 24 | QString localhostname = gCoreContext->GetHostName(); |
| … |
… |
bool PlaybackSock::SendReceiveStringList(
|
| 77 | 78 | { |
| 78 | 79 | bool ok = false; |
| 79 | 80 | |
| | 81 | QMutexLocker locker(&sockLock); |
| | 82 | |
| | 83 | if (!sock) |
| | 84 | return false; |
| | 85 | |
| 80 | 86 | sock->IncrRef(); |
| 81 | | sock->Lock(); |
| | 87 | |
| | 88 | bool status = false; |
| | 89 | unsigned int loop=50; |
| | 90 | status = sock->TryLock(false); |
| | 91 | while ((status == false) && (loop > 0)) |
| | 92 | { |
| | 93 | --loop; |
| | 94 | locker.unlock(); |
| | 95 | usleep(10000); |
| | 96 | status = sock->TryLock(false); |
| | 97 | } |
| | 98 | if (status == false) |
| | 99 | { |
| | 100 | sock->DecrRef(); |
| | 101 | return false; |
| | 102 | |
| | 103 | } |
| | 104 | |
| | 105 | locker.relock(); |
| | 106 | |
| | 107 | if (!sock) |
| | 108 | return false; |
| 82 | 109 | |
| 83 | 110 | { |
| 84 | | QMutexLocker locker(&sockLock); |
| 85 | 111 | expectingreply = true; |
| 86 | 112 | |
| 87 | 113 | sock->writeStringList(strlist); |
| … |
… |
bool PlaybackSock::IsBusy(int capturecardnum, InputInfo *busy_input,
|
| 322 | 348 | { |
| 323 | 349 | QStringList strlist(QString("QUERY_REMOTEENCODER %1").arg(capturecardnum)); |
| 324 | 350 | |
| | 351 | QMutexLocker locker(&sockLock); |
| | 352 | if (disconnected) |
| | 353 | return true; |
| | 354 | |
| 325 | 355 | strlist << "IS_BUSY"; |
| 326 | 356 | strlist << QString::number(time_buffer); |
| 327 | 357 | |
diff --git a/mythtv/programs/mythbackend/playbacksock.h b/mythtv/programs/mythbackend/playbacksock.h
index c273604..a74d43b 100644
|
a
|
b
|
class PlaybackSock : public ReferenceCounter
|
| 31 | 31 | QString lhostname, PlaybackSockEventsMode eventsMode); |
| 32 | 32 | virtual ~PlaybackSock(); |
| 33 | 33 | |
| 34 | | void SetDisconnected(void) { disconnected = true; } |
| | 34 | void SetDisconnected(void) { QMutexLocker locker(&sockLock); disconnected = true; } |
| 35 | 35 | bool IsDisconnected(void) const { return disconnected; } |
| 36 | 36 | |
| 37 | 37 | MythSocket *getSocket(void) const { return sock; } |