Android2.3-> Audio-> aplay播放的的问题

文章详细介绍了在aplay测试中遇到音乐播放卡顿问题时,通过调整pcm_open调用前的flags变量配置,以及定义AUDIO_HW_OUT_PERIOD_MULT和AUDIO_HW_OUT_PERIOD_CNT宏来优化audiobuffer大小,从而有效解决音乐播放卡顿的方法。
  你在aplay.c文件的play_file函数的pcm_open调用前面加上flags |= (AUDIO_HW_OUT_PERIOD_MULT - 1) << PCM_PERIOD_SZ_SHIFT;
        flags |= (AUDIO_HW_OUT_PERIOD_CNT - PCM_PERIOD_CNT_MIN) << PCM_PERIOD_CNT_SHIFT;

  然后加上#define AUDIO_HW_OUT_PERIOD_MULT 8 

#define AUDIO_HW_OUT_PERIOD_CNT 4这两个宏定义

解决aplay测试的时候, audio buffer过小引起音乐卡的问题


static int soc_pcm_open(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); struct snd_soc_component *component; struct snd_soc_dai *dai; int i, ret = 0; for_each_rtd_components(rtd, i, component) pinctrl_pm_select_default_state(component->dev); ret = snd_soc_pcm_component_pm_runtime_get(rtd, substream); if (ret < 0) goto pm_err; mutex_lock_nested(&rtd->card->pcm_mutex, rtd->card->pcm_subclass); ret = soc_pcm_components_open(substream); if (ret < 0) goto err; ret = snd_soc_link_startup(substream); if (ret < 0) goto err; /* startup the audio subsystem */ for_each_rtd_dais(rtd, i, dai) { ret = snd_soc_dai_startup(dai, substream); if (ret < 0) goto err; if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) dai->tx_mask = 0; else dai->rx_mask = 0; } /* Dynamic PCM DAI links compat checks use dynamic capabilities */ if (rtd->dai_link->dynamic || rtd->dai_link->no_pcm) goto dynamic; /* Check that the codec and cpu DAIs are compatible */ soc_pcm_init_runtime_hw(substream); soc_pcm_update_symmetry(substream); ret = soc_hw_sanity_check(substream); if (ret < 0) goto err; soc_pcm_apply_msb(substream); /* Symmetry only applies if we&#39;ve already got an active stream. */ for_each_rtd_dais(rtd, i, dai) { ret = soc_pcm_apply_symmetry(substream, dai); if (ret != 0) goto err; } dynamic: snd_soc_runtime_activate(rtd, substream->stream); ret = 0; err: mutex_unlock(&rtd->card->pcm_mutex); pm_err: if (ret < 0) { soc_pcm_clean(substream, 1); dev_err(rtd->dev, "%s() failed (%d)", __func__, ret); } return ret; }
最新发布
11-04
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值