-
Notifications
You must be signed in to change notification settings - Fork 349
Tools: Testbench: Add support for ALSA controls script #9916
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tools: Testbench: Add support for ALSA controls script #9916
Conversation
8ab6f9a to
3e8aa01
Compare
|
Seems to be a bug in testbench, the end of component configuration blob becomes corrupt with this PR... finding out why. Found, there's no check in testbench for bytes control data vs. allocated max size. |
6271a95 to
bc41954
Compare
kv2019i
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, some comment/questions inline, please check
tools/testbench/utils.c
Outdated
| return 0; | ||
|
|
||
| raw_line = malloc(TB_MAX_CMD_CHARS); | ||
| if (!raw_line) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can just assert on alloc error and not deal with memory handling.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
tools/testbench/utils.c
Outdated
|
|
||
| line = malloc(TB_MAX_CMD_CHARS); | ||
| if (!line) | ||
| return -ENOMEM; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you do check for alloc errors, then you'd need to free "raw_line" here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert() then for simplicity, not expecting to run out memory in this.
| fprintf(stderr, "error: failed parse of sleep command.\n"); | ||
| break; | ||
| } | ||
| break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
continue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function tb_read_controls() should return and continue pipelines scheduling when sleep is encountered and be called back after nanoseconds if simulated time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, right, this is the main purpose of "sleep". Sorry my bad. I guess a comment might help to explain why we need to return to main loop after "sleep", but not after other commands.
tools/testbench/utils.c
Outdated
| memcpy(control_name, name_str + find_len, len); | ||
|
|
||
| line_end = line + strlen(line); | ||
| len = line_end - end_str - find_end_len; // Todo rememove linefeed from end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
todo still valid (rememove?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The line feeds were handled, just remove comment.
The non-threaded version of testbench no more support these features so, they are removed to simplify the code. The removed command line switches are -D for pipeline duration and -T tick duration. The cleanup is done to ease adding support for simulated run-time ALSA controls into pipelines schedule loop. Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
The stream parameters channels count and sample rate are moved into the struct file state that is monitored by testbench pipelines schedule loop. The simulated "time" can be derived from file state samples count when the parameters are known. Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
This patch adds to testbench command line option -s <controls file>. The controls file can contain comments with line starting with #, empty lines, amixer cset name= commands and sleep n commands. The script format is similar to what can be applied to a real SOF device running Linux OS. E.g. amixer -c0 cset name='Post Mixer Analog Playback DRC switch' off amixer -c0 cset name='Post Mixer Analog Playback Volume' 42,43 sleep 0.5 amixer -c0 cset name='Post Mixer Analog Playback Volume' 45 The result simulated waveform would show in the beginning left channel set to gain value 42, and right channel to gain value 43. After processing 0.5 seconds of audio both left and right channel gains are set to 45. The supported controls types are mixer, switch and enum. Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
The added example generates a sine wave file and processed it with various stereo mixer control settings. Since the example topology contains also a DRC it is switched off as demo with switch control. Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
This patch adds check for bytes data control size into sof-testbench4 for topology embedded control data. Also the missing error handling is added to the topology parser. Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
The max size is increased to 8 kB. Instead of copying the data from topology to controls array the data can be referenced with a pointer. Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
bc41954 to
bf04b74
Compare
| fprintf(stderr, "error: failed parse of sleep command.\n"); | ||
| break; | ||
| } | ||
| break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, right, this is the main purpose of "sleep". Sorry my bad. I guess a comment might help to explain why we need to return to main loop after "sleep", but not after other commands.
lgirdwood
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can deal with the comment in the next PR as I know there is more work to come here.
Adds support for command line, e.g.
Where controls.sh script can be e.g. similar as control for a real device:
In the above, the comments are ignored. Only the amixer and sleep commands are parsed. For sleep the numerical argument, and for amixer the cset name='' part and the arguments after.