Esempio n. 1
0
// Only use is internal, but let those parameters be available
Action* Replay::GetAction()
{
  ASSERT(!is_recorder && replay_state == PLAYING);

  // Does it contain the 2 elements needed to decode at least
  // action header?
  if (MemUsed() > bufsize-sizeof(Action::Header)) {
    return NULL;
  }

  // Read action
  Action *a = new Action((char*)ptr, NULL);
  Action::Action_t type = a->GetType();
  if (type > Action::ACTION_TIME_VERIFY_SYNC) {
    Error(Format(_("Malformed replay: action with unknow type %08X"), type));
    StopPlaying();
    return NULL;
  }

  // Move pointer
  uint size = a->GetSize();
  if (MemUsed() > bufsize-size) {
    Error(Format(_("Malformed replay: action with datasize=%u"), size));
    StopPlaying();
    return NULL;
  }
  ptr += size;

  MSG_DEBUG("replay", "Read action %s: type=%u length=%i frameless=%i\n",
            ActionHandler::GetActionName(type).c_str(), type, size, a->IsFrameLess());

  return a;
}
/** \fn PlayerContext::StartPlaying(int)
 *  \brief Starts player, must be called after StartRecorder().
 *  \param maxWait How long to wait for MythPlayer to start playing.
 *  \return true when successful, false otherwise.
 */
bool PlayerContext::StartPlaying(int maxWait)
{
    if (!player)
        return false;

    player->StartPlaying();

    maxWait = (maxWait <= 0) ? 20000 : maxWait;
#ifdef USING_VALGRIND
    maxWait = (1<<30);
#endif // USING_VALGRIND
    MythTimer t;
    t.start();

    while (!player->IsPlaying(50, true) && (t.elapsed() < maxWait))
        ReloadTVChain();

    if (player->IsPlaying())
    {
        LOG(VB_PLAYBACK, LOG_INFO, LOC +
            QString("StartPlaying(): took %1 ms to start player.")
                .arg(t.elapsed()));
        return true;
    }
    else
    {
        LOG(VB_GENERAL, LOG_ERR, LOC + "StartPlaying() Failed to start player");
        StopPlaying();
        return false;
    }
}
Esempio n. 3
0
const std::vector <float> & REPLAY::PlayFrame(CAR & car)
{
	if (!GetPlaying())
	{
		return inputbuffer;
	}

	frame++;

	assert(inputbuffer.size() == CARINPUT::GAME_ONLY_INPUTS_START_HERE);
	assert((unsigned int) version_info.inputs_supported == CARINPUT::GAME_ONLY_INPUTS_START_HERE);

	//fast forward through the inputframes until we're up to date
	while (cur_inputframe < inputframes.size() && inputframes[cur_inputframe].GetFrame() <= frame)
	{
		ProcessPlayInputFrame(inputframes[cur_inputframe]);
		cur_inputframe++;
	}

	//fast forward through the stateframes until we're up to date
	while (cur_stateframe < stateframes.size() && stateframes[cur_stateframe].GetFrame() <= frame)
	{
		if (stateframes[cur_stateframe].GetFrame() == frame) ProcessPlayStateFrame(stateframes[cur_stateframe], car);
		cur_stateframe++;
	}

	//detect end of input
	if (cur_stateframe == stateframes.size() && cur_inputframe == inputframes.size())
	{
		StopPlaying();
	}

	return inputbuffer;
}
Esempio n. 4
0
bool
BFileGameSound::Load()
{
	if (!fAudioStream || !fAudioStream->stream)
		return false;

	// read a new buffer
	int64 frames = 0;
	fAudioStream->stream->ReadFrames(fBuffer, &frames);
	fBufferSize = frames * fFrameSize;
	fPlayPosition = 0;

	if (fBufferSize <= 0) {
		// EOF
		if (fLooping) {
			// start reading next time from the start of the file
			int64 frame = 0;
			fAudioStream->stream->SeekToFrame(&frame);
		} else {
			StopPlaying();
		}
	}

	return true;
}
Esempio n. 5
0
void ControlToolBar::OnStop(wxCommandEvent & WXUNUSED(evt))
{
   if (CanStopAudioStream()) {
      StopPlaying();
      UpdateStatusBar(GetActiveProject());
   }
}
Esempio n. 6
0
/** \fn PlayerContext::StartPlaying(int)
 *  \brief Starts player, must be called after StartRecorder().
 *  \param maxWait How long to wait for MythPlayer to start playing.
 *  \return true when successful, false otherwise.
 */
bool PlayerContext::StartPlaying(int maxWait)
{
    if (!player)
        return false;

    player->StartPlaying();

    maxWait = (maxWait <= 0) ? 20000 : maxWait;
#ifdef USING_VALGRIND
    maxWait = (1<<30);
#endif // USING_VALGRIND
    MythTimer t;
    t.start();

    while (!player->IsPlaying(50, true) && (t.elapsed() < maxWait))
        ReloadTVChain();

    if (player->IsPlaying())
    {
        VERBOSE(VB_PLAYBACK, LOC + "StartPlaying(): took "<<t.elapsed()
                <<" ms to start player.");
        return true;
    }
    else
    {
        VERBOSE(VB_IMPORTANT, LOC_ERR + "StartPlaying() "
                "Failed to start player");
        StopPlaying();
        return false;
    }
}
Esempio n. 7
0
void ControlToolBar::OnPlay(wxCommandEvent & WXUNUSED(evt))
{
   StopPlaying();

   AudacityProject *p = GetActiveProject();
   if (p) p->TP_DisplaySelection();

   PlayDefault();
}
Esempio n. 8
0
status_t
BFileGameSound::StartPlaying()
{
	// restart playback if needed
	if (IsPlaying())
		StopPlaying();

	// start playing the file
	return BStreamingGameSound::StartPlaying();
}
Esempio n. 9
0
LRESULT CMainDlg::OnStop(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
	if (idTimer)
		KillTimer(idTimer);
	StopPlaying();
	btnPlay.EnableWindow(TRUE);
	btnLoop.EnableWindow(TRUE);
	btnStop.EnableWindow(FALSE);
	return 0;
}
Esempio n. 10
0
void MHStream::Deactivation(MHEngine *engine)
{
    if (! m_fRunning)
    {
        return;
    }

    MHPresentable::Deactivation(engine);
    StopPlaying(engine);
}
void PlayerContext::SetPlayer(MythPlayer *newplayer)
{
    QMutexLocker locker(&deletePlayerLock);
    if (player)
    {
        StopPlaying();
        delete player;
    }
    player = newplayer;
}
Esempio n. 12
0
//------------------------------------------------------------------------------
// Purpose:
//------------------------------------------------------------------------------
void CPointCommentaryNode::PlayerActivated( void )
{
	if ( m_bActive )
	{
		StopPlaying();
	}
	else
	{
		StartCommentary();
		g_CommentarySystem.SetActiveNode( this );
	}
}
Esempio n. 13
0
void RageSound::Unload()
{
	LockMut(m_Mutex);

	if(IsPlaying())
		StopPlaying();

	delete m_pSource;
	m_pSource = NULL;
	
	m_sFilePath = "";
	m_DataBuffer.clear();
}
Esempio n. 14
0
   void ControlToolBar::OnLoopPlay(wxCommandEvent &evt)
   {
	   if(mAlwaysEnablePlay)
		   StopPlaying();

      PlayCurrentRegion(true);

      if(mAlwaysEnablePlay)
      {
	      mPlay->PopUp();
         mLoopPlay->PopUp();
      }
   }
Esempio n. 15
0
void ControlToolBar::OnPlay(wxCommandEvent &evt)
{
	if(mAlwaysEnablePlay)
		StopPlaying();

   if(mPlay->WasShiftDown())
      PlayCurrentRegion(true);
   else
      PlayCurrentRegion(false);

   if(mAlwaysEnablePlay)
	   mPlay->PopUp();
}
Esempio n. 16
0
void ControlToolBar::PlayDefault()
{
   StopPlaying();

   if(mPlay->WasControlDown())
      PlayCurrentRegion(false, true); /* play with cut preview */
   else if(mPlay->WasShiftDown())
      PlayCurrentRegion(true); /* play looped */
   else
      PlayCurrentRegion(false); /* play normal */

   mPlay->PopUp();
}
Esempio n. 17
0
void ControlToolBar::OnPlay(wxCommandEvent & WXUNUSED(evt))
{
   auto p = GetActiveProject();

   if (!CanStopAudioStream())
      return;

   StopPlaying();

   if (p) p->TP_DisplaySelection();

   PlayDefault();
   UpdateStatusBar(p);
}
Esempio n. 18
0
ap_result MediaKitAgent::Run(int32 index, uint32 command, void *args)
{
	switch (command)
	{
		// Initialize the output hardware
		case APOA_INIT_HARDWARE:
		{
			return (InitHardware((APAgent_InitHardware *)args));
		}

		// Cleanup the output hardware
		case APOA_END_HARDWARE:
		{
			EndHardware();
			return (AP_OK);
		}

		// Get output information
		case APOA_GET_OUTPUT_INFORMATION:
		{
			GetOutputInformation((APAgent_OutputInfo *)args);
			return (AP_OK);
		}

		// Start playing
		case APOA_START_PLAYING:
		{
			StartPlaying();
			return (AP_OK);
		}

		// Stop playing
		case APOA_STOP_PLAYING:
		{
			StopPlaying();
			return (AP_OK);
		}

		// Set volume
		case APOA_SET_VOLUME:
		{
			SetVolume((APAgent_SetVolume *)args);
			return (AP_OK);
		}
	}

	return (AP_UNKNOWN);
}
Esempio n. 19
0
void Scrubber::StopScrubbing()
{
   mScrubStartPosition = -1;
   mSmoothScrollingScrub = false;
   const auto ctb = mProject->GetControlToolBar();

   if (IsScrubbing())
   {
      if (gAudioIO->IsBusy()) {
         ctb->StopPlaying();
      }
   }
   else {
      // Didn't really play, but did change button apperance
      ctb->SetPlay(false, ControlToolBar::PlayAppearance::Straight);
   }
}
void PlayerContext::PIPTeardown(void)
{
    if (buffer)
    {
        buffer->Pause();
        buffer->WaitForPause();
    }

    {
        QMutexLocker locker(&deletePlayerLock);
        StopPlaying();
    }

    SetPlayer(NULL);

    useNullVideo = false;
    parentWidget = NULL;
}
Esempio n. 21
0
CommonPool::~CommonPool(){
	if (progress)
		progress->Quit();
	
	if (IsPlaying())
		StopPlaying();

	if (play_cookie.buffer)
		delete [] play_cookie.buffer;

#ifndef __VM_SYSTEM				// RAM
	if (sample_memory)
		free(sample_memory);
#endif

	if (PrefWin)
		PrefWin->Quit();
	
//	if (tt)	delete tt;
}
Esempio n. 22
0
void ControlToolBar::OnPlay(wxCommandEvent & WXUNUSED(evt))
{
   auto doubleClicked = mPlay->IsDoubleClicked();
   mPlay->ClearDoubleClicked();

   auto p = GetActiveProject();

   if (doubleClicked)
      p->GetPlaybackScroller().Activate(true);
   else {
      if (!CanStopAudioStream())
         return;

      StopPlaying();

      if (p) p->TP_DisplaySelection();

      PlayDefault();
      UpdateStatusBar(p);
   }
}
Esempio n. 23
0
CommonPool::~CommonPool(){
	if (progress && progress->Lock())  {
		progress->Quit();
		progress->Unlock();
	}
	if (IsPlaying())
		StopPlaying();

	if (play_cookie.buffer)
		delete [] play_cookie.buffer;

#ifndef __VM_SYSTEM				// RAM
	if (sample_memory)
		free(sample_memory);
#endif

	if (PrefWin && PrefWin->Lock()) {
		PrefWin->Quit();
		PrefWin->Unlock();
	}
//	if (tt)	delete tt;
}
Esempio n. 24
0
void ControlToolBar::OnKeyEvent(wxKeyEvent & event)
{
   if (event.ControlDown() || event.AltDown()) {
      event.Skip();
      return;
   }

   if (event.GetKeyCode() == WXK_SPACE) {
      if (gAudioIO->IsStreamActive(GetActiveProject()->GetAudioIOToken())) {
         SetPlay(false);
         SetStop(true);
         StopPlaying();
      }
      else if (!gAudioIO->IsBusy()) {
         //SetPlay(true);// Not needed as done in PlayPlayRegion
         SetStop(false);
         PlayCurrentRegion();
      }
      return;
   }
   event.Skip();
}
Esempio n. 25
0
void VideoPlayer::Buttons() {
    playButton = new QPushButton;
    playButton->setEnabled(false);
    playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
    playButton->setFixedWidth(30);
    playButton->setGeometry(10,10,30,30);

    stopButton = new QPushButton;
    stopButton->setEnabled(false);
    stopButton->setIcon(style()->standardIcon(QStyle::SP_MediaStop));
    stopButton->setFixedWidth(30);

    muteButton = new QPushButton;
    muteButton->setEnabled(true);
    muteButton->setIcon((style()->standardIcon(QStyle::SP_MediaVolume)));
    muteButton->setFixedWidth(30);


    connect(playButton, SIGNAL(clicked()),
            this, SLOT(play()));
    connect(stopButton, SIGNAL(clicked()),this,SLOT(StopPlaying()));
    connect(muteButton,SIGNAL(clicked()),this,SLOT(MutePlaying()));
}
Esempio n. 26
0
void ControlToolBar::OnKeyEvent(wxKeyEvent & event)
{
   if (event.ControlDown() || event.AltDown()) {
      event.Skip();
      return;
   }

   // Does not appear to be needed on Linux. Perhaps on some other platform?
   // If so, "!CanStopAudioStream()" should probably apply.
   if (event.GetKeyCode() == WXK_SPACE) {
      if (gAudioIO->IsStreamActive(GetActiveProject()->GetAudioIOToken())) {
         SetPlay(false);
         SetStop(true);
         StopPlaying();
      }
      else if (!gAudioIO->IsBusy()) {
         //SetPlay(true);// Not needed as done in PlayPlayRegion
         SetStop(false);
         PlayCurrentRegion();
      }
      return;
   }
   event.Skip();
}
Esempio n. 27
0
void ControlToolBar::OnStop(wxCommandEvent & WXUNUSED(evt))
{
   StopPlaying();
}
Esempio n. 28
0
LRESULT CALLBACK HWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch(msg)
	{
		//case WM_ACTIVE:
		//break;
		case WM_KEYDOWN:
		case WM_KEYUP:
			CallWindowProc((WNDPROC)GetWindowLong(hGLWnd, GWL_WNDPROC), hGLWnd, msg, wParam, lParam);
			return TRUE;//オリジナルのメッセージ処理を行わないとLayouterWindow.cppが機能しない
		case WM_COMMAND:
		{
			switch(LOWORD(wParam))
			{
				case ID_FILE_NEW_LAYOUT:
				{
					//long nUndoBuffer = GetUndoBufferNum();
					//if(dwLastSaveTime){
					//	if(MBQ("This document has been modified. Save?")){
					//		CallWindowProc((WNDPROC)GetWindowLong(hWnd, GWL_WNDPROC), hWnd, WM_COMMAND, ID_FILE_SAVE_OW, 0);
					//	}
					//}
					FreeAll();
					RefreshAllView();
					break;
				}
				case ID_FILE_OPEN_LAYOUT:
				{
					char* szFile = (char*)GlobalAlloc(GPTR, sizeof(char) * 1024);
						if(GetOpenFileNameSingle(hGLWnd, "kdf", szFile, FALSE))
						{
							lstrcpy(g_szFileName, szFile);
							FreeAll();
							demo.Load(szFile);
							RefreshAllView();
						}
					GlobalFree(szFile);
					break;
				}
				case ID_FILE_SAVE_OW:
				{
					if(g_szFileName[0] == '\0')
					{
						char* szFile = (char*)GlobalAlloc(GPTR, sizeof(char) * 1024);
							if(GetSaveFileNameSingle(hGLWnd, "kdf", szFile, FALSE))
							{
								lstrcpy(g_szFileName, szFile);
							}else return TRUE;
						GlobalFree(szFile);
					}
					
					demo.Save(g_szFileName);
					RefreshAllView();
					break;
				}
				case ID_FILE_SAVE_AS:
				{
					char* szFile = (char*)GlobalAlloc(GPTR, sizeof(char) * 1024);
						if(GetSaveFileNameSingle(hGLWnd, "kdf", szFile, FALSE))
						{
							lstrcpy(g_szFileName, szFile);
							demo.Save(szFile);
							RefreshAllView();
						}
					GlobalFree(szFile);
					break;
				}
				case ID_FILE_EXPORT:
				{
					char* szFile = (char*)GlobalAlloc(GPTR, sizeof(char) * 1024);
						if(GetSaveFileNameSingle(hGLWnd, "kdb", szFile, FALSE))
						{
							//lstrcpy(g_szFileName, szFile);
							demo.BinarySave(szFile);
							MessageBox(hWnd, "Export done", "", MB_ICONINFORMATION|MB_OK|MB_TOPMOST);
							RefreshAllView();
						}
					GlobalFree(szFile);
					break;
				}
				case ID_FILE_EXIT:
				{
					VerifyOnExit();	
					break;
				}
				case ID_EDIT_UNDO:
				{
					Undo();	
					break;
				}
				case ID_EDIT_REDO:
				{
					Redo();	
					break;
				}
				case ID_MODE_LAYOUTER:
				{
					StopPlaying();

					nCurrentMode = LAYOUTER;
					HMENU hMenu = GetMenu(hWnd);
					HMENU hSub = GetSubMenu(hMenu, 2);
					CheckMenuItem(hSub, 1, MF_BYPOSITION|MF_UNCHECKED);
					CheckMenuItem(hSub, 0, MF_BYPOSITION|MF_CHECKED);

				
					//vSound.Hide();
					//vSynth.Hide();
					ShowWindow(vSound.GetHolderWnd(), FALSE);
					//ShowWindow(vTime.GetHolderWnd(), FALSE);
					ShowWindow(vSynth.GetHolderWnd(), FALSE);

					//ShowWindow(vScene.GetHolderWnd(), TRUE);
					ShowWindow(vClone.GetHolderWnd(), TRUE);
					ShowWindow(vObjectList.GetHolderWnd(), TRUE);
					ShowWindow(vSceneObjectList.GetHolderWnd(), TRUE);

					RefreshWindows();
					break;
				}
				case ID_MODE_TIMELINER:
				{
					StopPlaying();

					nCurrentMode = TIMELINER;
					HMENU hMenu = GetMenu(hWnd);
					HMENU hSub = GetSubMenu(hMenu, 2);
					CheckMenuItem(hSub, 0, MF_BYPOSITION|MF_UNCHECKED);
					CheckMenuItem(hSub, 1, MF_BYPOSITION|MF_CHECKED);

					//ShowWindow(vScene.GetHolderWnd(), FALSE;
					ShowWindow(vClone.GetHolderWnd(), FALSE);
					//ShowWindow(vSceneObjectList.GetHolderWnd(), FALSE);
					ShowWindow(vObjectList.GetHolderWnd(), FALSE);

					//vSound.Show();
					//vSynth.Show();
					ShowWindow(vSound.GetHolderWnd(), TRUE);
					//ShowWindow(vTime.GetHolderWnd(), TRUE);
					ShowWindow(vSynth.GetHolderWnd(), TRUE);

					RefreshWindows();
					break;
				}
				case ID_FRAME_000:
				case ID_FRAME_025:
				case ID_FRAME_050:
				case ID_FRAME_075:
				case ID_FRAME_100:
				{
					float mul = (LOWORD(wParam) - ID_FRAME_000) * 0.25f;
					UpdateFrameTransparency(mul);
					break;
				}
			}
			return FALSE;
		}
		case WM_DESTROY:
		case WM_CLOSE:
		{
			VerifyOnExit();
			return FALSE;
		}
		case WM_SIZE:
		{
			RefreshWindows();
			return FALSE;
		}
	}
	return TRUE;
}
Esempio n. 29
0
void RageSound::Stop()
{
	StopPlaying();
}
Esempio n. 30
0
mitk::NavigationDataPlayer::~NavigationDataPlayer()
{
  StopPlaying();
}