Ticket #2434: 2434-v2.patch
File 2434-v2.patch, 7.2 KB (added by , 17 years ago) |
---|
-
libs/libmythtv/NuppelVideoPlayer.cpp
398 398 PauseDecoder(); 399 399 400 400 //cout << "stopping other threads" << endl; 401 internalPauseLock.lock(); 401 402 PauseVideo(waitvideo); 403 internalPauseLock.unlock(); 404 402 405 if (audioOutput) 403 406 { 404 407 audio_paused = true; … … 425 428 QString("Play(%1, normal %2, unpause audio %3)") 426 429 .arg(speed,5,'f',1).arg(normal).arg(unpauseaudio)); 427 430 431 internalPauseLock.lock(); 428 432 UnpauseVideo(); 433 internalPauseLock.unlock(); 434 429 435 if (audioOutput && unpauseaudio) 430 436 audio_paused = false; 431 437 if (ringBuffer) … … 443 449 return (actuallypaused && 444 450 (ringBuffer == NULL || ringBuffer->isPaused()) && 445 451 (audioOutput == NULL || audioOutput->GetPause()) && 446 GetVideoPause());452 IsVideoActuallyPaused()); 447 453 } 448 454 449 455 void NuppelVideoPlayer::PauseVideo(bool wait) 450 456 { 457 QMutexLocker locker(&pauseUnpauseLock); 451 458 video_actually_paused = false; 452 459 pausevideo = true; 453 460 454 if (wait && !video_actually_paused) 455 { 456 while (!videoThreadPaused.wait(1000)) 461 for (uint i = 0; wait && !video_actually_paused; i++) 457 462 { 458 if (eof) 459 return; 463 videoThreadPaused.wait(&pauseUnpauseLock, 250); 464 465 if (video_actually_paused || eof) 466 break; 467 468 if ((i % 10) == 9) 460 469 VERBOSE(VB_IMPORTANT, "Waited too long for video out to pause"); 461 470 } 462 }463 471 } 464 472 465 void NuppelVideoPlayer::UnpauseVideo( void)473 void NuppelVideoPlayer::UnpauseVideo(bool wait) 466 474 { 475 QMutexLocker locker(&pauseUnpauseLock); 467 476 pausevideo = false; 477 478 for (uint i = 0; wait && video_actually_paused; i++) 479 { 480 videoThreadUnpaused.wait(&pauseUnpauseLock, 250); 481 482 if (!video_actually_paused || eof) 483 break; 484 485 if ((i % 10) == 9) 486 VERBOSE(VB_IMPORTANT, "Waited too long for video out to unpause"); 487 } 488 } 489 490 void NuppelVideoPlayer::SetVideoActuallyPaused(bool val) 491 { 492 QMutexLocker locker(&pauseUnpauseLock); 493 video_actually_paused = val; 494 495 if (val) 496 videoThreadPaused.wakeAll(); 497 else 498 videoThreadUnpaused.wakeAll(); 468 499 } 469 500 470 501 void NuppelVideoPlayer::SetPrebuffering(bool prebuffer) … … 2291 2322 resetvideo = false; 2292 2323 } 2293 2324 2294 video_actually_paused = true; 2295 videoThreadPaused.wakeAll(); 2325 SetVideoActuallyPaused(true); 2296 2326 2297 2327 if (videoOutput->IsErrored()) 2298 2328 { … … 2391 2421 2392 2422 void NuppelVideoPlayer::DisplayNormalFrame(void) 2393 2423 { 2394 video_actually_paused = false;2424 SetVideoActuallyPaused(false); 2395 2425 resetvideo = false; 2396 2426 2397 2427 if (!ringBuffer->InDVDMenuOrStillFrame()) … … 2674 2704 } 2675 2705 2676 2706 resetvideo = false; 2677 video_actually_paused = pausevideo;2707 SetVideoActuallyPaused(pausevideo); 2678 2708 2679 2709 if (pausevideo) 2680 2710 { 2681 videoThreadPaused.wakeAll();2682 2711 videofiltersLock.lock(); 2683 2712 videoOutput->ProcessFrame(NULL, osd, videoFilters, pipplayer); 2684 2713 videofiltersLock.unlock(); … … 3297 3326 3298 3327 if (rewindtime >= 1) 3299 3328 { 3300 PauseVideo();3329 QMutexLocker locker(&internalPauseLock); 3301 3330 3331 PauseVideo(true); 3302 3332 DoRewind(); 3303 3304 UnpauseVideo(); 3305 while (GetVideoPause()) 3306 usleep(1000); 3333 UnpauseVideo(true); 3307 3334 } 3308 3335 rewindtime = 0; 3309 3336 } … … 3314 3341 3315 3342 if (fftime >= 5) 3316 3343 { 3317 PauseVideo(); 3344 QMutexLocker locker(&internalPauseLock); 3345 3346 PauseVideo(true); 3318 3347 3319 3348 if (fftime >= 5) 3320 3349 DoFastForward(); … … 3322 3351 if (eof) 3323 3352 continue; 3324 3353 3325 UnpauseVideo(); 3326 while (GetVideoPause()) 3327 usleep(1000); 3354 UnpauseVideo(true); 3328 3355 } 3329 3356 3330 3357 fftime = 0; … … 3332 3359 3333 3360 if (need_change_dvd_track) 3334 3361 { 3335 PauseVideo();3362 QMutexLocker locker(&internalPauseLock); 3336 3363 3364 PauseVideo(true); 3337 3365 DoChangeDVDTrack(); 3338 3339 UnpauseVideo(); 3340 while (GetVideoPause()) 3341 usleep(1000); 3366 UnpauseVideo(true); 3342 3367 3343 3368 need_change_dvd_track = 0; 3344 3369 } 3345 3370 3346 3371 if (skipcommercials != 0 && ffrew_skip == 1) 3347 3372 { 3348 PauseVideo();3373 QMutexLocker locker(&internalPauseLock); 3349 3374 3375 PauseVideo(true); 3350 3376 DoSkipCommercials(skipcommercials); 3351 UnpauseVideo(); 3352 while (GetVideoPause()) 3353 usleep(1000); 3377 UnpauseVideo(true); 3354 3378 3355 3379 skipcommercials = 0; 3356 3380 continue; … … 3377 3401 eof = true; 3378 3402 else 3379 3403 { 3380 PauseVideo(); 3404 QMutexLocker locker(&internalPauseLock); 3405 3406 PauseVideo(true); 3381 3407 JumpToFrame(deleteIter.key()); 3382 UnpauseVideo(); 3383 while (GetVideoPause()) 3384 usleep(1000); 3408 UnpauseVideo(true); 3385 3409 } 3386 3410 } 3387 3411 } … … 5534 5558 .arg(commBreakIter.key() - 5535 5559 (int)(commrewindamount * video_frame_rate))); 5536 5560 5537 PauseVideo(); 5561 { 5562 QMutexLocker locker(&internalPauseLock); 5563 5564 PauseVideo(true); 5538 5565 JumpToFrame(commBreakIter.key() - 5539 5566 (int)(commrewindamount * video_frame_rate)); 5540 UnpauseVideo(); 5541 while (GetVideoPause()) 5542 usleep(1000); 5567 UnpauseVideo(true); 5568 } 5543 5569 5544 5570 GetFrame(1, true); 5545 5571 } -
libs/libmythtv/NuppelVideoPlayer.h
409 409 410 410 // Private pausing stuff 411 411 void PauseVideo(bool wait = true); 412 void UnpauseVideo(void); 413 bool GetVideoPause(void) const { return video_actually_paused; } 412 void UnpauseVideo(bool wait = false); 413 bool IsVideoActuallyPaused(void) const { return video_actually_paused; } 414 void SetVideoActuallyPaused(bool val); 414 415 415 416 // Private decoder stuff 416 417 void SetDecoder(DecoderBase *dec); … … 513 514 // State 514 515 QWaitCondition decoderThreadPaused; 515 516 QWaitCondition videoThreadPaused; 517 QWaitCondition videoThreadUnpaused; 516 518 QMutex vidExitLock; 519 QMutex pauseUnpauseLock; 520 QMutex internalPauseLock; 517 521 bool eof; ///< At end of file/ringbuffer 518 522 bool m_double_framerate;///< Output fps is double Video (input) rate 519 523 bool m_can_double; ///< VideoOutput capable of doubling frame rate