static int out_standby_stream_locked(struct astream_out *out) { int ret = 0; int attempts = MAX_WRITE_COMPLETION_ATTEMPTS; if (out->standby || !out->data) return 0; out->standby = true; /* wait for write completion if needed */ while (out->write_busy && attempts--) { ret = pthread_cond_timeout_np(&out->write_cond, &out->lock, BUF_WRITE_COMPLETION_TIMEOUT_MS); LOGE_IF(ret != 0, "out_standby_stream_locked() wait cond error %d", ret); } LOGE_IF(attempts == 0, "out_standby_stream_locked() a2dp_write() would not stop!!!"); LOGV_IF(!out->bt_enabled, "Standby skip stop: enabled %d", out->bt_enabled); if (out->bt_enabled) { ret = a2dp_stop(out->data); } release_wake_lock(A2DP_WAKE_LOCK_NAME); return ret; }
status_t A2dpAudioInterface::A2dpAudioStreamOut::standby() { int result = 0; Mutex::Autolock lock(mLock); if (!mStandby) { result = a2dp_stop(mData); if (result == 0) mStandby = true; } return result; }
status_t A2dpAudioInterface::A2dpAudioStreamOut::standby() { int result = 0; if (mClosing) { LOGV("Ignore standby, closing"); return result; } Mutex::Autolock lock(mLock); if (!mStandby) { result = a2dp_stop(mData); if (result == 0) mStandby = true; } return result; }