Set Timer a function callback

Newbie Member
29Sep2008,14:17   #1
davidhai's Avatar
Hi everybody,

I am trying to switch from a multicast address to another multicast address. On the bottom of ExecSwitchStreams that perform switch, I want to register a function (ExecSwitchStreamsBack ) so that the program will auto call to after t_time seconds. ExecSwitchStreamsBack will switch back to old multicast address.

Code:
static void ExecSwitchStreams(input_thread_t *p_input, char *p_new_server, int64_t t_time)
{		
	InputClean( p_input, &p_input->input );		
	
	input_source_t *other_input = &p_input->input;		
 
	   /* Create the stream_t */
	   other_input->p_stream = streamAccessNew( other_input->p_access, p_new_server, MY_FALSE );
   
		RegisterTimer ( t_time, p_old_server, ExecSwitchStreamsBack) //  Function to register call ExecSwitchStreamsBack after t_time seconds 
																	// p_old_server is a parameter for ExecSwitchStreamsBack 
  
}

static void ExecSwitchStreamsBack(char *p_old_server )
{
	 // code
}
How can I implement the RegisterTimer like that?

Please give me any ideas to implement this function. Many thanks
Newbie Member
30Sep2008,07:38   #2
davidhai's Avatar
Quote:
Originally Posted by davidhai
Hi everybody,

I am trying to switch from a multicast address to another multicast address. On the bottom of ExecSwitchStreams that perform switch, I want to register a function (ExecSwitchStreamsBack ) so that the program will auto call to after t_time seconds. ExecSwitchStreamsBack will switch back to old multicast address.

Code:
static void ExecSwitchStreams(input_thread_t *p_input, char *p_new_server, int64_t t_time)
{		
	InputClean( p_input, &p_input->input );		
	
	input_source_t *other_input = &p_input->input;		
 
	   /* Create the stream_t */
	   other_input->p_stream = streamAccessNew( other_input->p_access, p_new_server, MY_FALSE );
   
		RegisterTimer ( t_time, p_old_server, ExecSwitchStreamsBack) //  Function to register call ExecSwitchStreamsBack after t_time seconds 
																	// p_old_server is a parameter for ExecSwitchStreamsBack 
  
}

static void ExecSwitchStreamsBack(char *p_old_server )
{
	 // code
}
How can I implement the RegisterTimer like that?

Please give me any ideas to implement this function. Many thanks
If anybody knows about this problem, please help me to solve it.
Ambitious contributor
30Sep2008,20:45   #3
oogabooga's Avatar
What operating system?
(Looks like unix. What is the function for creating a timer?)
Where is p_old_server coming from.
Newbie Member
1Oct2008,07:13   #4
davidhai's Avatar
This is a program that it can run on Unix, Window,Mac Os. On window, I use cygwin to compile source. I have use <time.h> library in my source code.

p_old_server is a static variable that is stored before performing switch.