audio: fix potential messy offload state.
Bug: 119035383
Test: manual audio test
Change-Id: Ie87e1fa330bb7904fde2c429db5392ab24001510
Signed-off-by: juyuchen <juyuchen@google.com>
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 3312cbe..7661e58 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -1743,15 +1743,15 @@
struct stream_out *out = (struct stream_out *) context;
struct listnode *item;
- out->offload_state = OFFLOAD_STATE_IDLE;
- out->playback_started = 0;
-
setpriority(PRIO_PROCESS, 0, ANDROID_PRIORITY_AUDIO);
set_sched_policy(0, SP_FOREGROUND);
prctl(PR_SET_NAME, (unsigned long)"Offload Callback", 0, 0, 0);
ALOGV("%s", __func__);
+
lock_output_stream(out);
+ out->offload_state = OFFLOAD_STATE_IDLE;
+ out->playback_started = 0;
for (;;) {
struct offload_cmd *cmd = NULL;
stream_callback_event_t event;