blob: 08a7588b5af9db95f92727aa1ba126d2f78f02aa [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;
41 virtual Return<void> setParameters(const hidl_vec<VendorKeyValue>& parameters,
42 setParameters_cb _hidl_cb) override;
43 virtual Return<void> getParameters(const hidl_vec<hidl_string>& keys,
44 getParameters_cb _hidl_cb) override;
45 virtual Return<void> close() override;
46
47 private:
48 std::mutex mMut;
49 WorkerThread mThread;
50 bool mIsClosed = false;
51
52 const sp<ITunerCallback> mCallback;
53
54 std::reference_wrapper<BroadcastRadio> mModule;
55 bool mIsTuneCompleted = false;
56 ProgramSelector mCurrentProgram = {};
57
58 void tuneInternalLocked(const ProgramSelector& sel);
59 const VirtualRadio& virtualRadio() const;
60};
61
62} // namespace implementation
63} // namespace V2_0
64} // namespace broadcastradio
65} // namespace hardware
66} // namespace android
67
68#endif // ANDROID_HARDWARE_BROADCASTRADIO_V2_0_TUNER_H