int main(int argc, char *argv[]) { snd_pcm_t *handle; snd_pcm_t *handle_play; int err, morehelp; snd_pcm_hw_params_t *hwparams; snd_pcm_sw_params_t *swparams; int method = 0; signed short *samples; unsigned int chn; snd_pcm_hw_params_alloca(&hwparams); snd_pcm_sw_params_alloca(&swparams); printf("Capture device is %s\n", device); printf("Stream parameters are %iHz, %s, %i channels\n", rate, snd_pcm_format_name(format), channels); /*open the playback*/ if ((err = snd_pcm_open(&handle_play, device,SND_PCM_STREAM_PLAYBACK, 0)) < 0) { printf("Capture open error: %s\n", snd_strerror(err)); return 0; } /* set the hard ware parameter*/ if ((err = set_hwparams(handle_play,hwparams,SND_PCM_ACCESS_RW_INTERLEAVED)) < 0) { printf("Setting of hwparams failed: %s\n", snd_strerror(err)); exit(EXIT_FAILURE); } /*open the capture*/ if ((err = snd_pcm_open(&handle, device,SND_PCM_STREAM_CAPTURE, 0)) < 0) { printf("Capture open error: %s\n", snd_strerror(err)); return 0; } /* set the hard ware parameter*/ if ((err = set_hwparams(handle, hwparams,SND_PCM_ACCESS_RW_INTERLEAVED)) < 0) { printf("Setting of hwparams failed: %s\n", snd_strerror(err)); exit(EXIT_FAILURE); } static struct timeval oldtv; static struct timeval tv; /*avasounil = snd_pcm_avail_update(handle);*/ gettimeofday(&tv,NULL); // printf("play back time %lu\n",(tv.tv_sec-oldtv.tv_sec)*1000000+tv.tv_usec-oldtv.tv_usec); printf("main time %u: %u \n",tv.tv_sec,tv.tv_usec); oldtv = tv; /*async for capture */ async_loop(handle); /* */ write_loop(handle_play); /*while(1) { }*/ }
int main() { int i = 0; async_state_t state; async_init(&state); async_push(&state, get_action(h3)); async_loop(&state); return 0; }
int main(int argc, char *argv[]) { snd_pcm_t *handle; snd_pcm_t *handle_play; int err, morehelp; snd_pcm_hw_params_t *hwparams; snd_pcm_sw_params_t *swparams; int method = 0; signed short *samples; unsigned int chn; snd_pcm_hw_params_alloca(&hwparams); snd_pcm_sw_params_alloca(&swparams); printf("Capture device is %s\n", device); printf("Stream parameters are %iHz, %s, %i channels\n", rate, snd_pcm_format_name(format), channels); /*open the playback*/ if ((err = snd_pcm_open(&handle_play, device,SND_PCM_STREAM_PLAYBACK, 0)) < 0) { printf("Capture open error: %s\n", snd_strerror(err)); return 0; } /* set the hard ware parameter*/ if ((err = set_hwparams(handle_play,hwparams,SND_PCM_ACCESS_RW_INTERLEAVED)) < 0) { printf("Setting of hwparams failed: %s\n", snd_strerror(err)); exit(EXIT_FAILURE); } /*open the capture*/ if ((err = snd_pcm_open(&handle, device,SND_PCM_STREAM_CAPTURE, 0)) < 0) { printf("Capture open error: %s\n", snd_strerror(err)); return 0; } /* set the hard ware parameter*/ if ((err = set_hwparams(handle, hwparams,SND_PCM_ACCESS_RW_INTERLEAVED)) < 0) { printf("Setting of hwparams failed: %s\n", snd_strerror(err)); exit(EXIT_FAILURE); } /*async for capture */ async_loop(handle); /* */ write_loop(handle_play); /*while(1) { }*/ }