示例#1
0
        astra_status_t read(astra_frame_index_t frameIndex)
        {
            if (!is_open() || !is_started())
                return astra_status_t::ASTRA_STATUS_INVALID_OPERATION;

            return on_read(frameIndex);
        }
示例#2
0
    error::errors start_p2p_engine(
        char const * gid,
        char const * pid,
        char const * auth)
    {
        LOG_SECTION();

        error_code ec;
        if (is_started()) {
            ec = already_start;
        } else {
#ifndef PPBOX_DISABLE_CERTIFY
            ppbox::certify::Certifier & cert =
                util::daemon::use_module<ppbox::certify::Certifier>(*this);
            cert.set_auth_code(gid, pid, auth);
#endif

#ifndef PPBOX_DISABLE_DAC
            ppbox::dac::DacModule & dac =
                util::daemon::use_module<ppbox::dac::DacModule>(*this);
            dac.set_auth_code(gid, pid, auth);
#endif
            ec = start(1);
        }

        return last_error(__FUNCTION__, ec);
    }
示例#3
0
server_node::~server_node()
{
    if (is_started()) {
        stop();
        wait_to_stop();
    }
}
示例#4
0
	void start(boost::system::error_code& ec)
	{
		if(!is_started()) init_socket(ec);
		if(ec) return;
		static const endpoint_type multicast_endpoint = endpoint_type(address_type::from_string("239.255.255.250"), 1900);
		_socket.send_to(boost::asio::buffer(discovery_msg, sizeof(discovery_msg)), multicast_endpoint, 0, ec);
	}
示例#5
0
/**
 * @brief Sets the maximum duration of the movement.
 *
 * When this delay is reached, the movement stops.
 * Note that if the radius changes gradually, the movement will continue
 * for a while until the radius reaches zero.
 *
 * @param duration duration of the movement in milliseconds, or 0 to make it infinite
 */
void CircleMovement::set_duration(uint32_t duration) {

  this->duration = duration;
  if (duration != 0 && is_started()) {
    this->end_movement_date = System::now() + duration;
  }
}
示例#6
0
bool AudioEngine::start()
{
  SLresult ret = SL_RESULT_SUCCESS;

  if (is_started()) {
    LOG_E("error: already started");
    return false;
  }

  ret = initialize();
  if (SL_RESULT_SUCCESS != ret) {
    goto err;
  }

  ret = setup_player();
  if (SL_RESULT_SUCCESS != ret) {
    goto err;
  }

  ret = enable();
  if (SL_RESULT_SUCCESS != ret) {
    goto err;
  }

  started_ = true;

  return true;

err:
  finalize();
  return false;
}
示例#7
0
文件: jscript.c 项目: pstrealer/wine
static HRESULT WINAPI JScriptParse_ParseScriptText(IActiveScriptParse *iface,
        LPCOLESTR pstrCode, LPCOLESTR pstrItemName, IUnknown *punkContext,
        LPCOLESTR pstrDelimiter, CTXARG_T dwSourceContextCookie, ULONG ulStartingLine,
        DWORD dwFlags, VARIANT *pvarResult, EXCEPINFO *pexcepinfo)
{
    JScript *This = ASPARSE_THIS(iface);
    parser_ctx_t *parser_ctx;
    HRESULT hres;

    TRACE("(%p)->(%s %s %p %s %s %u %x %p %p)\n", This, debugstr_w(pstrCode),
          debugstr_w(pstrItemName), punkContext, debugstr_w(pstrDelimiter),
          wine_dbgstr_longlong(dwSourceContextCookie), ulStartingLine, dwFlags, pvarResult, pexcepinfo);

    if(This->thread_id != GetCurrentThreadId() || This->ctx->state == SCRIPTSTATE_CLOSED)
        return E_UNEXPECTED;

    hres = script_parse(This->ctx, pstrCode, pstrDelimiter, &parser_ctx);
    if(FAILED(hres))
        return hres;

    if(!is_started(This->ctx)) {
        if(This->queue_tail)
            This->queue_tail = This->queue_tail->next = parser_ctx;
        else
            This->queue_head = This->queue_tail = parser_ctx;
        return S_OK;
    }

    hres = exec_global_code(This, parser_ctx);
    parser_release(parser_ctx);

    return hres;
}
示例#8
0
int check_SDL_events()
{
    SDL_Event event;
    while(SDL_PollEvent(&event)) {
        if(event.type == SDL_QUIT)
            return 1;
        else if(event.type == SDL_KEYDOWN) {
            if(event.key.keysym.sym == SDLK_ESCAPE)
                return 1;
            else if(event.key.keysym.sym == SDLK_RETURN) {
                if(is_paused()) {
                    if(!is_started()) {
                        set_started(1);
                    }
                    else if(is_game_over()) {
                        set_game_over(0);
                        ent_table_shutdown();
                        ent_table_init();
                        create_entities();
                    }
                }

                toggle_paused();
            }
        }
    }

    return 0;
}
/** \brief Start the bt_httpo_full_t BUT only to reply an error in the http_rephd_t
 * 
 * - typically used to reply a "404 not found" or similar before deleting bt_httpo_full_t
 * - WARNING: mutually exclusive between the normal start() and the error start()
 *   - aka it is NOT intended to be used to deliver anything after that
 * - NOTE: to ensure that it is not used later, the socket_full_t will be closed
 *   - leaving the 'linger' sending the http_rephd_t data to the remote peer
 */
bt_err_t bt_httpo_full_t::start_reply_error(const http_rephd_t &http_rephd)	throw()
{
	// log to debug
	KLOG_DBG("enter");
	// sanity check - this object MUST NOT be already started
	DBG_ASSERT( !is_started() );
	// if socket_full is NULL at this point, so it returns an error
	// - NOTE: this is likely due to an socket_event_t occured before the start()
	if( !socket_full )	return bt_err_t::ERROR;

	// setup the sendbuf maxlen for the socket_full_t
	socket_full->xmitbuf_maxlen( 50*1024 );
	// sanity check - the socket_full_t sendbuf MUST have enougth room to accept the http_rephd_t
	DBG_ASSERT( socket_full->xmitbuf_freelen() >= http_rephd.to_http().size() );
	// send the http_rephd_t thru the socket_full_t
	socket_full->send( datum_t(http_rephd.to_http()) );
	
	// delete the socket_full to ensure 
	nipmem_zdelete socket_full;
	// sanity check - bt_io_read MUST be NULL at this point
	DBG_ASSERT( !bt_io_read );
	
	// return no error
	return bt_err_t::OK;	
}
示例#10
0
文件: jscript.c 项目: AndreRH/wine
static HRESULT WINAPI JScriptParse_ParseScriptText(IActiveScriptParse *iface,
        LPCOLESTR pstrCode, LPCOLESTR pstrItemName, IUnknown *punkContext,
        LPCOLESTR pstrDelimiter, CTXARG_T dwSourceContextCookie, ULONG ulStartingLine,
        DWORD dwFlags, VARIANT *pvarResult, EXCEPINFO *pexcepinfo)
{
    JScript *This = impl_from_IActiveScriptParse(iface);
    bytecode_t *code;
    HRESULT hres;

    TRACE("(%p)->(%s %s %p %s %s %u %x %p %p)\n", This, debugstr_w(pstrCode),
          debugstr_w(pstrItemName), punkContext, debugstr_w(pstrDelimiter),
          wine_dbgstr_longlong(dwSourceContextCookie), ulStartingLine, dwFlags, pvarResult, pexcepinfo);

    if(This->thread_id != GetCurrentThreadId() || This->ctx->state == SCRIPTSTATE_CLOSED)
        return E_UNEXPECTED;

    hres = compile_script(This->ctx, pstrCode, NULL, pstrDelimiter, (dwFlags & SCRIPTTEXT_ISEXPRESSION) != 0,
            This->is_encode, &code);
    if(FAILED(hres))
        return hres;

    if(dwFlags & SCRIPTTEXT_ISEXPRESSION) {
        jsval_t r;

        IActiveScriptSite_OnEnterScript(This->site);

        clear_ei(This->ctx);
        hres = exec_source(This->ctx, EXEC_GLOBAL, code, &code->global_code, NULL, NULL, NULL, This->ctx->global, 0, NULL, &r);
        if(SUCCEEDED(hres)) {
            if(pvarResult)
                hres = jsval_to_variant(r, pvarResult);
            jsval_release(r);
        }

        IActiveScriptSite_OnLeaveScript(This->site);
        return hres;
    }

    /*
     * Although pvarResult is not really used without SCRIPTTEXT_ISEXPRESSION flag, if it's not NULL,
     * script is executed immediately, even if it's not in started state yet.
     */
    if(!pvarResult && !is_started(This->ctx)) {
        if(This->queue_tail)
            This->queue_tail = This->queue_tail->next = code;
        else
            This->queue_head = This->queue_tail = code;
        return S_OK;
    }

    hres = exec_global_code(This, code);
    release_bytecode(code);
    if(FAILED(hres))
        return hres;

    if(pvarResult)
        V_VT(pvarResult) = VT_EMPTY;
    return S_OK;
}
示例#11
0
AudioEngine::~AudioEngine()
{
  if (is_started()) {
    shutdown();
  }
  delete buffer_;
  buffer_ = NULL;
}
示例#12
0
/**
 * \brief Sets the speed to apply when the movement is started.
 * \param normal_speed The new speed.
 */
void RandomMovement::set_normal_speed(double normal_speed) {

  this->normal_speed = normal_speed;

  if (is_started()) {
    StraightMovement::set_speed(normal_speed);
  }
}
示例#13
0
/* Pause the recorder. */
void pause_recorder ()
{
  if (is_started ())
    {
      recorder_pid = call_recorder (NULL, "pause");
      paused = TRUE;
    }
}
示例#14
0
 void device_stream<TFrameWrapper>::on_connection_stopped(astra_streamconnection_t connection)
 {
     LOG_INFO("orbbec.mocks.device_stream", "client stopped: %u", description().type());
     if (is_open() && is_started())
     {
         stop();
     }
 }
示例#15
0
/* Resume the recorder. */
void resume_recorder ()
{
  if (is_started ())
    {
      recorder_pid = call_recorder (NULL, "resume");
      paused = FALSE;
    }
}
示例#16
0
static HRESULT WINAPI JScriptParse_ParseScriptText(IActiveScriptParse *iface,
        LPCOLESTR pstrCode, LPCOLESTR pstrItemName, IUnknown *punkContext,
        LPCOLESTR pstrDelimiter, CTXARG_T dwSourceContextCookie, ULONG ulStartingLine,
        DWORD dwFlags, VARIANT *pvarResult, EXCEPINFO *pexcepinfo)
{
    JScript *This = impl_from_IActiveScriptParse(iface);
    bytecode_t *code;
    HRESULT hres;

    TRACE("(%p)->(%s %s %p %s %s %u %x %p %p)\n", This, debugstr_w(pstrCode),
          debugstr_w(pstrItemName), punkContext, debugstr_w(pstrDelimiter),
          wine_dbgstr_longlong(dwSourceContextCookie), ulStartingLine, dwFlags, pvarResult, pexcepinfo);

    if(This->thread_id != GetCurrentThreadId() || This->ctx->state == SCRIPTSTATE_CLOSED)
        return E_UNEXPECTED;

    hres = compile_script(This->ctx, pstrCode, NULL, pstrDelimiter, (dwFlags & SCRIPTTEXT_ISEXPRESSION) != 0,
            This->is_encode, &code);
    if(FAILED(hres))
        return hres;

    if(dwFlags & SCRIPTTEXT_ISEXPRESSION) {
        exec_ctx_t *exec_ctx;

        hres = create_exec_ctx(This->ctx, NULL, This->ctx->global, NULL, TRUE, &exec_ctx);
        if(SUCCEEDED(hres)) {
            jsval_t r;

            IActiveScriptSite_OnEnterScript(This->site);

            clear_ei(This->ctx);
            hres = exec_source(exec_ctx, code, &code->global_code, TRUE, &r);
            if(SUCCEEDED(hres)) {
                hres = jsval_to_variant(r, pvarResult);
                jsval_release(r);
            }
            exec_release(exec_ctx);

            IActiveScriptSite_OnLeaveScript(This->site);
        }

        return hres;
    }

    if(!is_started(This->ctx)) {
        if(This->queue_tail)
            This->queue_tail = This->queue_tail->next = code;
        else
            This->queue_head = This->queue_tail = code;
        return S_OK;
    }

    hres = exec_global_code(This, code);

    release_bytecode(code);
    return hres;
}
示例#17
0
/**
 * \brief Destructor.
 */
Map::~Map() {

  Debug::check_assertion(!is_started(),
      "Deleting a map that is still running. Call Map::leave() before.");

  if (is_loaded()) {
    unload();
  }
}
示例#18
0
/**
 * @brief Sets the radius of the circles.
 * @param radius the radius in pixels
 */
void CircleMovement::set_radius(int radius) {

  Debug::check_assertion(radius >= 0, StringConcat() << "Invalid radius: " << radius);

  this->wanted_radius = radius;
  if (radius_change_delay == 0) {
    if (is_started()) {
      this->current_radius = wanted_radius;
    }
  }
  else {
    this->radius_increment = (radius > this->current_radius) ? 1 : -1;
    if (is_started()) {
      this->next_radius_change_date = System::now();
    }
  }
  recompute_position();
}
示例#19
0
/** \brief Reinit the http_reqhd_t of this bt_httpo_full_t (valid IIF not yet started)
 * 
 * - this is used in neoip-oload to rewrite the http_reqhd_t depending on
 *   the oload module
 */
bt_httpo_full_t & bt_httpo_full_t::http_reqhd(const http_reqhd_t &new_reqhd)	throw()
{
	// sanity check - the bt_httpo_full_t MUST NOT be started 
	DBG_ASSERT( !is_started() );
	// copy the new value
	m_http_reqhd	= new_reqhd;
	// return the object itself
	return *this;
}
示例#20
0
/** \brief Reinit the userptr of this bt_httpo_full_t (valid IIF not yet started)
 * 
 * - this is used in neoip-oload to rewrite the userptr depending on
 *   the oload module. userptr points to the oload_mod_vapi_t
 */
bt_httpo_full_t &	bt_httpo_full_t::userptr(void *new_val)			throw()
{
	// sanity check - the bt_httpo_full_t MUST NOT be started 
	DBG_ASSERT( !is_started() );
	// copy the new value
	m_userptr	= new_val;
	// return the object itself
	return *this;	
}
示例#21
0
  bool WaitForInternalThreadToExit(){
	   if (is_started()) {
		      try {
			           thread_->join();
				      } catch (...) {
					           return false;
						      }
		       }
	    return true;
  } 
示例#22
0
文件: app.cpp 项目: webjb/bbb
int s_app_t::stop()
{
	PRINT_INFO("app stop\n");
	if( !is_started() )
		return 0;
	s_object_t::stop();

	m_soccer_player->stop();
	return 0;
}
示例#23
0
bool ViewAnimator::set_view(View *v)
{
	if (is_started() || !v)
	{
		return false;
	}
	view = v;
	view->connect(object_destroy_signal, this, SLOT_FUNC(&ViewAnimator::on_view_destroy));
	return true;
}
示例#24
0
文件: app.cpp 项目: webjb/bbb
int s_app_t::start()
{
	if( is_started() )
		return 0;
	s_object_t::start();
	m_soccer_player->start();

	m_run_state = 0;
	return 0;
}
示例#25
0
void server_node::start()
{
    if (is_started())
        throw std::runtime_error("Server node \"" + m_path + "\" is already started");

    if (m_fork) {
        m_kill_sent = false;
        m_pid = fork();
        if (m_pid == -1) {
            m_pid = 0;
            int err = -errno;
            throw_error(err, "Failed to fork process");
        } else if (m_pid == 0) {
            char buffer[3][1024] = {
                " ",
                "-c"
            };
            std::string ios_path = ioserv_path();
            char * const args[] = {
                const_cast<char*>(ios_path.c_str()),
                buffer[1],
                const_cast<char*>(m_path.c_str()),
                NULL
            };
            auto ld_path = std::string("LD_LIBRARY_PATH=") + getenv("LD_LIBRARY_PATH");
            char * const env[] = {
                const_cast<char*>(ld_path.c_str()),
                NULL
            };
            if (execve(ios_path.data(), args, env) == -1) {
                int err = -errno;
                std::cerr << create_error(err, "Failed to start process \"%s\"", ios_path.c_str()).message() << std::endl;
                quick_exit(1);
            }
        }
    } else {
        m_node = dnet_parse_config(m_path.c_str(), 0);
    }

    if (!is_started())
        throw std::runtime_error("Can not start server with config file: \"" + m_path + "\"");
}
示例#26
0
void InternalThread::StopInternalThread() {
  if (is_started()) {
    thread_->interrupt();
    try {
      thread_->join();
    } catch (boost::thread_interrupted&) {
    } catch (std::exception& e) {
      LOG(FATAL) << "Thread exception: " << e.what();
    }
  }
}
示例#27
0
文件: drivePlayer.cpp 项目: webjb/bbb
int s_drive_player_t::on_location(char * msg)
{
    parse(msg);

    if( !is_started() )
        return 0;

    drive();

    return 0;
}
示例#28
0
bool PollerThread::stop()
{
    if (!is_started()) {
        return false;
    }

    _should_exit = true;
    _poller.wakeup();

    return true;
}
示例#29
0
void Scheduler::run() {
  if(m_pHAL == NULL)
    return;

  for(uint_fast8_t i = 0; i < m_iItems; i++) {
    // Run all tasks
    if(!is_started(i) ) {
      continue;
    }
  }
}
示例#30
0
/* Stop the recorder. */
void
stop_recorder ()
{
  if (is_started ())
    {
      g_spawn_close_pid (recorder_pid);
      recorder_pid = call_recorder (NULL, "stop");
      g_spawn_close_pid (recorder_pid);
      started = FALSE;
    }
}