snd_pcm_set_managed_buffer_all 未找到

问题描述

我试图为 USB 麦克风制作带有 alsa 内核子系统的内核模块。

我正在关注这个驱动程序的代码 https://github.com/torvalds/linux/blob/master/sound/usb/misc/ua101.c

在取得一些进展后,我的构建失败了

error: implicit declaration of function ‘snd_pcm_set_managed_buffer_all’; did you mean ‘snd_pcm_set_runtime_buffer’? [-Werror=implicit-function-declaration]
  146 |   snd_pcm_set_managed_buffer_all(mic->pcm,SNDRV_DMA_TYPE_VMALLOC,NULL,0);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |   snd_pcm_set_runtime_buffer
/home/maglash/Work/ldd/alsa/alsad.c:146:43: error: ‘SNDRV_DMA_TYPE_VMALLOC’ undeclared (first use in this function); did you mean ‘SNDRV_DMA_TYPE_DEV_UC’?
  146 |   snd_pcm_set_managed_buffer_all(mic->pcm,0);
      |                                           ^~~~~~~~~~~~~~~~~~~~~~
      |                                           SNDRV_DMA_TYPE_DEV_UC

//the following API call is the culprit.
snd_pcm_set_managed_buffer_all(ua->pcm,0);

我包含了以下内核头文件

#include <linux/init.h>   // Macros used to mark up functions e.g. __init __exit
#include <linux/module.h> // Core header for loading LKMs into the kernel
#include <linux/slab.h>
#include <linux/usb.h>
#include <linux/usb/audio.h>
#include <sound/core.h>
#include <sound/initval.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>

但他们似乎都没有这个 API? 我正在使用内核版本 5.4.0-62-generic

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)