// Handle messages for this resource. UtlBoolean MprFromStream::handleMessage(MpFlowGraphMsg& rMsg) { UtlBoolean bHandled = FALSE ; switch (rMsg.getMsg()) { case SOURCE_RENDER: bHandled = handleRender((MpStreamFeeder*) rMsg.getPtr1()) ; break ; case SOURCE_PLAY: bHandled = handlePlay((MpStreamFeeder*) rMsg.getPtr1()) ; break ; case SOURCE_REWIND: bHandled = handleRewind((MpStreamFeeder*) rMsg.getPtr1()) ; break ; case SOURCE_PAUSE: bHandled = handlePause((MpStreamFeeder*) rMsg.getPtr1()) ; break ; case SOURCE_STOP: bHandled = handleStop((MpStreamFeeder*) rMsg.getPtr1()) ; break ; case SOURCE_DESTROY: bHandled = handleDestroy((MpStreamFeeder*) rMsg.getPtr1()) ; break ; default: bHandled = MpResource::handleMessage(rMsg); break; } return bHandled ; }
void ControlWidget::handleSkipTrack() { if( mpSkipAction->isEnabled() ) { bool checkstate = true; mpSkipButton->clearFocus(); if( (mpPlayer[0]->getState() == PlayerFSM::ready) || (mpPlayer[1]->getState() == PlayerFSM::ready) ) { log( "p0n", "skip" ); if( mPaused ) { handlePause( true ); } mpPlayer[0]->disablePlayPosition( true ); mpPlayer[1]->disablePlayPosition( true ); mpPlayer[0]->skip(); mpPlayer[1]->skip(); checkstate = false; } mpSkipAction->setChecked( checkstate ); } }
void Debugger::pauseIfNeeded(CallFrame* callFrame) { if (m_isPaused) return; if (m_suppressAllPauses) return; JSGlobalObject* vmEntryGlobalObject = callFrame->vmEntryGlobalObject(); if (!needPauseHandling(vmEntryGlobalObject)) return; Breakpoint breakpoint; bool didHitBreakpoint = false; bool pauseNow = m_pauseOnNextStatement; pauseNow |= (m_pauseOnCallFrame == m_currentCallFrame); DebuggerPausedScope debuggerPausedScope(*this); intptr_t sourceID = DebuggerCallFrame::sourceIDForCallFrame(m_currentCallFrame); TextPosition position = DebuggerCallFrame::positionForCallFrame(m_currentCallFrame); pauseNow |= didHitBreakpoint = hasBreakpoint(sourceID, position, &breakpoint); m_lastExecutedLine = position.m_line.zeroBasedInt(); if (!pauseNow) return; // Make sure we are not going to pause again on breakpoint actions by // reseting the pause state before executing any breakpoint actions. TemporaryPausedState pausedState(*this); m_pauseOnCallFrame = 0; m_pauseOnNextStatement = false; if (didHitBreakpoint) { handleBreakpointHit(vmEntryGlobalObject, breakpoint); // Note that the actions can potentially stop the debugger, so we need to check that // we still have a current call frame when we get back. if (breakpoint.autoContinue || !m_currentCallFrame) return; m_pausingBreakpointID = breakpoint.id; } { PauseReasonDeclaration reason(*this, didHitBreakpoint ? PausedForBreakpoint : m_reasonForPause); handlePause(vmEntryGlobalObject, m_reasonForPause); RELEASE_ASSERT(!callFrame->hadException()); } m_pausingBreakpointID = noBreakpointID; if (!m_pauseOnNextStatement && !m_pauseOnCallFrame) { setSteppingMode(SteppingModeDisabled); m_currentCallFrame = nullptr; } }
void ReplayConductor::handleSetReplayRate( double rate ) { bool wasPlaying = isPlaying_; if ( wasPlaying ) handlePause(); clock_.setReplayRate( rate ); if ( wasPlaying ) handleStart(); }
void ControlWidget::initConnect() { if( !mConnected ) { QString hostname( "localhost" ); int port = Settings::value( Settings::PartymanDerMixDport ); if( Settings::value( Settings::PartymanDerMixDrun ) ) { QStringList args; QString params( Settings::value( Settings::PartymanDerMixDparams ) ); args << "-c" << QString("main.port=%1").arg( port ); if( !params.isEmpty() ) { args << params.split(' '); } qlonglong pid = Settings::value( Settings::PartymanDerMixDpid ); if( pid > 0 ) { #ifdef Q_OS_UNIX ::kill( static_cast<pid_t>( pid ), SIGTERM ); #endif } mpDerMixDprocess->start( Settings::value( Settings::PartymanDerMixDcmd ), args ); /* block until dermixd is up an running */ for( mWaitForDerMixD = true; mWaitForDerMixD; ) { QCoreApplication::processEvents(); } if( !mDerMixDstarted ) { QMessageBox::critical( this, QApplication::applicationName(), tr("Could not start DerMixD") ); } pid = static_cast<qlonglong>( mpDerMixDprocess->pid() ); Settings::setValue( Settings::PartymanDerMixDpid, pid ); } else { mDerMixDstarted = true; hostname = Settings::value( Settings::PartymanDerMixDhost ); } mConnected = true; mpPlayer[0]->connectTo( hostname, port ); mpPlayer[1]->connectTo( hostname, port ); mpStartButton->setMenu( mpStartButtonMenu ); mpTrayIcon->setContextMenu( mpTrayIconPlayMenu ); mpPlayAction->setChecked( true ); mpSkipAction->setDisabled( mKioskMode ); emit signalConnected( true ); } handlePause( true ); }
PlayerCommand* PlayerDriver::DoProcessQueue(status_t& ret) { PlayerCommand* ec = dequeueCommand(); printf("HelixOverWebkit [%s] [%s] [%d] ec %p, ec->command() %d\n", __FILE__, __FUNCTION__, __LINE__, ec, (ec == NULL)?-1: ec->command()); if (ec) { switch(ec->command()) { case PlayerCommand::PLAYER_SET_DATA_SOURCE: ret = handleSetDataSource(static_cast<PlayerSetDataSource*>(ec)); break; case PlayerCommand::PLAYER_PREPARE: ret = handlePrepare(static_cast<PlayerPrepare*>(ec)); break; case PlayerCommand::PLAYER_START: ret = handleStart(static_cast<PlayerStart*>(ec)); break; case PlayerCommand::PLAYER_STOP: ret = handleStop(static_cast<PlayerStop*>(ec)); break; case PlayerCommand::PLAYER_PAUSE: ret = handlePause(static_cast<PlayerPause*>(ec)); break; case PlayerCommand::PLAYER_SEEK: ret = handleSeek(static_cast<PlayerSeek*>(ec)); break; case PlayerCommand::PLAYER_GET_POSITION: ret = handleGetPosition(static_cast<PlayerGetPosition*>(ec)); break; case PlayerCommand::PLAYER_RESET: ret = handleReset(static_cast<PlayerReset*>(ec)); break; case PlayerCommand::PLAYER_QUIT: ret = handleQuit(static_cast<PlayerQuit*>(ec)); break; default: //cout << "Unexpected command %d" << ec->command(); break; } } return ec; }
void ControlWidget::initDisconnect( ErrorCode errorCode ) { PartymanMainWindow::setIconAndTitle( this, mPartymanIcon, QApplication::applicationName() + ": " + tr("(disconnected)") ); mpTrayIcon->setToolTip( QString() ); mpTrayIcon->setContextMenu( mpTrayIconStopMenu ); if( mConnected ) { mConnected = false; QString errorText; handlePause( true ); saveTracks( true ); mpPlayer[0]->disconnect(); mpPlayer[1]->disconnect(); //mpSkipButton->setDisabled( true ); mpSkipAction->setDisabled( true ); mpStartButton->setMenu( 0 ); mpStartButton->setChecked( false ); switch( errorCode ) { case ErrorNoConnection: errorText = tr("Could not connect to DerMixD. Is it running?"); break; case ErrorConnectionLost: errorText = tr("The connection to DerMixD was lost."); break; case ErrorWrongVersion: errorText = tr("The Version of DerMixD is not compatible."); break; case ErrorNone: default: break; } if( !errorText.isEmpty() && mDerMixDstarted ) { QMessageBox::critical( this, QApplication::applicationName(), errorText ); } if( Settings::value( Settings::PartymanDerMixDrun ) ) { mpDerMixDprocess->terminate(); Settings::setValue( Settings::PartymanDerMixDpid, 0 ); } emit signalConnected( false ); mpPlaylist->setTrackInfo( TrackInfo() ); log( "p0s", "stop" ); } }
void ReplayConductor::handleEvents() { IceUtil::Mutex::Lock lock(mutex_); // Pop all the events off the queue and deal with them. while ( !eventQueue_.empty() ) { Event e = eventQueue_.front(); eventQueue_.pop(); switch ( e.type() ) { case SetReplayRate: handleSetReplayRate(e.replayRate()); break; case Start: handleStart(); break; case Pause: handlePause(); break; case StepForward: handleStepForward(); break; case StepBackward: handleStepBackward(); break; case FastForward: handleFastForward(e.time()); break; case FastForwardToEnd: handleFastForwardToEnd(); break; case Rewind: handleRewind(e.time()); break; case RewindToStartAndStop: handleRewindToStartAndStop(); break; default: cout << "ERROR(replayconductor.cpp): Don't know how to handle event: " << toString(e) << endl; } } }
void ReplayConductor::handleRewind( const IceUtil::Time &deltaT ) { bool wasPlaying = isPlaying_; if ( wasPlaying ) handlePause(); int sec, usec; masterFileReader_.getCursorTime( sec, usec ); IceUtil::Time tNew = orcalog::iceUtilTime( sec, usec ); tNew -= deltaT; masterFileReader_.placeCursorAtOrAfterTime( tNew.toSeconds(), (int)(tNew.toMicroSeconds()-tNew.toSeconds()*1e6) ); if ( wasPlaying ) handleStart(); }
void AnimationThread::threadMethod() { while (!_killThread.load(std::memory_order_relaxed)) { if (EventMan.quitRequested()) break; if (handlePause()) continue; handleYield(); std::lock_guard<std::recursive_mutex> lock(_modelsMutex); registerQueuedModels(); if (_models.empty()) { EventMan.delay(100); continue; } for (auto &m : _models) { if (EventMan.quitRequested() || (_pause.load(std::memory_order_seq_cst) == kPausePaused)) break; if (m.second.skippedCount < getNumIterationsToSkip(m.second.model)) { ++m.second.skippedCount; continue; } else { m.second.skippedCount = 0; } handleFlush(); uint32 now = EventMan.getTimestamp(); float dt = 0; if (m.second.lastChanged > 0) { dt = (now - m.second.lastChanged) / 1000.0f; } m.second.lastChanged = now; m.second.model->manageAnimations(dt); } } }
void __loadds far mouseEvent(int event, int x, int y) { #pragma aux mouseEvent parm [EAX] [ECX] [EDX]; static left_button_hold_down = 0; if (event & MOUSE_MOVE) { if (left_button_hold_down) { recMouseBackground(); saveMouseBackground(x, y); } moveMouse(x, y); } else if (event & MOUSE_RIGHT_UP) { //gameState = GAME_QUIT; } else if (event & MOUSE_LEFT_DOWN) { left_button_hold_down = 1; /* 以下为鼠标单击按钮事件处理 */ if (inButton(x, y, &quitButton)) { gameState = GAME_QUIT; } if (inButton(x, y, &playButton)) { if (playButton.state == BUTTON_UP) { playButton.state = BUTTON_DOWN; } else { playButton.state = BUTTON_UP; } handlePause(); paintButton(&playButton); } if (inButton(x, y, &soundButton)) { switchSound(); } } else if (event & MOUSE_LEFT_UP) { left_button_hold_down = 0; } else if (event & MOUSE_RIGHT_DOWN) { } }
void handleKeyPress(XInfo &xinfo, XEvent &event,Ship &ship, unsigned long &lastRepaint) { KeySym key; char text[BufferSize]; /* * Exit when 'q' is typed. * This is a simplified approach that does NOT use localization. */ int i = XLookupString( (XKeyEvent *)&event, // the keyboard event text, // buffer when text will be written BufferSize, // size of the text buffer &key, // workstation-independent key symbol NULL ); // pointer to a composeStatus structure (unused) switch( key) { case XK_Up: case XK_Down: case XK_Left: case XK_Right: if( key == XK_Up ) { printf("Got key press -- Up\n"); //xinfo.y = xinfo.y - 5; //ship.move_ship(ship, ship.x, ship.y-5); ship.up(xinfo, ship); } else if( key == XK_Left ){ printf("Got key press -- Left\n"); //xinfo.x = xinfo.x - 5; //ship.x = ship.x -5; //ship.move_ship(ship, ship.x-5, ship.y); ship.left(xinfo, ship); } else if( key == XK_Right ){ printf("Got key press -- Right\n"); //xinfo.x = xinfo.x + 5; //ship.x = ship.x + 5; //ship.move_ship(ship,ship.x+5, ship.y); ship.right(xinfo, ship); } else if( key == XK_Down ){ printf("Got key press -- Down\n"); //xinfo.x = xinfo.x + 5; //ship.x = ship.x + 5; //ship.move_ship(ship,ship.x, ship.y+5); ship.down(xinfo, ship); } } if ( i == 1) { printf("Got key press -- %c\n", text[0]); /*if (text[0] == 'a' ) { ship.move_ship(ship, ship.x-1, ship.y); } if (text[0] == 'd' ) { ship.move_ship(ship,ship.x+1, ship.y); } if (text[0] == 'w' ) { ship.move_ship(ship, ship.x, ship.y-1); } // moving down for testing if (text[0] == 's' ) { ship.move_ship(ship,ship.x, ship.y+1); }*/ // now handle pause if (text[0] == ' ') { handlePause(xinfo, lastRepaint); } // if space if (text[0] == 'q') { error("Terminating normally."); } } }
void ControlWidget::handleSatellite( const QByteArray &msg ) { QStringList src( Satellite::split( msg ) ); if( src.size() > 0 ) { if( src.at(0) == "P0Q" ) { QStringList dest; /* convert from url to filename if necessary */ for( int i = 1; i < src.size(); i++ ) { QFileInfo qfi( src.at(i) ); if( qfi.isFile() ) { dest << qfi.absoluteFilePath(); } } if( dest.size() > 0 ) { emit requestAddToPlaylist( dest, false ); } } else if( src.at(0) == "P0A" ) { if( mConnected ) { if( mPaused || !mKioskMode ) { handlePause(); } } else { initConnect(); } } else if( src.at(0) == "P0N" ) { handleSkipTrack(); } else if( src.at(0) == "P0S" ) { if( !mKioskMode ) { initDisconnect(); } } else if( src.at(0) == "P0R" ) { if( mpSatellite && !mLastP0p.isEmpty() ) { mpSatellite->send( mLastP0p ); } } else if( src.at(0) == "P0C" ) { bool favorite = false; bool unwanted = false; if( src.size() > 1 ) { switch( src.at(1).toUInt() ) { case 1: favorite = true; break; case 2: unwanted = true; break; default: break; } mpPlaylist->setTrackInfoFavoriteUnwanted( favorite, unwanted ); } } else if( src.at(0) == "P0T" ) { if( src.size() > 1 ) { emit requestTab( src.at(1) ); } } else if( (src.at(0) == "k0u") || (src.at(0) == "r0u") ) { emit trackUpdate(); } else if( src.at(0) == "u0p" ) { if( Settings::value( Settings::PartymanStopOnUnderpassStart ) && !mKioskMode ) { initDisconnect(); } } } }
ControlWidget::ControlWidget( Database *database, PartymanConfigDialog *config, PartymanMainWindow *parent ) : QWidget( parent ) , mpConfig( config ) , mpPlaylist( parent ) , mpSatellite( Satellite::get() ) , mpGenericSatelliteHandler( 0 ) , mPartymanIcon( QIcon( ":/Partyman/Icon.png" ) ) , mStopIcon( QCommonStyle().standardIcon(QStyle::SP_MediaStop) /*QIcon(":/Stop.png")*/ ) , mPlayIcon( QCommonStyle().standardIcon(QStyle::SP_MediaPlay) /*QIcon(":/Play.png")*/ ) , mPauseIcon( QCommonStyle().standardIcon(QStyle::SP_MediaPause) /*QIcon(":/Pause.png")*/ ) , mSkipIcon( QCommonStyle().standardIcon(QStyle::SP_MediaSkipForward) /*QIcon(":/Skip.png")*/ ) , mLoadIcon( QIcon( ":/Partyman/Load.png" ) ) , mpSettingsButton( new QPushButton( tr("Settings"), this ) ) , mpStartButton( new QToolButton( /*tr("Connect"),*/ this ) ) , mpSkipButton( new QToolButton( /*mSkipIcon, tr("Next"),*/ this ) ) , mpTrayIcon( new QSystemTrayIcon( this ) ) , mpTrayIconStopMenu( new QMenu( this ) ) , mpTrayIconPlayMenu( new QMenu( this ) ) , mpStartButtonMenu( new QMenu( mpStartButton ) ) , mpPlayAction( mpTrayIconStopMenu->addAction( mPlayIcon, tr("Start" ) ) ) , mpSkipAction( mpTrayIconPlayMenu->addAction( mSkipIcon, tr("Next" ) ) ) , mpPauseAction( mpStartButtonMenu->addAction( mPauseIcon, tr("Pause" ) ) ) , mpStopAction( mpStartButtonMenu->addAction( mStopIcon, tr("Disconnect" ) ) ) , mpLoadAction( mpStartButtonMenu->addAction( mLoadIcon, tr("Load" ) ) ) , mpTrayIconClickTimer( new QTimer( this ) ) , mConnected( false ) , mPaused( false ) , mKioskMode( false ) , mpDerMixDprocess( new QProcess( this ) ) , mpLoggerProcess( new QProcess( this ) ) , mWaitForDerMixD( false ) , mDerMixDstarted( false ) , mLastP0p() { CrashCleanup::addObject( mpDerMixDprocess ); setAcceptDrops( true ); setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); mpSettingsButton->setObjectName( QString("SettingsButton") ); mpPlayer[0] = new PlayerWidget( 0, database, this ); mpPlayer[1] = new PlayerWidget( 1, database, this ); mpTrayIconClickTimer->setSingleShot( true ); QGridLayout *mainLayout = new QGridLayout( this ); mainLayout->setContentsMargins( 3, 3, 3 ,3 ); mainLayout->setSpacing( 5 ); mainLayout->addWidget( mpPlayer[0], 1, 0, 4, 1 ); mainLayout->addWidget( mpPlayer[1], 1, 2, 4, 1 ); mainLayout->addWidget( mpSettingsButton, 1, 1 ); mainLayout->addWidget( mpStartButton, 3, 1 ); mainLayout->addWidget( mpSkipButton, 4, 1 ); mainLayout->setColumnStretch( 0, 1 ); mainLayout->setColumnStretch( 2, 1 ); mainLayout->setRowStretch( 0, 1 ); mainLayout->setRowStretch( 5, 1 ); setLayout( mainLayout ); mpStartButton->setDefaultAction( mpPlayAction ); mpStartButton->setPopupMode( QToolButton::InstantPopup ); mpStartButton->setToolButtonStyle( Qt::ToolButtonTextBesideIcon ); mpStartButton->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed ); mpPlayAction->setCheckable( true ); mpPlayAction->setDisabled( true ); mpSkipButton->setDefaultAction( mpSkipAction ); mpSkipButton->setPopupMode( QToolButton::InstantPopup ); mpSkipButton->setToolButtonStyle( Qt::ToolButtonTextBesideIcon ); mpSkipButton->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed ); mpSkipAction->setCheckable( true ); mpSkipAction->setDisabled( true ); mpTrayIcon->setIcon( QIcon(":/Partyman/Icon.png") ); mpTrayIcon->setContextMenu( mpTrayIconStopMenu ); mpTrayIconPlayMenu->addAction( mpPauseAction ); mpTrayIconPlayMenu->addAction( mpStopAction ); connect( mpSettingsButton, SIGNAL(clicked()), mpConfig, SLOT(exec()) ); connect( mpStartButton, SIGNAL(clicked()), this, SLOT(initConnect()) ); connect( mpPlayAction, SIGNAL(triggered()), this, SLOT(initConnect()) ); connect( mpPauseAction, SIGNAL(triggered()), this, SLOT(handlePause()) ); connect( mpStopAction, SIGNAL(triggered()), this, SLOT(initDisconnect()) ); connect( mpLoadAction, SIGNAL(triggered()), this, SLOT(handleLoad()) ); connect( mpSkipAction, SIGNAL(triggered()), this, SLOT(handleSkipTrack()) ); connect( mpConfig, SIGNAL(configChanged()), this, SLOT(readConfig()) ); connect( mpPlayer[0], SIGNAL(trackPlaying(TrackInfo)), this, SLOT(handleTrackPlaying(TrackInfo)) ); connect( mpPlayer[1], SIGNAL(trackPlaying(TrackInfo)), this, SLOT(handleTrackPlaying(TrackInfo)) ); connect( mpTrayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(handleTrayIcon(QSystemTrayIcon::ActivationReason)) ); connect( mpTrayIconClickTimer, SIGNAL(timeout()), this, SLOT(handlePause()) ); connect( mpDerMixDprocess, SIGNAL(readyReadStandardError()), this, SLOT(handleDerMixDstartup()) ); connect( mpDerMixDprocess, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(handleDerMixDfinish(int,QProcess::ExitStatus)) ); connect( mpDerMixDprocess, SIGNAL(error(QProcess::ProcessError)), this, SLOT(handleDerMixDerror(QProcess::ProcessError)) ); if( mpSatellite ) { mpGenericSatelliteHandler = new GenericSatelliteHandler( mpSatellite, GenericSatelliteHandler::WithPingAndDialog, this ); connect( mpGenericSatelliteHandler, SIGNAL(updateConfig()), mpConfig, SLOT(readSettings()) ); connect( mpGenericSatelliteHandler, SIGNAL(anotherInstance()), this, SLOT(initDisconnect()) ); connect( mpSatellite, SIGNAL(received(QByteArray)), this, SLOT(handleSatellite(QByteArray)) ); } }