Update to latest tinyalsa for 32_LE support
bc03b62 pcm: fix TODOs for 32 bit support
Change-Id: I9f4d83c808a664aed5cefae271e3ad7b5c522c99
diff --git a/pcm.c b/pcm.c
index 1fab6f4..adc0495 100644
--- a/pcm.c
+++ b/pcm.c
@@ -165,6 +165,28 @@
return -1;
}
+static unsigned int pcm_format_to_alsa(enum pcm_format format)
+{
+ switch (format) {
+ case PCM_FORMAT_S32_LE:
+ return SNDRV_PCM_FORMAT_S32_LE;
+ default:
+ case PCM_FORMAT_S16_LE:
+ return SNDRV_PCM_FORMAT_S16_LE;
+ };
+}
+
+static unsigned int pcm_format_to_bits(enum pcm_format format)
+{
+ switch (format) {
+ case PCM_FORMAT_S32_LE:
+ return 32;
+ default:
+ case PCM_FORMAT_S16_LE:
+ return 16;
+ };
+}
+
int pcm_write(struct pcm *pcm, void *data, unsigned int count)
{
struct snd_xferi x;
@@ -173,7 +195,8 @@
return -EINVAL;
x.buf = data;
- x.frames = count / (pcm->config.channels * 2); /* TODO: handle 32bit */
+ x.frames = count / (pcm->config.channels *
+ pcm_format_to_bits(pcm->config.format) / 8);
for (;;) {
if (!pcm->running) {
@@ -205,7 +228,8 @@
return -EINVAL;
x.buf = data;
- x.frames = count / (pcm->config.channels * 2); /* TODO: handle 32bit */
+ x.frames = count / (pcm->config.channels *
+ pcm_format_to_bits(pcm->config.format) / 8);
for (;;) {
if (!pcm->running) {
@@ -245,28 +269,6 @@
return 0;
}
-static unsigned int pcm_format_to_alsa(enum pcm_format format)
-{
- switch (format) {
- case PCM_FORMAT_S32_LE:
- return SNDRV_PCM_FORMAT_S32_LE;
- default:
- case PCM_FORMAT_S16_LE:
- return SNDRV_PCM_FORMAT_S16_LE;
- };
-}
-
-static unsigned int pcm_format_to_bits(enum pcm_format format)
-{
- switch (format) {
- case PCM_FORMAT_S32_LE:
- return 32;
- default:
- case PCM_FORMAT_S16_LE:
- return 16;
- };
-}
-
struct pcm *pcm_open(unsigned int card, unsigned int device,
unsigned int flags, struct pcm_config *config)
{