hal: Remove in_get_stream and out_get_stream

Remove in_get_stream and out_get_stream and
add in_ctxt and out_ctxt members to stream_in/out
structs to track and directly access stream contexts.
Mitigate race conditions with the active_in/outputs_list
when in/out_get_stream reads the list.

Change-Id: Iefc77d3c862b16dce8086e1afba15cf0210155b4
diff --git a/hal/audio_hw.h b/hal/audio_hw.h
index 05382e4..8caefe8 100755
--- a/hal/audio_hw.h
+++ b/hal/audio_hw.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013-2020, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2021, The Linux Foundation. All rights reserved.
  * Not a contribution.
  *
  * Copyright (C) 2013 The Android Open Source Project
@@ -361,6 +361,16 @@
     unsigned int bit_width;
 };
 
+typedef struct streams_input_ctxt {
+    struct listnode list;
+    struct stream_in *input;
+} streams_input_ctxt_t;
+
+typedef struct streams_output_ctxt {
+    struct listnode list;
+    struct stream_out *output;
+} streams_output_ctxt_t;
+
 struct stream_inout {
     pthread_mutex_t lock; /* see note below on mutex acquisition order */
     pthread_mutex_t pre_lock; /* acquire before lock to avoid DOS by playback thread */
@@ -409,6 +419,7 @@
     int64_t mmap_time_offset_nanos; /* fudge factor to correct inaccuracies in DSP */
     int     mmap_shared_memory_fd; /* file descriptor associated with MMAP NOIRQ shared memory */
     audio_io_handle_t handle;
+    streams_output_ctxt_t out_ctxt;
     struct stream_app_type_cfg app_type_cfg;
 
     int non_blocking;
@@ -515,6 +526,7 @@
     int64_t mmap_time_offset_nanos; /* fudge factor to correct inaccuracies in DSP */
     int     mmap_shared_memory_fd; /* file descriptor associated with MMAP NOIRQ shared memory */
     audio_io_handle_t capture_handle;
+    streams_input_ctxt_t in_ctxt;
     audio_input_flags_t flags;
     char profile[MAX_STREAM_PROFILE_STR_LEN];
     bool is_st_session;
@@ -623,16 +635,6 @@
     struct stream_app_type_cfg app_type_cfg;
 };
 
-typedef struct streams_input_ctxt {
-    struct listnode list;
-    struct stream_in *input;
-} streams_input_ctxt_t;
-
-typedef struct streams_output_ctxt {
-    struct listnode list;
-    struct stream_out *output;
-} streams_output_ctxt_t;
-
 typedef void* (*adm_init_t)();
 typedef void (*adm_deinit_t)(void *);
 typedef void (*adm_register_output_stream_t)(void *, audio_io_handle_t, audio_output_flags_t);
@@ -814,11 +816,6 @@
 
 bool is_interactive_usecase(audio_usecase_t uc_id);
 
-streams_input_ctxt_t *in_get_stream(struct audio_device *dev,
-                                  audio_io_handle_t input);
-streams_output_ctxt_t *out_get_stream(struct audio_device *dev,
-                                  audio_io_handle_t output);
-
 size_t get_output_period_size(uint32_t sample_rate,
                             audio_format_t format,
                             int channel_count,