[alsa-devel] [PATCH v1 3/4] alsabat: add XRUN injections function
Takashi Iwai
tiwai at suse.de
Thu Aug 31 20:22:06 CEST 2017
On Thu, 31 Aug 2017 15:37:08 +0200,
Zhang Keqiao wrote:
>
> This patch add XRUN injections function, alsabat can trigger the XRUNs
> by writing the 'XRUN INJECTION' files.
>
> Signed-off-by: Zhang Keqiao <keqiao.zhang at intel.com>
> ---
> bat/bat.c | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
> bat/common.h | 6 ++++
> 2 files changed, 101 insertions(+), 2 deletions(-)
>
> diff --git a/bat/bat.c b/bat/bat.c
> index b12e5d3..20fa926 100644
> --- a/bat/bat.c
> +++ b/bat/bat.c
> @@ -127,8 +127,81 @@ static void get_sine_frequencies(struct bat *bat, char *freq)
> }
> }
>
> -/* parse the card and pcm ID of playback device and capture device */
> -/* Then we can get the path for specify device to do the XRUN injection */
> +static int xrun_injection(struct bat *bat)
> +{
> + char playback_file[MAX_PATH + MAX_FILE];
> + char capture_file[MAX_PATH + MAX_FILE];
> + char filename[MAX_FILE] = XRUN_INJECTION_FILE;
> + char playback_filepath[MAX_PATH] = PLAYBACK_XRUN_INJECTION_PATH;
> + char capture_filepath[MAX_PATH] = CAPTURE_XRUN_INJECTION_PATH;
> + FILE *fp, *fc;
> +
> + if (bat->xrun_playback) {
> + /* replace the card ID and PCM ID in macro for xrun injection path */
> + sprintf(playback_filepath, playback_filepath, bat->playback.card_id,
> + bat->playback.pcm_id);
This doesn't look sane. The format path shouldn't be same as the
target. There is no guarantee that the format path is evaluated
before storing the resultant string.
Moreover:
> +#define PLAYBACK_XRUN_INJECTION_PATH "/proc/asound/card%s/pcm%sp/sub0"
> +#define CAPTURE_XRUN_INJECTION_PATH "/proc/asound/card%s/pcm%sc/sub0"
This assumes the PCM#0, which isn't always true.
thanks,
Takashi
More information about the Alsa-devel
mailing list