]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android-sdk/platform-external-tinyalsa.git/blobdiff - include/tinyalsa/asoundlib.h
Update to latest tinyalsa
[android-sdk/platform-external-tinyalsa.git] / include / tinyalsa / asoundlib.h
index bd0cdee35fe0ca4e2b5aebf2f38fe07a87edb4d3..3c86c844733dc9b61471a9e9cab0a061959c80a3 100644 (file)
 #ifndef ASOUNDLIB_H
 #define ASOUNDLIB_H
 
+#include <sys/time.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
 
 /*
  * PCM API
@@ -38,6 +43,19 @@ struct pcm;
 
 #define PCM_OUT        0x00000000
 #define PCM_IN         0x10000000
+#define PCM_MMAP       0x00000001
+#define PCM_NOIRQ      0x00000002
+
+/* PCM runtime states */
+#define        PCM_STATE_OPEN          0
+#define        PCM_STATE_SETUP         1
+#define        PCM_STATE_PREPARED      2
+#define        PCM_STATE_RUNNING               3
+#define        PCM_STATE_XRUN          4
+#define        PCM_STATE_DRAINING      5
+#define        PCM_STATE_PAUSED                6
+#define        PCM_STATE_SUSPENDED     7
+#define        PCM_STATE_DISCONNECTED  8
 
 /* Bit formats */
 enum pcm_format {
@@ -54,6 +72,18 @@ struct pcm_config {
     unsigned int period_size;
     unsigned int period_count;
     enum pcm_format format;
+
+    /* Values to use for the ALSA start, stop and silence thresholds.  Setting
+     * any one of these values to 0 will cause the default tinyalsa values to be
+     * used instead.  Tinyalsa defaults are as follows.
+     *
+     * start_threshold   : period_count * period_size
+     * stop_threshold    : period_count * period_size
+     * silence_threshold : 0
+     */
+    unsigned int start_threshold;
+    unsigned int stop_threshold;
+    unsigned int silence_threshold;
 };
 
 /* Mixer control types */
@@ -82,14 +112,25 @@ int pcm_set_config(struct pcm *pcm, struct pcm_config *config);
 /* Returns a human readable reason for the last error */
 const char *pcm_get_error(struct pcm *pcm);
 
-/* Returns the buffer size (int bytes) that should be used for pcm_write.
+/* Returns the buffer size (int frames) that should be used for pcm_write.
  * This will be 1/2 of the actual fifo size.
  */
 unsigned int pcm_get_buffer_size(struct pcm *pcm);
+unsigned int pcm_frames_to_bytes(struct pcm *pcm, unsigned int frames);
+unsigned int pcm_bytes_to_frames(struct pcm *pcm, unsigned int frames);
 
 /* Returns the pcm latency in ms */
 unsigned int pcm_get_latency(struct pcm *pcm);
 
+/* Returns available frames in pcm buffer and corresponding time stamp.
+ * For an input stream, frames available are frames ready for the
+ * application to read.
+ * For an output stream, frames available are the number of empty frames available
+ * for the application to write.
+ */
+int pcm_get_htimestamp(struct pcm *pcm, unsigned int *avail,
+                       struct timespec *tstamp);
+
 /* Write data to the fifo.
  * Will start playback on the first write or on a write that
  * occurs after a fifo underrun.
@@ -97,6 +138,18 @@ unsigned int pcm_get_latency(struct pcm *pcm);
 int pcm_write(struct pcm *pcm, void *data, unsigned int count);
 int pcm_read(struct pcm *pcm, void *data, unsigned int count);
 
+/*
+ * mmap() support.
+ */
+int pcm_mmap_write(struct pcm *pcm, void *data, unsigned int count);
+int pcm_mmap_begin(struct pcm *pcm, void **areas, unsigned int *offset,
+                   unsigned int *frames);
+int pcm_mmap_commit(struct pcm *pcm, unsigned int offset, unsigned int frames);
+
+/* Start and stop a PCM channel that doesn't transfer data */
+int pcm_start(struct pcm *pcm);
+int pcm_stop(struct pcm *pcm);
+
 
 /*
  * MIXER API
@@ -135,4 +188,8 @@ int mixer_ctl_set_enum_by_string(struct mixer_ctl *ctl, const char *string);
 int mixer_ctl_get_range_min(struct mixer_ctl *ctl);
 int mixer_ctl_get_range_max(struct mixer_ctl *ctl);
 
+#if defined(__cplusplus)
+}  /* extern "C" */
+#endif
+
 #endif