int snd_ctl_switch_write(snd_ctl_t *handle, snd_switch_t * sw);
int snd_ctl_pcm_info(snd_ctl_t *handle, int dev, snd_pcm_info_t * info);
int snd_ctl_pcm_playback_info(snd_ctl_t *handle, int dev, snd_pcm_playback_info_t * info);
-int snd_ctl_pcm_record_info(snd_ctl_t *handle, int dev, snd_pcm_record_info_t * info);
+int snd_ctl_pcm_capture_info(snd_ctl_t *handle, int dev, snd_pcm_capture_info_t * info);
int snd_ctl_pcm_playback_switch_list(snd_ctl_t *handle, int dev, snd_switch_list_t * list);
int snd_ctl_pcm_playback_switch_read(snd_ctl_t *handle, int dev, snd_switch_t * sw);
int snd_ctl_pcm_playback_switch_write(snd_ctl_t *handle, int dev, snd_switch_t * sw);
-int snd_ctl_pcm_record_switch_list(snd_ctl_t *handle, int dev, snd_switch_list_t * list);
-int snd_ctl_pcm_record_switch_read(snd_ctl_t *handle, int dev, snd_switch_t * sw);
-int snd_ctl_pcm_record_switch_write(snd_ctl_t *handle, int dev, snd_switch_t * sw);
+int snd_ctl_pcm_capture_switch_list(snd_ctl_t *handle, int dev, snd_switch_list_t * list);
+int snd_ctl_pcm_capture_switch_read(snd_ctl_t *handle, int dev, snd_switch_t * sw);
+int snd_ctl_pcm_capture_switch_write(snd_ctl_t *handle, int dev, snd_switch_t * sw);
int snd_ctl_mixer_info(snd_ctl_t *handle, int dev, snd_mixer_info_t * info);
int snd_ctl_mixer_switch_list(snd_ctl_t *handle, int dev, snd_switch_list_t *list);
int snd_ctl_mixer_switch_read(snd_ctl_t *handle, int dev, snd_switch_t * sw);
****************************************************************************/
#define SND_PCM_OPEN_PLAYBACK (O_WRONLY)
-#define SND_PCM_OPEN_RECORD (O_RDONLY)
+#define SND_PCM_OPEN_CAPTURE (O_RDONLY)
#define SND_PCM_OPEN_DUPLEX (O_RDWR)
#ifdef __cplusplus
int snd_pcm_block_mode(snd_pcm_t *handle, int enable);
int snd_pcm_info(snd_pcm_t *handle, snd_pcm_info_t * info);
int snd_pcm_playback_info(snd_pcm_t *handle, snd_pcm_playback_info_t * info);
-int snd_pcm_record_info(snd_pcm_t *handle, snd_pcm_record_info_t * info);
+int snd_pcm_capture_info(snd_pcm_t *handle, snd_pcm_capture_info_t * info);
int snd_pcm_playback_format(snd_pcm_t *handle, snd_pcm_format_t * format);
-int snd_pcm_record_format(snd_pcm_t *handle, snd_pcm_format_t * format);
+int snd_pcm_capture_format(snd_pcm_t *handle, snd_pcm_format_t * format);
int snd_pcm_playback_params(snd_pcm_t *handle, snd_pcm_playback_params_t * params);
-int snd_pcm_record_params(snd_pcm_t *handle, snd_pcm_record_params_t * params);
+int snd_pcm_capture_params(snd_pcm_t *handle, snd_pcm_capture_params_t * params);
int snd_pcm_playback_status(snd_pcm_t *handle, snd_pcm_playback_status_t * status);
-int snd_pcm_record_status(snd_pcm_t *handle, snd_pcm_record_status_t * status);
+int snd_pcm_capture_status(snd_pcm_t *handle, snd_pcm_capture_status_t * status);
int snd_pcm_drain_playback(snd_pcm_t *handle);
int snd_pcm_flush_playback(snd_pcm_t *handle);
-int snd_pcm_flush_record(snd_pcm_t *handle);
+int snd_pcm_flush_capture(snd_pcm_t *handle);
int snd_pcm_playback_pause(snd_pcm_t *handle, int enable);
int snd_pcm_playback_time(snd_pcm_t *handle, int enable);
-int snd_pcm_record_time(snd_pcm_t *handle, int enable);
+int snd_pcm_capture_time(snd_pcm_t *handle, int enable);
ssize_t snd_pcm_write(snd_pcm_t *handle, const void *buffer, size_t size);
ssize_t snd_pcm_read(snd_pcm_t *handle, void *buffer, size_t size);
#endif
#define SND_PCM_LB_OPEN_PLAYBACK 0
-#define SND_PCM_LB_OPEN_RECORD 1
+#define SND_PCM_LB_OPEN_CAPTURE 1
#ifdef __cplusplus
extern "C" {
return 0;
}
-int snd_ctl_pcm_record_info(snd_ctl_t *handle, int dev, snd_pcm_record_info_t * info)
+int snd_ctl_pcm_capture_info(snd_ctl_t *handle, int dev, snd_pcm_capture_info_t * info)
{
snd_ctl_t *ctl;
return -EINVAL;
if (ioctl(ctl->fd, SND_CTL_IOCTL_PCM_DEVICE, &dev) < 0)
return -errno;
- if (ioctl(ctl->fd, SND_CTL_IOCTL_PCM_RECORD_INFO, info) < 0)
+ if (ioctl(ctl->fd, SND_CTL_IOCTL_PCM_CAPTURE_INFO, info) < 0)
return -errno;
return 0;
}
return 0;
}
-int snd_ctl_pcm_record_switch_list(snd_ctl_t *handle, int dev, snd_switch_list_t * list)
+int snd_ctl_pcm_capture_switch_list(snd_ctl_t *handle, int dev, snd_switch_list_t * list)
{
snd_ctl_t *ctl;
return 0;
}
-int snd_ctl_pcm_record_switch_read(snd_ctl_t *handle, int dev, snd_switch_t * sw)
+int snd_ctl_pcm_capture_switch_read(snd_ctl_t *handle, int dev, snd_switch_t * sw)
{
snd_ctl_t *ctl;
return 0;
}
-int snd_ctl_pcm_record_switch_write(snd_ctl_t *handle, int dev, snd_switch_t * sw)
+int snd_ctl_pcm_capture_switch_write(snd_ctl_t *handle, int dev, snd_switch_t * sw)
{
snd_ctl_t *ctl;
return 0;
}
-int snd_pcm_record_info(snd_pcm_t *handle, snd_pcm_record_info_t * info)
+int snd_pcm_capture_info(snd_pcm_t *handle, snd_pcm_capture_info_t * info)
{
snd_pcm_t *pcm;
pcm = handle;
if (!pcm || !info)
return -EINVAL;
- if (ioctl(pcm->fd, SND_PCM_IOCTL_RECORD_INFO, info) < 0)
+ if (ioctl(pcm->fd, SND_PCM_IOCTL_CAPTURE_INFO, info) < 0)
return -errno;
return 0;
}
return 0;
}
-int snd_pcm_record_format(snd_pcm_t *handle, snd_pcm_format_t * format)
+int snd_pcm_capture_format(snd_pcm_t *handle, snd_pcm_format_t * format)
{
snd_pcm_t *pcm;
pcm = handle;
if (!pcm || !format)
return -EINVAL;
- if (ioctl(pcm->fd, SND_PCM_IOCTL_RECORD_FORMAT, format) < 0)
+ if (ioctl(pcm->fd, SND_PCM_IOCTL_CAPTURE_FORMAT, format) < 0)
return -errno;
return 0;
}
return 0;
}
-int snd_pcm_record_params(snd_pcm_t *handle, snd_pcm_record_params_t * params)
+int snd_pcm_capture_params(snd_pcm_t *handle, snd_pcm_capture_params_t * params)
{
snd_pcm_t *pcm;
pcm = handle;
if (!pcm || !params)
return -EINVAL;
- if (ioctl(pcm->fd, SND_PCM_IOCTL_RECORD_PARAMS, params) < 0)
+ if (ioctl(pcm->fd, SND_PCM_IOCTL_CAPTURE_PARAMS, params) < 0)
return -errno;
return 0;
}
return 0;
}
-int snd_pcm_record_status(snd_pcm_t *handle, snd_pcm_record_status_t * status)
+int snd_pcm_capture_status(snd_pcm_t *handle, snd_pcm_capture_status_t * status)
{
snd_pcm_t *pcm;
pcm = handle;
if (!pcm || !status)
return -EINVAL;
- if (ioctl(pcm->fd, SND_PCM_IOCTL_RECORD_STATUS, status) < 0)
+ if (ioctl(pcm->fd, SND_PCM_IOCTL_CAPTURE_STATUS, status) < 0)
return -errno;
return 0;
}
return 0;
}
-int snd_pcm_flush_record(snd_pcm_t *handle)
+int snd_pcm_flush_capture(snd_pcm_t *handle)
{
snd_pcm_t *pcm;
pcm = handle;
if (!pcm)
return -EINVAL;
- if (ioctl(pcm->fd, SND_PCM_IOCTL_FLUSH_RECORD) < 0)
+ if (ioctl(pcm->fd, SND_PCM_IOCTL_FLUSH_CAPTURE) < 0)
return -errno;
return 0;
}
return 0;
}
-int snd_pcm_record_time(snd_pcm_t *handle, int enable)
+int snd_pcm_capture_time(snd_pcm_t *handle, int enable)
{
snd_pcm_t *pcm;
pcm = handle;
if (!pcm)
return -EINVAL;
- if (ioctl(pcm->fd, SND_PCM_IOCTL_RECORD_TIME, &enable) < 0)
+ if (ioctl(pcm->fd, SND_PCM_IOCTL_CAPTURE_TIME, &enable) < 0)
return -errno;
return 0;
}
if (card < 0 || card >= SND_CARDS)
return -EINVAL;
sprintf(filename, SND_FILE_PCM_LB, card, device,
- mode == SND_PCM_LB_OPEN_RECORD ? "r" : "p");
+ mode == SND_PCM_LB_OPEN_CAPTURE ? "r" : "p");
if ((fd = open(filename, mode)) < 0) {
snd_card_load(card);
if ((fd = open(filename, mode)) < 0)
/*
* This small demo program can be used for measuring latency between
- * record and playback. This latency is measured from driver (diff when
- * playback and record was started). Scheduler is set to SCHED_RR.
+ * capture and playback. This latency is measured from driver (diff when
+ * playback and capture was started). Scheduler is set to SCHED_RR.
*
* Used format is 44100Hz, Signed Little Endian 16-bit, Stereo.
*
* Program begins with 128-byte fragment (about 726us) and step is 32-byte
* until playback without underruns is reached. This program starts playback
- * after two fragments are recorded (teoretical latency is 1452us by 128-byte
+ * after two fragments are captureed (teoretical latency is 1452us by 128-byte
* fragment).
*/
printf("Playback format error: %s\n", snd_strerror(err));
exit(0);
}
- if ((err = snd_pcm_record_format(rhandle, &format)) < 0) {
+ if ((err = snd_pcm_capture_format(rhandle, &format)) < 0) {
printf("Record format error: %s\n", snd_strerror(err));
exit(0);
}
printf("Playback time error: %s\n", snd_strerror(err));
exit(0);
}
- if ((err = snd_pcm_record_time(rhandle, 1)) < 0) {
+ if ((err = snd_pcm_capture_time(rhandle, 1)) < 0) {
printf("Record time error: %s\n", snd_strerror(err));
exit(0);
}
{
int err, step = 4;
snd_pcm_playback_info_t pinfo;
- snd_pcm_record_info_t rinfo;
+ snd_pcm_capture_info_t rinfo;
snd_pcm_playback_params_t pparams;
- snd_pcm_record_params_t rparams;
+ snd_pcm_capture_params_t rparams;
if ((err = snd_pcm_playback_info(phandle, &pinfo)) < 0) {
printf("Playback info error: %s\n", snd_strerror(err));
exit(0);
}
- if ((err = snd_pcm_record_info(rhandle, &rinfo)) < 0) {
+ if ((err = snd_pcm_capture_info(rhandle, &rinfo)) < 0) {
printf("Record info error: %s\n", snd_strerror(err));
exit(0);
}
bzero(&rparams, sizeof(rparams));
rparams.fragment_size = *fragmentsize;
rparams.fragments_min = 1; /* wakeup if at least one fragment is ready */
- if ((err = snd_pcm_record_params(rhandle, &rparams)) < 0) {
+ if ((err = snd_pcm_capture_params(rhandle, &rparams)) < 0) {
*fragmentsize += step;
continue;
}
return pstatus.underrun;
}
-void recordfragment(void *rhandle, char *buffer, int index, int fragmentsize)
+void capturefragment(void *rhandle, char *buffer, int index, int fragmentsize)
{
int err;
int err, fragmentsize = 0;
int ridx, pidx, size, ok;
snd_pcm_playback_status_t pstatus;
- snd_pcm_record_status_t rstatus;
+ snd_pcm_capture_status_t rstatus;
setscheduler();
if ((err = snd_pcm_open(&phandle, pcard, pdevice, SND_PCM_OPEN_PLAYBACK)) < 0) {
printf("Playback open error: %s\n", snd_strerror(err));
return 0;
}
- if ((err = snd_pcm_open(&rhandle, rcard, rdevice, SND_PCM_OPEN_RECORD)) < 0) {
+ if ((err = snd_pcm_open(&rhandle, rcard, rdevice, SND_PCM_OPEN_CAPTURE)) < 0) {
printf("Record open error: %s\n", snd_strerror(err));
return 0;
}
break;
ok = 1;
ridx = pidx = size = 0;
- recordfragment(rhandle, buffer, ridx++, fragmentsize);
- recordfragment(rhandle, buffer, ridx++, fragmentsize);
- if ((err = snd_pcm_record_status(rhandle, &rstatus)) < 0) {
+ capturefragment(rhandle, buffer, ridx++, fragmentsize);
+ capturefragment(rhandle, buffer, ridx++, fragmentsize);
+ if ((err = snd_pcm_capture_status(rhandle, &rstatus)) < 0) {
printf("Record status error: %s\n", snd_strerror(err));
exit(0);
}
pidx += 2;
pidx %= 2;
while (ok && size < 3 * 176400) { /* 30 seconds */
- recordfragment(rhandle, buffer, ridx++, fragmentsize);
+ capturefragment(rhandle, buffer, ridx++, fragmentsize);
ridx %= 2;
playfragment(phandle, buffer, pidx++, fragmentsize);
size += fragmentsize;
printf("Playback status error: %s\n", snd_strerror(err));
exit(0);
}
- snd_pcm_flush_record(rhandle);
+ snd_pcm_flush_capture(rhandle);
snd_pcm_flush_playback(phandle);
if (ok && !playbackunderrun(phandle) > 0) {
printf("Playback OK!!!\n");
if ((err = snd_pcm_playback_format(phandle, &format)) < 0) {
printf("Playback format error: %s\n", snd_strerror(err));
}
- if ((err = snd_pcm_record_format(rhandle, &format)) < 0) {
+ if ((err = snd_pcm_capture_format(rhandle, &format)) < 0) {
printf("Record format error: %s\n", snd_strerror(err));
}
}
printf("Playback open error: %s\n", snd_strerror(err));
return;
}
- if ((err = snd_pcm_open(&rhandle, 0, 0, SND_PCM_OPEN_RECORD)) < 0) {
+ if ((err = snd_pcm_open(&rhandle, 0, 0, SND_PCM_OPEN_CAPTURE)) < 0) {
printf("Record open error: %s\n", snd_strerror(err));
return;
}
printf("Playback open error: %s\n", snd_strerror(err));
return;
}
- if ((err = snd_pcm_open(&rhandle, 0, 0, SND_PCM_OPEN_RECORD)) < 0) {
+ if ((err = snd_pcm_open(&rhandle, 0, 0, SND_PCM_OPEN_CAPTURE)) < 0) {
printf("Record open error: %s\n", snd_strerror(err));
return;
}
return;
}
printf("done...\n");
- if ((err = snd_pcm_flush_record(rhandle)) < 0) {
+ if ((err = snd_pcm_flush_capture(rhandle)) < 0) {
printf("Record flush error: %s\n", snd_strerror(err));
return;
}
return;
}
printf("done...\n");
- if ((err = snd_pcm_flush_record(handle)) < 0) {
+ if ((err = snd_pcm_flush_capture(handle)) < 0) {
printf("Record flush error: %s\n", snd_strerror(err));
return;
}
case 2:
return "PCM playback";
case 3:
- return "PCM record";
+ return "PCM capture";
case 4:
return "rawmidi output";
case 5:
case 2:
return snd_ctl_pcm_playback_switch_list(ctl_handle, sw_device, list);
case 3:
- return snd_ctl_pcm_record_switch_list(ctl_handle, sw_device, list);
+ return snd_ctl_pcm_capture_switch_list(ctl_handle, sw_device, list);
case 4:
return snd_ctl_rawmidi_output_switch_list(ctl_handle, sw_device, list);
case 5:
case 2:
return snd_ctl_pcm_playback_switch_read(ctl_handle, sw_device, sw);
case 3:
- return snd_ctl_pcm_record_switch_write(ctl_handle, sw_device, sw);
+ return snd_ctl_pcm_capture_switch_write(ctl_handle, sw_device, sw);
case 4:
return snd_ctl_rawmidi_output_switch_read(ctl_handle, sw_device, sw);
case 5:
case 2:
return snd_ctl_pcm_playback_switch_write(ctl_handle, sw_device, sw);
case 3:
- return snd_ctl_pcm_record_switch_write(ctl_handle, sw_device, sw);
+ return snd_ctl_pcm_capture_switch_write(ctl_handle, sw_device, sw);
case 4:
return snd_ctl_rawmidi_output_switch_write(ctl_handle, sw_device, sw);
case 5:
process(" ", "Mixer", 1, idx);
for (idx = 0; idx < info.pcmdevs; idx++) {
process(" ", "PCM playback", 2, idx);
- process(" ", "PCM record", 3, idx);
+ process(" ", "PCM capture", 3, idx);
}
snd_ctl_close(ctl_handle);
}