Example #1
0
void os_wait_sample (void)
{
  stop_player(SIGINT);
}/* os_wait_sample */
	void CPlayerHandler::handle_delete( const CNode &player_node )
	{
		stop_player( player_node.get_id() );
	}
Example #3
0
void os_stop_sample (int number)
{
  /* INCOMPLETE */

  stop_player(SIGTERM);
}/* os_stop_sample */
	void CPlayerHandler::update( const CNode &player_node )
	{
		const INodeEndpoint *play_endpoint = player_node.get_node_endpoint( CPlayerLogic::endpoint_play );
		const INodeEndpoint *active_endpoint = player_node.get_node_endpoint( CPlayerLogic::endpoint_active );
		const INodeEndpoint *tick_endpoint = player_node.get_node_endpoint( CPlayerLogic::endpoint_tick );
		assert( play_endpoint && active_endpoint && tick_endpoint );

		int play_value = *play_endpoint->get_value();
		int active_value = *active_endpoint->get_value();

		if( play_value == 0 || active_value == 0 )
		{
			stop_player( player_node.get_id() );
			return;
		}

		/*
		lookup player attributes
		*/
		const INodeEndpoint *rate_endpoint = player_node.get_node_endpoint( CPlayerLogic::endpoint_rate );
		const INodeEndpoint *loop_endpoint = player_node.get_node_endpoint( CPlayerLogic::endpoint_loop );
		const INodeEndpoint *start_endpoint = player_node.get_node_endpoint( CPlayerLogic::endpoint_start );
		const INodeEndpoint *end_endpoint = player_node.get_node_endpoint( CPlayerLogic::endpoint_end );

		assert( rate_endpoint && loop_endpoint && start_endpoint && end_endpoint );

		pthread_mutex_lock( &m_mutex );

		/*
		see if the player is already playing
		*/

		CPlayerState *player_state = NULL;

		internal_id player_id = player_node.get_id();
		player_state_map::iterator lookup = m_player_states.find( player_id );
		if( lookup == m_player_states.end() )
		{
			/* create new player if not already playing */
			player_state = new CPlayerState;
			player_state->m_id = player_id;
			m_player_states[ player_id ] = player_state;
		}
		else
		{
			/*this player is already playing - update it*/
			player_state = lookup->second;
		}

		/* recreate paths, in case they have changed */
		player_state->m_tick_path = player_node.get_path();
		player_state->m_tick_path.append_element( CPlayerLogic::endpoint_tick );

		player_state->m_play_path = player_node.get_path();
		player_state->m_play_path.append_element( CPlayerLogic::endpoint_play );

		/*
		setup all other player state fields
		*/

		player_state->m_initial_ticks = *tick_endpoint->get_value(); 
		player_state->m_previous_ticks = player_state->m_initial_ticks; 
		player_state->m_rate = *rate_endpoint->get_value();
		player_state->m_start_msecs = get_current_msecs();

		int loop_value = *loop_endpoint->get_value();
		player_state->m_loop = ( loop_value != 0 );
		player_state->m_loop_start_ticks = *start_endpoint->get_value();
		player_state->m_loop_end_ticks = *end_endpoint->get_value();

		pthread_mutex_unlock( &m_mutex );
	}