summaryrefslogtreecommitdiffstats
path: root/qahw
diff options
context:
space:
mode:
authorManish Dewangan <manish@codeaurora.org>2018-12-13 18:18:59 +0530
committerDeeraj Soman <sdeeraj@codeaurora.org>2019-07-03 15:32:43 +0530
commit46e079872cf1293539babdbb6bb0ec093fe637b3 (patch)
tree21e049084829ac7330c3e0ea5c1796011de834ac /qahw
parent007e5e9cd5028f9890d5995a3621a01ad7dd6839 (diff)
downloadandroid_hardware_qcom_audio-46e079872cf1293539babdbb6bb0ec093fe637b3.tar.gz
android_hardware_qcom_audio-46e079872cf1293539babdbb6bb0ec093fe637b3.tar.bz2
android_hardware_qcom_audio-46e079872cf1293539babdbb6bb0ec093fe637b3.zip
hal: Add API support to stop input stream
Add API support to stop input stream. Expose in_stop in HAL via QAHW so that clients may call it when necessary. Change-Id: I5b1112166453371ab4d79c31fa99fb1f6b3bff3f
Diffstat (limited to 'qahw')
-rw-r--r--qahw/inc/qahw.h4
-rw-r--r--qahw/src/qahw.c42
2 files changed, 44 insertions, 2 deletions
diff --git a/qahw/inc/qahw.h b/qahw/inc/qahw.h
index dd5b403f..5020c8f2 100644
--- a/qahw/inc/qahw.h
+++ b/qahw/inc/qahw.h
@@ -358,6 +358,10 @@ char* qahw_in_get_parameters_l(const qahw_stream_handle_t *in_handle,
ssize_t qahw_in_read_l(qahw_stream_handle_t *in_handle,
qahw_in_buffer_t *in_buf);
/*
+ * Stop input stream. Returns zero on success.
+ */
+int qahw_in_stop_l(qahw_stream_handle_t *in_handle);
+/*
* Return the amount of input frames lost in the audio driver since the
* last call of this function.
* Audio driver is expected to reset the value to 0 and restart counting
diff --git a/qahw/src/qahw.c b/qahw/src/qahw.c
index 3390c269..545152c1 100644
--- a/qahw/src/qahw.c
+++ b/qahw/src/qahw.c
@@ -61,6 +61,8 @@ typedef int (*qahwi_set_param_data_t) (audio_hw_device_t *,
typedef uint64_t (*qahwi_in_read_v2_t)(audio_stream_in_t *in, void* buffer,
size_t bytes, int64_t *timestamp);
+typedef int (*qahwi_in_stop_t)(audio_stream_in_t *in);
+
typedef int (*qahwi_out_set_param_data_t)(struct audio_stream_out *out,
qahw_param_id param_id,
qahw_param_payload *payload);
@@ -109,6 +111,7 @@ typedef struct {
struct listnode list;
pthread_mutex_t lock;
qahwi_in_read_v2_t qahwi_in_read_v2;
+ qahwi_in_stop_t qahwi_in_stop;
} qahw_stream_in_t;
typedef enum {
@@ -1035,6 +1038,31 @@ exit:
}
/*
+ * Stop input stream. Returns zero on success.
+ */
+int qahw_in_stop_l(qahw_stream_handle_t *in_handle)
+{
+ int rc = -EINVAL;
+ qahw_stream_in_t *qahw_stream_in = (qahw_stream_in_t *)in_handle;
+ audio_stream_in_t *in = NULL;
+
+ if (!is_valid_qahw_stream_l((void *)qahw_stream_in, STREAM_DIR_IN)) {
+ ALOGV("%s::Invalid in handle %p", __func__, in_handle);
+ goto exit;
+ }
+ ALOGD("%s", __func__);
+
+ in = qahw_stream_in->stream;
+
+ if (qahw_stream_in->qahwi_in_stop)
+ rc = qahw_stream_in->qahwi_in_stop(in);
+ ALOGD("%s: exit", __func__);
+
+exit:
+ return rc;
+}
+
+/*
* Return the amount of input frames lost in the audio driver since the
* last call of this function.
* Audio driver is expected to reset the value to 0 and restart counting
@@ -1718,6 +1746,7 @@ int qahw_open_input_stream_l(qahw_module_handle_t *hw_module,
qahw_module_t *qahw_module_temp = NULL;
audio_hw_device_t *audio_device = NULL;
qahw_stream_in_t *qahw_stream_in = NULL;
+ const char *error;
pthread_mutex_lock(&qahw_module_init_lock);
qahw_module_temp = get_qahw_module_by_ptr_l(qahw_module);
@@ -1747,6 +1776,7 @@ int qahw_open_input_stream_l(qahw_module_handle_t *hw_module,
if (rc) {
ALOGE("%s::open input stream failed %d",__func__, rc);
free(qahw_stream_in);
+ goto exit;
} else {
qahw_stream_in->module = hw_module;
*in_handle = (void *)qahw_stream_in;
@@ -1757,7 +1787,6 @@ int qahw_open_input_stream_l(qahw_module_handle_t *hw_module,
/* dlsym qahwi_in_read_v2 if timestamp flag is used */
if (!rc && ((flags & QAHW_INPUT_FLAG_TIMESTAMP) ||
(flags & QAHW_INPUT_FLAG_PASSTHROUGH))) {
- const char *error;
/* clear any existing errors */
dlerror();
@@ -1769,7 +1798,16 @@ int qahw_open_input_stream_l(qahw_module_handle_t *hw_module,
}
}
-exit:
+ /* clear any existing errors */
+ dlerror();
+ qahw_stream_in->qahwi_in_stop = (qahwi_in_stop_t)
+ dlsym(qahw_module->module->dso, "qahwi_in_stop");
+ if ((error = dlerror()) != NULL) {
+ ALOGI("%s: dlsym error %s for qahwi_in_stop", __func__, error);
+ qahw_stream_in->qahwi_in_stop = NULL;
+ }
+
+ exit:
pthread_mutex_unlock(&qahw_module->lock);
return rc;
}