diff --git a/mythtv/programs/mythbackend/encoderlink.cpp b/mythtv/programs/mythbackend/encoderlink.cpp
index 2c7bc76..95cf662 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; |
| 113 | 108 | } |
| 114 | 109 | |
| | 110 | void EncoderLink::Disconnect() |
| | 111 | { |
| | 112 | disconnected = true; |
| | 113 | if (IsFallingAsleep()) |
| | 114 | SetSleepStatus(sStatus_Asleep); |
| | 115 | else |
| | 116 | SetSleepStatus(sStatus_Undefined); |
| | 117 | |
| | 118 | if (sock) |
| | 119 | sock->DecrRef(); |
| | 120 | } |
| | 121 | |
| 115 | 122 | /** \fn EncoderLink::SetSleepStatus(SleepStatus) |
| 116 | 123 | * \brief Sets the sleep status of a recorder |
| 117 | 124 | */ |
| … |
… |
void EncoderLink::SetSleepStatus(SleepStatus newStatus)
|
| 128 | 135 | */ |
| 129 | 136 | bool EncoderLink::IsBusy(TunedInputInfo *busy_input, int time_buffer) |
| 130 | 137 | { |
| | 138 | if (disconnected) |
| | 139 | return false; |
| | 140 | |
| 131 | 141 | if (local) |
| 132 | 142 | return tv->IsBusy(busy_input, time_buffer); |
| 133 | 143 | |
| | 144 | QMutexLocker locker(&sockLock); |
| 134 | 145 | if (sock) |
| 135 | 146 | return sock->IsBusy(m_capturecardnum, busy_input, time_buffer); |
| 136 | 147 | |
| … |
… |
bool EncoderLink::IsBusyRecording(void)
|
| 149 | 160 | { |
| 150 | 161 | bool retval = false; |
| 151 | 162 | |
| | 163 | if (disconnected) |
| | 164 | return false; |
| | 165 | |
| 152 | 166 | TVState state = GetState(); |
| 153 | 167 | |
| 154 | 168 | if (state == kState_RecordingOnly || state == kState_WatchingRecording || |
| … |
… |
TVState EncoderLink::GetState(void)
|
| 174 | 188 | if (local) |
| 175 | 189 | retval = tv->GetState(); |
| 176 | 190 | else if (sock) |
| 177 | | retval = (TVState)sock->GetEncoderState(m_capturecardnum); |
| | 191 | { |
| | 192 | QMutexLocker locker(&sockLock); |
| | 193 | if (sock) |
| | 194 | retval = (TVState)sock->GetEncoderState(m_capturecardnum); |
| | 195 | } |
| 178 | 196 | else |
| 179 | 197 | LOG(VB_GENERAL, LOG_ERR, QString("Broken for card: %1") |
| 180 | 198 | .arg(m_capturecardnum)); |
| … |
… |
TVState EncoderLink::GetState(void)
|
| 186 | 204 | * \brief Returns the flag state of the recorder. |
| 187 | 205 | * \sa TVRec::GetFlags(void) const, \ref recorder_subsystem |
| 188 | 206 | */ |
| 189 | | uint EncoderLink::GetFlags(void) const |
| | 207 | uint EncoderLink::GetFlags(void) |
| 190 | 208 | { |
| 191 | 209 | uint retval = 0; |
| 192 | 210 | |
| 193 | | if (!IsConnected()) |
| | 211 | if (disconnected) |
| 194 | 212 | return retval; |
| 195 | 213 | |
| 196 | 214 | if (local) |
| 197 | 215 | retval = tv->GetFlags(); |
| 198 | 216 | else if (sock) |
| 199 | | retval = sock->GetEncoderState(m_capturecardnum); |
| | 217 | { |
| | 218 | QMutexLocker locker(&sockLock); |
| | 219 | if (sock) |
| | 220 | retval = sock->GetEncoderState(m_capturecardnum); |
| | 221 | } |
| 200 | 222 | else |
| 201 | 223 | LOG(VB_GENERAL, LOG_ERR, LOC + "GetFlags failed"); |
| 202 | 224 | |
| … |
… |
uint EncoderLink::GetFlags(void) const
|
| 210 | 232 | */ |
| 211 | 233 | bool EncoderLink::IsRecording(const ProgramInfo *rec) |
| 212 | 234 | { |
| | 235 | if (disconnected) |
| | 236 | return false; |
| 213 | 237 | return (rec->GetChanID() == chanid && |
| 214 | 238 | rec->GetRecordingStartTime() == startRecordingTime); |
| 215 | 239 | } |
| … |
… |
bool EncoderLink::MatchesRecording(const ProgramInfo *rec)
|
| 227 | 251 | bool retval = false; |
| 228 | 252 | ProgramInfo *tvrec = NULL; |
| 229 | 253 | |
| | 254 | if (disconnected) |
| | 255 | return false; |
| | 256 | |
| 230 | 257 | if (local) |
| 231 | 258 | { |
| 232 | 259 | while (kState_ChangingState == GetState()) |
| … |
… |
bool EncoderLink::MatchesRecording(const ProgramInfo *rec)
|
| 243 | 270 | } |
| 244 | 271 | else |
| 245 | 272 | { |
| | 273 | QMutexLocker locker(&sockLock); |
| 246 | 274 | if (sock) |
| 247 | 275 | retval = sock->EncoderIsRecording(m_capturecardnum, rec); |
| 248 | 276 | } |
| … |
… |
bool EncoderLink::MatchesRecording(const ProgramInfo *rec)
|
| 261 | 289 | void EncoderLink::RecordPending(const ProgramInfo *rec, int secsleft, |
| 262 | 290 | bool hasLater) |
| 263 | 291 | { |
| | 292 | if (disconnected) |
| | 293 | return; |
| | 294 | |
| 264 | 295 | if (local) |
| 265 | 296 | tv->RecordPending(rec, secsleft, hasLater); |
| 266 | | else if (sock) |
| 267 | | sock->RecordPending(m_capturecardnum, rec, secsleft, hasLater); |
| | 297 | else |
| | 298 | { |
| | 299 | QMutexLocker locker(&sockLock); |
| | 300 | if (sock) |
| | 301 | sock->RecordPending(m_capturecardnum, rec, secsleft, hasLater); |
| | 302 | } |
| 268 | 303 | } |
| 269 | 304 | |
| 270 | 305 | /** \fn EncoderLink::WouldConflict(const ProgramInfo*) |
| … |
… |
bool EncoderLink::WouldConflict(const ProgramInfo *rec)
|
| 286 | 321 | /// Checks if program is stored locally |
| 287 | 322 | bool EncoderLink::CheckFile(ProgramInfo *pginfo) |
| 288 | 323 | { |
| | 324 | if (disconnected) |
| | 325 | return false; |
| | 326 | |
| | 327 | QMutexLocker locker(&sockLock); |
| 289 | 328 | if (sock) |
| 290 | 329 | return sock->CheckFile(pginfo); |
| 291 | 330 | |
| … |
… |
bool EncoderLink::CheckFile(ProgramInfo *pginfo)
|
| 300 | 339 | */ |
| 301 | 340 | void EncoderLink::GetDiskSpace(QStringList &o_strlist) |
| 302 | 341 | { |
| | 342 | if (disconnected) |
| | 343 | return; |
| | 344 | |
| | 345 | QMutexLocker locker(&sockLock); |
| 303 | 346 | if (sock) |
| 304 | 347 | sock->GetDiskSpace(o_strlist); |
| 305 | 348 | } |
| … |
… |
void EncoderLink::GetDiskSpace(QStringList &o_strlist)
|
| 312 | 355 | */ |
| 313 | 356 | long long EncoderLink::GetMaxBitrate() |
| 314 | 357 | { |
| | 358 | if (disconnected) |
| | 359 | return -1; |
| | 360 | |
| 315 | 361 | if (local) |
| 316 | 362 | return tv->GetMaxBitrate(); |
| 317 | | else if (sock) |
| 318 | | return sock->GetMaxBitrate(m_capturecardnum); |
| 319 | | |
| | 363 | else |
| | 364 | { |
| | 365 | QMutexLocker locker(&sockLock); |
| | 366 | if (sock) |
| | 367 | return sock->GetMaxBitrate(m_capturecardnum); |
| | 368 | } |
| 320 | 369 | return -1; |
| 321 | 370 | } |
| 322 | 371 | |
| … |
… |
int EncoderLink::SetSignalMonitoringRate(int rate, int notifyFrontend)
|
| 338 | 387 | { |
| 339 | 388 | if (local) |
| 340 | 389 | return tv->SetSignalMonitoringRate(rate, notifyFrontend); |
| 341 | | else if (sock) |
| 342 | | return sock->SetSignalMonitoringRate(m_capturecardnum, rate, |
| 343 | | notifyFrontend); |
| | 390 | else |
| | 391 | { |
| | 392 | QMutexLocker locker(&sockLock); |
| | 393 | if (sock) |
| | 394 | return sock->SetSignalMonitoringRate(m_capturecardnum, rate, |
| | 395 | notifyFrontend); |
| | 396 | } |
| 344 | 397 | return -1; |
| 345 | 398 | } |
| 346 | 399 | |
| … |
… |
int EncoderLink::SetSignalMonitoringRate(int rate, int notifyFrontend)
|
| 348 | 401 | */ |
| 349 | 402 | bool EncoderLink::GoToSleep(void) |
| 350 | 403 | { |
| 351 | | if (IsLocal() || !sock) |
| | 404 | if (disconnected) |
| 352 | 405 | return false; |
| 353 | 406 | |
| | 407 | if (IsLocal()) |
| | 408 | return false; |
| | 409 | |
| | 410 | QMutexLocker locker(&sockLock); |
| | 411 | if (!sock) |
| | 412 | return false; |
| | 413 | |
| | 414 | if (sock->getBlockShutdown()) |
| | 415 | { |
| | 416 | LOG(VB_GENERAL, LOG_NOTICE, |
| | 417 | QString("EncoderLink::GoToSleep() Socket shutdown is currently blocked!")); |
| | 418 | return false; |
| | 419 | } |
| | 420 | |
| 354 | 421 | lastSleepTime = MythDate::current(); |
| 355 | 422 | |
| 356 | 423 | return sock->GoToSleep(); |
| … |
… |
bool EncoderLink::GoToSleep(void)
|
| 362 | 429 | */ |
| 363 | 430 | int EncoderLink::LockTuner() |
| 364 | 431 | { |
| | 432 | if (disconnected) |
| | 433 | return -2; |
| | 434 | |
| 365 | 435 | if (locked) |
| 366 | 436 | return -2; |
| 367 | 437 | |
| … |
… |
RecStatusType EncoderLink::StartRecording(const ProgramInfo *rec)
|
| 380 | 450 | { |
| 381 | 451 | RecStatusType retval = rsAborted; |
| 382 | 452 | |
| | 453 | if (disconnected) |
| | 454 | return retval; |
| | 455 | |
| 383 | 456 | endRecordingTime = rec->GetRecordingEndTime(); |
| 384 | 457 | startRecordingTime = rec->GetRecordingStartTime(); |
| 385 | 458 | chanid = rec->GetChanID(); |
| 386 | 459 | |
| 387 | 460 | if (local) |
| 388 | 461 | retval = tv->StartRecording(rec); |
| 389 | | else if (sock) |
| 390 | | retval = sock->StartRecording(m_capturecardnum, rec); |
| 391 | 462 | 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)); |
| | 463 | { |
| | 464 | QMutexLocker locker(&sockLock); |
| | 465 | if (sock) |
| | 466 | retval = sock->StartRecording(m_capturecardnum, rec); |
| | 467 | else |
| | 468 | LOG(VB_GENERAL, LOG_ERR, |
| | 469 | QString("Wanted to start recording on recorder %1,\n\t\t\t" |
| | 470 | "but the backend is not there anymore\n") |
| | 471 | .arg(m_capturecardnum)); |
| | 472 | } |
| 396 | 473 | |
| 397 | 474 | if (retval != rsRecording && retval != rsTuning) |
| 398 | 475 | { |
| … |
… |
RecStatusType EncoderLink::GetRecordingStatus(void)
|
| 408 | 485 | { |
| 409 | 486 | RecStatusType retval = rsAborted; |
| 410 | 487 | |
| | 488 | if (disconnected) |
| | 489 | return retval; |
| | 490 | |
| 411 | 491 | if (local) |
| 412 | 492 | retval = tv->GetRecordingStatus(); |
| 413 | | else if (sock) |
| 414 | | retval = sock->GetRecordingStatus(m_capturecardnum); |
| 415 | 493 | 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)); |
| | 494 | { |
| | 495 | QMutexLocker locker(&sockLock); |
| | 496 | if (sock) |
| | 497 | retval = sock->GetRecordingStatus(m_capturecardnum); |
| | 498 | else |
| | 499 | LOG(VB_GENERAL, LOG_ERR, |
| | 500 | QString("Wanted to get status on recorder %1,\n\t\t\t" |
| | 501 | "but the backend is not there anymore\n") |
| | 502 | .arg(m_capturecardnum)); |
| | 503 | } |
| 420 | 504 | |
| 421 | 505 | if (retval != rsRecording && retval != rsTuning) |
| 422 | 506 | { |
| … |
… |
ProgramInfo *EncoderLink::GetRecording(void)
|
| 438 | 522 | { |
| 439 | 523 | ProgramInfo *info = NULL; |
| 440 | 524 | |
| | 525 | if (disconnected) |
| | 526 | return info; |
| | 527 | |
| 441 | 528 | if (local) |
| 442 | 529 | info = tv->GetRecording(); |
| 443 | | else if (sock) |
| 444 | | info = sock->GetRecording(m_capturecardnum); |
| | 530 | else |
| | 531 | { |
| | 532 | QMutexLocker locker(&sockLock); |
| | 533 | if (sock) |
| | 534 | info = sock->GetRecording(m_capturecardnum); |
| | 535 | } |
| 445 | 536 | |
| 446 | 537 | return info; |
| 447 | 538 | } |
| … |
… |
ProgramInfo *EncoderLink::GetRecording(void)
|
| 453 | 544 | */ |
| 454 | 545 | void EncoderLink::StopRecording(bool killFile) |
| 455 | 546 | { |
| | 547 | if (disconnected) |
| | 548 | return; |
| | 549 | |
| 456 | 550 | endRecordingTime = MythDate::current().addDays(-2); |
| 457 | 551 | startRecordingTime = endRecordingTime; |
| 458 | 552 | chanid = 0; |
| … |
… |
void EncoderLink::StopRecording(bool killFile)
|
| 471 | 565 | */ |
| 472 | 566 | void EncoderLink::FinishRecording(void) |
| 473 | 567 | { |
| | 568 | if (disconnected) |
| | 569 | return; |
| | 570 | |
| 474 | 571 | if (local) |
| 475 | 572 | { |
| 476 | 573 | tv->FinishRecording(); |
| … |
… |
bool EncoderLink::IsReallyRecording(void)
|
| 505 | 602 | */ |
| 506 | 603 | float EncoderLink::GetFramerate(void) |
| 507 | 604 | { |
| | 605 | if (disconnected) |
| | 606 | return -1; |
| | 607 | |
| 508 | 608 | if (local) |
| 509 | 609 | return tv->GetFramerate(); |
| 510 | 610 | |
| … |
… |
float EncoderLink::GetFramerate(void)
|
| 521 | 621 | */ |
| 522 | 622 | long long EncoderLink::GetFramesWritten(void) |
| 523 | 623 | { |
| | 624 | if (disconnected) |
| | 625 | return -1; |
| | 626 | |
| 524 | 627 | if (local) |
| 525 | 628 | return tv->GetFramesWritten(); |
| 526 | 629 | |
| … |
… |
long long EncoderLink::GetFramesWritten(void)
|
| 536 | 639 | */ |
| 537 | 640 | long long EncoderLink::GetFilePosition(void) |
| 538 | 641 | { |
| | 642 | if (disconnected) |
| | 643 | return -1; |
| | 644 | |
| 539 | 645 | if (local) |
| 540 | 646 | return tv->GetFilePosition(); |
| 541 | 647 | |
| … |
… |
long long EncoderLink::GetFilePosition(void)
|
| 551 | 657 | */ |
| 552 | 658 | int64_t EncoderLink::GetKeyframePosition(uint64_t desired) |
| 553 | 659 | { |
| | 660 | if (disconnected) |
| | 661 | return -1; |
| | 662 | |
| 554 | 663 | if (local) |
| 555 | 664 | return tv->GetKeyframePosition(desired); |
| 556 | 665 | |
| … |
… |
int64_t EncoderLink::GetKeyframePosition(uint64_t desired)
|
| 561 | 670 | bool EncoderLink::GetKeyframePositions( |
| 562 | 671 | int64_t start, int64_t end, frm_pos_map_t &map) |
| 563 | 672 | { |
| | 673 | if (disconnected) |
| | 674 | return false; |
| | 675 | |
| 564 | 676 | if (!local) |
| 565 | 677 | { |
| 566 | 678 | LOG(VB_GENERAL, LOG_ERR, |
| … |
… |
bool EncoderLink::GetKeyframePositions(
|
| 578 | 690 | */ |
| 579 | 691 | void EncoderLink::FrontendReady(void) |
| 580 | 692 | { |
| | 693 | if (disconnected) |
| | 694 | return; |
| | 695 | |
| 581 | 696 | if (local) |
| 582 | 697 | tv->FrontendReady(); |
| 583 | 698 | else |
| … |
… |
void EncoderLink::FrontendReady(void)
|
| 594 | 709 | */ |
| 595 | 710 | void EncoderLink::CancelNextRecording(bool cancel) |
| 596 | 711 | { |
| | 712 | if (disconnected) |
| | 713 | return; |
| | 714 | |
| 597 | 715 | if (local) |
| 598 | 716 | tv->CancelNextRecording(cancel); |
| 599 | 717 | else |
| 600 | | sock->CancelNextRecording(m_capturecardnum, cancel); |
| | 718 | { |
| | 719 | QMutexLocker locker(&sockLock); |
| | 720 | if (sock) |
| | 721 | sock->CancelNextRecording(m_capturecardnum, cancel); |
| | 722 | } |
| 601 | 723 | } |
| 602 | 724 | |
| 603 | 725 | /** \fn EncoderLink::SpawnLiveTV(LiveTVChain*, bool, QString) |
| … |
… |
void EncoderLink::CancelNextRecording(bool cancel)
|
| 613 | 735 | */ |
| 614 | 736 | void EncoderLink::SpawnLiveTV(LiveTVChain *chain, bool pip, QString startchan) |
| 615 | 737 | { |
| | 738 | if (disconnected) |
| | 739 | return; |
| | 740 | |
| 616 | 741 | if (local) |
| 617 | 742 | tv->SpawnLiveTV(chain, pip, startchan); |
| 618 | 743 | else |
| … |
… |
void EncoderLink::SpawnLiveTV(LiveTVChain *chain, bool pip, QString startchan)
|
| 624 | 749 | */ |
| 625 | 750 | QString EncoderLink::GetChainID(void) |
| 626 | 751 | { |
| | 752 | if (disconnected) |
| | 753 | return ""; |
| | 754 | |
| 627 | 755 | if (local) |
| 628 | 756 | return tv->GetChainID(); |
| 629 | 757 | |
| … |
… |
QString EncoderLink::GetChainID(void)
|
| 638 | 766 | */ |
| 639 | 767 | void EncoderLink::StopLiveTV(void) |
| 640 | 768 | { |
| | 769 | if (disconnected) |
| | 770 | return; |
| | 771 | |
| 641 | 772 | if (local) |
| 642 | 773 | tv->StopLiveTV(); |
| 643 | 774 | else |
| … |
… |
void EncoderLink::StopLiveTV(void)
|
| 652 | 783 | */ |
| 653 | 784 | void EncoderLink::PauseRecorder(void) |
| 654 | 785 | { |
| | 786 | if (disconnected) |
| | 787 | return; |
| | 788 | |
| 655 | 789 | if (local) |
| 656 | 790 | tv->PauseRecorder(); |
| 657 | 791 | else |
| … |
… |
void EncoderLink::PauseRecorder(void)
|
| 665 | 799 | */ |
| 666 | 800 | void EncoderLink::SetLiveRecording(int recording) |
| 667 | 801 | { |
| | 802 | if (disconnected) |
| | 803 | return; |
| | 804 | |
| 668 | 805 | if (local) |
| 669 | 806 | tv->SetLiveRecording(recording); |
| 670 | 807 | else |
| … |
… |
void EncoderLink::SetLiveRecording(int recording)
|
| 677 | 814 | */ |
| 678 | 815 | void EncoderLink::SetNextLiveTVDir(QString dir) |
| 679 | 816 | { |
| | 817 | if (disconnected) |
| | 818 | return; |
| | 819 | |
| 680 | 820 | if (local) |
| 681 | 821 | tv->SetNextLiveTVDir(dir); |
| 682 | 822 | else |
| 683 | | sock->SetNextLiveTVDir(m_capturecardnum, dir); |
| | 823 | { |
| | 824 | QMutexLocker locker(&sockLock); |
| | 825 | if (sock) |
| | 826 | sock->SetNextLiveTVDir(m_capturecardnum, dir); |
| | 827 | } |
| 684 | 828 | } |
| 685 | 829 | |
| 686 | 830 | /** \fn EncoderLink::GetFreeInputs(const vector<uint>&) const |
| … |
… |
void EncoderLink::SetNextLiveTVDir(QString dir)
|
| 689 | 833 | * \sa TVRec::GetFreeInputs(const vector<uint>&) const |
| 690 | 834 | */ |
| 691 | 835 | vector<InputInfo> EncoderLink::GetFreeInputs( |
| 692 | | const vector<uint> &excluded_cardids) const |
| | 836 | const vector<uint> &excluded_cardids) |
| 693 | 837 | { |
| 694 | 838 | vector<InputInfo> list; |
| 695 | 839 | |
| | 840 | if (disconnected) |
| | 841 | return list; |
| | 842 | |
| 696 | 843 | if (local) |
| 697 | 844 | list = tv->GetFreeInputs(excluded_cardids); |
| 698 | 845 | else |
| 699 | | list = sock->GetFreeInputs(m_capturecardnum, excluded_cardids); |
| | 846 | { |
| | 847 | QMutexLocker locker(&sockLock); |
| | 848 | if (sock) |
| | 849 | list = sock->GetFreeInputs(m_capturecardnum, excluded_cardids); |
| | 850 | } |
| 700 | 851 | |
| 701 | 852 | return list; |
| 702 | 853 | } |
| … |
… |
vector<InputInfo> EncoderLink::GetFreeInputs(
|
| 709 | 860 | */ |
| 710 | 861 | QString EncoderLink::GetInput(void) const |
| 711 | 862 | { |
| | 863 | if (disconnected) |
| | 864 | return QString(); |
| | 865 | |
| 712 | 866 | if (local) |
| 713 | 867 | return tv->GetInput(); |
| 714 | 868 | |
| … |
… |
QString EncoderLink::GetInput(void) const
|
| 728 | 882 | */ |
| 729 | 883 | QString EncoderLink::SetInput(QString input) |
| 730 | 884 | { |
| | 885 | if (disconnected) |
| | 886 | return QString(); |
| | 887 | |
| 731 | 888 | if (local) |
| 732 | 889 | return tv->SetInput(input); |
| 733 | 890 | |
| … |
… |
QString EncoderLink::SetInput(QString input)
|
| 742 | 899 | */ |
| 743 | 900 | void EncoderLink::ToggleChannelFavorite(QString changroup) |
| 744 | 901 | { |
| | 902 | if (disconnected) |
| | 903 | return; |
| | 904 | |
| 745 | 905 | if (local) |
| 746 | 906 | tv->ToggleChannelFavorite(changroup); |
| 747 | 907 | else |
| … |
… |
void EncoderLink::ToggleChannelFavorite(QString changroup)
|
| 757 | 917 | */ |
| 758 | 918 | void EncoderLink::ChangeChannel(ChannelChangeDirection channeldirection) |
| 759 | 919 | { |
| | 920 | if (disconnected) |
| | 921 | return; |
| | 922 | |
| 760 | 923 | if (local) |
| 761 | 924 | tv->ChangeChannel(channeldirection); |
| 762 | 925 | else |
| … |
… |
void EncoderLink::ChangeChannel(ChannelChangeDirection channeldirection)
|
| 772 | 935 | */ |
| 773 | 936 | void EncoderLink::SetChannel(const QString &name) |
| 774 | 937 | { |
| | 938 | if (disconnected) |
| | 939 | return; |
| | 940 | |
| 775 | 941 | if (local) |
| 776 | 942 | tv->SetChannel(name); |
| 777 | 943 | else |
| … |
… |
void EncoderLink::SetChannel(const QString &name)
|
| 788 | 954 | */ |
| 789 | 955 | int EncoderLink::GetPictureAttribute(PictureAttribute attr) |
| 790 | 956 | { |
| | 957 | if (disconnected) |
| | 958 | return -1; |
| | 959 | |
| 791 | 960 | if (!local) |
| 792 | 961 | { |
| 793 | 962 | LOG(VB_GENERAL, LOG_ERR, |
| … |
… |
int EncoderLink::ChangePictureAttribute(PictureAdjustType type,
|
| 810 | 979 | PictureAttribute attr, |
| 811 | 980 | bool direction) |
| 812 | 981 | { |
| | 982 | if (disconnected) |
| | 983 | return -1; |
| | 984 | |
| 813 | 985 | if (!local) |
| 814 | 986 | { |
| 815 | 987 | LOG(VB_GENERAL, LOG_ERR, |
| … |
… |
int EncoderLink::ChangePictureAttribute(PictureAdjustType type,
|
| 831 | 1003 | */ |
| 832 | 1004 | bool EncoderLink::CheckChannel(const QString &name) |
| 833 | 1005 | { |
| | 1006 | if (disconnected) |
| | 1007 | return false; |
| | 1008 | |
| 834 | 1009 | if (local) |
| 835 | 1010 | return tv->CheckChannel(name); |
| 836 | 1011 | |
| … |
… |
bool EncoderLink::CheckChannel(const QString &name)
|
| 849 | 1024 | */ |
| 850 | 1025 | bool EncoderLink::ShouldSwitchToAnotherCard(const QString &channelid) |
| 851 | 1026 | { |
| | 1027 | if (disconnected) |
| | 1028 | return false; |
| | 1029 | |
| 852 | 1030 | if (local) |
| 853 | 1031 | return tv->ShouldSwitchToAnotherCard(channelid); |
| 854 | 1032 | |
| … |
… |
bool EncoderLink::CheckChannelPrefix(
|
| 870 | 1048 | bool &is_extra_char_useful, |
| 871 | 1049 | QString &needed_spacer) |
| 872 | 1050 | { |
| | 1051 | if (disconnected) |
| | 1052 | return false; |
| | 1053 | |
| 873 | 1054 | if (local) |
| 874 | 1055 | { |
| 875 | 1056 | return tv->CheckChannelPrefix( |
| … |
… |
void EncoderLink::GetNextProgram(BrowseDirection direction,
|
| 897 | 1078 | QString &channelname, uint &_chanid, |
| 898 | 1079 | QString &seriesid, QString &programid) |
| 899 | 1080 | { |
| | 1081 | if (disconnected) |
| | 1082 | return; |
| | 1083 | |
| 900 | 1084 | if (local) |
| 901 | 1085 | { |
| 902 | 1086 | tv->GetNextProgram(direction, |
| … |
… |
bool EncoderLink::GetChannelInfo(uint &chanid, uint &sourceid,
|
| 912 | 1096 | QString &callsign, QString &channum, |
| 913 | 1097 | QString &channame, QString &xmltv) const |
| 914 | 1098 | { |
| | 1099 | if (disconnected) |
| | 1100 | return false; |
| | 1101 | |
| 915 | 1102 | if (!local) |
| 916 | 1103 | { |
| 917 | 1104 | LOG(VB_GENERAL, LOG_ERR, "Should be local only query: GetChannelInfo"); |
| … |
… |
bool EncoderLink::SetChannelInfo(uint chanid, uint sourceid,
|
| 927 | 1114 | QString callsign, QString channum, |
| 928 | 1115 | QString channame, QString xmltv) |
| 929 | 1116 | { |
| | 1117 | if (disconnected) |
| | 1118 | return false; |
| | 1119 | |
| 930 | 1120 | if (!local) |
| 931 | 1121 | { |
| 932 | 1122 | 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..36bd6fc 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=10; |
| | 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 | { |
| | 109 | sock->DecrRef(); |
| | 110 | return false; |
| | 111 | } |
| 82 | 112 | |
| 83 | 113 | { |
| 84 | | QMutexLocker locker(&sockLock); |
| 85 | 114 | expectingreply = true; |
| 86 | 115 | |
| 87 | 116 | sock->writeStringList(strlist); |
| … |
… |
bool PlaybackSock::IsBusy(int capturecardnum, InputInfo *busy_input,
|
| 322 | 351 | { |
| 323 | 352 | QStringList strlist(QString("QUERY_REMOTEENCODER %1").arg(capturecardnum)); |
| 324 | 353 | |
| | 354 | QMutexLocker locker(&sockLock); |
| | 355 | if (disconnected) |
| | 356 | return true; |
| | 357 | |
| 325 | 358 | strlist << "IS_BUSY"; |
| 326 | 359 | strlist << QString::number(time_buffer); |
| 327 | 360 | |
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; } |