Commit 9a6494fb authored by Simon Morlat's avatar Simon Morlat

fix bugs regarding assign of priorities for MSTicker threads

parent 854a020e
......@@ -82,6 +82,13 @@ struct _MSTicker
typedef struct _MSTicker MSTicker;
struct _MSTickerParams{
MSTickerPrio prio;
const char *name;
};
typedef struct _MSTickerParams MSTickerParams;
#ifdef __cplusplus
extern "C"{
#endif
......@@ -95,13 +102,21 @@ extern "C"{
*/
MS2_PUBLIC MSTicker *ms_ticker_new(void);
/**
* Create a ticker that will be used to start
* and stop a graph.
*
* Returns: MSTicker * if successfull, NULL otherwise.
*/
MS2_PUBLIC MSTicker *ms_ticker_new_with_params(const MSTickerParams *params);
/**
* Set a name to the ticker (used for logging)
**/
MS2_PUBLIC void ms_ticker_set_name(MSTicker *ticker, const char *name);
/**
* Set priority to the ticker
* Deprecated: Set priority to the ticker
**/
MS2_PUBLIC void ms_ticker_set_priority(MSTicker *ticker, MSTickerPrio prio);
......
......@@ -287,10 +287,10 @@ static mblk_t* audio_stream_payload_picker(MSRtpPayloadPickerContext* context,u
}
static void start_ticker(AudioStream *stream){
stream->ticker=ms_ticker_new();
ms_ticker_set_name(stream->ticker,"Audio MSTicker");
ms_ticker_set_priority(stream->ticker,__ms_get_default_prio(FALSE));
MSTickerParams params={0};
params.name="Audio MSTicker";
params.prio=__ms_get_default_prio(FALSE);
stream->ticker=ms_ticker_new_with_params(&params);
}
static void stop_preload_graph(AudioStream *stream){
......
......@@ -43,12 +43,12 @@ static const double smooth_coef=0.9;
void * ms_ticker_run(void *s);
static uint64_t get_cur_time_ms(void *);
void ms_ticker_start(MSTicker *s){
static void ms_ticker_start(MSTicker *s){
s->run=TRUE;
ms_thread_create(&s->thread,NULL,ms_ticker_run,s);
}
void ms_ticker_init(MSTicker *ticker)
static void ms_ticker_init(MSTicker *ticker, const MSTickerParams *params)
{
ms_mutex_init(&ticker->lock,NULL);
ticker->execution_list=NULL;
......@@ -59,19 +59,26 @@ void ms_ticker_init(MSTicker *ticker)
ticker->exec_id=0;
ticker->get_cur_time_ptr=&get_cur_time_ms;
ticker->get_cur_time_data=NULL;
ticker->name=ms_strdup("MSTicker");
ticker->name=ms_strdup(params->name);
ticker->av_load=0;
ticker->prio=MS_TICKER_PRIO_NORMAL;
ticker->prio=params->prio;
ms_ticker_start(ticker);
}
MSTicker *ms_ticker_new(){
MSTickerParams params;
params.name="MSTicker";
params.prio=MS_TICKER_PRIO_NORMAL;
return ms_ticker_new_with_params(&params);
}
MSTicker *ms_ticker_new_with_params(const MSTickerParams *params){
MSTicker *obj=(MSTicker *)ms_new(MSTicker,1);
ms_ticker_init(obj);
ms_ticker_init(obj,params);
return obj;
}
void ms_ticker_stop(MSTicker *s){
static void ms_ticker_stop(MSTicker *s){
ms_mutex_lock(&s->lock);
s->run=FALSE;
ms_mutex_unlock(&s->lock);
......@@ -335,7 +342,7 @@ static int set_high_prio(MSTicker *obj){
policy==SCHED_FIFO ? "SCHED_FIFO" : "SCHED_RR", param.sched_priority);
}
#endif
}
}else ms_message("%s priority left to normal.",obj->name);
return precision;
}
......
......@@ -491,11 +491,15 @@ int video_stream_start (VideoStream *stream, RtpProfile *profile, const char *re
}
/* create the ticker */
stream->ticker = ms_ticker_new();
ms_ticker_set_name(stream->ticker,"Video MSTicker");
MSTickerParams params={0};
params.name="Video MSTicker";
#ifdef __ios
ms_ticker_set_priority(stream->ticker,MS_TICKER_PRIO_HIGH);
params.prio=MS_TICKER_PRIO_HIGH;
#else
params.prio=MS_TICKER_PRIO_NORMAL;
#endif
stream->ticker = ms_ticker_new_with_params(&params);
/* attach the graphs */
if (stream->source)
ms_ticker_attach (stream->ticker, stream->source);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment