Example #1
0
ESPEAK_API espeak_ERROR espeak_Synth_Mark(const void *text, size_t size, 
					  const char *index_mark, 
					  unsigned int end_position, 
					  unsigned int flags, 
					  unsigned int* unique_identifier,
					  void* user_data)
{//=========================================================================
#ifdef DEBUG_ENABLED
  ENTER("espeak_Synth_Mark");
  SHOW("espeak_Synth_Mark > index_mark=%s, end_position=%d, flags=%d, text=%s\n", index_mark, end_position, flags, text);
#endif

	espeak_ERROR a_error=EE_OK;
	static unsigned int temp_identifier;

	if (unique_identifier == NULL)
	{
		unique_identifier = &temp_identifier;
	}
	*unique_identifier = 0;

	if(synchronous_mode)
	{
		return(sync_espeak_Synth_Mark(0,text,size,index_mark,end_position,flags,user_data));
	}

#ifdef USE_ASYNC
	// Create the mark command
	t_espeak_command* c1 = create_espeak_mark(text, size, index_mark, end_position, 
						flags, user_data);
	
	// Retrieve the unique identifier
	*unique_identifier = c1->u.my_mark.unique_identifier;
	
	// Create the "terminated msg" command (same uid)
	t_espeak_command* c2 = create_espeak_terminated_msg(*unique_identifier, user_data);
	
	// Try to add these 2 commands (single transaction)
	if (c1 && c2)
	{
		a_error = fifo_add_commands(c1, c2);
		if (a_error != EE_OK)
		{
			delete_espeak_command(c1);
			delete_espeak_command(c2);
			c1=c2=NULL;
		}
	}
	else
	{
		delete_espeak_command(c1);
		delete_espeak_command(c2);
	}

#endif
	return a_error;
}  //  end of espeak_Synth_Mark
Example #2
0
ESPEAK_NG_API espeak_ng_STATUS
espeak_ng_SynthesizeMark(const void *text,
                         size_t size,
                         const char *index_mark,
                         unsigned int end_position,
                         unsigned int flags,
                         unsigned int *unique_identifier,
                         void *user_data)
{
	(void)size; // unused in non-async modes

	static unsigned int temp_identifier;

	if (unique_identifier == NULL)
		unique_identifier = &temp_identifier;
	*unique_identifier = 0;

	if (my_mode & ENOUTPUT_MODE_SYNCHRONOUS)
		return sync_espeak_Synth_Mark(0, text, index_mark, end_position, flags, user_data);

#ifdef USE_ASYNC
	// Create the mark command
	t_espeak_command *c1 = create_espeak_mark(text, size, index_mark, end_position,
	                                          flags, user_data);
	if (c1) {
		// Retrieve the unique identifier
		*unique_identifier = c1->u.my_mark.unique_identifier;
	}

	// Create the "terminated msg" command (same uid)
	t_espeak_command *c2 = create_espeak_terminated_msg(*unique_identifier, user_data);

	// Try to add these 2 commands (single transaction)
	if (c1 && c2) {
		espeak_ng_STATUS status = fifo_add_commands(c1, c2);
		if (status != ENS_OK) {
			delete_espeak_command(c1);
			delete_espeak_command(c2);
		}
		return status;
	}

	delete_espeak_command(c1);
	delete_espeak_command(c2);
	return ENOMEM;
#else
	return sync_espeak_Synth_Mark(0, text, index_mark, end_position, flags, user_data);
#endif
}