1 /* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef OHOS_DAUDIO_SINK_HANDLER_H 17 #define OHOS_DAUDIO_SINK_HANDLER_H 18 19 #include "idistributed_hardware_sink.h" 20 #include "single_instance.h" 21 22 #include "idaudio_sink.h" 23 24 namespace OHOS { 25 namespace DistributedHardware { 26 class DAudioSinkHandler : public IDistributedHardwareSink { 27 DECLARE_SINGLE_INSTANCE_BASE(DAudioSinkHandler); 28 public: 29 int32_t InitSink(const std::string ¶ms) override; 30 int32_t ReleaseSink() override; 31 int32_t SubscribeLocalHardware(const std::string &dhId, const std::string ¶m) override; 32 int32_t UnsubscribeLocalHardware(const std::string &dhId) override; 33 void OnRemoteSinkSvrDied(const wptr<IRemoteObject> &remote); 34 void FinishStartSA(const std::string ¶m, const sptr<IRemoteObject> &remoteObject); 35 36 private: 37 class DAudioSinkSvrRecipient : public IRemoteObject::DeathRecipient { 38 public: 39 void OnRemoteDied(const wptr<IRemoteObject> &remote) override; 40 }; 41 42 DAudioSinkHandler(); 43 ~DAudioSinkHandler(); 44 45 std::mutex sinkProxyMutex_; 46 std::condition_variable sinkProxyConVar_; 47 sptr<IDAudioSink> dAudioSinkProxy_ = nullptr; 48 sptr<DAudioSinkSvrRecipient> sinkSvrRecipient_ = nullptr; 49 }; 50 51 #ifdef __cplusplus 52 extern "C" { 53 #endif 54 __attribute__((visibility("default"))) IDistributedHardwareSink *GetSinkHardwareHandler(); 55 #ifdef __cplusplus 56 } 57 #endif 58 } // namespace DistributedHardware 59 } // namespace OHOS 60 #endif // OHOS_DAUDIO_SINK_HANDLER_H