aboutsummaryrefslogtreecommitdiff
path: root/src/pcm.c
diff options
context:
space:
mode:
authorTaylor Holberton <taylorcholberton@gmail.com>2016-12-01 20:04:04 -0800
committerTaylor Holberton <taylorcholberton@gmail.com>2016-12-01 20:04:04 -0800
commit77979a8855015803c80a3bc99712ed9b72f96020 (patch)
treec83b4c96945c55c695c70178baa57b0b2e816d53 /src/pcm.c
parent94c7c83c01a1d00a5e36cc77bc1b71a8ebdcd1e9 (diff)
Added format related getters for PCM
Added functions: - pcm_get_channels - pcm_get_rate - pcm_get_format These were added since they're required for iterating samples and frames.
Diffstat (limited to 'src/pcm.c')
-rw-r--r--src/pcm.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/pcm.c b/src/pcm.c
index 540fd72..41f072c 100644
--- a/src/pcm.c
+++ b/src/pcm.c
@@ -204,6 +204,37 @@ unsigned int pcm_get_buffer_size(const struct pcm *pcm)
return pcm->buffer_size;
}
+/** Gets the channel count of the PCM.
+ * @param pcm A PCM handle.
+ * @return The channel count of the PCM.
+ * @ingroup libtinyalsa-pcm
+ */
+unsigned int pcm_get_channels(const struct pcm *pcm)
+{
+ return pcm->config.channels;
+}
+
+/** Gets the rate of the PCM.
+ * The rate is given in frames per second.
+ * @param pcm A PCM handle.
+ * @return The rate of the PCM.
+ * @ingroup libtinyalsa-pcm
+ */
+unsigned int pcm_get_rate(const struct pcm *pcm)
+{
+ return pcm->config.rate;
+}
+
+/** Gets the format of the PCM.
+ * @param pcm A PCM handle.
+ * @return The format of the PCM.
+ * @ingroup libtinyalsa-pcm
+ */
+enum pcm_format pcm_get_format(const struct pcm *pcm)
+{
+ return pcm->config.format;
+}
+
/** Gets the file descriptor of the PCM.
* Useful for extending functionality of the PCM when needed.
* @param pcm A PCM handle.