1 /*
2  * Copyright (c) 2023 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 #ifndef LOG_TAG
16 #define LOG_TAG "IpcStreamListenerImpl"
17 #endif
18 
19 #include "cinttypes"
20 #include "ipc_stream_listener_impl.h"
21 #include "audio_service_log.h"
22 #include "audio_errors.h"
23 
24 namespace OHOS {
25 namespace AudioStandard {
IpcStreamListenerImpl(std::shared_ptr<IStreamListener> innerListener)26 IpcStreamListenerImpl::IpcStreamListenerImpl(std::shared_ptr<IStreamListener> innerListener)
27 {
28     if (innerListener == nullptr) {
29         AUDIO_ERR_LOG("IpcStreamListenerImpl() find null rendererInClinet");
30     }
31     innerListener_ = innerListener;
32 }
33 
OnOperationHandled(Operation operation,int64_t result)34 int32_t IpcStreamListenerImpl::OnOperationHandled(Operation operation, int64_t result)
35 {
36     std::shared_ptr<IStreamListener> listener = innerListener_.lock();
37     if (listener == nullptr) {
38         AUDIO_WARNING_LOG("OnOperationHandled() find innerListener_ is null, operation:%{public}d result:"
39             "%{public}" PRId64".", operation, result);
40         return ERR_ILLEGAL_STATE;
41     }
42     return listener->OnOperationHandled(operation, result);
43 }
44 } // namespace AudioStandard
45 } // namespace OHOS
46