Diffstat (limited to 'core/multimedia/opieplayer/loopcontrol_threaded.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/multimedia/opieplayer/loopcontrol_threaded.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/core/multimedia/opieplayer/loopcontrol_threaded.cpp b/core/multimedia/opieplayer/loopcontrol_threaded.cpp index 3796549..0a1fc17 100644 --- a/core/multimedia/opieplayer/loopcontrol_threaded.cpp +++ b/core/multimedia/opieplayer/loopcontrol_threaded.cpp | |||
@@ -488,137 +488,137 @@ void LoopControl::stop( bool willPlayAgainShortly ) { | |||
488 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 488 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
489 | } | 489 | } |
490 | #endif | 490 | #endif |
491 | 491 | ||
492 | if ( mediaPlayerState->curDecoder() && mediaPlayerState->curDecoder()->isOpen() ) { | 492 | if ( mediaPlayerState->curDecoder() && mediaPlayerState->curDecoder()->isOpen() ) { |
493 | 493 | ||
494 | killTimers(); | 494 | killTimers(); |
495 | 495 | ||
496 | mediaPlayerState->curDecoder()->close(); | 496 | mediaPlayerState->curDecoder()->close(); |
497 | 497 | ||
498 | if ( audioDevice ) { | 498 | if ( audioDevice ) { |
499 | delete audioDevice; | 499 | delete audioDevice; |
500 | delete audioBuffer; | 500 | delete audioBuffer; |
501 | audioDevice = 0; | 501 | audioDevice = 0; |
502 | audioBuffer = 0; | 502 | audioBuffer = 0; |
503 | } | 503 | } |
504 | 504 | ||
505 | } | 505 | } |
506 | } | 506 | } |
507 | 507 | ||
508 | 508 | ||
509 | bool LoopControl::init( const QString& filename ) { | 509 | bool LoopControl::init( const QString& filename ) { |
510 | stop(); | 510 | stop(); |
511 | fileName = filename; | 511 | fileName = filename; |
512 | stream = 0; // only play stream 0 for now | 512 | stream = 0; // only play stream 0 for now |
513 | current_frame = total_video_frames = total_audio_samples = 0; | 513 | current_frame = total_video_frames = total_audio_samples = 0; |
514 | 514 | ||
515 | // qDebug( "Using the %s decoder", mediaPlayerState->curDecoder()->pluginName() ); | 515 | // qDebug( "Using the %s decoder", mediaPlayerState->curDecoder()->pluginName() ); |
516 | 516 | ||
517 | // ### Hack to use libmpeg3plugin to get the number of audio samples if we are using the libmad plugin | 517 | // ### Hack to use libmpeg3plugin to get the number of audio samples if we are using the libmad plugin |
518 | if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibMadPlugin") ) { | 518 | if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibMadPlugin") ) { |
519 | if ( mediaPlayerState->libMpeg3Decoder() && mediaPlayerState->libMpeg3Decoder()->open( filename ) ) { | 519 | if ( mediaPlayerState->libMpeg3Decoder() && mediaPlayerState->libMpeg3Decoder()->open( filename ) ) { |
520 | total_audio_samples = mediaPlayerState->libMpeg3Decoder()->audioSamples( 0 ); | 520 | total_audio_samples = mediaPlayerState->libMpeg3Decoder()->audioSamples( 0 ); |
521 | mediaPlayerState->libMpeg3Decoder()->close(); | 521 | mediaPlayerState->libMpeg3Decoder()->close(); |
522 | } | 522 | } |
523 | } | 523 | } |
524 | 524 | ||
525 | if ( !mediaPlayerState->curDecoder()|| !mediaPlayerState->curDecoder()->open( filename ) ) | 525 | if ( !mediaPlayerState->curDecoder()|| !mediaPlayerState->curDecoder()->open( filename ) ) |
526 | return FALSE; | 526 | return FALSE; |
527 | 527 | ||
528 | hasAudioChannel = mediaPlayerState->curDecoder()->audioStreams() > 0; | 528 | hasAudioChannel = mediaPlayerState->curDecoder()->audioStreams() > 0; |
529 | hasVideoChannel = mediaPlayerState->curDecoder()->videoStreams() > 0; | 529 | hasVideoChannel = mediaPlayerState->curDecoder()->videoStreams() > 0; |
530 | 530 | ||
531 | if ( hasAudioChannel ) { | 531 | if ( hasAudioChannel ) { |
532 | int astream = 0; | 532 | int astream = 0; |
533 | 533 | ||
534 | channels = mediaPlayerState->curDecoder()->audioChannels( astream ); | 534 | channels = mediaPlayerState->curDecoder()->audioChannels( astream ); |
535 | DecodeLoopDebug(( "channels = %d\n", channels )); | 535 | DecodeLoopDebug(( "channels = %d\n", channels )); |
536 | 536 | ||
537 | if ( !total_audio_samples ) | 537 | if ( !total_audio_samples ) |
538 | total_audio_samples = mediaPlayerState->curDecoder()->audioSamples( astream ); | 538 | total_audio_samples = mediaPlayerState->curDecoder()->audioSamples( astream ); |
539 | 539 | ||
540 | mediaPlayerState->setLength( total_audio_samples ); | 540 | mediaPlayerState->setLength( total_audio_samples ); |
541 | 541 | ||
542 | freq = mediaPlayerState->curDecoder()->audioFrequency( astream ); | 542 | freq = mediaPlayerState->curDecoder()->audioFrequency( astream ); |
543 | DecodeLoopDebug(( "frequency = %d\n", freq )); | 543 | DecodeLoopDebug(( "frequency = %d\n", freq )); |
544 | 544 | ||
545 | audioSampleCounter = 0; | 545 | audioSampleCounter = 0; |
546 | 546 | ||
547 | static const int bytes_per_sample = 2; //16 bit | 547 | static const int bytes_per_sample = 2; //16 bit |
548 | 548 | ||
549 | audioDevice = new AudioDevice( freq, channels, bytes_per_sample ); | 549 | audioDevice = new AudioDevice( freq, channels, bytes_per_sample ); |
550 | audioBuffer = new char[ audioDevice->bufferSize() ]; | 550 | audioBuffer = new char[ audioDevice->bufferSize() ]; |
551 | channels = audioDevice->channels(); | 551 | channels = audioDevice->channels(); |
552 | 552 | ||
553 | //### must check which frequency is actually used. | 553 | //### must check which frequency is actually used. |
554 | static const int size = 1; | 554 | static const int size = 1; |
555 | short int buf[size]; | 555 | short int buf[size]; |
556 | long samplesRead = 0; | 556 | long samplesRead = 0; |
557 | mediaPlayerState->curDecoder()->audioReadSamples( buf, channels, size, samplesRead, stream ); | 557 | mediaPlayerState->curDecoder()->audioReadSamples( buf, channels, size, samplesRead, stream ); |
558 | } | 558 | } |
559 | 559 | ||
560 | if ( hasVideoChannel ) { | 560 | if ( hasVideoChannel ) { |
561 | total_video_frames = mediaPlayerState->curDecoder()->videoFrames( stream ); | 561 | total_video_frames = mediaPlayerState->curDecoder()->videoFrames( stream ); |
562 | 562 | ||
563 | mediaPlayerState->setLength( total_video_frames ); | 563 | mediaPlayerState->setLength( total_video_frames ); |
564 | 564 | ||
565 | framerate = mediaPlayerState->curDecoder()->videoFrameRate( stream ); | 565 | framerate = mediaPlayerState->curDecoder()->videoFrameRate( stream ); |
566 | DecodeLoopDebug(( "Frame rate %g total %ld", framerate, total_video_frames )); | 566 | DecodeLoopDebug(( "Frame rate %g total %ld", framerate, total_video_frames )); |
567 | 567 | ||
568 | if ( framerate <= 1.0 ) { | 568 | if ( framerate <= 1.0 ) { |
569 | DecodeLoopDebug(( "Crazy frame rate, resetting to sensible" )); | 569 | DecodeLoopDebug(( "Crazy frame rate, resetting to sensible" )); |
570 | framerate = 25; | 570 | framerate = 25; |
571 | } | 571 | } |
572 | 572 | ||
573 | if ( total_video_frames == 1 ) { | 573 | if ( total_video_frames == 1 ) { |
574 | DecodeLoopDebug(( "Cannot seek to frame" )); | 574 | DecodeLoopDebug(( "Cannot seek to frame" )); |
575 | } | 575 | } |
576 | 576 | ||
577 | } | 577 | } |
578 | 578 | ||
579 | videoMutex->lock(); | 579 | videoMutex->lock(); |
580 | current_frame = 0; | 580 | current_frame = 0; |
581 | prev_frame = -1; | 581 | prev_frame = -1; |
582 | videoMutex->unlock(); | 582 | videoMutex->unlock(); |
583 | 583 | ||
584 | connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( setPosition( long ) ) ); | 584 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ), this, SLOT( setPosition(long) ) ); |
585 | connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( setPaused( bool ) ) ); | 585 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); |
586 | 586 | ||
587 | //setBackgroundColor( black ); | 587 | //setBackgroundColor( black ); |
588 | return TRUE; | 588 | return TRUE; |
589 | } | 589 | } |
590 | 590 | ||
591 | 591 | ||
592 | void LoopControl::play() { | 592 | void LoopControl::play() { |
593 | 593 | ||
594 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 594 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
595 | if ( !disabledSuspendScreenSaver ) { | 595 | if ( !disabledSuspendScreenSaver ) { |
596 | disabledSuspendScreenSaver = TRUE; | 596 | disabledSuspendScreenSaver = TRUE; |
597 | // Stop the screen from blanking and power saving state | 597 | // Stop the screen from blanking and power saving state |
598 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) | 598 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) |
599 | << ( hasVideoChannel ? QPEApplication::Disable : QPEApplication::DisableSuspend ); | 599 | << ( hasVideoChannel ? QPEApplication::Disable : QPEApplication::DisableSuspend ); |
600 | } | 600 | } |
601 | #endif | 601 | #endif |
602 | 602 | ||
603 | //begin = clock(); | 603 | //begin = clock(); |
604 | playtime.start(); | 604 | playtime.start(); |
605 | startTimers(); | 605 | startTimers(); |
606 | //updateGeometry(); | 606 | //updateGeometry(); |
607 | } | 607 | } |
608 | 608 | ||
609 | 609 | ||
610 | void LoopControl::setMute( bool on ) { | 610 | void LoopControl::setMute( bool on ) { |
611 | if ( isMuted != on ) { | 611 | if ( isMuted != on ) { |
612 | isMuted = on; | 612 | isMuted = on; |
613 | if ( isMuted ) { | 613 | if ( isMuted ) { |
614 | } else { | 614 | } else { |
615 | int frame = current_frame; // mediaPlayerState->curDecoder()->videoGetFrame( stream ); | 615 | int frame = current_frame; // mediaPlayerState->curDecoder()->videoGetFrame( stream ); |
616 | playtime.restart(); | 616 | playtime.restart(); |
617 | playtime = playtime.addMSecs( -frame * 1000 / framerate ); | 617 | playtime = playtime.addMSecs( -frame * 1000 / framerate ); |
618 | //begin = clock() - (double)frame * CLOCKS_PER_SEC / framerate; | 618 | //begin = clock() - (double)frame * CLOCKS_PER_SEC / framerate; |
619 | mediaPlayerState->curDecoder()->audioSetSample( frame*freq/framerate, stream ); | 619 | mediaPlayerState->curDecoder()->audioSetSample( frame*freq/framerate, stream ); |
620 | } | 620 | } |
621 | } | 621 | } |
622 | } | 622 | } |
623 | 623 | ||
624 | 624 | ||