blob: 0eab7aee7207ee9a560e1bdbf556f3dc9c51672c [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{
Tomasz Wasilczyk100f2ed2017-06-29 16:04:05 -070030 {94900, "Wild 94.9", "Drake ft. Rihanna", "Too Good"},
31 {96500, "KOIT", "Celine Dion", "All By Myself"},
32 {97300, "Alice@97.3", "Drops of Jupiter", "Train"},
33 {99700, "99.7 Now!", "The Chainsmokers", "Closer"},
34 {101300, "101-3 KISS-FM", "Justin Timberlake", "Rock Your Body"},
35 {103700, "iHeart80s @ 103.7", "Michael Jackson", "Billie Jean"},
36 {106100, "106 KMEL", "Drake", "Marvins Room"},
Tomasz Wasilczyk48377552017-06-22 10:45:33 -070037};
38
39VirtualRadio::VirtualRadio(VirtualRadio&& o) : mPrograms(move(o.mPrograms)) {}
40
41VirtualRadio::VirtualRadio(vector<VirtualProgram> initialList) : mPrograms(initialList) {}
42
43vector<VirtualProgram> VirtualRadio::getProgramList() {
44 lock_guard<mutex> lk(mMut);
45 return mPrograms;
46}
47
48bool VirtualRadio::getProgram(uint32_t channel, VirtualProgram& programOut) {
49 lock_guard<mutex> lk(mMut);
50 for (auto&& program : mPrograms) {
51 if (program.channel == channel) {
52 programOut = program;
53 return true;
54 }
55 }
56 return false;
57}
58
59VirtualRadio make_fm_radio() {
60 return VirtualRadio(gInitialFmPrograms);
61}
62
63} // namespace implementation
64} // namespace V1_1
65} // namespace broadcastradio
66} // namespace hardware
67} // namespace android