#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sched.h>
#include <errno.h>
#include <getopt.h>
#include "../include/asoundlib.h"
#include <sys/time.h>
#include <math.h>
static char *device = "plughw:0,0";
static unsigned int rate = 44100;
static unsigned int channels = 1;
static unsigned int buffer_time = 500000;
static unsigned int period_time = 100000;
static double freq = 440;
static int verbose = 0;
static int resample = 1;
static int period_event = 0;
int count, double *_phase)
{
static double max_phase = 2. * M_PI;
double phase = *_phase;
double step = max_phase*freq/(double)rate;
unsigned char *samples[channels];
int steps[channels];
unsigned int chn;
unsigned int maxval = (1 << (format_bits - 1)) - 1;
int bps = format_bits / 8;
for (chn = 0; chn < channels; chn++) {
if ((areas[chn].first % 8) != 0) {
printf("areas[%u].first == %u, aborting...\n", chn, areas[chn].first);
exit(EXIT_FAILURE);
}
samples[chn] = (((
unsigned char *)areas[chn].addr) + (areas[chn].
first / 8));
if ((areas[chn].step % 16) != 0) {
printf("areas[%u].step == %u, aborting...\n", chn, areas[chn].step);
exit(EXIT_FAILURE);
}
steps[chn] = areas[chn].
step / 8;
samples[chn] += offset * steps[chn];
}
while (count-- > 0) {
union {
float f;
int i;
} fval;
int res, i;
if (is_float) {
fval.f = sin(phase);
res = fval.i;
} else
res = sin(phase) * maxval;
if (to_unsigned)
res ^= 1U << (format_bits - 1);
for (chn = 0; chn < channels; chn++) {
if (big_endian) {
for (i = 0; i < bps; i++)
*(samples[chn] + phys_bps - 1 - i) = (res >> i * 8) & 0xff;
} else {
for (i = 0; i < bps; i++)
*(samples[chn] + i) = (res >> i * 8) & 0xff;
}
samples[chn] += steps[chn];
}
phase += step;
if (phase >= max_phase)
phase -= max_phase;
}
*_phase = phase;
}
{
unsigned int rrate;
int err, dir;
if (err < 0) {
printf(
"Broken configuration for playback: no configurations available: %s\n",
snd_strerror(err));
return err;
}
if (err < 0) {
printf(
"Resampling setup failed for playback: %s\n",
snd_strerror(err));
return err;
}
if (err < 0) {
printf(
"Access type not available for playback: %s\n",
snd_strerror(err));
return err;
}
if (err < 0) {
printf(
"Sample format not available for playback: %s\n",
snd_strerror(err));
return err;
}
if (err < 0) {
printf(
"Channels count (%u) not available for playbacks: %s\n", channels,
snd_strerror(err));
return err;
}
rrate = rate;
if (err < 0) {
printf(
"Rate %uHz not available for playback: %s\n", rate,
snd_strerror(err));
return err;
}
if (rrate != rate) {
printf("Rate doesn't match (requested %uHz, get %iHz)\n", rate, err);
return -EINVAL;
}
if (err < 0) {
printf(
"Unable to set buffer time %u for playback: %s\n", buffer_time,
snd_strerror(err));
return err;
}
if (err < 0) {
printf(
"Unable to get buffer size for playback: %s\n",
snd_strerror(err));
return err;
}
buffer_size = size;
if (err < 0) {
printf(
"Unable to set period time %u for playback: %s\n", period_time,
snd_strerror(err));
return err;
}
if (err < 0) {
printf(
"Unable to get period size for playback: %s\n",
snd_strerror(err));
return err;
}
period_size = size;
if (err < 0) {
printf(
"Unable to set hw params for playback: %s\n",
snd_strerror(err));
return err;
}
return 0;
}
{
int err;
if (err < 0) {
printf(
"Unable to determine current swparams for playback: %s\n",
snd_strerror(err));
return err;
}
if (err < 0) {
printf(
"Unable to set start threshold mode for playback: %s\n",
snd_strerror(err));
return err;
}
if (err < 0) {
printf(
"Unable to set avail min for playback: %s\n",
snd_strerror(err));
return err;
}
if (period_event) {
if (err < 0) {
printf(
"Unable to set period event: %s\n",
snd_strerror(err));
return err;
}
}
if (err < 0) {
printf(
"Unable to set sw params for playback: %s\n",
snd_strerror(err));
return err;
}
return 0;
}
static int xrun_recovery(
snd_pcm_t *handle,
int err)
{
if (verbose)
printf("stream recovery\n");
if (err == -EPIPE) {
if (err < 0)
printf(
"Can't recovery from underrun, prepare failed: %s\n",
snd_strerror(err));
return 0;
} else if (err == -ESTRPIPE) {
sleep(1);
if (err < 0) {
if (err < 0)
printf(
"Can't recovery from suspend, prepare failed: %s\n",
snd_strerror(err));
}
return 0;
}
return err;
}
signed short *samples,
{
double phase = 0;
int err, cptr;
while (1) {
generate_sine(areas, 0, period_size, &phase);
cptr = period_size;
while (cptr > 0) {
if (err == -EAGAIN)
continue;
if (err < 0) {
if (xrun_recovery(handle, err) < 0) {
exit(EXIT_FAILURE);
}
break;
}
cptr -= err;
}
}
}
static int wait_for_poll(
snd_pcm_t *handle,
struct pollfd *ufds,
unsigned int count)
{
unsigned short revents;
while (1) {
poll(ufds, count, -1);
if (revents & POLLERR)
return -EIO;
if (revents & POLLOUT)
return 0;
}
}
static int write_and_poll_loop(
snd_pcm_t *handle,
signed short *samples,
{
struct pollfd *ufds;
double phase = 0;
int err, count, cptr, init;
if (count <= 0) {
printf("Invalid poll descriptors count\n");
return count;
}
ufds = malloc(sizeof(struct pollfd) * count);
if (ufds == NULL) {
printf("No enough memory\n");
return -ENOMEM;
}
printf(
"Unable to obtain poll descriptors for playback: %s\n",
snd_strerror(err));
return err;
}
init = 1;
while (1) {
if (!init) {
err = wait_for_poll(handle, ufds, count);
if (err < 0) {
if (xrun_recovery(handle, err) < 0) {
exit(EXIT_FAILURE);
}
init = 1;
} else {
printf("Wait for poll failed\n");
return err;
}
}
}
generate_sine(areas, 0, period_size, &phase);
cptr = period_size;
while (cptr > 0) {
if (err < 0) {
if (xrun_recovery(handle, err) < 0) {
exit(EXIT_FAILURE);
}
init = 1;
break;
}
init = 0;
cptr -= err;
if (cptr == 0)
break;
err = wait_for_poll(handle, ufds, count);
if (err < 0) {
if (xrun_recovery(handle, err) < 0) {
exit(EXIT_FAILURE);
}
init = 1;
} else {
printf("Wait for poll failed\n");
return err;
}
}
}
}
}
struct async_private_data {
signed short *samples;
double phase;
};
{
signed short *samples = data->samples;
int err;
while (avail >= period_size) {
generate_sine(areas, 0, period_size, &data->phase);
if (err < 0) {
exit(EXIT_FAILURE);
}
if (err != period_size) {
printf("Write error: written %i expected %li\n", err, period_size);
exit(EXIT_FAILURE);
}
}
}
signed short *samples,
{
struct async_private_data data;
int err, count;
data.samples = samples;
data.areas = areas;
data.phase = 0;
if (err < 0) {
printf("Unable to register async handler\n");
exit(EXIT_FAILURE);
}
for (count = 0; count < 2; count++) {
generate_sine(areas, 0, period_size, &data.phase);
if (err < 0) {
exit(EXIT_FAILURE);
}
if (err != period_size) {
printf("Initial write error: written %i expected %li\n", err, period_size);
exit(EXIT_FAILURE);
}
}
if (err < 0) {
exit(EXIT_FAILURE);
}
}
while (1) {
sleep(1);
}
}
{
int first = 0, err;
while (1) {
err = xrun_recovery(handle, -EPIPE);
if (err < 0) {
exit(EXIT_FAILURE);
}
first = 1;
err = xrun_recovery(handle, -ESTRPIPE);
if (err < 0) {
exit(EXIT_FAILURE);
}
}
if (avail < 0) {
err = xrun_recovery(handle, avail);
if (err < 0) {
exit(EXIT_FAILURE);
}
first = 1;
continue;
}
if (avail < period_size) {
if (first) {
first = 0;
if (err < 0) {
exit(EXIT_FAILURE);
}
} else {
break;
}
continue;
}
size = period_size;
while (size > 0) {
frames = size;
if (err < 0) {
if ((err = xrun_recovery(handle, err)) < 0) {
exit(EXIT_FAILURE);
}
first = 1;
}
generate_sine(my_areas, offset, frames, &data->phase);
if ((err = xrun_recovery(handle, commitres >= 0 ? -EPIPE : commitres)) < 0) {
exit(EXIT_FAILURE);
}
first = 1;
}
size -= frames;
}
}
}
static int async_direct_loop(
snd_pcm_t *handle,
signed short *samples ATTRIBUTE_UNUSED,
{
struct async_private_data data;
int err, count;
data.samples = NULL;
data.areas = NULL;
data.phase = 0;
if (err < 0) {
printf("Unable to register async handler\n");
exit(EXIT_FAILURE);
}
for (count = 0; count < 2; count++) {
size = period_size;
while (size > 0) {
frames = size;
if (err < 0) {
if ((err = xrun_recovery(handle, err)) < 0) {
exit(EXIT_FAILURE);
}
}
generate_sine(my_areas, offset, frames, &data.phase);
if ((err = xrun_recovery(handle, commitres >= 0 ? -EPIPE : commitres)) < 0) {
exit(EXIT_FAILURE);
}
}
size -= frames;
}
}
if (err < 0) {
exit(EXIT_FAILURE);
}
while (1) {
sleep(1);
}
}
signed short *samples ATTRIBUTE_UNUSED,
{
double phase = 0;
int err, first = 1;
while (1) {
err = xrun_recovery(handle, -EPIPE);
if (err < 0) {
return err;
}
first = 1;
err = xrun_recovery(handle, -ESTRPIPE);
if (err < 0) {
return err;
}
}
if (avail < 0) {
err = xrun_recovery(handle, avail);
if (err < 0) {
return err;
}
first = 1;
continue;
}
if (avail < period_size) {
if (first) {
first = 0;
if (err < 0) {
exit(EXIT_FAILURE);
}
} else {
if (err < 0) {
if ((err = xrun_recovery(handle, err)) < 0) {
exit(EXIT_FAILURE);
}
first = 1;
}
}
continue;
}
size = period_size;
while (size > 0) {
frames = size;
if (err < 0) {
if ((err = xrun_recovery(handle, err)) < 0) {
exit(EXIT_FAILURE);
}
first = 1;
}
generate_sine(my_areas, offset, frames, &phase);
if ((err = xrun_recovery(handle, commitres >= 0 ? -EPIPE : commitres)) < 0) {
exit(EXIT_FAILURE);
}
first = 1;
}
size -= frames;
}
}
}
static int direct_write_loop(
snd_pcm_t *handle,
signed short *samples,
{
double phase = 0;
int err, cptr;
while (1) {
generate_sine(areas, 0, period_size, &phase);
cptr = period_size;
while (cptr > 0) {
if (err == -EAGAIN)
continue;
if (err < 0) {
if (xrun_recovery(handle, err) < 0) {
exit(EXIT_FAILURE);
}
break;
}
cptr -= err;
}
}
}
struct transfer_method {
const char *name;
signed short *samples,
};
static struct transfer_method transfer_methods[] = {
};
static void help(void)
{
int k;
printf(
"Usage: pcm [OPTION]... [FILE]...\n"
"-h,--help help\n"
"-D,--device playback device\n"
"-r,--rate stream rate in Hz\n"
"-c,--channels count of channels in stream\n"
"-f,--frequency sine wave frequency in Hz\n"
"-b,--buffer ring buffer size in us\n"
"-p,--period period size in us\n"
"-m,--method transfer method\n"
"-o,--format sample format\n"
"-v,--verbose show the PCM setup parameters\n"
"-n,--noresample do not resample\n"
"-e,--pevent enable poll event after each period\n"
"\n");
printf("Recognized sample formats are:");
for (k = 0; k < SND_PCM_FORMAT_LAST; ++k) {
if (s)
printf(" %s", s);
}
printf("\n");
printf("Recognized transfer methods are:");
for (k = 0; transfer_methods[k].name; k++)
printf(" %s", transfer_methods[k].name);
printf("\n");
}
int main(int argc, char *argv[])
{
struct option long_option[] =
{
{"help", 0, NULL, 'h'},
{"device", 1, NULL, 'D'},
{"rate", 1, NULL, 'r'},
{"channels", 1, NULL, 'c'},
{"frequency", 1, NULL, 'f'},
{"buffer", 1, NULL, 'b'},
{"period", 1, NULL, 'p'},
{"method", 1, NULL, 'm'},
{"format", 1, NULL, 'o'},
{"verbose", 1, NULL, 'v'},
{"noresample", 1, NULL, 'n'},
{"pevent", 1, NULL, 'e'},
{NULL, 0, NULL, 0},
};
int err, morehelp;
int method = 0;
signed short *samples;
unsigned int chn;
morehelp = 0;
while (1) {
int c;
if ((c = getopt_long(argc, argv, "hD:r:c:f:b:p:m:o:vne", long_option, NULL)) < 0)
break;
switch (c) {
case 'h':
morehelp++;
break;
case 'D':
device = strdup(optarg);
break;
case 'r':
rate = atoi(optarg);
rate = rate < 4000 ? 4000 : rate;
rate = rate > 196000 ? 196000 : rate;
break;
case 'c':
channels = atoi(optarg);
channels = channels < 1 ? 1 : channels;
channels = channels > 1024 ? 1024 : channels;
break;
case 'f':
freq = atoi(optarg);
freq = freq < 50 ? 50 : freq;
freq = freq > 5000 ? 5000 : freq;
break;
case 'b':
buffer_time = atoi(optarg);
buffer_time = buffer_time < 1000 ? 1000 : buffer_time;
buffer_time = buffer_time > 1000000 ? 1000000 : buffer_time;
break;
case 'p':
period_time = atoi(optarg);
period_time = period_time < 1000 ? 1000 : period_time;
period_time = period_time > 1000000 ? 1000000 : period_time;
break;
case 'm':
for (method = 0; transfer_methods[method].name; method++)
if (!strcasecmp(transfer_methods[method].name, optarg))
break;
if (transfer_methods[method].name == NULL)
method = 0;
break;
case 'o':
for (format = 0; format < SND_PCM_FORMAT_LAST; format++) {
if (format_name)
if (!strcasecmp(format_name, optarg))
break;
}
if (format == SND_PCM_FORMAT_LAST)
printf("Invalid (non-linear/float) format %s\n",
optarg);
return 1;
}
break;
case 'v':
verbose = 1;
break;
case 'n':
resample = 0;
break;
case 'e':
period_event = 1;
break;
}
}
if (morehelp) {
help();
return 0;
}
if (err < 0) {
return 0;
}
printf("Playback device is %s\n", device);
printf(
"Stream parameters are %uHz, %s, %u channels\n", rate,
snd_pcm_format_name(format), channels);
printf("Sine wave rate is %.4fHz\n", freq);
printf("Using transfer method: %s\n", transfer_methods[method].name);
return 0;
}
if ((err = set_hwparams(handle, hwparams, transfer_methods[method].access)) < 0) {
printf(
"Setting of hwparams failed: %s\n",
snd_strerror(err));
exit(EXIT_FAILURE);
}
if ((err = set_swparams(handle, swparams)) < 0) {
printf(
"Setting of swparams failed: %s\n",
snd_strerror(err));
exit(EXIT_FAILURE);
}
if (verbose > 0)
if (samples == NULL) {
printf("No enough memory\n");
exit(EXIT_FAILURE);
}
if (areas == NULL) {
printf("No enough memory\n");
exit(EXIT_FAILURE);
}
for (chn = 0; chn < channels; chn++) {
areas[chn].
addr = samples;
}
err = transfer_methods[method].transfer_loop(handle, samples, areas);
if (err < 0)
free(areas);
free(samples);
return 0;
}
const char * snd_strerror(int errnum)
Returns the message for an error code.
Definition: error.c:51
struct _snd_async_handler snd_async_handler_t
Internal structure for an async notification client handler.
Definition: global.h:115
void * snd_async_handler_get_callback_private(snd_async_handler_t *handler)
Returns the private data assigned to an async handler.
Definition: async.c:217
struct _snd_output snd_output_t
Internal structure for an output object.
Definition: output.h:56
int snd_output_stdio_attach(snd_output_t **outputp, FILE *fp, int _close)
Creates a new output object using an existing stdio FILE pointer.
Definition: output.c:188
const char * snd_pcm_format_name(const snd_pcm_format_t format)
get name of PCM sample format
Definition: pcm.c:2121
snd_pcm_sframes_t snd_pcm_mmap_writei(snd_pcm_t *pcm, const void *buffer, snd_pcm_uframes_t size)
Write interleaved frames to a PCM using direct buffer (mmap)
Definition: pcm_mmap.c:151
int snd_pcm_mmap_begin(snd_pcm_t *pcm, const snd_pcm_channel_area_t **areas, snd_pcm_uframes_t *offset, snd_pcm_uframes_t *frames)
Application request to access a portion of direct (mmap) area.
Definition: pcm.c:7221
snd_pcm_sframes_t snd_pcm_mmap_commit(snd_pcm_t *pcm, snd_pcm_uframes_t offset, snd_pcm_uframes_t frames)
Application has completed the access to area requested with snd_pcm_mmap_begin.
Definition: pcm.c:7334
int snd_pcm_dump(snd_pcm_t *pcm, snd_output_t *out)
Dump PCM info.
Definition: pcm.c:2373
#define snd_pcm_hw_params_alloca(ptr)
allocate an invalid snd_pcm_hw_params_t using standard alloca
Definition: pcm.h:764
int snd_pcm_hw_params_set_rate_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
Restrict a configuration space to have rate nearest to a target.
Definition: pcm.c:4779
int snd_pcm_hw_params_set_channels(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val)
Restrict a configuration space to contain only one channels count.
Definition: pcm.c:4544
int snd_pcm_hw_params_set_buffer_time_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
Restrict a configuration space to have buffer time nearest to a target.
Definition: pcm.c:5707
int snd_pcm_hw_params_set_access(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_access_t _access)
Restrict a configuration space to contain only one access type.
Definition: pcm.c:4229
int snd_pcm_hw_params_set_format(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_format_t val)
Restrict a configuration space to contain only one format.
Definition: pcm.c:4326
int snd_pcm_hw_params_any(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
Fill params with a full configuration space for a PCM.
Definition: pcm.c:3833
int snd_pcm_hw_params_set_rate_resample(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val)
Restrict a configuration space to contain only real hardware rates.
Definition: pcm.c:4830
int snd_pcm_hw_params_set_period_time_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir)
Restrict a configuration space to have period time nearest to a target.
Definition: pcm.c:5083
int snd_pcm_hw_params_get_buffer_size(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val)
Extract buffer size from a configuration space.
Definition: pcm.c:5761
int snd_pcm_hw_params_get_period_size(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *frames, int *dir)
Extract period size from a configuration space.
Definition: pcm.c:5138
int snd_pcm_format_big_endian(snd_pcm_format_t format)
Return endian info for a PCM sample format.
Definition: pcm_misc.c:181
int snd_pcm_format_linear(snd_pcm_format_t format)
Return linear info for a PCM sample format.
Definition: pcm_misc.c:100
int snd_pcm_format_unsigned(snd_pcm_format_t format)
Return sign info for a PCM sample linear format.
Definition: pcm_misc.c:85
int snd_pcm_format_width(snd_pcm_format_t format)
Return nominal bits per a PCM sample.
Definition: pcm_misc.c:210
int snd_pcm_format_physical_width(snd_pcm_format_t format)
Return bits needed to store a PCM sample.
Definition: pcm_misc.c:277
int snd_pcm_sw_params_set_start_threshold(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val)
Set start threshold inside a software configuration container.
Definition: pcm.c:6598
int snd_pcm_sw_params_set_avail_min(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val)
Set avail min inside a software configuration container.
Definition: pcm.c:6490
#define snd_pcm_sw_params_alloca(ptr)
allocate an invalid snd_pcm_sw_params_t using standard alloca
Definition: pcm.h:905
int snd_pcm_sw_params_set_period_event(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, int val)
Set period event inside a software configuration container.
Definition: pcm.c:6533
int snd_pcm_close(snd_pcm_t *pcm)
close PCM handle
Definition: pcm.c:766
int snd_pcm_resume(snd_pcm_t *pcm)
Resume from suspend, no samples are lost.
Definition: pcm.c:1168
int snd_pcm_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
Install one PCM hardware configuration chosen from a configuration space and snd_pcm_prepare it.
Definition: pcm.c:940
snd_pcm_t * snd_async_handler_get_pcm(snd_async_handler_t *handler)
Return PCM handle related to an async handler.
Definition: pcm.c:2490
int snd_async_add_pcm_handler(snd_async_handler_t **handler, snd_pcm_t *pcm, snd_async_callback_t callback, void *private_data)
Add an async handler for a PCM.
Definition: pcm.c:2460
snd_pcm_state_t
Definition: pcm.h:291
int snd_pcm_sw_params_current(snd_pcm_t *pcm, snd_pcm_sw_params_t *params)
Return current software configuration for a PCM.
Definition: pcm.c:6178
struct _snd_pcm_hw_params snd_pcm_hw_params_t
Definition: pcm.h:64
snd_pcm_access_t
Definition: pcm.h:110
int snd_pcm_start(snd_pcm_t *pcm)
Start a PCM.
Definition: pcm.c:1277
long snd_pcm_sframes_t
Definition: pcm.h:390
int snd_pcm_poll_descriptors(snd_pcm_t *pcm, struct pollfd *pfds, unsigned int space)
get poll descriptors
Definition: pcm.c:1804
int snd_pcm_prepare(snd_pcm_t *pcm)
Prepare PCM for use.
Definition: pcm.c:1222
struct _snd_pcm_sw_params snd_pcm_sw_params_t
Definition: pcm.h:67
int snd_pcm_poll_descriptors_revents(snd_pcm_t *pcm, struct pollfd *pfds, unsigned int nfds, unsigned short *revents)
get returned events from poll descriptors
Definition: pcm.c:1839
int snd_pcm_open(snd_pcm_t **pcm, const char *name, snd_pcm_stream_t stream, int mode)
Opens a PCM.
Definition: pcm.c:2688
snd_pcm_state_t snd_pcm_state(snd_pcm_t *pcm)
Return PCM state.
Definition: pcm.c:1070
int snd_pcm_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t *params)
Install PCM software configuration defined by params.
Definition: pcm.c:988
snd_pcm_sframes_t snd_pcm_avail_update(snd_pcm_t *pcm)
Return number of frames ready to be read (capture) / written (playback)
Definition: pcm.c:2956
struct _snd_pcm snd_pcm_t
Definition: pcm.h:408
snd_pcm_format_t
Definition: pcm.h:125
unsigned long snd_pcm_uframes_t
Definition: pcm.h:388
snd_pcm_sframes_t snd_pcm_writei(snd_pcm_t *pcm, const void *buffer, snd_pcm_uframes_t size)
Write interleaved frames to a PCM.
Definition: pcm.c:1556
int snd_pcm_poll_descriptors_count(snd_pcm_t *pcm)
get count of poll descriptors for PCM handle
Definition: pcm.c:1746
int snd_pcm_wait(snd_pcm_t *pcm, int timeout)
Wait for a PCM to become ready.
Definition: pcm.c:2846
@ SND_PCM_STATE_PREPARED
Definition: pcm.h:297
@ SND_PCM_STATE_SUSPENDED
Definition: pcm.h:307
@ SND_PCM_STATE_RUNNING
Definition: pcm.h:299
@ SND_PCM_STATE_XRUN
Definition: pcm.h:301
@ SND_PCM_ACCESS_RW_INTERLEAVED
Definition: pcm.h:118
@ SND_PCM_ACCESS_MMAP_NONINTERLEAVED
Definition: pcm.h:114
@ SND_PCM_ACCESS_MMAP_INTERLEAVED
Definition: pcm.h:112
@ SND_PCM_FORMAT_FLOAT_LE
Definition: pcm.h:157
@ SND_PCM_FORMAT_S16
Definition: pcm.h:234
@ SND_PCM_FORMAT_FLOAT_BE
Definition: pcm.h:159
@ SND_PCM_STREAM_PLAYBACK
Definition: pcm.h:103
void * ptr
Definition: seq_event.h:1
void * addr
Definition: pcm.h:484
unsigned int first
Definition: pcm.h:486
unsigned int step
Definition: pcm.h:488