DEBUG("A2DP COMMAND %s", audio_a2dp_hw_dump_ctrl_event(cmd));
if (common->ctrl_fd == AUDIO_SKT_DISCONNECTED) {
- INFO("recovering from previous error");
+ INFO("starting up or recovering from previous error");
a2dp_open_ctrl_path(common);
if (common->ctrl_fd == AUDIO_SKT_DISCONNECTED) {
ERROR("failure to open ctrl path");
static void a2dp_open_ctrl_path(struct a2dp_stream_common* common) {
int i;
+ if (common->ctrl_fd != AUDIO_SKT_DISCONNECTED) return; // already connected
+
/* retry logic to catch any timing variations on control channel */
for (i = 0; i < CTRL_CHAN_RETRY_COUNT; i++) {
/* connect control channel if not already connected */
if ((common->ctrl_fd = skt_connect(
- A2DP_CTRL_PATH, AUDIO_STREAM_CONTROL_OUTPUT_BUFFER_SZ)) > 0) {
+ A2DP_CTRL_PATH, AUDIO_STREAM_CONTROL_OUTPUT_BUFFER_SZ)) >= 0) {
/* success, now check if stack is ready */
if (check_a2dp_ready(common) == 0) break;
ret = -1;
goto err_open;
}
+ // a2dp_read_output_audio_config() opens the socket control path (or fails)
/* set output config values */
if (config != nullptr) {
*stream_out = &out->stream;
a2dp_dev->output = out;
- a2dp_open_ctrl_path(&out->common);
- if (out->common.ctrl_fd == AUDIO_SKT_DISCONNECTED) {
- ERROR("ctrl socket failed to connect (%s)", strerror(errno));
- ret = -1;
- goto err_open;
- }
-
DEBUG("success");
/* Delay to ensure Headset is in proper state when START is initiated from
* DUT immediately after the connection due to ongoing music playback. */
*stream_in = &in->stream;
a2dp_dev->input = in;
- a2dp_open_ctrl_path(&in->common);
- if (in->common.ctrl_fd == AUDIO_SKT_DISCONNECTED) {
- ERROR("ctrl socket failed to connect (%s)", strerror(errno));
- ret = -1;
- goto err_open;
- }
-
if (a2dp_read_input_audio_config(&in->common) < 0) {
ERROR("a2dp_read_input_audio_config failed (%s)", strerror(errno));
ret = -1;
goto err_open;
}
+ // a2dp_read_input_audio_config() opens socket control path (or fails)
DEBUG("success");
return 0;