Example #1
0
bool Path::copy( const QString & src, const QString & dest )
{
	Path srcp( src ), destp( dest );
	if( !srcp.fileExists() || !destp.dir().dirExists() )
		return false;
#ifdef Q_OS_WIN
	bool s_unc = false, d_unc = false;
	
	QString srcw( srcp.path() );
	srcw = srcw.replace( "/", "\\" );
	QString destw( destp.path() );
	destw = destw.replace( "/", "\\" );
	
	if( srcw[0] == '\\' && srcw[1] == '\\' ) s_unc = true;
	if( destw[0] == '\\' && destw[1] == '\\' ) d_unc = true;
	srcw.replace( "\\\\", "\\" );
	if( s_unc ) srcw = "\\" + srcw;
	destw.replace( "\\\\", "\\" );
	if( d_unc ) destw = "\\" + destw;
	
	bool ret = CopyFileA( srcw.toLatin1(), destw.toLatin1(), false ) != 0;
	if( !ret ) {
		DWORD err = GetLastError();
		LOG_1( "Copy failed with error: " + QString::number(err) );
		LOG_1( "Src: " + srcw +  "Dest: " + destw );
	}
	return ret;
#else
	system( QString( "cp " + srcp.path() + " " + destp.path() ).toLatin1() );
	return true;
#endif
}
Example #2
0
void mixer_agent_t::run()
{
  // TODO:ミキサーの実装
  // COMの初期化
  sf::com_initialize init(0,multi_threaded);

  // MMCSSの初期化
  //av_mm_thread_characteristics avmm(wstring(L"Pro Audio"));
  //avmm.set_priority(AVRT_PRIORITY::AVRT_PRIORITY_HIGH);
  int status;
  application& app(*application::instance());

  // outputデバイスが稼働するまで待つ
  //app.output_thread().wait_status(output_agent_t::status_processing,10);
  // バッファ初期化
  //init_buffer();
  change_status(status_config);
  while(status = status_.load(),status !=status_exit)
  {
  switch(status)
  {
  case status_config:
    {
      change_status(status_config_ok);
    }
    break;
  case status_process:
    {
      init_buffer();
      change_status(status_processing);
    }
  case status_processing:
    {
      Sleep(app.output_device().get_buffer_duration() / 20000);
      BYTE *in(0),*reader(0);
      app.input_ringbuffer().pop(in);
      app.reader_ringbuffer().pop(reader);
      int size(app.output_device().get_buffer_byte_size());
      BYTE *dest(buffer_[index_].get());
      if(in != 0 && reader != 0)
      {
        ::CopyMemory(dest,in,size);
        size = size / app.output_device().get_frame_size();
        WORD *destw((WORD*)dest),*srcw((WORD*)reader);
        for(int i = 0;i < size;++i)
        {
          *destw++ += *srcw++;
          *destw++ += *srcw++;
        }
      } else if(in != 0)
      {
        ::CopyMemory(dest,in,size);
      } else if(reader != 0)
      {
        ::CopyMemory(dest,reader,size);
      } else {
        ::ZeroMemory(dest,size);
      }
      
      while(!ringbuffer_.push(buffer_[index_].get()))
      {
        Sleep(app.output_device().get_buffer_duration() / 20000);
      }

      index_ = (index_ + 1) & (buffer_.size() -1 );

    }
    break;
  case status_pause:
    change_status(status_pause_ok);
    break;
  default:
        wait_event();
//        WaitForSingleObject(event_.get(),WAIT_TIMEOUT_DEFAULT);
  }
  }
    debug_out(L"***** mixerは終了!\n");
  agent::done();
}