aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/tinyalsa/asoundlib.h3
-rw-r--r--pcm.c7
2 files changed, 10 insertions, 0 deletions
diff --git a/include/tinyalsa/asoundlib.h b/include/tinyalsa/asoundlib.h
index eb3e4c4..045c8b5 100644
--- a/include/tinyalsa/asoundlib.h
+++ b/include/tinyalsa/asoundlib.h
@@ -179,6 +179,9 @@ unsigned int pcm_bytes_to_frames(struct pcm *pcm, unsigned int bytes);
int pcm_get_htimestamp(struct pcm *pcm, unsigned int *avail,
struct timespec *tstamp);
+/* Returns the subdevice on which the pcm has been opened */
+unsigned int pcm_get_subdevice(struct pcm *pcm);
+
/* Write data to the fifo.
* Will start playback on the first write or on a write that
* occurs after a fifo underrun.
diff --git a/pcm.c b/pcm.c
index 90c9dad..d58d6a3 100644
--- a/pcm.c
+++ b/pcm.c
@@ -171,6 +171,7 @@ struct pcm {
void *mmap_buffer;
unsigned int noirq_frames_per_msec;
long pcm_delay;
+ unsigned int subdevice;
};
unsigned int pcm_get_buffer_size(struct pcm *pcm)
@@ -183,6 +184,11 @@ const char* pcm_get_error(struct pcm *pcm)
return pcm->error;
}
+unsigned int pcm_get_subdevice(struct pcm *pcm)
+{
+ return pcm->subdevice;
+}
+
static int oops(struct pcm *pcm, int e, const char *fmt, ...)
{
va_list ap;
@@ -654,6 +660,7 @@ struct pcm *pcm_open(unsigned int card, unsigned int device,
oops(pcm, errno, "cannot get info");
goto fail_close;
}
+ pcm->subdevice = info.subdevice;
param_init(&params);
param_set_mask(&params, SNDRV_PCM_HW_PARAM_FORMAT,