mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2026-03-03 01:40:08 -05:00
test: latency - add --policy option to allow using SCHED_FIFO
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
536c93928b
commit
ea0850f3f3
1 changed files with 17 additions and 5 deletions
|
|
@ -40,6 +40,7 @@
|
||||||
|
|
||||||
typedef struct timespec timestamp_t;
|
typedef struct timespec timestamp_t;
|
||||||
|
|
||||||
|
char *sched_policy = "rr";
|
||||||
char *pdevice = "hw:0,0";
|
char *pdevice = "hw:0,0";
|
||||||
char *cdevice = "hw:0,0";
|
char *cdevice = "hw:0,0";
|
||||||
snd_pcm_format_t format = SND_PCM_FORMAT_S16_LE;
|
snd_pcm_format_t format = SND_PCM_FORMAT_S16_LE;
|
||||||
|
|
@ -354,18 +355,24 @@ void gettimestamp(snd_pcm_t *handle, snd_timestamp_t *timestamp)
|
||||||
void setscheduler(void)
|
void setscheduler(void)
|
||||||
{
|
{
|
||||||
struct sched_param sched_param;
|
struct sched_param sched_param;
|
||||||
|
int policy = SCHED_RR;
|
||||||
|
const char *spolicy = "Round Robin";
|
||||||
|
|
||||||
|
if (strcasecmp(sched_policy, "fifo") == 0) {
|
||||||
|
policy = SCHED_FIFO;
|
||||||
|
spolicy = "FIFO";
|
||||||
|
}
|
||||||
if (sched_getparam(0, &sched_param) < 0) {
|
if (sched_getparam(0, &sched_param) < 0) {
|
||||||
printf("Scheduler getparam failed...\n");
|
printf("Scheduler getparam failed...\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sched_param.sched_priority = sched_get_priority_max(SCHED_RR);
|
sched_param.sched_priority = sched_get_priority_max(policy);
|
||||||
if (!sched_setscheduler(0, SCHED_RR, &sched_param)) {
|
if (!sched_setscheduler(0, policy, &sched_param)) {
|
||||||
printf("Scheduler set to Round Robin with priority %i...\n", sched_param.sched_priority);
|
printf("Scheduler set to %s with priority %i...\n", spolicy, sched_param.sched_priority);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
printf("!!!Scheduler set to Round Robin with priority %i FAILED!!!\n", sched_param.sched_priority);
|
printf("!!!Scheduler set to %s with priority %i FAILED!!!\n", spolicy, sched_param.sched_priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
long timediff(snd_timestamp_t t1, snd_timestamp_t t2)
|
long timediff(snd_timestamp_t t1, snd_timestamp_t t2)
|
||||||
|
|
@ -515,6 +522,7 @@ void help(void)
|
||||||
"-e,--effect apply an effect (bandpass filter sweep)\n"
|
"-e,--effect apply an effect (bandpass filter sweep)\n"
|
||||||
"-x,--posdump dump buffer positions\n"
|
"-x,--posdump dump buffer positions\n"
|
||||||
"-X,--realtime do a realtime check (buffering)\n"
|
"-X,--realtime do a realtime check (buffering)\n"
|
||||||
|
"-O,--policy set scheduler policy (RR or FIFO)\n"
|
||||||
);
|
);
|
||||||
printf("Recognized sample formats are:");
|
printf("Recognized sample formats are:");
|
||||||
for (k = 0; k < SND_PCM_FORMAT_LAST; ++k) {
|
for (k = 0; k < SND_PCM_FORMAT_LAST; ++k) {
|
||||||
|
|
@ -555,6 +563,7 @@ int main(int argc, char *argv[])
|
||||||
{"effect", 0, NULL, 'e'},
|
{"effect", 0, NULL, 'e'},
|
||||||
{"posdump", 0, NULL, 'x'},
|
{"posdump", 0, NULL, 'x'},
|
||||||
{"realtime", 0, NULL, 'X'},
|
{"realtime", 0, NULL, 'X'},
|
||||||
|
{"policy", 1, NULL, 'O'},
|
||||||
{NULL, 0, NULL, 0},
|
{NULL, 0, NULL, 0},
|
||||||
};
|
};
|
||||||
snd_pcm_t *phandle, *chandle;
|
snd_pcm_t *phandle, *chandle;
|
||||||
|
|
@ -569,7 +578,7 @@ int main(int argc, char *argv[])
|
||||||
morehelp = 0;
|
morehelp = 0;
|
||||||
while (1) {
|
while (1) {
|
||||||
int c;
|
int c;
|
||||||
if ((c = getopt_long(argc, argv, "hP:C:m:M:U:F:f:c:r:B:E:s:y:bpenxX", long_option, NULL)) < 0)
|
if ((c = getopt_long(argc, argv, "hP:C:m:M:U:F:f:c:r:B:E:s:y:O:bpenxX", long_option, NULL)) < 0)
|
||||||
break;
|
break;
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'h':
|
case 'h':
|
||||||
|
|
@ -643,6 +652,9 @@ int main(int argc, char *argv[])
|
||||||
case 'X':
|
case 'X':
|
||||||
realtime_check = 1;
|
realtime_check = 1;
|
||||||
break;
|
break;
|
||||||
|
case 'O':
|
||||||
|
sched_policy = optarg;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue