From 6262e5fa2b4cf691ee082ad8f88081d60409ccde Mon Sep 17 00:00:00 2001 From: Ajay Panicker Date: Thu, 5 Apr 2018 09:14:51 -0700 Subject: [PATCH] Check if socket is closed before getting presentation position Bug: 76456293 Test: Listen to music on a device that supports delay reporting Change-Id: I4ca1c31819594750a7beb1d11ca5b8d64a7f836c (cherry picked from commit d4f2566ace5acf05d4f19143497c9bdfaf9dce67) --- audio_a2dp_hw/src/audio_a2dp_hw.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/audio_a2dp_hw/src/audio_a2dp_hw.cc b/audio_a2dp_hw/src/audio_a2dp_hw.cc index d8c39b87c..a43a4fbaa 100644 --- a/audio_a2dp_hw/src/audio_a2dp_hw.cc +++ b/audio_a2dp_hw/src/audio_a2dp_hw.cc @@ -742,6 +742,10 @@ static int a2dp_write_output_audio_config(struct a2dp_stream_common* common) { static int a2dp_get_presentation_position_cmd(struct a2dp_stream_common* common, uint64_t* bytes, uint16_t* delay, struct timespec* timestamp) { + if (common->ctrl_fd == AUDIO_SKT_DISCONNECTED) { // Already disconnected + return -1; + } + if (a2dp_command(common, A2DP_CTRL_GET_PRESENTATION_POSITION) < 0) { return -1; } -- 2.11.0