Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1308242
  • 博文数量: 860
  • 博客积分: 425
  • 博客等级: 下士
  • 技术积分: 1464
  • 用 户 组: 普通用户
  • 注册时间: 2011-08-20 19:57
个人简介

对技术执着

文章分类

全部博文(860)

文章存档

2019年(16)

2018年(12)

2015年(732)

2013年(85)

2012年(15)

我的朋友

分类:

2015-03-14 17:10:11

原文地址:alsa中pcm_min.c测试源码 作者:gliethttp


/test/pcm_min.c

00001 /*
00002 * This extra small demo sends a random samples to your speakers.
00003 */
00004
00005 #include "../include/asoundlib.h"
00006
00007 static char *device = "default"; /* playback device */
00008
00009 *output = NULL;
00010 unsigned char buffer[16*1024]; /* some random data */
00011
00012 int main(void)
00013 {
00014 int err;
00015 unsigned int i;
00016 *handle;
00017 frames;
00018
00019 for (i = 0; i < sizeof(buffer); i++)
00020 buffer[i] = random() & 0xff;
00021
00022 if ((err = (&handle, device, , 0)) < 0) {
00023 printf("Playback open error: %s\n", (err));
00024 exit(EXIT_FAILURE);
00025 }
00026 if ((err = (handle,
00027 ,
00028 ,
00029 1,
00030 48000,
00031 1,
00032 500000)) < 0) { /* 0.5sec */
00033 printf("Playback open error: %s\n", (err));
00034 exit(EXIT_FAILURE);
00035 }
00036
00037 for (i = 0; i < 16; i++) {
00038 frames = (handle, buffer, sizeof(buffer));
00039 if (frames < 0)
00040 frames = (handle, frames, 0);
00041 if (frames < 0) {
00042 printf("snd_pcm_writei failed: %s\n", (err));
00043 break;
00044 }
00045 if (frames > 0 && frames < (long)sizeof(buffer))
00046 printf("Short write (expected %li, wrote %li)\n", (long)sizeof(buffer), frames);
00047 }
00048
00049 (handle);
00050 return 0;
00051 }

阅读(363) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~