[RK3288][Android6.0] Audio播放时的pcm数据dump思路

来源:互联网 发布:淘宝天猫苏宁易购 编辑:程序博客网 时间:2024/06/06 02:20
Platform: Rockchip
OS: Android 6.0
Kernel: 3.10.92

其实这块RK已经写了,不过它的思路很好,即通过动态调节property而来决定是否需要dump data,这样的话在不用reboot的情况下就可以拿数据了,适合处理once的bug,其他模块也可以用这个思路。

static ssize_t out_write(struct audio_stream_out *stream, const void* buffer,                         size_t bytes){......//通过property来控制是否要dump pcm data    property_get("media.audio.record", value, NULL);    //    prop_pcm = atoi(value);    //非0的值决定要dump多少数据才停止,单位是M    if (prop_pcm > 0) {        dump_out_data(buffer, bytes, &prop_pcm);    }......}
dump_out_data():
static void dump_out_data(const void* buffer,size_t bytes, int *size) {    ALOGD("dump pcm file.");    static FILE* fd;    static int offset = 0;    if(fd == NULL) {        fd=fopen("/data/debug.pcm","wb+");            if(fd == NULL) {            ALOGD("DEBUG open /data/debug.pcm error =%d ,errno = %d",fd,errno);            offset = 0;        }    }    //写pcm数据    fwrite(buffer,bytes,1,fd);    offset += bytes;    fflush(fd);    //比如size是1,那么就是1M后停止dump数据    if(offset >= (*size)*1024*1024) {        *size = 0;        fclose(fd);        offset = 0;        system("setprop media.audio.record 0");        ALOGD("TEST playback pcmfile end");    } }

阅读全文
1 0
原创粉丝点击