hal: Add support for Tunnel mode audio playback
- Initial implementation to support audio playback in tunnel mode.
Change-Id: I4ffa660bd9beb855fdfe6a7572d8f6b7eade7bd9
diff --git a/hal/audio_hw.h b/hal/audio_hw.h
index 5702f37..b61bcd4 100644
--- a/hal/audio_hw.h
+++ b/hal/audio_hw.h
@@ -21,6 +21,7 @@
#include <hardware/audio.h>
#include <tinyalsa/asoundlib.h>
+#include <tinycompress/tinycompress.h>
#include <audio_route/audio_route.h>
@@ -49,13 +50,13 @@
USECASE_AUDIO_PLAYBACK_DEEP_BUFFER = 0,
USECASE_AUDIO_PLAYBACK_LOW_LATENCY,
USECASE_AUDIO_PLAYBACK_MULTI_CH,
+ USECASE_AUDIO_PLAYBACK_OFFLOAD,
/* Capture usecases */
USECASE_AUDIO_RECORD,
USECASE_AUDIO_RECORD_LOW_LATENCY,
USECASE_VOICE_CALL,
-
AUDIO_USECASE_MAX
} audio_usecase_t;
@@ -70,14 +71,38 @@
* the buffer size of an input/output stream
*/
+enum {
+ OFFLOAD_CMD_EXIT, /* exit compress offload thread loop*/
+ OFFLOAD_CMD_DRAIN, /* send a full drain request to DSP */
+ OFFLOAD_CMD_PARTIAL_DRAIN, /* send a partial drain request to DSP */
+ OFFLOAD_CMD_WAIT_FOR_BUFFER, /* wait for buffer released by DSP */
+};
+
+enum {
+ OFFLOAD_STATE_IDLE,
+ OFFLOAD_STATE_PLAYING,
+ OFFLOAD_STATE_PAUSED,
+};
+
+struct offload_cmd {
+ struct listnode node;
+ int cmd;
+ int data[];
+};
+
struct stream_out {
struct audio_stream_out stream;
pthread_mutex_t lock; /* see note below on mutex acquisition order */
+ pthread_cond_t cond;
struct pcm_config config;
+ struct compr_config compr_config;
struct pcm *pcm;
+ struct compress *compr;
int standby;
int pcm_device_id;
+ unsigned int sample_rate;
audio_channel_mask_t channel_mask;
+ audio_format_t format;
audio_devices_t devices;
audio_output_flags_t flags;
audio_usecase_t usecase;
@@ -85,6 +110,17 @@
audio_channel_mask_t supported_channel_masks[MAX_SUPPORTED_CHANNEL_MASKS + 1];
bool muted;
+ int non_blocking;
+ int playback_started;
+ int offload_state;
+ pthread_cond_t offload_cond;
+ pthread_t offload_thread;
+ struct listnode offload_cmd_list;
+ bool offload_thread_blocked;
+
+ stream_callback_t offload_callback;
+ void *offload_cookie;
+
struct audio_device *dev;
};