case SND_PCM_IOCTL_START:
ctrl->result = snd_pcm_start(pcm);
break;
- case SND_PCM_IOCTL_FLUSH:
- ctrl->result = snd_pcm_flush(pcm);
+ case SND_PCM_IOCTL_DRAIN:
+ ctrl->result = snd_pcm_drain(pcm);
break;
case SND_PCM_IOCTL_STOP:
ctrl->result = snd_pcm_stop(pcm);
int snd_pcm_prepare(snd_pcm_t *handle);
int snd_pcm_start(snd_pcm_t *handle);
int snd_pcm_stop(snd_pcm_t *handle);
-int snd_pcm_flush(snd_pcm_t *handle);
+int snd_pcm_drain(snd_pcm_t *handle);
int snd_pcm_pause(snd_pcm_t *handle, int enable);
int snd_pcm_state(snd_pcm_t *handle);
int snd_pcm_delay(snd_pcm_t *handle, ssize_t *delayp);
int snd_rawmidi_stream_params(snd_rawmidi_t *handle, snd_rawmidi_params_t * params);
int snd_rawmidi_stream_setup(snd_rawmidi_t *handle, snd_rawmidi_setup_t * setup);
int snd_rawmidi_stream_status(snd_rawmidi_t *handle, snd_rawmidi_status_t * status);
+int snd_rawmidi_output_drop(snd_rawmidi_t *handle);
int snd_rawmidi_output_drain(snd_rawmidi_t *handle);
-int snd_rawmidi_output_flush(snd_rawmidi_t *handle);
-int snd_rawmidi_input_flush(snd_rawmidi_t *handle);
-int snd_rawmidi_stream_flush(snd_rawmidi_t *handle, int channel);
+int snd_rawmidi_input_drain(snd_rawmidi_t *handle);
+int snd_rawmidi_stream_drain(snd_rawmidi_t *handle, int channel);
ssize_t snd_rawmidi_write(snd_rawmidi_t *handle, const void *buffer, size_t size);
ssize_t snd_rawmidi_read(snd_rawmidi_t *handle, void *buffer, size_t size);
int snd_seq_event_output_direct(snd_seq_t *handle, snd_seq_event_t *ev);
int snd_seq_event_input(snd_seq_t *handle, snd_seq_event_t **ev);
int snd_seq_event_input_pending(snd_seq_t *seq, int fetch_sequencer);
-int snd_seq_flush_output(snd_seq_t *handle);
+int snd_seq_drain_output(snd_seq_t *handle);
int snd_seq_event_output_pending(snd_seq_t *seq);
int snd_seq_extract_output(snd_seq_t *handle, snd_seq_event_t **ev);
-int snd_seq_drain_output(snd_seq_t *handle);
-int snd_seq_drain_output_buffer(snd_seq_t *handle);
-int snd_seq_drain_input(snd_seq_t *handle);
-int snd_seq_drain_input_buffer(snd_seq_t *handle);
+int snd_seq_drop_output(snd_seq_t *handle);
+int snd_seq_drop_output_buffer(snd_seq_t *handle);
+int snd_seq_drop_input(snd_seq_t *handle);
+int snd_seq_drop_input_buffer(snd_seq_t *handle);
int snd_seq_remove_events(snd_seq_t *handle, snd_seq_remove_events_t *info);
/* misc */
void snd_seq_set_bit(int nr, void *array);
return pcm->fast_ops->stop(pcm->fast_op_arg);
}
-int snd_pcm_flush(snd_pcm_t *pcm)
+int snd_pcm_drain(snd_pcm_t *pcm)
{
assert(pcm);
- return pcm->fast_ops->flush(pcm->fast_op_arg);
+ return pcm->fast_ops->drain(pcm->fast_op_arg);
}
int snd_pcm_pause(snd_pcm_t *pcm, int enable)
static assoc_t readys[] = { READY(FRAGMENT), READY(ASAP), END };
static assoc_t xfers[] = { XFER(INTERLEAVED), XFER(NONINTERLEAVED), END };
static assoc_t mmaps[] = { MMAP(INTERLEAVED), MMAP(NONINTERLEAVED), END };
-static assoc_t xrun_acts[] = { XRUN_ACT(FLUSH), XRUN_ACT(DRAIN), END };
+static assoc_t xrun_acts[] = { XRUN_ACT(STOP), XRUN_ACT(DROP), END };
static assoc_t onoff[] = { {0, "OFF", NULL}, {1, "ON", NULL}, {-1, "ON", NULL}, END };
int snd_pcm_dump_setup(snd_pcm_t *pcm, FILE *fp)
return ctrl->result;
}
-static int snd_pcm_client_shm_flush(snd_pcm_t *pcm)
+static int snd_pcm_client_shm_drain(snd_pcm_t *pcm)
{
snd_pcm_client_t *client = pcm->private;
snd_pcm_client_shm_t *ctrl = client->u.shm.ctrl;
int err;
- ctrl->cmd = SND_PCM_IOCTL_FLUSH;
+ ctrl->cmd = SND_PCM_IOCTL_DRAIN;
err = snd_pcm_client_shm_action(pcm);
if (err < 0)
return err;
prepare: snd_pcm_client_shm_prepare,
start: snd_pcm_client_shm_start,
stop: snd_pcm_client_shm_stop,
- flush: snd_pcm_client_shm_flush,
+ drain: snd_pcm_client_shm_drain,
pause: snd_pcm_client_shm_pause,
rewind: snd_pcm_client_shm_rewind,
writei: snd_pcm_mmap_writei,
return snd_pcm_stop(file->slave);
}
-static int snd_pcm_file_flush(snd_pcm_t *pcm)
+static int snd_pcm_file_drain(snd_pcm_t *pcm)
{
snd_pcm_file_t *file = pcm->private;
- return snd_pcm_flush(file->slave);
+ return snd_pcm_drain(file->slave);
}
static int snd_pcm_file_pause(snd_pcm_t *pcm, int enable)
prepare: snd_pcm_file_prepare,
start: snd_pcm_file_start,
stop: snd_pcm_file_stop,
- flush: snd_pcm_file_flush,
+ drain: snd_pcm_file_drain,
pause: snd_pcm_file_pause,
rewind: snd_pcm_file_rewind,
writei: snd_pcm_file_writei,
return 0;
}
-static int snd_pcm_hw_flush(snd_pcm_t *pcm)
+static int snd_pcm_hw_drain(snd_pcm_t *pcm)
{
snd_pcm_hw_t *hw = pcm->private;
int fd = hw->fd;
- if (ioctl(fd, SND_PCM_IOCTL_FLUSH) < 0)
+ if (ioctl(fd, SND_PCM_IOCTL_DRAIN) < 0)
return -errno;
return 0;
}
prepare: snd_pcm_hw_prepare,
start: snd_pcm_hw_start,
stop: snd_pcm_hw_stop,
- flush: snd_pcm_hw_flush,
+ drain: snd_pcm_hw_drain,
pause: snd_pcm_hw_pause,
rewind: snd_pcm_hw_rewind,
writei: snd_pcm_hw_writei,
int (*prepare)(snd_pcm_t *pcm);
int (*start)(snd_pcm_t *pcm);
int (*stop)(snd_pcm_t *pcm);
- int (*flush)(snd_pcm_t *pcm);
+ int (*drain)(snd_pcm_t *pcm);
int (*pause)(snd_pcm_t *pcm, int enable);
int (*state)(snd_pcm_t *pcm);
int (*delay)(snd_pcm_t *pcm, ssize_t *delayp);
int ret = 0;
if (pcm->mmap_status->state == SND_PCM_STATE_XRUN) {
ret = -EPIPE;
- if (pcm->setup.xrun_act == SND_PCM_XRUN_ACT_DRAIN)
+ if (pcm->setup.xrun_act == SND_PCM_XRUN_ACT_DROP)
return -EPIPE;
}
if (snd_pcm_mmap_capture_avail(pcm) >= pcm->setup.avail_min)
return snd_pcm_stop(multi->slaves[0].handle);
}
-static int snd_pcm_multi_flush(snd_pcm_t *pcm)
+static int snd_pcm_multi_drain(snd_pcm_t *pcm)
{
snd_pcm_multi_t *multi = pcm->private;
- return snd_pcm_flush(multi->slaves[0].handle);
+ return snd_pcm_drain(multi->slaves[0].handle);
}
static int snd_pcm_multi_pause(snd_pcm_t *pcm, int enable)
prepare: snd_pcm_multi_prepare,
start: snd_pcm_multi_start,
stop: snd_pcm_multi_stop,
- flush: snd_pcm_multi_flush,
+ drain: snd_pcm_multi_drain,
pause: snd_pcm_multi_pause,
writei: snd_pcm_mmap_writei,
writen: snd_pcm_mmap_writen,
return snd_pcm_stop(plugin->slave);
}
-int snd_pcm_plugin_flush(snd_pcm_t *pcm)
+int snd_pcm_plugin_drain(snd_pcm_t *pcm)
{
snd_pcm_plugin_t *plugin = pcm->private;
- return snd_pcm_flush(plugin->slave);
+ return snd_pcm_drain(plugin->slave);
}
int snd_pcm_plugin_pause(snd_pcm_t *pcm, int enable)
prepare: snd_pcm_plugin_prepare,
start: snd_pcm_plugin_start,
stop: snd_pcm_plugin_stop,
- flush: snd_pcm_plugin_flush,
+ drain: snd_pcm_plugin_drain,
pause: snd_pcm_plugin_pause,
rewind: snd_pcm_plugin_rewind,
writei: snd_pcm_plugin_writei,
int snd_pcm_plugin_prepare(snd_pcm_t *pcm);
int snd_pcm_plugin_start(snd_pcm_t *pcm);
int snd_pcm_plugin_stop(snd_pcm_t *pcm);
-int snd_pcm_plugin_flush(snd_pcm_t *pcm);
+int snd_pcm_plugin_drain(snd_pcm_t *pcm);
int snd_pcm_plugin_pause(snd_pcm_t *pcm, int enable);
ssize_t snd_pcm_plugin_rewind(snd_pcm_t *pcm, size_t frames);
ssize_t snd_pcm_plugin_writei(snd_pcm_t *pcm, const void *buffer, size_t size);
return 0;
}
-int snd_rawmidi_output_drain(snd_rawmidi_t *rmidi)
+int snd_rawmidi_output_drop(snd_rawmidi_t *rmidi)
{
int str = SND_RAWMIDI_STREAM_OUTPUT;
if (!rmidi)
return -EINVAL;
- if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_STREAM_DRAIN, &str) < 0)
+ if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_STREAM_DROP, &str) < 0)
return -errno;
return 0;
}
-int snd_rawmidi_stream_flush(snd_rawmidi_t *rmidi, int str)
+int snd_rawmidi_stream_drain(snd_rawmidi_t *rmidi, int str)
{
if (!rmidi)
return -EINVAL;
if (str < 0 || str > 1)
return -EINVAL;
- if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_STREAM_FLUSH, &str) < 0)
+ if (ioctl(rmidi->fd, SND_RAWMIDI_IOCTL_STREAM_DRAIN, &str) < 0)
return -errno;
return 0;
}
-int snd_rawmidi_output_flush(snd_rawmidi_t *rmidi)
+int snd_rawmidi_output_drain(snd_rawmidi_t *rmidi)
{
- return snd_rawmidi_stream_flush(rmidi, SND_RAWMIDI_STREAM_OUTPUT);
+ return snd_rawmidi_stream_drain(rmidi, SND_RAWMIDI_STREAM_OUTPUT);
}
-int snd_rawmidi_input_flush(snd_rawmidi_t *rmidi)
+int snd_rawmidi_input_drain(snd_rawmidi_t *rmidi)
{
- return snd_rawmidi_stream_flush(rmidi, SND_RAWMIDI_STREAM_INPUT);
+ return snd_rawmidi_stream_drain(rmidi, SND_RAWMIDI_STREAM_INPUT);
}
ssize_t snd_rawmidi_write(snd_rawmidi_t *rmidi, const void *buffer, size_t size)
return -EINVAL;
if (size < sizeof(snd_seq_event_t))
return -EINVAL;
- snd_seq_drain_output(seq);
+ snd_seq_drop_output(seq);
if (size != seq->obufsize) {
char *newbuf;
newbuf = calloc(1, size);
return -EINVAL;
if (size < sizeof(snd_seq_event_t))
return -EINVAL;
- snd_seq_drain_input(seq);
+ snd_seq_drop_input(seq);
size = (size + sizeof(snd_seq_event_t) - 1) / sizeof(snd_seq_event_t);
if (size != seq->ibufsize) {
snd_seq_event_t *newbuf;
result = snd_seq_event_output_buffer(seq, ev);
if (result == -EAGAIN) {
- result = snd_seq_flush_output(seq);
+ result = snd_seq_drain_output(seq);
if (result < 0)
return result;
return snd_seq_event_output_buffer(seq, ev);
}
/*
- * flush output buffer to sequencer
+ * drain output buffer to sequencer
*/
-int snd_seq_flush_output(snd_seq_t *seq)
+int snd_seq_drain_output(snd_seq_t *seq)
{
int result;
/*
* clear output buffer
*/
-int snd_seq_drain_output_buffer(snd_seq_t *seq)
+int snd_seq_drop_output_buffer(snd_seq_t *seq)
{
if (!seq)
return -EINVAL;
/*
* clear input buffer
*/
-int snd_seq_drain_input_buffer(snd_seq_t *seq)
+int snd_seq_drop_input_buffer(snd_seq_t *seq)
{
if (!seq)
return -EINVAL;
/*
* clear output buffer and remove events in sequencer queue
*/
-int snd_seq_drain_output(snd_seq_t *seq)
+int snd_seq_drop_output(snd_seq_t *seq)
{
snd_seq_remove_events_t rminfo;
/*
* clear input buffer and and remove events in sequencer queue
*/
-int snd_seq_drain_input(snd_seq_t *seq)
+int snd_seq_drop_input(snd_seq_t *seq)
{
snd_seq_remove_events_t rminfo;
* in the library.
*/
if (rmp->remove_mode == 0)
- snd_seq_drain_input_buffer(seq);
+ snd_seq_drop_input_buffer(seq);
/* other modes are not supported yet */
}
*/
if (rmp->remove_mode == 0) {
/* The simple case - remove all */
- snd_seq_drain_output_buffer(seq);
+ snd_seq_drop_output_buffer(seq);
} else {
char *ep;
size_t len;
params.format.channels = 2;
params.format.rate = USED_RATE;
params.start_mode = SND_PCM_START_EXPLICIT;
- params.xrun_action = SND_PCM_XRUN_ACT_DRAIN;
+ params.xrun_action = SND_PCM_XRUN_ACT_DROP;
params.time = 1;
*bufsize += 4;
if (pstatus.trigger_time.tv_sec == cstatus.trigger_time.tv_sec &&
pstatus.trigger_time.tv_usec == cstatus.trigger_time.tv_usec)
printf("Hardware sync\n");
- snd_pcm_flush(phandle);
+ snd_pcm_drain(phandle);
if (ok) {
#if 0
printf("Playback time = %li.%i, Record time = %li.%i, diff = %li\n",
fprintf(stderr,"Closing\n");
}
- snd_rawmidi_input_flush(handle_in);
+ snd_rawmidi_input_drain(handle_in);
snd_rawmidi_close(handle_in);
- snd_rawmidi_output_flush(handle_out);
+ snd_rawmidi_output_drain(handle_out);
snd_rawmidi_close(handle_out);
return 0;
return;
}
printf("done...\n");
- if ((err = snd_pcm_flush_capture(rhandle)) < 0) {
- printf("Record flush error: %s\n", snd_strerror(err));
+ if ((err = snd_pcm_drain_capture(rhandle)) < 0) {
+ printf("Record drain error: %s\n", snd_strerror(err));
return;
}
- printf("Record flush done...\n");
+ printf("Record drain done...\n");
printf("Playback... ");
fflush(stdout);
if ((err = snd_pcm_writei(phandle, buffer, sizeof(buffer))) != sizeof(buffer)) {
return;
}
printf("done...\n");
- if ((err = snd_pcm_flush_playback(phandle)) < 0) {
- printf("Playback flush error: %s\n", snd_strerror(err));
+ if ((err = snd_pcm_drain_playback(phandle)) < 0) {
+ printf("Playback drain error: %s\n", snd_strerror(err));
return;
}
- printf("Playback flush done...\n");
+ printf("Playback drain done...\n");
snd_pcm_close(phandle);
printf("Playback close...\n");
snd_pcm_close(rhandle);
return;
}
printf("done...\n");
- if ((err = snd_pcm_flush_capture(handle)) < 0) {
- printf("Record flush error: %s\n", snd_strerror(err));
+ if ((err = snd_pcm_drain_capture(handle)) < 0) {
+ printf("Record drain error: %s\n", snd_strerror(err));
return;
}
- printf("Record flush done...\n");
+ printf("Record drain done...\n");
printf("Playback... ");
fflush(stdout);
if ((err = snd_pcm_writei(handle, buffer, sizeof(buffer))) != sizeof(buffer)) {
return;
}
printf("done...\n");
- if ((err = snd_pcm_flush_playback(handle)) < 0) {
- printf("Playback flush error: %s\n", snd_strerror(err));
+ if ((err = snd_pcm_drain_playback(handle)) < 0) {
+ printf("Playback drain error: %s\n", snd_strerror(err));
return;
}
- printf("Playback flush done...\n");
+ printf("Playback drain done...\n");
snd_pcm_close(handle);
printf("Close...\n");
}
write_ev(&ev);
/* dump buffer */
- left = snd_seq_flush_output(seq_handle);
+ left = snd_seq_drain_output(seq_handle);
/* wait for the timer start event */
for (;;) {
ch=0x90; snd_rawmidi_write(handle_out,&ch,1);
ch=60; snd_rawmidi_write(handle_out,&ch,1);
ch=100; snd_rawmidi_write(handle_out,&ch,1);
- snd_rawmidi_output_flush(handle_in);
+ snd_rawmidi_output_drain(handle_in);
sleep(1);
ch=0x90; snd_rawmidi_write(handle_out,&ch,1);
ch=60; snd_rawmidi_write(handle_out,&ch,1);
ch=0; snd_rawmidi_write(handle_out,&ch,1);
- snd_rawmidi_output_flush(handle_out);
+ snd_rawmidi_output_drain(handle_out);
}
if (fd_out!=-1) {
unsigned char ch;
if (handle_out) {
snd_rawmidi_write(handle_out,&ch,1);
- snd_rawmidi_output_flush(handle_out);
+ snd_rawmidi_output_drain(handle_out);
}
if (fd_out!=-1) {
write(fd_out,&ch,1);
}
if (handle_in) {
- snd_rawmidi_output_flush(handle_in);
+ snd_rawmidi_output_drain(handle_in);
snd_rawmidi_close(handle_in);
}
if (handle_out) {
- snd_rawmidi_output_flush(handle_in);
+ snd_rawmidi_output_drain(handle_in);
snd_rawmidi_close(handle_in);
}
if (fd_in!=-1) {
if ((err = snd_seq_start_queue(handle, queue, NULL))<0)
fprintf(stderr, "Timer event output error: %s\n", snd_strerror(err));
- while (snd_seq_flush_output(handle)>0)
+ while (snd_seq_drain_output(handle)>0)
sleep(1);
}
#endif
if ((err = snd_seq_start_queue(handle, queue, NULL))<0)
fprintf(stderr, "Timer event output error: %s\n", snd_strerror(err));
- snd_seq_flush_output(handle);
+ snd_seq_drain_output(handle);
}
void event_sender_filter(snd_seq_t *handle)
ev.data.note.duration = 500; /* 0.5sec */
if ((err = snd_seq_event_output(handle, &ev))<0)
fprintf(stderr, "Event output error: %s\n", snd_strerror(err));
- if ((err = snd_seq_flush_output(handle))<0)
- fprintf(stderr, "Event flush error: %s\n", snd_strerror(err));
+ if ((err = snd_seq_drain_output(handle))<0)
+ fprintf(stderr, "Event drain error: %s\n", snd_strerror(err));
}
void event_sender(snd_seq_t *handle, int argc, char *argv[])
}
#endif
if (FD_ISSET(snd_seq_poll_descriptor(handle), &out))
- snd_seq_flush_output(handle);
+ snd_seq_drain_output(handle);
if (FD_ISSET(snd_seq_poll_descriptor(handle), &in)) {
do {
if ((err = snd_seq_event_input(handle, &ev))<0)