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 /* Play implementation */
17
18 #include <common.h>
19
20 using namespace OHOS::AudioStandard;
21
SetPlayState(SLPlayItf self,SLuint32 state)22 static SLresult SetPlayState(SLPlayItf self, SLuint32 state)
23 {
24 if (self == nullptr) {
25 return SL_RESULT_PARAMETER_INVALID;
26 }
27 IPlay *thiz = (IPlay *)self;
28 AudioPlayerAdapter::GetInstance()->SetPlayStateAdapter(thiz->mId, state);
29 return SL_RESULT_SUCCESS;
30 }
31
GetPlayState(SLPlayItf self,SLuint32 * state)32 static SLresult GetPlayState(SLPlayItf self, SLuint32 *state)
33 {
34 if (self == nullptr) {
35 return SL_RESULT_PARAMETER_INVALID;
36 }
37 IPlay *thiz = (IPlay *)self;
38 AudioPlayerAdapter::GetInstance()->GetPlayStateAdapter(thiz->mId, state);
39 return SL_RESULT_SUCCESS;
40 }
41
GetDuration(SLPlayItf self,SLmillisecond * pMsec)42 static SLresult GetDuration(SLPlayItf self, SLmillisecond *pMsec)
43 {
44 return SL_RESULT_FEATURE_UNSUPPORTED;
45 }
46
GetPosition(SLPlayItf self,SLmillisecond * pMsec)47 static SLresult GetPosition(SLPlayItf self, SLmillisecond *pMsec)
48 {
49 return SL_RESULT_FEATURE_UNSUPPORTED;
50 }
51
RegisterCallback(SLPlayItf self,slPlayCallback callback,void * pContext)52 static SLresult RegisterCallback(SLPlayItf self, slPlayCallback callback, void *pContext)
53 {
54 return SL_RESULT_FEATURE_UNSUPPORTED;
55 }
56
SetCallbackEventsMask(SLPlayItf self,SLuint32 eventFlags)57 static SLresult SetCallbackEventsMask(SLPlayItf self, SLuint32 eventFlags)
58 {
59 return SL_RESULT_FEATURE_UNSUPPORTED;
60 }
61
GetCallbackEventsMask(SLPlayItf self,SLuint32 * pEventFlags)62 static SLresult GetCallbackEventsMask(SLPlayItf self, SLuint32 *pEventFlags)
63 {
64 return SL_RESULT_FEATURE_UNSUPPORTED;
65 }
66
SetMarkerPosition(SLPlayItf self,SLmillisecond mSec)67 static SLresult SetMarkerPosition(SLPlayItf self, SLmillisecond mSec)
68 {
69 return SL_RESULT_FEATURE_UNSUPPORTED;
70 }
71
ClearMarkerPosition(SLPlayItf self)72 static SLresult ClearMarkerPosition(SLPlayItf self)
73 {
74 return SL_RESULT_FEATURE_UNSUPPORTED;
75 }
76
GetMarkerPosition(SLPlayItf self,SLmillisecond * pMsec)77 static SLresult GetMarkerPosition(SLPlayItf self, SLmillisecond *pMsec)
78 {
79 return SL_RESULT_FEATURE_UNSUPPORTED;
80 }
81
SetPositionUpdatePeriod(SLPlayItf self,SLmillisecond mSec)82 static SLresult SetPositionUpdatePeriod(SLPlayItf self, SLmillisecond mSec)
83 {
84 return SL_RESULT_FEATURE_UNSUPPORTED;
85 }
86
GetPositionUpdatePeriod(SLPlayItf self,SLmillisecond * pMsec)87 static SLresult GetPositionUpdatePeriod(SLPlayItf self, SLmillisecond *pMsec)
88 {
89 return SL_RESULT_FEATURE_UNSUPPORTED;
90 }
91
92 static const struct SLPlayItf_ PlayItf = {
93 SetPlayState,
94 GetPlayState,
95 GetDuration,
96 GetPosition,
97 RegisterCallback,
98 SetCallbackEventsMask,
99 GetCallbackEventsMask,
100 SetMarkerPosition,
101 ClearMarkerPosition,
102 GetMarkerPosition,
103 SetPositionUpdatePeriod,
104 GetPositionUpdatePeriod
105 };
106
IPlayInit(void * self,SLuint32 id)107 void IPlayInit(void *self, SLuint32 id)
108 {
109 IPlay *thiz = (IPlay *)self;
110 thiz->mItf = &PlayItf;
111 thiz->mState = SL_PLAYSTATE_STOPPED;
112 thiz->mId = id;
113 }
114