Exemplo n.º 1
0
/* espeak_thread is the "main" function of our secondary (queue-processing)
 * thread.
 * First, lock queue_guard, because it needs to be locked when we call
 * pthread_cond_wait on the runner_awake condition variable.
 * Next, enter an infinite loop.
 * The wait call also unlocks queue_guard, so that the other thread can
 * manipulate the queue.
 * When runner_awake is signaled, the pthread_cond_wait call re-locks
 * queue_guard, and the "queue processor" thread has access to the queue.
 * While there is an entry in the queue, call queue_process_entry.
 * queue_process_entry unlocks queue_guard after removing an item from the
 * queue, so that the main thread doesn't have to wait for us to finish
 * processing the entry.  So re-lock queue_guard after each call to
 * queue_process_entry.
 *
 * The main thread can add items to the queue in exactly two situations:
 * 1. We are waiting on runner_awake, or
 * 2. We are processing an entry that has just been removed from the queue.
*/
void *espeak_thread(void *arg)
{
	struct synth_t *s = (struct synth_t *) arg;

	pthread_mutex_lock(&queue_guard);
	while (should_run) {

		while (should_run && !queue_peek(synth_queue) && !stop_requested)
			pthread_cond_wait(&runner_awake, &queue_guard);

		if (stop_requested) {
			stop_speech();
			synth_queue_clear();
			stop_requested = 0;
			pthread_cond_signal(&stop_acknowledged);
		}

		while (should_run && queue_peek(synth_queue) && !stop_requested) {
			queue_process_entry(s);
			pthread_mutex_lock(&queue_guard);
		}
	}
	pthread_cond_signal(&stop_acknowledged);
	pthread_mutex_unlock(&queue_guard);
	return NULL;
}
Exemplo n.º 2
0
void Tutor::play_speech()
{
	if( !sys.dir_tutorial[0] )
		return;

	if( cur_speech_wav_id )
		stop_speech();

	//---------------------------------//

	String str;

	str  = sys.dir_tutorial;
	str += tutor[cur_tutor_id]->code;
	str += "\\TUT";

	if( cur_text_block_id < 10 )		// Add a zero. e.g. "TUT01"
		str += "0";

	str += cur_text_block_id;

	if( !misc.is_file_exist(str) )
		return;

	// ##### begin Gilbert 25/9 ######//
	cur_speech_wav_id = audio.play_long_wav(str, DEF_REL_VOLUME);		// cur_speech_wav_id is the WAV id that is needed for stopping playing of the WAV file
	// ##### end Gilbert 25/9 ######//
}
Exemplo n.º 3
0
Arquivo: oc_eas23.cpp Projeto: 7k2/7k2
//---- Begin of function CampaignEastWest::stage_23_prelude ----//
//
// Pick a state to attack.
//
void CampaignEastWest::stage_23_prelude()
{
    play_speech("PRE-23.WAV");
    disp_narrative( res_stage.read("23PRELUD") );
    stop_speech();

    attack_state( attacker_state_recno, target_state_recno, 0, 1, 2 );

    //------- set config settings -------//

    config.explore_whole_map = 0;
}
Exemplo n.º 4
0
//---- Begin of function CampaignEastWest::stage_4_prelude ----//
//
// Pick a state to attack.
//
void CampaignEastWest::stage_4_prelude()
{
	play_speech("PRE-04.WAV");
	disp_narrative( res_stage.read("4PRELUDE") );		// 0-the letter is from a human kingdom
	stop_speech();

	attacker_state_recno = random_pick_state( western_nation_recno, target_state_recno );		// pick a state of the Western empire that is next to defected state.

	attack_state( attacker_state_recno, target_state_recno, 0, 1, 2 );

	//------- set config settings -------//

	config.explore_whole_map = 0;
}
Exemplo n.º 5
0
int Tutor::detect()
{
	if( button_new_tutor.detect() )
	{
   	stop_speech();
		select_run_tutor(1);		// select and run tutorial, 1-called from in-game, not from the main menu
		return 1;
	}

	if( button_quit_tutor.detect() )
	{
		stop_speech();
		game.game_mode = GAME_SINGLE_PLAYER;
		return 1;
	}

	if( button_restart.detect() )
	{
		cur_text_block_id = 1;
		return 1;
	}

	if( cur_text_block_id > 1 && button_prev.detect() )
	{
		prev_text_block();
		return 1;
	}

	if( cur_text_block_id < text_block_count && button_next.detect() )
	{
		next_text_block();
		return 1;
	}

	return 0;
}
Exemplo n.º 6
0
Arquivo: oc_east1.cpp Projeto: 7k2/7k2
//---- Begin of function CampaignEastWest::stage_1_prelude ----//
//
// Pick a state to attack.
//
void CampaignEastWest::stage_1_prelude()
{
    cur_monster_nation_recno = random_pick_monster_campaign_nation();

    int rc = random_pick_attack_state(cur_monster_nation_recno, western_nation_recno);

    err_when( !rc );

    play_speech("PRE-01.WAV");
    disp_narrative( res_stage.read("1PRELUDE") );		// 1-the letter is from a Fryhtan kingdom
    stop_speech();

    attack_state( attacker_state_recno, target_state_recno, 0, 1, 2 );

    //------- set config settings -------//

    config.explore_whole_map = 1;
}
Exemplo n.º 7
0
//---- Begin of function CampaignEastWest::stage_28_prelude ----//
//
// Pick a state to attack.
//
void CampaignEastWest::stage_28_prelude()
{
	//-------- randomize goal settings --------//

	goal_population 	  = campaign_difficulty*100;
	goal_economic_score = campaign_difficulty*100;
	goal_year_limit     = 32 - campaign_difficulty*3;

	//---------------------------------------------//

	play_speech("PRE-28.WAV");
	disp_narrative( res_stage.read("28PRELUD"), goal_population, goal_economic_score, goal_year_limit );
	stop_speech();
	
	target_state_recno = random_pick_state(PLAYER_NATION_RECNO);

	flash_state( target_state_recno );

	//------- set config settings -------//

	config.explore_whole_map = 1;
}