Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 80cb9604 authored by Amy Zhang's avatar Amy Zhang
Browse files

Add a getAvSyncHwId_64bit in Tuner HAL 1.1 to support 64 bit hw sync id

Test: atest VtsHalTvTunerV1_1TargetTest
Bug: b/159058358
Change-Id: I3e58beaf4f61b27acce71a530e42293c4a87b181
parent 45cc57ac
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ hidl_interface {
    srcs: [
        "IFilter.hal",
        "ITuner.hal",
        "IDemux.hal",
    ],
    interfaces: [
        "android.hidl.base@1.0",
+41 −0
Original line number Diff line number Diff line
/*
 * Copyright 2020 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.hardware.tv.tuner@1.1;

import @1.0::IDemux;
import @1.0::Result;
import @1.0::IFilter;

/**
 * Demultiplexer(Demux) takes a single multiplexed input and splits it into
 * one or more output.
 */
interface IDemux extends @1.0::IDemux {
    /**
     * Get a 64-bit hardware sync ID for audio and video.
     *
     * It is used by the client to get the hardware sync ID for audio and video.
     *
     * @param filter the filter instance.
     * @return result Result status of the operation.
     *         SUCCESS if successful,
     *         INVALID_ARGUMENT if failed for a wrong filter ID.
     *         UNKNOWN_ERROR if failed for other reasons.
     * @return avSyncHwId the id of hardware A/V sync.
     */
    getAvSyncHwId64Bit(IFilter filter) generates (Result result, uint64_t avSyncHwId);
};
 No newline at end of file
+50 −0
Original line number Diff line number Diff line
@@ -34,6 +34,49 @@ Demux::Demux(uint32_t demuxId, sp<Tuner> tuner) {

Demux::~Demux() {}

Return<void> Demux::getAvSyncHwId64Bit(const sp<IFilter>& filter, getAvSyncHwId64Bit_cb _hidl_cb) {
    ALOGV("%s", __FUNCTION__);

    uint64_t avSyncHwId = -1;
    uint64_t id;
    Result status;

    sp<V1_1::IFilter> filter_v1_1 = V1_1::IFilter::castFrom(filter);
    if (filter_v1_1 != NULL) {
        filter_v1_1->getId64Bit([&](Result result, uint64_t filterId) {
            id = filterId;
            status = result;
        });
    } else {
        filter->getId([&](Result result, uint32_t filterId) {
            id = filterId;
            status = result;
        });
    }

    if (status != Result::SUCCESS) {
        ALOGE("[Demux] Can't get 64-bit filter Id.");
        _hidl_cb(Result::INVALID_STATE, avSyncHwId);
        return Void();
    }

    if (!mFilters[id]->isMediaFilter()) {
        ALOGE("[Demux] Given filter is not a media filter.");
        _hidl_cb(Result::INVALID_ARGUMENT, avSyncHwId);
        return Void();
    }

    if (!mPcrFilterIds.empty()) {
        // Return the lowest pcr filter id in the default implementation as the av sync id
        _hidl_cb(Result::SUCCESS, *mPcrFilterIds.begin());
        return Void();
    }

    ALOGE("[Demux] No PCR filter opened.");
    _hidl_cb(Result::INVALID_STATE, avSyncHwId);
    return Void();
}

Return<Result> Demux::setFrontendDataSource(uint32_t frontendId) {
    ALOGV("%s", __FUNCTION__);

@@ -170,6 +213,7 @@ Return<Result> Demux::close() {
    mRecordFilterIds.clear();
    mFilters.clear();
    mLastUsedFilterId = -1;
    mTunerService->removeDemux(mDemuxId);

    return Result::SUCCESS;
}
@@ -325,6 +369,12 @@ void Demux::frontendInputThreadLoop() {
    std::lock_guard<std::mutex> lock(mFrontendInputThreadLock);
    mFrontendInputThreadRunning = true;

    if (!mDvrPlayback) {
        ALOGW("[Demux] No software Frontend input configured. Ending Frontend thread loop.");
        mFrontendInputThreadRunning = false;
        return;
    }

    while (mFrontendInputThreadRunning) {
        uint32_t efState = 0;
        status_t status = mDvrPlayback->getDvrEventFlag()->wait(
+5 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
#ifndef ANDROID_HARDWARE_TV_TUNER_V1_1_DEMUX_H_
#define ANDROID_HARDWARE_TV_TUNER_V1_1_DEMUX_H_

#include <android/hardware/tv/tuner/1.1/IDemux.h>
#include <fmq/MessageQueue.h>
#include <math.h>
#include <set>
@@ -48,12 +49,15 @@ class Frontend;
class TimeFilter;
class Tuner;

class Demux : public IDemux {
class Demux : public V1_1::IDemux {
  public:
    Demux(uint32_t demuxId, sp<Tuner> tuner);

    ~Demux();

    virtual Return<void> getAvSyncHwId64Bit(const sp<IFilter>& filter,
                                            getAvSyncHwId64Bit_cb _hidl_cb) override;

    virtual Return<Result> setFrontendDataSource(uint32_t frontendId) override;

    virtual Return<void> openFilter(const DemuxFilterType& type, uint32_t bufferSize,
+1 −0
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ Return<Result> Frontend::close() {
    // Reset callback
    mCallback = nullptr;
    mIsLocked = false;
    mTunerService->removeFrontend(mId);

    return Result::SUCCESS;
}
Loading