1 /*
2  * Copyright (C) 2009 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 #include <media/MediaTrack.h>
18 
19 namespace android {
20 
MediaTrack()21 MediaTrack::MediaTrack() {}
22 
~MediaTrack()23 MediaTrack::~MediaTrack() {}
24 
25 ////////////////////////////////////////////////////////////////////////////////
26 
ReadOptions()27 MediaTrack::ReadOptions::ReadOptions() {
28     reset();
29 }
30 
reset()31 void MediaTrack::ReadOptions::reset() {
32     mOptions = 0;
33     mSeekTimeUs = 0;
34     mNonBlocking = false;
35 }
36 
setNonBlocking()37 void MediaTrack::ReadOptions::setNonBlocking() {
38     mNonBlocking = true;
39 }
40 
clearNonBlocking()41 void MediaTrack::ReadOptions::clearNonBlocking() {
42     mNonBlocking = false;
43 }
44 
getNonBlocking() const45 bool MediaTrack::ReadOptions::getNonBlocking() const {
46     return mNonBlocking;
47 }
48 
setSeekTo(int64_t time_us,SeekMode mode)49 void MediaTrack::ReadOptions::setSeekTo(int64_t time_us, SeekMode mode) {
50     mOptions |= kSeekTo_Option;
51     mSeekTimeUs = time_us;
52     mSeekMode = mode;
53 }
54 
clearSeekTo()55 void MediaTrack::ReadOptions::clearSeekTo() {
56     mOptions &= ~kSeekTo_Option;
57     mSeekTimeUs = 0;
58     mSeekMode = SEEK_CLOSEST_SYNC;
59 }
60 
getSeekTo(int64_t * time_us,SeekMode * mode) const61 bool MediaTrack::ReadOptions::getSeekTo(
62         int64_t *time_us, SeekMode *mode) const {
63     *time_us = mSeekTimeUs;
64     *mode = mSeekMode;
65     return (mOptions & kSeekTo_Option) != 0;
66 }
67 
68 }  // namespace android
69