xref: /aosp_15_r20/frameworks/wilhelm/src/itf/IDynamicSource.cpp (revision bebae9c0e76121f8312ccb50385c080b3a0b023c)
1*bebae9c0SAndroid Build Coastguard Worker /*
2*bebae9c0SAndroid Build Coastguard Worker  * Copyright (C) 2010 The Android Open Source Project
3*bebae9c0SAndroid Build Coastguard Worker  *
4*bebae9c0SAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
5*bebae9c0SAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
6*bebae9c0SAndroid Build Coastguard Worker  * You may obtain a copy of the License at
7*bebae9c0SAndroid Build Coastguard Worker  *
8*bebae9c0SAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
9*bebae9c0SAndroid Build Coastguard Worker  *
10*bebae9c0SAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
11*bebae9c0SAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
12*bebae9c0SAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*bebae9c0SAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
14*bebae9c0SAndroid Build Coastguard Worker  * limitations under the License.
15*bebae9c0SAndroid Build Coastguard Worker  */
16*bebae9c0SAndroid Build Coastguard Worker 
17*bebae9c0SAndroid Build Coastguard Worker /* DynamicSource implementation */
18*bebae9c0SAndroid Build Coastguard Worker 
19*bebae9c0SAndroid Build Coastguard Worker #include "sles_allinclusive.h"
20*bebae9c0SAndroid Build Coastguard Worker 
21*bebae9c0SAndroid Build Coastguard Worker 
IDynamicSource_SetSource(SLDynamicSourceItf self,SLDataSource * pDataSource)22*bebae9c0SAndroid Build Coastguard Worker static SLresult IDynamicSource_SetSource(SLDynamicSourceItf self, SLDataSource *pDataSource)
23*bebae9c0SAndroid Build Coastguard Worker {
24*bebae9c0SAndroid Build Coastguard Worker     SL_ENTER_INTERFACE
25*bebae9c0SAndroid Build Coastguard Worker 
26*bebae9c0SAndroid Build Coastguard Worker     if (NULL == pDataSource) {
27*bebae9c0SAndroid Build Coastguard Worker         result = SL_RESULT_PARAMETER_INVALID;
28*bebae9c0SAndroid Build Coastguard Worker     } else {
29*bebae9c0SAndroid Build Coastguard Worker         IDynamicSource *thiz = (IDynamicSource *) self;
30*bebae9c0SAndroid Build Coastguard Worker #if 0
31*bebae9c0SAndroid Build Coastguard Worker         DataLocatorFormat myDataSource;
32*bebae9c0SAndroid Build Coastguard Worker         SLresult result;
33*bebae9c0SAndroid Build Coastguard Worker         result = checkDataSource("pDataSource", pDataSource, &myDataSource, DATALOCATOR_MASK_ALL,
34*bebae9c0SAndroid Build Coastguard Worker                 DATAFORMAT_MASK_ALL);
35*bebae9c0SAndroid Build Coastguard Worker         // handle result here
36*bebae9c0SAndroid Build Coastguard Worker #endif
37*bebae9c0SAndroid Build Coastguard Worker         // need to lock the object, as a change to source can impact most of object
38*bebae9c0SAndroid Build Coastguard Worker         IObject *thisObject = InterfaceToIObject(thiz);
39*bebae9c0SAndroid Build Coastguard Worker         object_lock_exclusive(thisObject);
40*bebae9c0SAndroid Build Coastguard Worker         // a bit of a simplification to say the least! (see Khronos bug 6728)
41*bebae9c0SAndroid Build Coastguard Worker         thiz->mDataSource = pDataSource;
42*bebae9c0SAndroid Build Coastguard Worker         object_unlock_exclusive(thisObject);
43*bebae9c0SAndroid Build Coastguard Worker         result = SL_RESULT_FEATURE_UNSUPPORTED;
44*bebae9c0SAndroid Build Coastguard Worker     }
45*bebae9c0SAndroid Build Coastguard Worker 
46*bebae9c0SAndroid Build Coastguard Worker     SL_LEAVE_INTERFACE
47*bebae9c0SAndroid Build Coastguard Worker }
48*bebae9c0SAndroid Build Coastguard Worker 
49*bebae9c0SAndroid Build Coastguard Worker 
50*bebae9c0SAndroid Build Coastguard Worker static const struct SLDynamicSourceItf_ IDynamicSource_Itf = {
51*bebae9c0SAndroid Build Coastguard Worker     IDynamicSource_SetSource
52*bebae9c0SAndroid Build Coastguard Worker };
53*bebae9c0SAndroid Build Coastguard Worker 
IDynamicSource_init(void * self)54*bebae9c0SAndroid Build Coastguard Worker void IDynamicSource_init(void *self)
55*bebae9c0SAndroid Build Coastguard Worker {
56*bebae9c0SAndroid Build Coastguard Worker     IDynamicSource *thiz = (IDynamicSource *) self;
57*bebae9c0SAndroid Build Coastguard Worker     thiz->mItf = &IDynamicSource_Itf;
58*bebae9c0SAndroid Build Coastguard Worker     // mDataSource will be re-initialized later in the containing object constructor
59*bebae9c0SAndroid Build Coastguard Worker     thiz->mDataSource = NULL;
60*bebae9c0SAndroid Build Coastguard Worker }
61