aboutsummaryrefslogtreecommitdiffhomepage
path: root/audio/format.c
diff options
context:
space:
mode:
Diffstat (limited to 'audio/format.c')
-rw-r--r--audio/format.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/audio/format.c b/audio/format.c
index 5b1262956c..f9bfcb5ba8 100644
--- a/audio/format.c
+++ b/audio/format.c
@@ -110,6 +110,16 @@ static bool af_fmt_valid(int format)
return (format & AF_FORMAT_MASK) == format;
}
+int af_fmt_seconds_to_bytes(int format, float seconds, int channels)
+{
+ int bps = (af_fmt2bits(format) / 8);
+ int framelen = channels * bps;
+ int bytes = seconds * bps;
+ if (bytes % framelen)
+ bytes += framelen - (bytes % framelen);
+ return bytes;
+}
+
int af_str2fmt_short(bstr str)
{
if (bstr_startswith0(str, "0x")) {