Audio tinyalsa定时和PCM_MMAP问题

Audio tinyalsa定时和PCM_MMAP问题,audio,codec,qualcomm,tinyalsa,Audio,Codec,Qualcomm,Tinyalsa,我们使用的是使用高通PM8916编解码器的ARM64 Snapdragon。目标是以48000采样/秒的速度对单个通道进行采样,并使用高分辨率时间戳。tinyalsa文件坚持我们必须使用PCM_MMAP。当我们这样做时,pcm_open()不会抱怨,但pcm_readi()会失败。错误号:22 ioctl()中的无效参数 我认为与此相关的另一个症状是,当以这种形式调用pcm_open(无pcm_MMAP)时: 音频流非常流畅(period=256),与文档相反,pcm_get_htimestam

我们使用的是使用高通PM8916编解码器的ARM64 Snapdragon。目标是以48000采样/秒的速度对单个通道进行采样,并使用高分辨率时间戳。tinyalsa文件坚持我们必须使用PCM_MMAP。当我们这样做时,pcm_open()不会抱怨,但pcm_readi()会失败。错误号:22 ioctl()中的无效参数

我认为与此相关的另一个症状是,当以这种形式调用pcm_open(无pcm_MMAP)时:

音频流非常流畅(period=256),与文档相反,pcm_get_htimestamp()返回的值非常好。不确定时间有多准确,但明天我将注入GPS 1PPS,并进行标准测试以找出答案。 但当我按照说明使用PCM_MMAP时,例如:

tinyHandle = pcm_open( TINYALSA_CARD, TINYALSA_DEVICE, PCM_IN | PCM_MMAP | PCM_MONOTONIC | PCM_NOIRQ, &cfg );

如上所述,读取失败。我还没有试过所有可能的组合,但那就来了。奇怪的是,每当指定PCM_MMAP时

int err = pcm_get_htimestamp( tinyHandle, &available, &timestamp);
返回变得不敏感,tv_sec包含的值约为4917或5013,而不是合理的时间。我很想得出结论,tv_sec值是自启动以来经过的时间,除了时间戳发生在启动后的几秒钟内

哦,还有一个细节。我使用的sdk附带的tinyalsa版本中未识别PCM_NONBLOCK选项。所以我git克隆了tinyalsa,构建了一个静态库,并升级到了最新最棒的版本。PCM_MMAP的问题在两个版本中都存在。这一点,再加上几个小时来寻找有同样问题的人基本上是失败的,让我相信这是我们的新产品,而不是libs

你有没有想过下一步该去哪里

谢谢


今早确认pcm_readi()内的ioctl正在接收正确的文件描述符(4)和周期大小(256)。没有其他可能无效的参数

好的,GPS 1PPS测试显示时间戳的准确度为2-3毫秒,这让我们使用这种用法“足够了”(没有PCM_MMAP):

以下是让我陷入困境的评论:

/** Returns available frames in pcm buffer and corresponding time stamp.
 * The clock is CLOCK_MONOTONIC if flag @ref PCM_MONOTONIC was specified in @ref pcm_open,
 * otherwise the clock is CLOCK_REALTIME.
 * For an input stream, frames available are frames ready for the application to read.
 * For an output stream, frames available are the number of empty frames available for the application to write.
 * Only available for PCMs opened with the @ref PCM_MMAP flag.
 * @param pcm A PCM handle.
 * @param avail The number of available frames
 * @param tstamp The timestamp
 * @return On success, zero is returned; on failure, negative one.
 */
int pcm_get_htimestamp(struct pcm *pcm, unsigned int *avail,
                       struct timespec *tstamp)
这是误导,因为它阻止了我在没有pcm_MMAP工作的情况下尝试pcm_get_htimestamp()调用。会有进一步的调查,如果我能发布,我会的

谢谢大家!

int err = pcm_get_htimestamp( tinyHandle, &available, &timestamp);
tinyHandle = pcm_open( TINYALSA_CARD, TINYALSA_DEVICE, PCM_IN, &cfg );
/** Returns available frames in pcm buffer and corresponding time stamp.
 * The clock is CLOCK_MONOTONIC if flag @ref PCM_MONOTONIC was specified in @ref pcm_open,
 * otherwise the clock is CLOCK_REALTIME.
 * For an input stream, frames available are frames ready for the application to read.
 * For an output stream, frames available are the number of empty frames available for the application to write.
 * Only available for PCMs opened with the @ref PCM_MMAP flag.
 * @param pcm A PCM handle.
 * @param avail The number of available frames
 * @param tstamp The timestamp
 * @return On success, zero is returned; on failure, negative one.
 */
int pcm_get_htimestamp(struct pcm *pcm, unsigned int *avail,
                       struct timespec *tstamp)