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