plugins: tinyalsa: fix the subtraction overflow
Change-Id: I133a3261d94a031d2ebfe13041db687758b304e1
diff --git a/plugins/tinyalsa/src/agm_pcm_plugin.c b/plugins/tinyalsa/src/agm_pcm_plugin.c
index 3e07bf0..39fbfab 100644
--- a/plugins/tinyalsa/src/agm_pcm_plugin.c
+++ b/plugins/tinyalsa/src/agm_pcm_plugin.c
@@ -637,7 +637,7 @@
else if ((snd_pcm_uframes_t)avail >= priv->pos_buf->boundary)
avail -= priv->pos_buf->boundary;
} else if (plugin->mode & PCM_IN) {
- avail = priv->pos_buf->hw_ptr - priv->pos_buf->appl_ptr;
+ __builtin_sub_overflow(priv->pos_buf->hw_ptr, priv->pos_buf->appl_ptr, &avail);
if (avail < 0)
avail += priv->pos_buf->boundary;
}