summaryrefslogtreecommitdiffstats
path: root/include/hardware/audio.h
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2014-07-02 13:45:32 -0700
committerEric Laurent <elaurent@google.com>2014-07-03 16:51:09 -0700
commitc5ae6a030484f83beb3f2120f136cec1c0ef8b0a (patch)
treea2a780349d3d1e8b481119cf08ea5da2b7c4c08f /include/hardware/audio.h
parente1d83cda960ecb5ab2350a8848f0cc02667ffdf1 (diff)
downloadhardware_libhardware-c5ae6a030484f83beb3f2120f136cec1c0ef8b0a.zip
hardware_libhardware-c5ae6a030484f83beb3f2120f136cec1c0ef8b0a.tar.gz
hardware_libhardware-c5ae6a030484f83beb3f2120f136cec1c0ef8b0a.tar.bz2
audio: different frame size calculation for input and output
Bug: 15000850. Change-Id: I7813e99a0b7ce613cc3b7d7c95be0525cb2d6c81
Diffstat (limited to 'include/hardware/audio.h')
-rw-r--r--include/hardware/audio.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/include/hardware/audio.h b/include/hardware/audio.h
index 6558dda..7ff5b78 100644
--- a/include/hardware/audio.h
+++ b/include/hardware/audio.h
@@ -428,7 +428,10 @@ typedef struct audio_stream_in audio_stream_in_t;
/**
* return the frame size (number of bytes per sample).
+ *
+ * Deprecated: use audio_stream_out_frame_size() or audio_stream_in_frame_size() instead.
*/
+__attribute__((__deprecated__))
static inline size_t audio_stream_frame_size(const struct audio_stream *s)
{
size_t chan_samp_sz;
@@ -442,6 +445,37 @@ static inline size_t audio_stream_frame_size(const struct audio_stream *s)
return sizeof(int8_t);
}
+/**
+ * return the frame size (number of bytes per sample) of an output stream.
+ */
+static inline size_t audio_stream_out_frame_size(const struct audio_stream_out *s)
+{
+ size_t chan_samp_sz;
+ audio_format_t format = s->common.get_format(&s->common);
+
+ if (audio_is_linear_pcm(format)) {
+ chan_samp_sz = audio_bytes_per_sample(format);
+ return audio_channel_count_from_out_mask(s->common.get_channels(&s->common)) * chan_samp_sz;
+ }
+
+ return sizeof(int8_t);
+}
+
+/**
+ * return the frame size (number of bytes per sample) of an input stream.
+ */
+static inline size_t audio_stream_in_frame_size(const struct audio_stream_in *s)
+{
+ size_t chan_samp_sz;
+ audio_format_t format = s->common.get_format(&s->common);
+
+ if (audio_is_linear_pcm(format)) {
+ chan_samp_sz = audio_bytes_per_sample(format);
+ return audio_channel_count_from_in_mask(s->common.get_channels(&s->common)) * chan_samp_sz;
+ }
+
+ return sizeof(int8_t);
+}
/**********************************************************************/