diff --git a/services/audio_service/server/include/audio_endpoint_private.h b/services/audio_service/server/include/audio_endpoint_private.h index 2cac6d59fff45f56e7899f82b7c59eb20612dac3..840c96fdcdc0e0dd3097cfaf3193fc5b2d7b1e89 100644 --- a/services/audio_service/server/include/audio_endpoint_private.h +++ b/services/audio_service/server/include/audio_endpoint_private.h @@ -54,11 +54,13 @@ private: class AudioEndpointInner : public AudioEndpoint { public: + static constexpr int64_t INVALID_DELAY_STOP_HDI_TIME_NO_RUNNING_NS = -1; AudioEndpointInner(EndpointType type, uint64_t id, const AudioProcessConfig &clientConfig); ~AudioEndpointInner(); bool Config(const AudioDeviceDescriptor &deviceInfo, AudioStreamInfo &streamInfo) override; - bool StartDevice(EndpointStatus preferredState = INVALID); + bool StartDevice(EndpointStatus preferredState = INVALID, + int64_t delayStopTime_ = INVALID_DELAY_STOP_HDI_TIME_NO_RUNNING_NS); void HandleStartDeviceFailed(); bool StopDevice(); diff --git a/services/audio_service/server/src/audio_endpoint.cpp b/services/audio_service/server/src/audio_endpoint.cpp index 7425b93b764f41a2bae3a256df78feeb6da28072..dac08eae48c8294e5789369baa44c82409d4b48e 100644 --- a/services/audio_service/server/src/audio_endpoint.cpp +++ b/services/audio_service/server/src/audio_endpoint.cpp @@ -835,7 +835,7 @@ void AudioEndpointInner::ReSyncPosition() return; } -bool AudioEndpointInner::StartDevice(EndpointStatus preferredState) +bool AudioEndpointInner::StartDevice(EndpointStatus preferredState, int64_t delayStopTime) { AUDIO_INFO_LOG("StartDevice enter."); // how to modify the status while unlinked and started? @@ -880,6 +880,7 @@ bool AudioEndpointInner::StartDevice(EndpointStatus preferredState) workThreadCV_.notify_all(); AUDIO_DEBUG_LOG("StartDevice out, status is %{public}s", GetStatusStr(endpointStatus_).c_str()); AudioPerformanceMonitor::GetInstance().RecordTimeStamp(adapterType_, INIT_LASTWRITTEN_TIME); + delayStopTime_ = delayStopTime == INVALID_DELAY_STOP_HDI_TIME_NO_RUNNING_NS ? delayStopTime_ : delayStopTime; listLock.unlock(); return true; } @@ -982,7 +983,8 @@ int32_t AudioEndpointInner::OnStart(IAudioProcessStream *processStream) if (endpointStatus_ == IDEL) { // call sink start if (!isStarted_) { - CHECK_AND_RETURN_RET_LOG(StartDevice(RUNNING), ERR_OPERATION_FAILED, "StartDevice failed"); + CHECK_AND_RETURN_RET_LOG(StartDevice(RUNNING, INT64_MAX), ERR_OPERATION_FAILED, "StartDevice failed"); + return SUCCESS; } }