Ticket #2434: 2434-v3.patch
File 2434-v3.patch, 7.3 KB (added by , 17 years ago) |
---|
-
libs/libmythtv/NuppelVideoPlayer.cpp
401 401 PauseDecoder(); 402 402 403 403 //cout << "stopping other threads" << endl; 404 internalPauseLock.lock(); 404 405 PauseVideo(waitvideo); 406 internalPauseLock.unlock(); 407 405 408 if (audioOutput) 406 409 { 407 410 audio_paused = true; … … 428 431 QString("Play(%1, normal %2, unpause audio %3)") 429 432 .arg(speed,5,'f',1).arg(normal).arg(unpauseaudio)); 430 433 434 internalPauseLock.lock(); 431 435 UnpauseVideo(); 436 internalPauseLock.unlock(); 437 432 438 if (audioOutput && unpauseaudio) 433 439 audio_paused = false; 434 440 if (ringBuffer) … … 446 452 return (actuallypaused && 447 453 (ringBuffer == NULL || ringBuffer->isPaused()) && 448 454 (audioOutput == NULL || audioOutput->GetPause()) && 449 GetVideoPause());455 IsVideoActuallyPaused()); 450 456 } 451 457 452 458 void NuppelVideoPlayer::PauseVideo(bool wait) 453 459 { 460 QMutexLocker locker(&pauseUnpauseLock); 454 461 video_actually_paused = false; 455 462 pausevideo = true; 456 463 457 if (wait && !video_actually_paused)464 for (uint i = 0; wait && !video_actually_paused; i++) 458 465 { 459 while (!videoThreadPaused.wait(1000)) 460 { 461 if (eof) 462 return; 466 videoThreadPaused.wait(&pauseUnpauseLock, 250); 467 468 if (video_actually_paused || eof) 469 break; 470 471 if ((i % 10) == 9) 463 472 VERBOSE(VB_IMPORTANT, "Waited too long for video out to pause"); 464 }465 473 } 466 474 } 467 475 468 void NuppelVideoPlayer::UnpauseVideo( void)476 void NuppelVideoPlayer::UnpauseVideo(bool wait) 469 477 { 478 QMutexLocker locker(&pauseUnpauseLock); 470 479 pausevideo = false; 480 481 for (uint i = 0; wait && video_actually_paused; i++) 482 { 483 videoThreadUnpaused.wait(&pauseUnpauseLock, 250); 484 485 if (!video_actually_paused || eof) 486 break; 487 488 if ((i % 10) == 9) 489 VERBOSE(VB_IMPORTANT, "Waited too long for video out to unpause"); 490 } 471 491 } 472 492 493 void NuppelVideoPlayer::SetVideoActuallyPaused(bool val) 494 { 495 QMutexLocker locker(&pauseUnpauseLock); 496 video_actually_paused = val; 497 498 if (val) 499 videoThreadPaused.wakeAll(); 500 else 501 videoThreadUnpaused.wakeAll(); 502 } 503 504 bool NuppelVideoPlayer::IsVideoActuallyPaused(void) const 505 { 506 QMutexLocker locker(&pauseUnpauseLock); 507 return video_actually_paused; 508 } 509 473 510 void NuppelVideoPlayer::SetPrebuffering(bool prebuffer) 474 511 { 475 512 prebuffering_lock.lock(); … … 2300 2337 resetvideo = false; 2301 2338 } 2302 2339 2303 video_actually_paused = true; 2304 videoThreadPaused.wakeAll(); 2340 SetVideoActuallyPaused(true); 2305 2341 2306 2342 if (videoOutput->IsErrored()) 2307 2343 { … … 2408 2444 2409 2445 void NuppelVideoPlayer::DisplayNormalFrame(void) 2410 2446 { 2411 video_actually_paused = false;2447 SetVideoActuallyPaused(false); 2412 2448 resetvideo = false; 2413 2449 2414 2450 if (!ringBuffer->InDVDMenuOrStillFrame() || … … 2692 2728 } 2693 2729 2694 2730 resetvideo = false; 2695 video_actually_paused = pausevideo;2731 SetVideoActuallyPaused(pausevideo); 2696 2732 2697 2733 if (pausevideo) 2698 2734 { 2699 videoThreadPaused.wakeAll();2700 2735 videofiltersLock.lock(); 2701 2736 videoOutput->ProcessFrame(NULL, osd, videoFilters, pipplayer); 2702 2737 videofiltersLock.unlock(); … … 3332 3367 3333 3368 if (rewindtime >= 1) 3334 3369 { 3335 PauseVideo();3370 QMutexLocker locker(&internalPauseLock); 3336 3371 3372 PauseVideo(true); 3337 3373 DoRewind(); 3338 3339 UnpauseVideo(); 3340 while (GetVideoPause()) 3341 usleep(1000); 3374 UnpauseVideo(true); 3342 3375 } 3343 3376 rewindtime = 0; 3344 3377 } … … 3349 3382 3350 3383 if (fftime >= 5) 3351 3384 { 3352 PauseVideo();3385 QMutexLocker locker(&internalPauseLock); 3353 3386 3387 PauseVideo(true); 3388 3354 3389 if (fftime >= 5) 3355 3390 DoFastForward(); 3356 3391 3357 3392 if (eof) 3358 3393 continue; 3359 3394 3360 UnpauseVideo(); 3361 while (GetVideoPause()) 3362 usleep(1000); 3395 UnpauseVideo(true); 3363 3396 } 3364 3397 3365 3398 fftime = 0; … … 3367 3400 3368 3401 if (need_change_dvd_track) 3369 3402 { 3370 PauseVideo();3403 QMutexLocker locker(&internalPauseLock); 3371 3404 3405 PauseVideo(true); 3372 3406 DoChangeDVDTrack(); 3407 UnpauseVideo(true); 3373 3408 3374 UnpauseVideo();3375 while (GetVideoPause())3376 usleep(1000);3377 3378 3409 need_change_dvd_track = 0; 3379 3410 } 3380 3411 3381 3412 if (skipcommercials != 0 && ffrew_skip == 1) 3382 3413 { 3383 PauseVideo();3414 QMutexLocker locker(&internalPauseLock); 3384 3415 3416 PauseVideo(true); 3385 3417 DoSkipCommercials(skipcommercials); 3386 UnpauseVideo(); 3387 while (GetVideoPause()) 3388 usleep(1000); 3418 UnpauseVideo(true); 3389 3419 3390 3420 skipcommercials = 0; 3391 3421 continue; … … 3418 3448 } 3419 3449 else 3420 3450 { 3421 PauseVideo(); 3451 QMutexLocker locker(&internalPauseLock); 3452 3453 PauseVideo(true); 3422 3454 JumpToFrame(deleteIter.key()); 3423 UnpauseVideo(); 3424 while (GetVideoPause()) 3425 usleep(1000); 3455 UnpauseVideo(true); 3426 3456 } 3427 3457 } 3428 3458 } … … 5765 5795 .arg(commBreakIter.key() - 5766 5796 (int)(commrewindamount * video_frame_rate))); 5767 5797 5768 PauseVideo(); 5798 internalPauseLock.lock(); 5799 5800 PauseVideo(true); 5769 5801 JumpToFrame(commBreakIter.key() - 5770 5802 (int)(commrewindamount * video_frame_rate)); 5771 UnpauseVideo(); 5772 while (GetVideoPause()) 5773 usleep(1000); 5803 UnpauseVideo(true); 5774 5804 5805 internalPauseLock.unlock(); 5806 5775 5807 GetFrame(1, true); 5776 5808 } 5777 5809 else -
libs/libmythtv/NuppelVideoPlayer.h
418 418 419 419 // Private pausing stuff 420 420 void PauseVideo(bool wait = true); 421 void UnpauseVideo(void); 422 bool GetVideoPause(void) const { return video_actually_paused; } 421 void UnpauseVideo(bool wait = false); 422 void SetVideoActuallyPaused(bool val); 423 bool IsVideoActuallyPaused(void) const; 423 424 424 425 // Private decoder stuff 425 426 void SetDecoder(DecoderBase *dec); … … 523 524 // State 524 525 QWaitCondition decoderThreadPaused; 525 526 QWaitCondition videoThreadPaused; 526 QMutex vidExitLock; 527 QWaitCondition videoThreadUnpaused; 528 mutable QMutex vidExitLock; 529 mutable QMutex pauseUnpauseLock; 530 mutable QMutex internalPauseLock; 527 531 bool eof; ///< At end of file/ringbuffer 528 532 bool m_double_framerate;///< Output fps is double Video (input) rate 529 533 bool m_can_double; ///< VideoOutput capable of doubling frame rate