blob: 017a01f472a3b74030cbae83299034ea0a9b0b9a [file] [log] [blame]
Tomasz Wasilczyk48377552017-06-22 10:45:33 -07001/*
2 * Copyright (C) 2017 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#include "VirtualRadio.h"
17
18namespace android {
19namespace hardware {
20namespace broadcastradio {
21namespace V1_1 {
22namespace implementation {
23
24using std::lock_guard;
25using std::move;
26using std::mutex;
27using std::vector;
28
29vector<VirtualProgram> gInitialFmPrograms{
30 {94900}, {96500}, {97300}, {99700}, {101300}, {103700}, {106100},
31};
32
33VirtualRadio::VirtualRadio(VirtualRadio&& o) : mPrograms(move(o.mPrograms)) {}
34
35VirtualRadio::VirtualRadio(vector<VirtualProgram> initialList) : mPrograms(initialList) {}
36
37vector<VirtualProgram> VirtualRadio::getProgramList() {
38 lock_guard<mutex> lk(mMut);
39 return mPrograms;
40}
41
42bool VirtualRadio::getProgram(uint32_t channel, VirtualProgram& programOut) {
43 lock_guard<mutex> lk(mMut);
44 for (auto&& program : mPrograms) {
45 if (program.channel == channel) {
46 programOut = program;
47 return true;
48 }
49 }
50 return false;
51}
52
53VirtualRadio make_fm_radio() {
54 return VirtualRadio(gInitialFmPrograms);
55}
56
57} // namespace implementation
58} // namespace V1_1
59} // namespace broadcastradio
60} // namespace hardware
61} // namespace android