aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/tinyalsa/attributes.h39
-rw-r--r--include/tinyalsa/pcm.h33
2 files changed, 54 insertions, 18 deletions
diff --git a/include/tinyalsa/attributes.h b/include/tinyalsa/attributes.h
new file mode 100644
index 0000000..e33f46a
--- /dev/null
+++ b/include/tinyalsa/attributes.h
@@ -0,0 +1,39 @@
+#ifndef TINYALSA_ATTRIBUTES_H
+#define TINYALSA_ATTRIBUTES_H
+
+/** @defgroup libtinyalsa-attributes
+ * @brief GCC attributes to issue diagnostics
+ * when the library is being used incorrectly.
+ * */
+
+#ifdef __GNUC__
+
+/** Issues a warning when a function is being
+ * used that is now deprecated.
+ * @ingroup libtinyalsa-attributes
+ * */
+#define TINYALSA_DEPRECATED __attribute__((deprecated))
+
+/** Issues a warning when a return code of
+ * a function is not checked.
+ * @ingroup libtinyalsa-attributes
+ * */
+#define TINYALSA_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
+
+#else /* __GNUC__ */
+
+/** This is just a placeholder for compilers
+ * that aren't GCC or Clang.
+ * @ingroup libtinyalsa-attributes
+ * */
+#define TINYALSA_DEPRECATED
+
+/** This is just a placeholder for compilers
+ * that aren't GCC or Clang.
+ * @ingroup libtinyalsa-attributes
+ * */
+#define TINYALSA_WARN_UNUSED_RESULT
+
+#endif /* __GNUC__ */
+
+#endif /* TINYALSA_ATTRIBUTES_H */
diff --git a/include/tinyalsa/pcm.h b/include/tinyalsa/pcm.h
index 9b22c55..36aaf85 100644
--- a/include/tinyalsa/pcm.h
+++ b/include/tinyalsa/pcm.h
@@ -35,13 +35,11 @@
#ifndef TINYALSA_PCM_H
#define TINYALSA_PCM_H
+#include <tinyalsa/attributes.h>
+
#include <sys/time.h>
#include <stddef.h>
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
/** A flag that specifies that the PCM is an output.
* May not be bitwise AND'd with @ref PCM_IN.
* Used in @ref pcm_open.
@@ -97,6 +95,11 @@ extern "C" {
* */
#define PCM_NONBLOCK 0x00000010
+/** Means a PCM is prepared
+ * @ingroup libtinyalsa-pcm
+ */
+#define PCM_STATE_PREPARED 0x02
+
/** For inputs, this means the PCM is recording audio samples.
* For outputs, this means the PCM is playing audio samples.
* @ingroup libtinyalsa-pcm
@@ -123,6 +126,10 @@ extern "C" {
*/
#define PCM_STATE_DISCONNECTED 0x08
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
/** Audio sample format of a PCM.
* The first letter specifiers whether the sample is signed or unsigned.
* The letter 'S' means signed. The letter 'U' means unsigned.
@@ -279,23 +286,13 @@ int pcm_get_htimestamp(struct pcm *pcm, unsigned int *avail, struct timespec *ts
unsigned int pcm_get_subdevice(const struct pcm *pcm);
-int pcm_writei(struct pcm *pcm, const void *data, unsigned int frame_count);
-
-int pcm_readi(struct pcm *pcm, void *data, unsigned int frame_count);
-
-#ifdef __GNUC__
+int pcm_writei(struct pcm *pcm, const void *data, unsigned int frame_count) TINYALSA_WARN_UNUSED_RESULT;
-int pcm_write(struct pcm *pcm, const void *data, unsigned int count) __attribute((deprecated));
+int pcm_readi(struct pcm *pcm, void *data, unsigned int frame_count) TINYALSA_WARN_UNUSED_RESULT;
-int pcm_read(struct pcm *pcm, void *data, unsigned int count) __attribute((deprecated));
+int pcm_write(struct pcm *pcm, const void *data, unsigned int count) TINYALSA_DEPRECATED;
-#else
-
-int pcm_write(struct pcm *pcm, const void *data, unsigned int count);
-
-int pcm_read(struct pcm *pcm, void *data, unsigned int count);
-
-#endif
+int pcm_read(struct pcm *pcm, void *data, unsigned int count) TINYALSA_DEPRECATED;
int pcm_mmap_write(struct pcm *pcm, const void *data, unsigned int count);