To my surprise, this function showed up in the profiling info.
This is due to the fact that the old code was parsing the
FORMAT status item in audiod_pre_select() which gets called
on each iteration of the sheduler. However, this status item
gets only modified on audio file change.
So parse the status item string only once, when we receive it,
and store the current audio format number in the new field of
struct status_task.
static int open_current_receiver(struct sched *s)
{
static int open_current_receiver(struct sched *s)
{
- char *audio_format = stat_task->stat_item_values[SI_FORMAT];
+ int cafn = stat_task->current_audio_format_num;
- if (!audio_format || !stat_task->pcd)
- return 0;
- i = get_audio_format_num(audio_format + strlen(
- status_item_list[SI_FORMAT]) + 1);
- if (i < 0)
+ if (cafn < 0 || !stat_task->pcd)
- if (receiver_running(i))
+ if (receiver_running(cafn))
- if (tv_diff(now, &afi[i].restart_barrier, &diff) < 0) {
+ if (tv_diff(now, &afi[cafn].restart_barrier, &diff) < 0) {
s->timeout = diff;
return 0;
}
s->timeout = diff;
return 0;
}
- return open_receiver(i) < 0? 0 : 1;
+ return open_receiver(cafn) < 0? 0 : 1;
}
static unsigned compute_time_diff(const struct timeval *status_time)
}
static unsigned compute_time_diff(const struct timeval *status_time)
if (stat_task->clock_diff_count)
stat_task->clock_diff_count--;
break;
if (stat_task->clock_diff_count)
stat_task->clock_diff_count--;
break;
+ case SI_FORMAT:
+ stat_task->current_audio_format_num = get_audio_format_num(
+ line + ilen + 1);
st->task.private_data = st;
st->sa_time_diff_sign = 1;
st->clock_diff_count = conf.clock_diff_count_arg;
st->task.private_data = st;
st->sa_time_diff_sign = 1;
st->clock_diff_count = conf.clock_diff_count_arg;
+ st->current_audio_format_num = -1;
sprintf(st->task.status, "status task");
}
sprintf(st->task.status, "status task");
}
unsigned clock_diff_count;
/** when to start the next check for clock difference */
struct timeval clock_diff_barrier;
unsigned clock_diff_count;
/** when to start the next check for clock difference */
struct timeval clock_diff_barrier;
+ /** Number of the audio format as announced by para_server. */
+ int current_audio_format_num;
};
extern struct status_task *stat_task;
};
extern struct status_task *stat_task;