blob: 9a72182afe7e26b9ee463c51f6957433547096de [file] [log] [blame]
Tomasz Wasilczyk06100b32017-12-04 09:53:32 -08001/*
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#ifndef ANDROID_HARDWARE_BROADCASTRADIO_V2_0_TUNER_H
17#define ANDROID_HARDWARE_BROADCASTRADIO_V2_0_TUNER_H
18
19#include "VirtualRadio.h"
20
21#include <android/hardware/broadcastradio/2.0/ITunerCallback.h>
22#include <android/hardware/broadcastradio/2.0/ITunerSession.h>
23#include <broadcastradio-utils/WorkerThread.h>
24
25namespace android {
26namespace hardware {
27namespace broadcastradio {
28namespace V2_0 {
29namespace implementation {
30
31struct BroadcastRadio;
32
33struct TunerSession : public ITunerSession {
34 TunerSession(BroadcastRadio& module, const sp<ITunerCallback>& callback);
35
36 // V2_0::ITunerSession methods
37 virtual Return<Result> tune(const ProgramSelector& program) override;
38 virtual Return<Result> scan(bool directionUp, bool skipSubChannel) override;
39 virtual Return<Result> step(bool directionUp) override;
40 virtual Return<void> cancel() override;
Tomasz Wasilczyk43fe8942017-12-14 11:44:12 -080041 virtual Return<void> getConfigFlag(ConfigFlag flag, getConfigFlag_cb _hidl_cb);
42 virtual Return<Result> setConfigFlag(ConfigFlag flag, bool value);
Tomasz Wasilczyk06100b32017-12-04 09:53:32 -080043 virtual Return<void> setParameters(const hidl_vec<VendorKeyValue>& parameters,
44 setParameters_cb _hidl_cb) override;
45 virtual Return<void> getParameters(const hidl_vec<hidl_string>& keys,
46 getParameters_cb _hidl_cb) override;
47 virtual Return<void> close() override;
48
49 private:
50 std::mutex mMut;
51 WorkerThread mThread;
52 bool mIsClosed = false;
53
54 const sp<ITunerCallback> mCallback;
55
56 std::reference_wrapper<BroadcastRadio> mModule;
57 bool mIsTuneCompleted = false;
58 ProgramSelector mCurrentProgram = {};
59
60 void tuneInternalLocked(const ProgramSelector& sel);
61 const VirtualRadio& virtualRadio() const;
62};
63
64} // namespace implementation
65} // namespace V2_0
66} // namespace broadcastradio
67} // namespace hardware
68} // namespace android
69
70#endif // ANDROID_HARDWARE_BROADCASTRADIO_V2_0_TUNER_H