Home | History | Annotate | Download | only in filterfw
      1 /*
      2  * Copyright (C) 2011 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 package androidx.media.filterfw;
     18 
     19 import androidx.media.filterfw.BackingStore.Backing;
     20 
     21 public class FrameValue extends Frame {
     22 
     23     public Object getValue() {
     24         Object result = mBackingStore.lockData(MODE_READ, BackingStore.ACCESS_OBJECT);
     25         mBackingStore.unlock();
     26         return result;
     27     }
     28 
     29     public void setValue(Object value) {
     30         Backing backing = mBackingStore.lockBacking(MODE_WRITE, BackingStore.ACCESS_OBJECT);
     31         backing.setData(value);
     32         mBackingStore.unlock();
     33     }
     34 
     35     static FrameValue create(BackingStore backingStore) {
     36         assertObjectBased(backingStore.getFrameType());
     37         return new FrameValue(backingStore);
     38     }
     39 
     40     FrameValue(BackingStore backingStore) {
     41         super(backingStore);
     42     }
     43 
     44     static void assertObjectBased(FrameType type) {
     45         if (type.getElementId() != FrameType.ELEMENT_OBJECT) {
     46             throw new RuntimeException("Cannot access non-object based Frame as FrameValue!");
     47         }
     48     }
     49 }
     50 
     51