[automerger skipped] audio policy: add Spatializer effect control am: 6d60701ee2 am: 9c8a2e1a56 -s ours
am skip reason: Merged-In Ie2734fb9bb3ef9b945431c6c9bd110b1434a79cd with SHA-1 81dd0f584e is already in history
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/av/+/15302095
Change-Id: Id46069f2aac5918521914f8317a3da3cd730f459
diff --git a/camera/ndk/impl/ACameraManager.cpp b/camera/ndk/impl/ACameraManager.cpp
index 95ef2b2..5892f1a 100644
--- a/camera/ndk/impl/ACameraManager.cpp
+++ b/camera/ndk/impl/ACameraManager.cpp
@@ -189,8 +189,12 @@
sp<CameraManagerGlobal> cm = mCameraManager.promote();
if (cm != nullptr) {
AutoMutex lock(cm->mLock);
+ std::vector<String8> cameraIdList;
for (auto& pair : cm->mDeviceStatusMap) {
- const String8 &cameraId = pair.first;
+ cameraIdList.push_back(pair.first);
+ }
+
+ for (String8 cameraId : cameraIdList) {
cm->onStatusChangedLocked(
CameraServiceListener::STATUS_NOT_PRESENT, cameraId);
}
diff --git a/cmds/screenrecord/screenrecord.cpp b/cmds/screenrecord/screenrecord.cpp
index e6e3473..2e0b678 100644
--- a/cmds/screenrecord/screenrecord.cpp
+++ b/cmds/screenrecord/screenrecord.cpp
@@ -701,7 +701,7 @@
printf("Display is %dx%d @%.2ffps (orientation=%s), layerStack=%u\n",
layerStackSpaceRect.getWidth(), layerStackSpaceRect.getHeight(),
displayMode.refreshRate, toCString(displayState.orientation),
- displayState.layerStack);
+ displayState.layerStack.id);
fflush(stdout);
}
@@ -1067,7 +1067,7 @@
std::optional<PhysicalDisplayId> displayId = SurfaceComposerClient::getInternalDisplayId();
if (!displayId) {
- fprintf(stderr, "Failed to get token for internal display\n");
+ fprintf(stderr, "Failed to get ID for internal display\n");
return 1;
}
@@ -1168,17 +1168,14 @@
}
break;
case 'd':
- gPhysicalDisplayId = PhysicalDisplayId(atoll(optarg));
- if (gPhysicalDisplayId.value == 0) {
- fprintf(stderr, "Please specify a valid physical display id\n");
- return 2;
- } else if (SurfaceComposerClient::
- getPhysicalDisplayToken(gPhysicalDisplayId) == nullptr) {
- fprintf(stderr, "Invalid physical display id: %s\n",
- to_string(gPhysicalDisplayId).c_str());
- return 2;
+ if (const auto id = android::DisplayId::fromValue<PhysicalDisplayId>(atoll(optarg));
+ id && SurfaceComposerClient::getPhysicalDisplayToken(*id)) {
+ gPhysicalDisplayId = *id;
+ break;
}
- break;
+
+ fprintf(stderr, "Invalid physical display ID\n");
+ return 2;
default:
if (ic != '?') {
fprintf(stderr, "getopt_long returned unexpected value 0x%x\n", ic);
diff --git a/drm/mediadrm/plugins/TEST_MAPPING b/drm/mediadrm/plugins/TEST_MAPPING
index 7bd1568..87becb6 100644
--- a/drm/mediadrm/plugins/TEST_MAPPING
+++ b/drm/mediadrm/plugins/TEST_MAPPING
@@ -11,6 +11,9 @@
},
{
"include-filter": "android.media.cts.MediaDrmMetricsTest"
+ },
+ {
+ "include-filter": "android.media.cts.NativeMediaDrmClearkeyTest"
}
]
}
diff --git a/drm/mediadrm/plugins/clearkey/hidl/DrmPlugin.cpp b/drm/mediadrm/plugins/clearkey/hidl/DrmPlugin.cpp
index 6a374f9..0cd9375 100644
--- a/drm/mediadrm/plugins/clearkey/hidl/DrmPlugin.cpp
+++ b/drm/mediadrm/plugins/clearkey/hidl/DrmPlugin.cpp
@@ -221,7 +221,6 @@
if (requestString.find(kOfflineLicense) != std::string::npos) {
std::string emptyResponse;
std::string keySetIdString(keySetId.begin(), keySetId.end());
- Mutex::Autolock lock(mFileHandleLock);
if (!mFileHandle.StoreLicense(keySetIdString,
DeviceFiles::kLicenseStateReleasing,
emptyResponse)) {
@@ -337,7 +336,6 @@
}
*keySetId = kKeySetIdPrefix + ByteArrayToHexString(
reinterpret_cast<const uint8_t*>(randomData.data()), randomData.size());
- Mutex::Autolock lock(mFileHandleLock);
if (mFileHandle.LicenseExists(*keySetId)) {
// collision, regenerate
ALOGV("Retry generating KeySetId");
@@ -395,7 +393,6 @@
if (status == Status::OK) {
if (isOfflineLicense) {
if (isRelease) {
- Mutex::Autolock lock(mFileHandleLock);
mFileHandle.DeleteLicense(keySetId);
mSessionLibrary->destroySession(session);
} else {
@@ -404,7 +401,6 @@
return Void();
}
- Mutex::Autolock lock(mFileHandleLock);
bool ok = mFileHandle.StoreLicense(
keySetId,
DeviceFiles::kLicenseStateActive,
@@ -459,7 +455,6 @@
DeviceFiles::LicenseState licenseState;
std::string offlineLicense;
Status status = Status::OK;
- Mutex::Autolock lock(mFileHandleLock);
if (!mFileHandle.RetrieveLicense(std::string(keySetId.begin(), keySetId.end()),
&licenseState, &offlineLicense)) {
ALOGE("Failed to restore offline license");
@@ -769,8 +764,6 @@
}
Return<void> DrmPlugin::getOfflineLicenseKeySetIds(getOfflineLicenseKeySetIds_cb _hidl_cb) {
- Mutex::Autolock lock(mFileHandleLock);
-
std::vector<std::string> licenseNames = mFileHandle.ListLicenses();
std::vector<KeySetId> keySetIds;
if (mMockError != Status_V1_2::OK) {
@@ -791,7 +784,6 @@
return toStatus_1_0(mMockError);
}
std::string licenseName(keySetId.begin(), keySetId.end());
- Mutex::Autolock lock(mFileHandleLock);
if (mFileHandle.DeleteLicense(licenseName)) {
return Status::OK;
}
@@ -800,8 +792,6 @@
Return<void> DrmPlugin::getOfflineLicenseState(const KeySetId& keySetId,
getOfflineLicenseState_cb _hidl_cb) {
- Mutex::Autolock lock(mFileHandleLock);
-
std::string licenseName(keySetId.begin(), keySetId.end());
DeviceFiles::LicenseState state;
std::string license;
diff --git a/drm/mediadrm/plugins/clearkey/hidl/MemoryFileSystem.cpp b/drm/mediadrm/plugins/clearkey/hidl/MemoryFileSystem.cpp
index e61db3f..56910be 100644
--- a/drm/mediadrm/plugins/clearkey/hidl/MemoryFileSystem.cpp
+++ b/drm/mediadrm/plugins/clearkey/hidl/MemoryFileSystem.cpp
@@ -24,13 +24,11 @@
}
bool MemoryFileSystem::FileExists(const std::string& fileName) const {
- std::lock_guard<std::mutex> lock(mMemoryFileSystemLock);
auto result = mMemoryFileSystem.find(fileName);
return result != mMemoryFileSystem.end();
}
ssize_t MemoryFileSystem::GetFileSize(const std::string& fileName) const {
- std::lock_guard<std::mutex> lock(mMemoryFileSystemLock);
auto result = mMemoryFileSystem.find(fileName);
if (result != mMemoryFileSystem.end()) {
return static_cast<ssize_t>(result->second.getFileSize());
@@ -42,7 +40,6 @@
std::vector<std::string> MemoryFileSystem::ListFiles() const {
std::vector<std::string> list;
- std::lock_guard<std::mutex> lock(mMemoryFileSystemLock);
for (const auto& filename : mMemoryFileSystem) {
list.push_back(filename.first);
}
@@ -51,7 +48,6 @@
size_t MemoryFileSystem::Read(const std::string& path, std::string* buffer) {
std::string key = GetFileName(path);
- std::lock_guard<std::mutex> lock(mMemoryFileSystemLock);
auto result = mMemoryFileSystem.find(key);
if (result != mMemoryFileSystem.end()) {
std::string serializedHashFile = result->second.getContent();
@@ -65,7 +61,6 @@
size_t MemoryFileSystem::Write(const std::string& path, const MemoryFile& memoryFile) {
std::string key = GetFileName(path);
- std::lock_guard<std::mutex> lock(mMemoryFileSystemLock);
auto result = mMemoryFileSystem.find(key);
if (result != mMemoryFileSystem.end()) {
mMemoryFileSystem.erase(key);
@@ -75,7 +70,6 @@
}
bool MemoryFileSystem::RemoveFile(const std::string& fileName) {
- std::lock_guard<std::mutex> lock(mMemoryFileSystemLock);
auto result = mMemoryFileSystem.find(fileName);
if (result != mMemoryFileSystem.end()) {
mMemoryFileSystem.erase(result);
@@ -87,7 +81,6 @@
}
bool MemoryFileSystem::RemoveAllFiles() {
- std::lock_guard<std::mutex> lock(mMemoryFileSystemLock);
mMemoryFileSystem.clear();
return mMemoryFileSystem.empty();
}
diff --git a/drm/mediadrm/plugins/clearkey/hidl/include/DrmPlugin.h b/drm/mediadrm/plugins/clearkey/hidl/include/DrmPlugin.h
index 5d6e3da..cb5c9fe 100644
--- a/drm/mediadrm/plugins/clearkey/hidl/include/DrmPlugin.h
+++ b/drm/mediadrm/plugins/clearkey/hidl/include/DrmPlugin.h
@@ -432,8 +432,7 @@
mMockError = Status_V1_2::OK;
}
- DeviceFiles mFileHandle GUARDED_BY(mFileHandleLock);
- Mutex mFileHandleLock;
+ DeviceFiles mFileHandle;
Mutex mSecureStopLock;
CLEARKEY_DISALLOW_COPY_AND_ASSIGN_AND_NEW(DrmPlugin);
diff --git a/drm/mediadrm/plugins/clearkey/hidl/include/MemoryFileSystem.h b/drm/mediadrm/plugins/clearkey/hidl/include/MemoryFileSystem.h
index a90d818..1d98860 100644
--- a/drm/mediadrm/plugins/clearkey/hidl/include/MemoryFileSystem.h
+++ b/drm/mediadrm/plugins/clearkey/hidl/include/MemoryFileSystem.h
@@ -5,9 +5,7 @@
#ifndef CLEARKEY_MEMORY_FILE_SYSTEM_H_
#define CLEARKEY_MEMORY_FILE_SYSTEM_H_
-#include <android-base/thread_annotations.h>
#include <map>
-#include <mutex>
#include <string>
#include "ClearKeyTypes.h"
@@ -51,12 +49,10 @@
size_t Write(const std::string& pathName, const MemoryFile& memoryFile);
private:
- mutable std::mutex mMemoryFileSystemLock;
-
// License file name is made up of a unique keySetId, therefore,
// the filename can be used as the key to locate licenses in the
// memory file system.
- std::map<std::string, MemoryFile> mMemoryFileSystem GUARDED_BY(mMemoryFileSystemLock);
+ std::map<std::string, MemoryFile> mMemoryFileSystem;
std::string GetFileName(const std::string& path);
diff --git a/media/codec2/sfplugin/CCodecBuffers.cpp b/media/codec2/sfplugin/CCodecBuffers.cpp
index d7e0b1e..d94d0a2 100644
--- a/media/codec2/sfplugin/CCodecBuffers.cpp
+++ b/media/codec2/sfplugin/CCodecBuffers.cpp
@@ -33,7 +33,7 @@
namespace {
-sp<GraphicBlockBuffer> AllocateGraphicBuffer(
+sp<GraphicBlockBuffer> AllocateInputGraphicBuffer(
const std::shared_ptr<C2BlockPool> &pool,
const sp<AMessage> &format,
uint32_t pixelFormat,
@@ -45,9 +45,13 @@
return nullptr;
}
+ int64_t usageValue = 0;
+ (void)format->findInt64("android._C2MemoryUsage", &usageValue);
+ C2MemoryUsage fullUsage{usageValue | usage.expected};
+
std::shared_ptr<C2GraphicBlock> block;
c2_status_t err = pool->fetchGraphicBlock(
- width, height, pixelFormat, usage, &block);
+ width, height, pixelFormat, fullUsage, &block);
if (err != C2_OK) {
ALOGD("fetch graphic block failed: %d", err);
return nullptr;
@@ -885,6 +889,10 @@
return nullptr;
}
+ int64_t usageValue = 0;
+ (void)format->findInt64("android._C2MemoryUsage", &usageValue);
+ usage = C2MemoryUsage(usage.expected | usageValue);
+
std::shared_ptr<C2LinearBlock> block;
c2_status_t err = pool->fetchLinearBlock(capacity, usage, &block);
if (err != C2_OK || block == nullptr) {
@@ -1029,7 +1037,7 @@
[pool = mPool, format = mFormat, lbp = mLocalBufferPool, pixelFormat]()
-> sp<Codec2Buffer> {
C2MemoryUsage usage = { C2MemoryUsage::CPU_READ, C2MemoryUsage::CPU_WRITE };
- return AllocateGraphicBuffer(
+ return AllocateInputGraphicBuffer(
pool, format, pixelFormat, usage, lbp);
});
return std::move(array);
@@ -1040,10 +1048,8 @@
}
sp<Codec2Buffer> GraphicInputBuffers::createNewBuffer() {
- int64_t usageValue = 0;
- (void)mFormat->findInt64("android._C2MemoryUsage", &usageValue);
- C2MemoryUsage usage{usageValue | C2MemoryUsage::CPU_READ | C2MemoryUsage::CPU_WRITE};
- return AllocateGraphicBuffer(
+ C2MemoryUsage usage = { C2MemoryUsage::CPU_READ, C2MemoryUsage::CPU_WRITE };
+ return AllocateInputGraphicBuffer(
mPool, mFormat, extractPixelFormat(mFormat), usage, mLocalBufferPool);
}
diff --git a/media/codecs/m4v_h263/enc/src/mp4enc_api.cpp b/media/codecs/m4v_h263/enc/src/mp4enc_api.cpp
index ca58837..b295258 100644
--- a/media/codecs/m4v_h263/enc/src/mp4enc_api.cpp
+++ b/media/codecs/m4v_h263/enc/src/mp4enc_api.cpp
@@ -613,18 +613,19 @@
/* Find the maximum width*height for memory allocation of the VOPs */
for (idx = 0; idx < nLayers; idx++)
{
- temp_w = video->encParams->LayerWidth[idx];
- temp_h = video->encParams->LayerHeight[idx];
+ temp_w = ((video->encParams->LayerWidth[idx] + 15) >> 4) << 4;
+ temp_h = ((video->encParams->LayerHeight[idx] + 15) >> 4) << 4;
+
+ if (temp_w > 2048 || temp_h > 2048) {
+ goto CLEAN_UP;
+ }
if ((temp_w*temp_h) > max)
{
max = temp_w * temp_h;
- max_width = ((temp_w + 15) >> 4) << 4;
- max_height = ((temp_h + 15) >> 4) << 4;
- if (((uint64_t)max_width * max_height) > (uint64_t)INT32_MAX
- || temp_w > INT32_MAX - 15 || temp_h > INT32_MAX - 15) {
- goto CLEAN_UP;
- }
+ max_width = temp_w;
+ max_height = temp_h;
+
nTotalMB = ((max_width * max_height) >> 8);
}
diff --git a/media/libaaudio/include/aaudio/AAudio.h b/media/libaaudio/include/aaudio/AAudio.h
index f97fe4d..fc86001 100644
--- a/media/libaaudio/include/aaudio/AAudio.h
+++ b/media/libaaudio/include/aaudio/AAudio.h
@@ -782,8 +782,11 @@
* This is usually {@code Context#getPackageName()}.
*
* The default, if you do not call this function, is a random package in the calling uid.
- * The vast majority of apps have only one package per calling UID. If the package
- * name does not match the calling UID, then requests will be rejected.
+ * The vast majority of apps have only one package per calling UID.
+ * If an invalid package name is set, input streams may not be given permission to
+ * record when started.
+ *
+ * The package name is usually the applicationId in your app's build.gradle file.
*
* Available since API level 31.
*
diff --git a/media/libaaudio/src/Android.bp b/media/libaaudio/src/Android.bp
index 33a5c7f..da59da6 100644
--- a/media/libaaudio/src/Android.bp
+++ b/media/libaaudio/src/Android.bp
@@ -7,6 +7,65 @@
default_applicable_licenses: ["frameworks_av_license"],
}
+tidy_errors = [
+ // https://clang.llvm.org/extra/clang-tidy/checks/list.html
+ // For many categories, the checks are too many to specify individually.
+ // Feel free to disable as needed - as warnings are generally ignored,
+ // we treat warnings as errors.
+ "android-*",
+ "bugprone-*",
+ "cert-*",
+ "clang-analyzer-security*",
+ "google-*",
+ "misc-*",
+ //"modernize-*", // explicitly list the modernize as they can be subjective.
+ "modernize-avoid-bind",
+ //"modernize-avoid-c-arrays", // std::array<> can be verbose
+ "modernize-concat-nested-namespaces",
+ //"modernize-deprecated-headers", // C headers still ok even if there is C++ equivalent.
+ "modernize-deprecated-ios-base-aliases",
+ "modernize-loop-convert",
+ "modernize-make-shared",
+ "modernize-make-unique",
+ "modernize-pass-by-value",
+ "modernize-raw-string-literal",
+ "modernize-redundant-void-arg",
+ "modernize-replace-auto-ptr",
+ "modernize-replace-random-shuffle",
+ "modernize-return-braced-init-list",
+ "modernize-shrink-to-fit",
+ "modernize-unary-static-assert",
+ // "modernize-use-auto", // found in AAudioAudio.cpp
+ "modernize-use-bool-literals",
+ "modernize-use-default-member-init",
+ "modernize-use-emplace",
+ "modernize-use-equals-default",
+ "modernize-use-equals-delete",
+ // "modernize-use-nodiscard", // found in aidl generated files
+ "modernize-use-noexcept",
+ "modernize-use-nullptr",
+ // "modernize-use-override", // found in aidl generated files
+ // "modernize-use-trailing-return-type", // not necessarily more readable
+ "modernize-use-transparent-functors",
+ "modernize-use-uncaught-exceptions",
+ // "modernize-use-using", // found typedef in several files
+ "performance-*",
+
+ // Remove some pedantic stylistic requirements.
+ "-android-cloexec-dup", // found in SharedMemoryParcelable.cpp
+ "-bugprone-macro-parentheses", // found in SharedMemoryParcelable.h
+ "-bugprone-narrowing-conversions", // found in several interface from size_t to int32_t
+
+ "-google-readability-casting", // C++ casts not always necessary and may be verbose
+ "-google-readability-todo", // do not require TODO(info)
+ "-google-build-using-namespace", // Reenable and fix later.
+ "-google-global-names-in-headers", // found in several files
+
+ "-misc-non-private-member-variables-in-classes", // found in aidl generated files
+
+ "-performance-no-int-to-ptr", // found in SharedMemoryParcelable.h
+]
+
cc_library {
name: "libaaudio",
@@ -52,7 +111,7 @@
"libcutils",
"libutils",
"libbinder",
- "libpermission",
+ "framework-permission-aidl-cpp",
],
sanitize: {
@@ -64,6 +123,13 @@
symbol_file: "libaaudio.map.txt",
versions: ["28"],
},
+
+ tidy: true,
+ tidy_checks: tidy_errors,
+ tidy_checks_as_errors: tidy_errors,
+ tidy_flags: [
+ "-format-style=file",
+ ]
}
cc_library {
@@ -102,6 +168,7 @@
"libbinder",
"framework-permission-aidl-cpp",
"aaudio-aidl-cpp",
+ "audioclient-types-aidl-cpp",
"libaudioclient_aidl_conversion",
],
@@ -156,6 +223,13 @@
integer_overflow: true,
misc_undefined: ["bounds"],
},
+
+ tidy: true,
+ tidy_checks: tidy_errors,
+ tidy_checks_as_errors: tidy_errors,
+ tidy_flags: [
+ "-format-style=file",
+ ]
}
aidl_interface {
@@ -172,19 +246,14 @@
"binding/aidl/aaudio/IAAudioService.aidl",
],
imports: [
- "audio_common-aidl",
+ "audioclient-types-aidl",
"shared-file-region-aidl",
- "framework-permission-aidl"
+ "framework-permission-aidl",
],
backend:
{
- cpp: {
- enabled: true,
- },
java: {
- // TODO: need to have audio_common-aidl available in Java to enable
- // this.
- enabled: false,
+ sdk_version: "module_current",
},
},
}
diff --git a/media/libaaudio/src/binding/AAudioBinderClient.cpp b/media/libaaudio/src/binding/AAudioBinderClient.cpp
index fa5a2da..135bac3 100644
--- a/media/libaaudio/src/binding/AAudioBinderClient.cpp
+++ b/media/libaaudio/src/binding/AAudioBinderClient.cpp
@@ -36,13 +36,10 @@
using android::IServiceManager;
using android::defaultServiceManager;
using android::interface_cast;
-using android::IInterface;
using android::Mutex;
using android::ProcessState;
using android::sp;
using android::status_t;
-using android::wp;
-using android::binder::Status;
using namespace aaudio;
@@ -93,7 +90,7 @@
ALOGE("%s() - linkToDeath() returned %d", __func__, status);
}
aaudioService = interface_cast<IAAudioService>(binder);
- mAdapter.reset(new Adapter(aaudioService, mAAudioClient));
+ mAdapter = std::make_shared<Adapter>(aaudioService, mAAudioClient);
needToRegister = true;
// Make sure callbacks can be received by mAAudioClient
ProcessState::self()->startThreadPool();
diff --git a/media/libaaudio/src/binding/AAudioBinderClient.h b/media/libaaudio/src/binding/AAudioBinderClient.h
index 6a7b639..557ced5 100644
--- a/media/libaaudio/src/binding/AAudioBinderClient.h
+++ b/media/libaaudio/src/binding/AAudioBinderClient.h
@@ -108,7 +108,7 @@
return AAUDIO_ERROR_UNAVAILABLE;
}
- void onStreamChange(aaudio_handle_t handle, int32_t opcode, int32_t value) {
+ void onStreamChange(aaudio_handle_t /*handle*/, int32_t /*opcode*/, int32_t /*value*/) {
// TODO This is just a stub so we can have a client Binder to pass to the service.
// TODO Implemented in a later CL.
ALOGW("onStreamChange called!");
@@ -116,7 +116,7 @@
class AAudioClient : public android::IBinder::DeathRecipient, public BnAAudioClient {
public:
- AAudioClient(android::wp<AAudioBinderClient> aaudioBinderClient)
+ explicit AAudioClient(const android::wp<AAudioBinderClient>& aaudioBinderClient)
: mBinderClient(aaudioBinderClient) {
}
@@ -150,10 +150,10 @@
class Adapter : public AAudioBinderAdapter {
public:
Adapter(const android::sp<IAAudioService>& delegate,
- const android::sp<AAudioClient>& aaudioClient)
+ android::sp<AAudioClient> aaudioClient)
: AAudioBinderAdapter(delegate.get()),
mDelegate(delegate),
- mAAudioClient(aaudioClient) {}
+ mAAudioClient(std::move(aaudioClient)) {}
virtual ~Adapter() {
if (mDelegate != nullptr) {
diff --git a/media/libaaudio/src/binding/AAudioServiceInterface.h b/media/libaaudio/src/binding/AAudioServiceInterface.h
index 5d11512..bf94774 100644
--- a/media/libaaudio/src/binding/AAudioServiceInterface.h
+++ b/media/libaaudio/src/binding/AAudioServiceInterface.h
@@ -37,7 +37,7 @@
class AAudioServiceInterface {
public:
- AAudioServiceInterface() {};
+ AAudioServiceInterface() = default;
virtual ~AAudioServiceInterface() = default;
virtual void registerClient(const android::sp<IAAudioClient>& client) = 0;
diff --git a/media/libaaudio/src/binding/AAudioStreamConfiguration.cpp b/media/libaaudio/src/binding/AAudioStreamConfiguration.cpp
index dc19bb3..cf76225 100644
--- a/media/libaaudio/src/binding/AAudioStreamConfiguration.cpp
+++ b/media/libaaudio/src/binding/AAudioStreamConfiguration.cpp
@@ -23,11 +23,13 @@
#include <sys/mman.h>
#include <aaudio/AAudio.h>
+#include <media/AidlConversion.h>
+
#include "binding/AAudioStreamConfiguration.h"
using namespace aaudio;
-using android::media::audio::common::AudioFormat;
+using android::media::AudioFormatDescription;
AAudioStreamConfiguration::AAudioStreamConfiguration(const StreamParameters& parcelable) {
setChannelMask(parcelable.channelMask);
@@ -35,8 +37,9 @@
setDeviceId(parcelable.deviceId);
static_assert(sizeof(aaudio_sharing_mode_t) == sizeof(parcelable.sharingMode));
setSharingMode(parcelable.sharingMode);
- static_assert(sizeof(audio_format_t) == sizeof(parcelable.audioFormat));
- setFormat(static_cast<audio_format_t>(parcelable.audioFormat));
+ auto convFormat = android::aidl2legacy_AudioFormatDescription_audio_format_t(
+ parcelable.audioFormat);
+ setFormat(convFormat.ok() ? convFormat.value() : AUDIO_FORMAT_INVALID);
static_assert(sizeof(aaudio_direction_t) == sizeof(parcelable.direction));
setDirection(parcelable.direction);
static_assert(sizeof(audio_usage_t) == sizeof(parcelable.usage));
@@ -68,8 +71,13 @@
result.deviceId = getDeviceId();
static_assert(sizeof(aaudio_sharing_mode_t) == sizeof(result.sharingMode));
result.sharingMode = getSharingMode();
- static_assert(sizeof(audio_format_t) == sizeof(result.audioFormat));
- result.audioFormat = static_cast<AudioFormat>(getFormat());
+ auto convAudioFormat = android::legacy2aidl_audio_format_t_AudioFormatDescription(getFormat());
+ if (convAudioFormat.ok()) {
+ result.audioFormat = convAudioFormat.value();
+ } else {
+ result.audioFormat = AudioFormatDescription{};
+ result.audioFormat.type = android::media::AudioFormatType::SYS_RESERVED_INVALID;
+ }
static_assert(sizeof(aaudio_direction_t) == sizeof(result.direction));
result.direction = getDirection();
static_assert(sizeof(audio_usage_t) == sizeof(result.usage));
diff --git a/media/libaaudio/src/binding/AAudioStreamRequest.cpp b/media/libaaudio/src/binding/AAudioStreamRequest.cpp
index 8d90034..a4cc2bd 100644
--- a/media/libaaudio/src/binding/AAudioStreamRequest.cpp
+++ b/media/libaaudio/src/binding/AAudioStreamRequest.cpp
@@ -30,7 +30,7 @@
using namespace aaudio;
AAudioStreamRequest::AAudioStreamRequest(const StreamRequest& parcelable) :
- mConfiguration(std::move(parcelable.params)),
+ mConfiguration(parcelable.params),
mAttributionSource(parcelable.attributionSource),
mSharingModeMatchRequired(parcelable.sharingModeMatchRequired),
mInService(parcelable.inService) {
@@ -38,7 +38,7 @@
StreamRequest AAudioStreamRequest::parcelable() const {
StreamRequest result;
- result.params = std::move(mConfiguration).parcelable();
+ result.params = mConfiguration.parcelable();
result.attributionSource = mAttributionSource;
result.sharingModeMatchRequired = mSharingModeMatchRequired;
result.inService = mInService;
diff --git a/media/libaaudio/src/binding/AudioEndpointParcelable.cpp b/media/libaaudio/src/binding/AudioEndpointParcelable.cpp
index aa4ac27..dea3e4a 100644
--- a/media/libaaudio/src/binding/AudioEndpointParcelable.cpp
+++ b/media/libaaudio/src/binding/AudioEndpointParcelable.cpp
@@ -29,17 +29,15 @@
#include "binding/AudioEndpointParcelable.h"
using android::base::unique_fd;
-using android::media::SharedFileRegion;
-using android::NO_ERROR;
using android::status_t;
using namespace aaudio;
AudioEndpointParcelable::AudioEndpointParcelable(Endpoint&& parcelable)
- : mUpMessageQueueParcelable(std::move(parcelable.upMessageQueueParcelable)),
- mDownMessageQueueParcelable(std::move(parcelable.downMessageQueueParcelable)),
- mUpDataQueueParcelable(std::move(parcelable.upDataQueueParcelable)),
- mDownDataQueueParcelable(std::move(parcelable.downDataQueueParcelable)),
+ : mUpMessageQueueParcelable(parcelable.upMessageQueueParcelable),
+ mDownMessageQueueParcelable(parcelable.downMessageQueueParcelable),
+ mUpDataQueueParcelable(parcelable.upDataQueueParcelable),
+ mDownDataQueueParcelable(parcelable.downDataQueueParcelable),
mNumSharedMemories(parcelable.sharedMemories.size()) {
for (size_t i = 0; i < parcelable.sharedMemories.size() && i < MAX_SHARED_MEMORIES; ++i) {
// Re-construct.
@@ -56,10 +54,10 @@
Endpoint AudioEndpointParcelable::parcelable()&& {
Endpoint result;
- result.upMessageQueueParcelable = std::move(mUpMessageQueueParcelable).parcelable();
- result.downMessageQueueParcelable = std::move(mDownMessageQueueParcelable).parcelable();
- result.upDataQueueParcelable = std::move(mUpDataQueueParcelable).parcelable();
- result.downDataQueueParcelable = std::move(mDownDataQueueParcelable).parcelable();
+ result.upMessageQueueParcelable = mUpMessageQueueParcelable.parcelable();
+ result.downMessageQueueParcelable = mDownMessageQueueParcelable.parcelable();
+ result.upDataQueueParcelable = mUpDataQueueParcelable.parcelable();
+ result.downDataQueueParcelable = mDownDataQueueParcelable.parcelable();
result.sharedMemories.reserve(std::min(mNumSharedMemories, MAX_SHARED_MEMORIES));
for (size_t i = 0; i < mNumSharedMemories && i < MAX_SHARED_MEMORIES; ++i) {
result.sharedMemories.emplace_back(std::move(mSharedMemories[i]).parcelable());
diff --git a/media/libaaudio/src/binding/AudioEndpointParcelable.h b/media/libaaudio/src/binding/AudioEndpointParcelable.h
index 5237a1a..544aa92 100644
--- a/media/libaaudio/src/binding/AudioEndpointParcelable.h
+++ b/media/libaaudio/src/binding/AudioEndpointParcelable.h
@@ -43,7 +43,7 @@
// Ctor/assignment from a parcelable representation.
// Since the parcelable object owns unique FDs (for shared memory blocks), move semantics are
// provided to avoid the need to dupe.
- AudioEndpointParcelable(Endpoint&& parcelable);
+ explicit AudioEndpointParcelable(Endpoint&& parcelable);
AudioEndpointParcelable& operator=(Endpoint&& parcelable);
/**
diff --git a/media/libaaudio/src/binding/RingBufferParcelable.cpp b/media/libaaudio/src/binding/RingBufferParcelable.cpp
index a4b3cec..fa7ca72 100644
--- a/media/libaaudio/src/binding/RingBufferParcelable.cpp
+++ b/media/libaaudio/src/binding/RingBufferParcelable.cpp
@@ -30,9 +30,9 @@
using namespace aaudio;
RingBufferParcelable::RingBufferParcelable(const RingBuffer& parcelable)
- : mReadCounterParcelable(std::move(parcelable.readCounterParcelable)),
- mWriteCounterParcelable(std::move(parcelable.writeCounterParcelable)),
- mDataParcelable(std::move(parcelable.dataParcelable)),
+ : mReadCounterParcelable(parcelable.readCounterParcelable),
+ mWriteCounterParcelable(parcelable.writeCounterParcelable),
+ mDataParcelable(parcelable.dataParcelable),
mBytesPerFrame(parcelable.bytesPerFrame),
mFramesPerBurst(parcelable.framesPerBurst),
mCapacityInFrames(parcelable.capacityInFrames),
@@ -42,9 +42,9 @@
RingBuffer RingBufferParcelable::parcelable() const {
RingBuffer result;
- result.readCounterParcelable = std::move(mReadCounterParcelable).parcelable();
- result.writeCounterParcelable = std::move(mWriteCounterParcelable).parcelable();
- result.dataParcelable = std::move(mDataParcelable).parcelable();
+ result.readCounterParcelable = mReadCounterParcelable.parcelable();
+ result.writeCounterParcelable = mWriteCounterParcelable.parcelable();
+ result.dataParcelable = mDataParcelable.parcelable();
result.bytesPerFrame = mBytesPerFrame;
result.framesPerBurst = mFramesPerBurst;
result.capacityInFrames = mCapacityInFrames;
diff --git a/media/libaaudio/src/binding/SharedMemoryParcelable.cpp b/media/libaaudio/src/binding/SharedMemoryParcelable.cpp
index eef238f..3a49655 100644
--- a/media/libaaudio/src/binding/SharedMemoryParcelable.cpp
+++ b/media/libaaudio/src/binding/SharedMemoryParcelable.cpp
@@ -32,7 +32,6 @@
#include "binding/SharedMemoryParcelable.h"
using android::base::unique_fd;
-using android::NO_ERROR;
using android::status_t;
using android::media::SharedFileRegion;
@@ -78,7 +77,7 @@
}
aaudio_result_t SharedMemoryParcelable::resolveSharedMemory(const unique_fd& fd) {
- mResolvedAddress = (uint8_t *) mmap(0, mSizeInBytes, PROT_READ | PROT_WRITE,
+ mResolvedAddress = (uint8_t *) mmap(nullptr, mSizeInBytes, PROT_READ | PROT_WRITE,
MAP_SHARED, fd.get(), 0);
if (mResolvedAddress == MMAP_UNRESOLVED_ADDRESS) {
ALOGE("mmap() failed for fd = %d, nBytes = %" PRId64 ", errno = %s",
diff --git a/media/libaaudio/src/binding/SharedRegionParcelable.cpp b/media/libaaudio/src/binding/SharedRegionParcelable.cpp
index 56b99c0..6fa109b 100644
--- a/media/libaaudio/src/binding/SharedRegionParcelable.cpp
+++ b/media/libaaudio/src/binding/SharedRegionParcelable.cpp
@@ -29,10 +29,7 @@
#include "binding/SharedMemoryParcelable.h"
#include "binding/SharedRegionParcelable.h"
-using android::NO_ERROR;
using android::status_t;
-using android::Parcel;
-using android::Parcelable;
using namespace aaudio;
diff --git a/media/libaaudio/src/binding/aidl/aaudio/StreamParameters.aidl b/media/libaaudio/src/binding/aidl/aaudio/StreamParameters.aidl
index 1a971b0..3b274f2 100644
--- a/media/libaaudio/src/binding/aidl/aaudio/StreamParameters.aidl
+++ b/media/libaaudio/src/binding/aidl/aaudio/StreamParameters.aidl
@@ -16,14 +16,14 @@
package aaudio;
-import android.media.audio.common.AudioFormat;
+import android.media.AudioFormatDescription;
parcelable StreamParameters {
int channelMask; // = AAUDIO_UNSPECIFIED;
int sampleRate; // = AAUDIO_UNSPECIFIED;
int deviceId; // = AAUDIO_UNSPECIFIED;
int /* aaudio_sharing_mode_t */ sharingMode; // = AAUDIO_SHARING_MODE_SHARED;
- AudioFormat audioFormat; // = AUDIO_FORMAT_DEFAULT;
+ AudioFormatDescription audioFormat; // = AUDIO_FORMAT_DEFAULT;
int /* aaudio_direction_t */ direction; // = AAUDIO_DIRECTION_OUTPUT;
int /* aaudio_usage_t */ usage; // = AAUDIO_UNSPECIFIED;
int /* aaudio_content_type_t */ contentType; // = AAUDIO_UNSPECIFIED;
diff --git a/media/libaaudio/src/client/AudioEndpoint.cpp b/media/libaaudio/src/client/AudioEndpoint.cpp
index ebc9f2b..24888de 100644
--- a/media/libaaudio/src/client/AudioEndpoint.cpp
+++ b/media/libaaudio/src/client/AudioEndpoint.cpp
@@ -31,13 +31,6 @@
#define RIDICULOUSLY_LARGE_BUFFER_CAPACITY (256 * 1024)
#define RIDICULOUSLY_LARGE_FRAME_SIZE 4096
-AudioEndpoint::AudioEndpoint()
- : mFreeRunning(false)
- , mDataReadCounter(0)
- , mDataWriteCounter(0)
-{
-}
-
// TODO Consider moving to a method in RingBufferDescriptor
static aaudio_result_t AudioEndpoint_validateQueueDescriptor(const char *type,
const RingBufferDescriptor *descriptor) {
diff --git a/media/libaaudio/src/client/AudioEndpoint.h b/media/libaaudio/src/client/AudioEndpoint.h
index 4c8d60f..b3dbc20 100644
--- a/media/libaaudio/src/client/AudioEndpoint.h
+++ b/media/libaaudio/src/client/AudioEndpoint.h
@@ -34,7 +34,7 @@
class AudioEndpoint {
public:
- AudioEndpoint();
+ AudioEndpoint() = default;
/**
* Configure based on the EndPointDescriptor_t.
@@ -95,9 +95,9 @@
private:
std::unique_ptr<android::FifoBufferIndirect> mUpCommandQueue;
std::unique_ptr<android::FifoBufferIndirect> mDataQueue;
- bool mFreeRunning;
- android::fifo_counter_t mDataReadCounter; // only used if free-running
- android::fifo_counter_t mDataWriteCounter; // only used if free-running
+ bool mFreeRunning{false};
+ android::fifo_counter_t mDataReadCounter{0}; // only used if free-running
+ android::fifo_counter_t mDataWriteCounter{0}; // only used if free-running
};
} // namespace aaudio
diff --git a/media/libaaudio/src/client/AudioStreamInternal.cpp b/media/libaaudio/src/client/AudioStreamInternal.cpp
index 3063a7b..8284be5 100644
--- a/media/libaaudio/src/client/AudioStreamInternal.cpp
+++ b/media/libaaudio/src/client/AudioStreamInternal.cpp
@@ -49,8 +49,6 @@
// This is needed to make sense of the logs more easily.
#define LOG_TAG (mInService ? "AudioStreamInternal_Service" : "AudioStreamInternal_Client")
-using android::Mutex;
-using android::WrappingBuffer;
using android::content::AttributionSourceState;
using namespace aaudio;
@@ -334,10 +332,10 @@
{
AudioStreamInternal *stream = (AudioStreamInternal *)context;
//LOGD("oboe_callback_thread, stream = %p", stream);
- if (stream != NULL) {
+ if (stream != nullptr) {
return stream->callbackLoop();
} else {
- return NULL;
+ return nullptr;
}
}
@@ -426,7 +424,7 @@
if (isDataCallbackSet()
&& (isActive() || getState() == AAUDIO_STREAM_STATE_DISCONNECTED)) {
mCallbackEnabled.store(false);
- aaudio_result_t result = joinThread_l(NULL); // may temporarily unlock mStreamLock
+ aaudio_result_t result = joinThread_l(nullptr); // may temporarily unlock mStreamLock
if (result == AAUDIO_ERROR_INVALID_HANDLE) {
ALOGD("%s() INVALID_HANDLE, stream was probably stolen", __func__);
result = AAUDIO_OK;
@@ -513,7 +511,7 @@
return result;
}
-aaudio_result_t AudioStreamInternal::getTimestamp(clockid_t clockId,
+aaudio_result_t AudioStreamInternal::getTimestamp(clockid_t /*clockId*/,
int64_t *framePosition,
int64_t *timeNanoseconds) {
// Generated in server and passed to client. Return latest.
diff --git a/media/libaaudio/src/client/AudioStreamInternal.h b/media/libaaudio/src/client/AudioStreamInternal.h
index fbe4c13..eab1382 100644
--- a/media/libaaudio/src/client/AudioStreamInternal.h
+++ b/media/libaaudio/src/client/AudioStreamInternal.h
@@ -116,7 +116,7 @@
virtual void prepareBuffersForStart() {}
- virtual void advanceClientToMatchServerPosition(int32_t serverMargin = 0) = 0;
+ virtual void advanceClientToMatchServerPosition(int32_t serverMargin) = 0;
virtual void onFlushFromServer() {}
diff --git a/media/libaaudio/src/client/AudioStreamInternalCapture.cpp b/media/libaaudio/src/client/AudioStreamInternalCapture.cpp
index 2da5406..1efccb1 100644
--- a/media/libaaudio/src/client/AudioStreamInternalCapture.cpp
+++ b/media/libaaudio/src/client/AudioStreamInternalCapture.cpp
@@ -46,8 +46,6 @@
}
-AudioStreamInternalCapture::~AudioStreamInternalCapture() {}
-
void AudioStreamInternalCapture::advanceClientToMatchServerPosition(int32_t serverMargin) {
int64_t readCounter = mAudioEndpoint->getDataReadCounter();
int64_t writeCounter = mAudioEndpoint->getDataWriteCounter() + serverMargin;
@@ -109,7 +107,7 @@
if (mNeedCatchUp.isRequested()) {
// Catch an MMAP pointer that is already advancing.
// This will avoid initial underruns caused by a slow cold start.
- advanceClientToMatchServerPosition();
+ advanceClientToMatchServerPosition(0 /*serverMargin*/);
mNeedCatchUp.acknowledge();
}
@@ -228,7 +226,7 @@
void *AudioStreamInternalCapture::callbackLoop() {
aaudio_result_t result = AAUDIO_OK;
aaudio_data_callback_result_t callbackResult = AAUDIO_CALLBACK_RESULT_CONTINUE;
- if (!isDataCallbackSet()) return NULL;
+ if (!isDataCallbackSet()) return nullptr;
// result might be a frame count
while (mCallbackEnabled.load() && isActive() && (result >= 0)) {
@@ -260,5 +258,5 @@
ALOGD("callbackLoop() exiting, result = %d, isActive() = %d",
result, (int) isActive());
- return NULL;
+ return nullptr;
}
diff --git a/media/libaaudio/src/client/AudioStreamInternalCapture.h b/media/libaaudio/src/client/AudioStreamInternalCapture.h
index 251a7f2..87017de 100644
--- a/media/libaaudio/src/client/AudioStreamInternalCapture.h
+++ b/media/libaaudio/src/client/AudioStreamInternalCapture.h
@@ -28,8 +28,9 @@
class AudioStreamInternalCapture : public AudioStreamInternal {
public:
- AudioStreamInternalCapture(AAudioServiceInterface &serviceInterface, bool inService = false);
- virtual ~AudioStreamInternalCapture();
+ explicit AudioStreamInternalCapture(AAudioServiceInterface &serviceInterface,
+ bool inService = false);
+ virtual ~AudioStreamInternalCapture() = default;
aaudio_result_t read(void *buffer,
int32_t numFrames,
@@ -45,7 +46,7 @@
}
protected:
- void advanceClientToMatchServerPosition(int32_t serverOffset = 0) override;
+ void advanceClientToMatchServerPosition(int32_t serverOffset) override;
/**
* Low level data processing that will not block. It will just read or write as much as it can.
diff --git a/media/libaaudio/src/client/AudioStreamInternalPlay.cpp b/media/libaaudio/src/client/AudioStreamInternalPlay.cpp
index 71bde90..5921799 100644
--- a/media/libaaudio/src/client/AudioStreamInternalPlay.cpp
+++ b/media/libaaudio/src/client/AudioStreamInternalPlay.cpp
@@ -44,8 +44,6 @@
}
-AudioStreamInternalPlay::~AudioStreamInternalPlay() {}
-
constexpr int kRampMSec = 10; // time to apply a change in volume
aaudio_result_t AudioStreamInternalPlay::open(const AudioStreamBuilder &builder) {
@@ -115,7 +113,7 @@
}
void AudioStreamInternalPlay::onFlushFromServer() {
- advanceClientToMatchServerPosition();
+ advanceClientToMatchServerPosition(0 /*serverMargin*/);
}
// Write the data, block if needed and timeoutMillis > 0
@@ -281,7 +279,7 @@
ALOGD("%s() entering >>>>>>>>>>>>>>>", __func__);
aaudio_result_t result = AAUDIO_OK;
aaudio_data_callback_result_t callbackResult = AAUDIO_CALLBACK_RESULT_CONTINUE;
- if (!isDataCallbackSet()) return NULL;
+ if (!isDataCallbackSet()) return nullptr;
int64_t timeoutNanos = calculateReasonableTimeout(mCallbackFrames);
// result might be a frame count
@@ -309,7 +307,7 @@
ALOGD("%s() exiting, result = %d, isActive() = %d <<<<<<<<<<<<<<",
__func__, result, (int) isActive());
- return NULL;
+ return nullptr;
}
//------------------------------------------------------------------------------
diff --git a/media/libaaudio/src/client/AudioStreamInternalPlay.h b/media/libaaudio/src/client/AudioStreamInternalPlay.h
index 03c957d..e761807 100644
--- a/media/libaaudio/src/client/AudioStreamInternalPlay.h
+++ b/media/libaaudio/src/client/AudioStreamInternalPlay.h
@@ -30,8 +30,9 @@
class AudioStreamInternalPlay : public AudioStreamInternal {
public:
- AudioStreamInternalPlay(AAudioServiceInterface &serviceInterface, bool inService = false);
- virtual ~AudioStreamInternalPlay();
+ explicit AudioStreamInternalPlay(AAudioServiceInterface &serviceInterface,
+ bool inService = false);
+ virtual ~AudioStreamInternalPlay() = default;
aaudio_result_t open(const AudioStreamBuilder &builder) override;
@@ -66,7 +67,7 @@
void prepareBuffersForStart() override;
- void advanceClientToMatchServerPosition(int32_t serverMargin = 0) override;
+ void advanceClientToMatchServerPosition(int32_t serverMargin) override;
void onFlushFromServer() override;
diff --git a/media/libaaudio/src/client/IsochronousClockModel.cpp b/media/libaaudio/src/client/IsochronousClockModel.cpp
index f0dcd44..6921271 100644
--- a/media/libaaudio/src/client/IsochronousClockModel.cpp
+++ b/media/libaaudio/src/client/IsochronousClockModel.cpp
@@ -43,14 +43,7 @@
// and dumped to the log when the stream is stopped.
IsochronousClockModel::IsochronousClockModel()
- : mMarkerFramePosition(0)
- , mMarkerNanoTime(0)
- , mSampleRate(48000)
- , mFramesPerBurst(48)
- , mBurstPeriodNanos(0) // this will be updated before use
- , mMaxMeasuredLatenessNanos(0)
- , mLatenessForDriftNanos(kInitialLatenessForDriftNanos)
- , mState(STATE_STOPPED)
+ : mLatenessForDriftNanos(kInitialLatenessForDriftNanos)
{
if ((AAudioProperty_getLogMask() & AAUDIO_LOG_CLOCK_MODEL_HISTOGRAM) != 0) {
mHistogramMicros = std::make_unique<Histogram>(kHistogramBinCount,
diff --git a/media/libaaudio/src/client/IsochronousClockModel.h b/media/libaaudio/src/client/IsochronousClockModel.h
index 6280013..3007237 100644
--- a/media/libaaudio/src/client/IsochronousClockModel.h
+++ b/media/libaaudio/src/client/IsochronousClockModel.h
@@ -149,16 +149,16 @@
static constexpr int32_t kHistogramBinWidthMicros = 50;
static constexpr int32_t kHistogramBinCount = 128;
- int64_t mMarkerFramePosition; // Estimated HW position.
- int64_t mMarkerNanoTime; // Estimated HW time.
- int32_t mSampleRate;
- int32_t mFramesPerBurst; // number of frames transferred at one time.
- int32_t mBurstPeriodNanos; // Time between HW bursts.
+ int64_t mMarkerFramePosition{0}; // Estimated HW position.
+ int64_t mMarkerNanoTime{0}; // Estimated HW time.
+ int32_t mSampleRate{48000};
+ int32_t mFramesPerBurst{48}; // number of frames transferred at one time.
+ int32_t mBurstPeriodNanos{0}; // Time between HW bursts.
// Includes mBurstPeriodNanos because we sample randomly over time.
- int32_t mMaxMeasuredLatenessNanos;
+ int32_t mMaxMeasuredLatenessNanos{0};
// Threshold for lateness that triggers a drift later in time.
int32_t mLatenessForDriftNanos;
- clock_model_state_t mState; // State machine handles startup sequence.
+ clock_model_state_t mState{STATE_STOPPED}; // State machine handles startup sequence.
int32_t mTimestampCount = 0; // For logging.
diff --git a/media/libaaudio/src/core/AAudioStreamParameters.cpp b/media/libaaudio/src/core/AAudioStreamParameters.cpp
index 59d94eb..84133f4 100644
--- a/media/libaaudio/src/core/AAudioStreamParameters.cpp
+++ b/media/libaaudio/src/core/AAudioStreamParameters.cpp
@@ -30,9 +30,6 @@
// HDMI supports up to 32 channels at 1536000 Hz.
#define SAMPLE_RATE_HZ_MAX 1600000
-AAudioStreamParameters::AAudioStreamParameters() {}
-AAudioStreamParameters::~AAudioStreamParameters() {}
-
void AAudioStreamParameters::copyFrom(const AAudioStreamParameters &other) {
mSamplesPerFrame = other.mSamplesPerFrame;
mSampleRate = other.mSampleRate;
diff --git a/media/libaaudio/src/core/AAudioStreamParameters.h b/media/libaaudio/src/core/AAudioStreamParameters.h
index a5c8043..7a6ed3e 100644
--- a/media/libaaudio/src/core/AAudioStreamParameters.h
+++ b/media/libaaudio/src/core/AAudioStreamParameters.h
@@ -26,8 +26,8 @@
class AAudioStreamParameters {
public:
- AAudioStreamParameters();
- virtual ~AAudioStreamParameters();
+ AAudioStreamParameters() = default;
+ virtual ~AAudioStreamParameters() = default;
int32_t getDeviceId() const {
return mDeviceId;
@@ -134,7 +134,7 @@
}
// TODO b/182392769: reexamine if Identity can be used
- void setOpPackageName(const std::optional<std::string> opPackageName) {
+ void setOpPackageName(const std::optional<std::string>& opPackageName) {
mOpPackageName = opPackageName;
}
@@ -142,7 +142,7 @@
return mAttributionTag;
}
- void setAttributionTag(const std::optional<std::string> attributionTag) {
+ void setAttributionTag(const std::optional<std::string>& attributionTag) {
mAttributionTag = attributionTag;
}
diff --git a/media/libaaudio/src/core/AudioGlobal.h b/media/libaaudio/src/core/AudioGlobal.h
index 1e88d15..6c22744 100644
--- a/media/libaaudio/src/core/AudioGlobal.h
+++ b/media/libaaudio/src/core/AudioGlobal.h
@@ -31,7 +31,8 @@
const char* AudioGlobal_convertResultToText(aaudio_result_t returnCode);
const char* AudioGlobal_convertSharingModeToText(aaudio_sharing_mode_t mode);
const char* AudioGlobal_convertStreamStateToText(aaudio_stream_state_t state);
-}
+
+} // namespace aaudio
#endif // AAUDIO_AUDIOGLOBAL_H
diff --git a/media/libaaudio/src/core/AudioStream.h b/media/libaaudio/src/core/AudioStream.h
index 47693f8..8bb9b19 100644
--- a/media/libaaudio/src/core/AudioStream.h
+++ b/media/libaaudio/src/core/AudioStream.h
@@ -439,7 +439,7 @@
// PlayerBase allows the system to control the stream volume.
class MyPlayerBase : public android::PlayerBase {
public:
- MyPlayerBase() {};
+ MyPlayerBase() = default;
virtual ~MyPlayerBase() = default;
@@ -568,7 +568,7 @@
* @param numFrames
* @return original pointer or the conversion buffer
*/
- virtual const void * maybeConvertDeviceData(const void *audioData, int32_t numFrames) {
+ virtual const void * maybeConvertDeviceData(const void *audioData, int32_t /*numFrames*/) {
return audioData;
}
diff --git a/media/libaaudio/src/core/AudioStreamBuilder.cpp b/media/libaaudio/src/core/AudioStreamBuilder.cpp
index 5e1e007..a8fd0d9 100644
--- a/media/libaaudio/src/core/AudioStreamBuilder.cpp
+++ b/media/libaaudio/src/core/AudioStreamBuilder.cpp
@@ -53,16 +53,10 @@
/*
* AudioStreamBuilder
*/
-AudioStreamBuilder::AudioStreamBuilder() {
-}
-
-AudioStreamBuilder::~AudioStreamBuilder() {
-}
-
static aaudio_result_t builder_createStream(aaudio_direction_t direction,
- aaudio_sharing_mode_t sharingMode,
- bool tryMMap,
- android::sp<AudioStream> &stream) {
+ aaudio_sharing_mode_t /*sharingMode*/,
+ bool tryMMap,
+ android::sp<AudioStream> &stream) {
aaudio_result_t result = AAUDIO_OK;
switch (direction) {
diff --git a/media/libaaudio/src/core/AudioStreamBuilder.h b/media/libaaudio/src/core/AudioStreamBuilder.h
index 9f93341..f91c25a 100644
--- a/media/libaaudio/src/core/AudioStreamBuilder.h
+++ b/media/libaaudio/src/core/AudioStreamBuilder.h
@@ -31,9 +31,9 @@
*/
class AudioStreamBuilder : public AAudioStreamParameters {
public:
- AudioStreamBuilder();
+ AudioStreamBuilder() = default;
- ~AudioStreamBuilder();
+ ~AudioStreamBuilder() = default;
bool isSharingModeMatchRequired() const {
return mSharingModeMatchRequired;
diff --git a/media/libaaudio/src/fifo/FifoBuffer.h b/media/libaaudio/src/fifo/FifoBuffer.h
index 37548f0..7b0aca1 100644
--- a/media/libaaudio/src/fifo/FifoBuffer.h
+++ b/media/libaaudio/src/fifo/FifoBuffer.h
@@ -38,7 +38,7 @@
class FifoBuffer {
public:
- FifoBuffer(int32_t bytesPerFrame);
+ explicit FifoBuffer(int32_t bytesPerFrame);
virtual ~FifoBuffer() = default;
@@ -162,6 +162,6 @@
uint8_t *mExternalStorage = nullptr;
};
-} // android
+} // namespace android
#endif //FIFO_FIFO_BUFFER_H
diff --git a/media/libaaudio/src/fifo/FifoController.h b/media/libaaudio/src/fifo/FifoController.h
index 057a94e..e15d444 100644
--- a/media/libaaudio/src/fifo/FifoController.h
+++ b/media/libaaudio/src/fifo/FifoController.h
@@ -36,7 +36,7 @@
, mWriteCounter(0)
{}
- virtual ~FifoController() {}
+ virtual ~FifoController() = default;
// TODO review use of memory barriers, probably incorrect
virtual fifo_counter_t getReadCounter() override {
@@ -57,6 +57,6 @@
std::atomic<fifo_counter_t> mWriteCounter;
};
-} // android
+} // namespace android
#endif //FIFO_FIFO_CONTROLLER_H
diff --git a/media/libaaudio/src/fifo/FifoControllerBase.cpp b/media/libaaudio/src/fifo/FifoControllerBase.cpp
index 1dece0e..ad6d041 100644
--- a/media/libaaudio/src/fifo/FifoControllerBase.cpp
+++ b/media/libaaudio/src/fifo/FifoControllerBase.cpp
@@ -29,9 +29,6 @@
{
}
-FifoControllerBase::~FifoControllerBase() {
-}
-
fifo_frames_t FifoControllerBase::getFullFramesAvailable() {
fifo_frames_t temp = 0;
__builtin_sub_overflow(getWriteCounter(), getReadCounter(), &temp);
diff --git a/media/libaaudio/src/fifo/FifoControllerBase.h b/media/libaaudio/src/fifo/FifoControllerBase.h
index 1edb8a3..2a6173b 100644
--- a/media/libaaudio/src/fifo/FifoControllerBase.h
+++ b/media/libaaudio/src/fifo/FifoControllerBase.h
@@ -43,7 +43,7 @@
*/
FifoControllerBase(fifo_frames_t capacity, fifo_frames_t threshold);
- virtual ~FifoControllerBase();
+ virtual ~FifoControllerBase() = default;
// Abstract methods to be implemented in subclasses.
/**
@@ -123,6 +123,6 @@
fifo_frames_t mThreshold;
};
-} // android
+} // namespace android
#endif // FIFO_FIFO_CONTROLLER_BASE_H
diff --git a/media/libaaudio/src/fifo/FifoControllerIndirect.h b/media/libaaudio/src/fifo/FifoControllerIndirect.h
index ec48e57..a59225a 100644
--- a/media/libaaudio/src/fifo/FifoControllerIndirect.h
+++ b/media/libaaudio/src/fifo/FifoControllerIndirect.h
@@ -44,7 +44,7 @@
setReadCounter(0);
setWriteCounter(0);
}
- virtual ~FifoControllerIndirect() {};
+ virtual ~FifoControllerIndirect() = default;
// TODO review use of memory barriers, probably incorrect
virtual fifo_counter_t getReadCounter() override {
@@ -68,6 +68,6 @@
std::atomic<fifo_counter_t> * mWriteCounterAddress;
};
-} // android
+} // namespace android
#endif //FIFO_FIFO_CONTROLLER_INDIRECT_H
diff --git a/media/libaaudio/src/flowgraph/AudioProcessorBase.cpp b/media/libaaudio/src/flowgraph/AudioProcessorBase.cpp
index 5667fdb..d8ffd00 100644
--- a/media/libaaudio/src/flowgraph/AudioProcessorBase.cpp
+++ b/media/libaaudio/src/flowgraph/AudioProcessorBase.cpp
@@ -34,8 +34,7 @@
int32_t samplesPerFrame,
int32_t framesPerBlock)
: AudioPort(parent, samplesPerFrame)
- , mFramesPerBlock(framesPerBlock)
- , mSampleBlock(NULL) {
+ , mFramesPerBlock(framesPerBlock) {
int32_t numFloats = framesPerBlock * getSamplesPerFrame();
mSampleBlock = new float[numFloats]{0.0f};
}
@@ -61,13 +60,13 @@
/***************************************************************************/
int32_t AudioFloatInputPort::pullData(int64_t framePosition, int32_t numFrames) {
- return (mConnected == NULL)
+ return (mConnected == nullptr)
? std::min(getFramesPerBlock(), numFrames)
: mConnected->pullData(framePosition, numFrames);
}
float *AudioFloatInputPort::getBlock() {
- if (mConnected == NULL) {
+ if (mConnected == nullptr) {
return AudioFloatBlockPort::getBlock(); // loaded using setValue()
} else {
return mConnected->getBlock();
diff --git a/media/libaaudio/src/flowgraph/MonoToMultiConverter.cpp b/media/libaaudio/src/flowgraph/MonoToMultiConverter.cpp
index 78aad52..c6fcac6 100644
--- a/media/libaaudio/src/flowgraph/MonoToMultiConverter.cpp
+++ b/media/libaaudio/src/flowgraph/MonoToMultiConverter.cpp
@@ -26,8 +26,6 @@
, output(*this, channelCount) {
}
-MonoToMultiConverter::~MonoToMultiConverter() { }
-
int32_t MonoToMultiConverter::onProcess(int64_t framePosition, int32_t numFrames) {
int32_t framesToProcess = input.pullData(framePosition, numFrames);
diff --git a/media/libaaudio/src/flowgraph/MonoToMultiConverter.h b/media/libaaudio/src/flowgraph/MonoToMultiConverter.h
index 34d53c7..5058ae0 100644
--- a/media/libaaudio/src/flowgraph/MonoToMultiConverter.h
+++ b/media/libaaudio/src/flowgraph/MonoToMultiConverter.h
@@ -29,7 +29,7 @@
public:
explicit MonoToMultiConverter(int32_t channelCount);
- virtual ~MonoToMultiConverter();
+ virtual ~MonoToMultiConverter() = default;
int32_t onProcess(int64_t framePosition, int32_t numFrames) override;
diff --git a/media/libaaudio/src/flowgraph/RampLinear.cpp b/media/libaaudio/src/flowgraph/RampLinear.cpp
index a260828..0cc32e5 100644
--- a/media/libaaudio/src/flowgraph/RampLinear.cpp
+++ b/media/libaaudio/src/flowgraph/RampLinear.cpp
@@ -37,6 +37,10 @@
void RampLinear::setTarget(float target) {
mTarget.store(target);
+ // If the ramp has not been used then start immediately at this level.
+ if (mLastFramePosition < 0) {
+ forceCurrent(target);
+ }
}
float RampLinear::interpolateCurrent() {
diff --git a/media/libaaudio/src/flowgraph/SourceFloat.cpp b/media/libaaudio/src/flowgraph/SourceFloat.cpp
index 4bb674f..5b3a51e 100644
--- a/media/libaaudio/src/flowgraph/SourceFloat.cpp
+++ b/media/libaaudio/src/flowgraph/SourceFloat.cpp
@@ -25,7 +25,7 @@
: AudioSource(channelCount) {
}
-int32_t SourceFloat::onProcess(int64_t framePosition, int32_t numFrames) {
+int32_t SourceFloat::onProcess(int64_t /*framePosition*/, int32_t numFrames) {
float *outputBuffer = output.getBlock();
int32_t channelCount = output.getSamplesPerFrame();
diff --git a/media/libaaudio/src/flowgraph/SourceI16.cpp b/media/libaaudio/src/flowgraph/SourceI16.cpp
index c3fcec2..a645cc2 100644
--- a/media/libaaudio/src/flowgraph/SourceI16.cpp
+++ b/media/libaaudio/src/flowgraph/SourceI16.cpp
@@ -30,7 +30,7 @@
: AudioSource(channelCount) {
}
-int32_t SourceI16::onProcess(int64_t framePosition, int32_t numFrames) {
+int32_t SourceI16::onProcess(int64_t /*framePosition*/, int32_t numFrames) {
float *floatData = output.getBlock();
int32_t channelCount = output.getSamplesPerFrame();
diff --git a/media/libaaudio/src/flowgraph/SourceI24.cpp b/media/libaaudio/src/flowgraph/SourceI24.cpp
index 097954e..50fb98e 100644
--- a/media/libaaudio/src/flowgraph/SourceI24.cpp
+++ b/media/libaaudio/src/flowgraph/SourceI24.cpp
@@ -32,7 +32,7 @@
: AudioSource(channelCount) {
}
-int32_t SourceI24::onProcess(int64_t framePosition, int32_t numFrames) {
+int32_t SourceI24::onProcess(int64_t /*framePosition*/, int32_t numFrames) {
float *floatData = output.getBlock();
int32_t channelCount = output.getSamplesPerFrame();
diff --git a/media/libaaudio/src/flowgraph/SourceI32.cpp b/media/libaaudio/src/flowgraph/SourceI32.cpp
index e8177ad..95bfd8f 100644
--- a/media/libaaudio/src/flowgraph/SourceI32.cpp
+++ b/media/libaaudio/src/flowgraph/SourceI32.cpp
@@ -30,7 +30,7 @@
: AudioSource(channelCount) {
}
-int32_t SourceI32::onProcess(int64_t framePosition, int32_t numFrames) {
+int32_t SourceI32::onProcess(int64_t /*framePosition*/, int32_t numFrames) {
float *floatData = output.getBlock();
int32_t channelCount = output.getSamplesPerFrame();
diff --git a/media/libaaudio/src/legacy/AudioStreamLegacy.cpp b/media/libaaudio/src/legacy/AudioStreamLegacy.cpp
index e96e134..0f24771 100644
--- a/media/libaaudio/src/legacy/AudioStreamLegacy.cpp
+++ b/media/libaaudio/src/legacy/AudioStreamLegacy.cpp
@@ -37,9 +37,6 @@
: AudioStream() {
}
-AudioStreamLegacy::~AudioStreamLegacy() {
-}
-
// Called from AudioTrack.cpp or AudioRecord.cpp
static void AudioStreamLegacy_callback(int event, void* userData, void *info) {
AudioStreamLegacy *streamLegacy = (AudioStreamLegacy *) userData;
diff --git a/media/libaaudio/src/legacy/AudioStreamLegacy.h b/media/libaaudio/src/legacy/AudioStreamLegacy.h
index 88ef270..d9ba990 100644
--- a/media/libaaudio/src/legacy/AudioStreamLegacy.h
+++ b/media/libaaudio/src/legacy/AudioStreamLegacy.h
@@ -60,7 +60,7 @@
public:
AudioStreamLegacy();
- virtual ~AudioStreamLegacy();
+ virtual ~AudioStreamLegacy() = default;
aaudio_legacy_callback_t getLegacyCallback();
diff --git a/media/libaaudio/src/legacy/AudioStreamRecord.cpp b/media/libaaudio/src/legacy/AudioStreamRecord.cpp
index fe8fb19..12771cc 100644
--- a/media/libaaudio/src/legacy/AudioStreamRecord.cpp
+++ b/media/libaaudio/src/legacy/AudioStreamRecord.cpp
@@ -504,7 +504,7 @@
return (aaudio_result_t) framesRead;
}
-aaudio_result_t AudioStreamRecord::setBufferSize(int32_t requestedFrames)
+aaudio_result_t AudioStreamRecord::setBufferSize(int32_t /*requestedFrames*/)
{
return getBufferSize();
}
diff --git a/media/libaaudio/src/legacy/AudioStreamTrack.cpp b/media/libaaudio/src/legacy/AudioStreamTrack.cpp
index 2291ad7..118c004 100644
--- a/media/libaaudio/src/legacy/AudioStreamTrack.cpp
+++ b/media/libaaudio/src/legacy/AudioStreamTrack.cpp
@@ -157,11 +157,11 @@
callback,
callbackData,
notificationFrames,
- 0, // DEFAULT sharedBuffer*/,
+ nullptr, // DEFAULT sharedBuffer*/,
false, // DEFAULT threadCanCallJava
sessionId,
streamTransferType,
- NULL, // DEFAULT audio_offload_info_t
+ nullptr, // DEFAULT audio_offload_info_t
AttributionSourceState(), // DEFAULT uid and pid
&attributes,
// WARNING - If doNotReconnect set true then audio stops after plugging and unplugging
diff --git a/media/libaaudio/src/utility/AAudioUtilities.h b/media/libaaudio/src/utility/AAudioUtilities.h
index 5eda30c..52e57da 100644
--- a/media/libaaudio/src/utility/AAudioUtilities.h
+++ b/media/libaaudio/src/utility/AAudioUtilities.h
@@ -225,7 +225,7 @@
* @return true if f() eventually returns true.
*/
static inline bool AAudio_tryUntilTrue(
- std::function<bool()> f, int times, int sleepMs) {
+ const std::function<bool()>& f, int times, int sleepMs) {
static const useconds_t US_PER_MS = 1000;
sleepMs = std::max(sleepMs, 0);
@@ -297,9 +297,7 @@
class Timestamp {
public:
- Timestamp()
- : mPosition(0)
- , mNanoseconds(0) {}
+ Timestamp() = default;
Timestamp(int64_t position, int64_t nanoseconds)
: mPosition(position)
, mNanoseconds(nanoseconds) {}
@@ -310,8 +308,8 @@
private:
// These cannot be const because we need to implement the copy assignment operator.
- int64_t mPosition;
- int64_t mNanoseconds;
+ int64_t mPosition{0};
+ int64_t mNanoseconds{0};
};
diff --git a/media/libaaudio/src/utility/FixedBlockAdapter.h b/media/libaaudio/src/utility/FixedBlockAdapter.h
index 4dc7e68..290e473 100644
--- a/media/libaaudio/src/utility/FixedBlockAdapter.h
+++ b/media/libaaudio/src/utility/FixedBlockAdapter.h
@@ -35,7 +35,7 @@
class FixedBlockAdapter
{
public:
- FixedBlockAdapter(FixedBlockProcessor &fixedBlockProcessor)
+ explicit FixedBlockAdapter(FixedBlockProcessor &fixedBlockProcessor)
: mFixedBlockProcessor(fixedBlockProcessor) {}
virtual ~FixedBlockAdapter() = default;
diff --git a/media/libaaudio/src/utility/FixedBlockReader.h b/media/libaaudio/src/utility/FixedBlockReader.h
index 128dd52..dc82416 100644
--- a/media/libaaudio/src/utility/FixedBlockReader.h
+++ b/media/libaaudio/src/utility/FixedBlockReader.h
@@ -30,7 +30,7 @@
class FixedBlockReader : public FixedBlockAdapter
{
public:
- FixedBlockReader(FixedBlockProcessor &fixedBlockProcessor);
+ explicit FixedBlockReader(FixedBlockProcessor &fixedBlockProcessor);
virtual ~FixedBlockReader() = default;
diff --git a/media/libaaudio/src/utility/FixedBlockWriter.h b/media/libaaudio/src/utility/FixedBlockWriter.h
index f1d917c..3e89b5d 100644
--- a/media/libaaudio/src/utility/FixedBlockWriter.h
+++ b/media/libaaudio/src/utility/FixedBlockWriter.h
@@ -28,7 +28,7 @@
class FixedBlockWriter : public FixedBlockAdapter
{
public:
- FixedBlockWriter(FixedBlockProcessor &fixedBlockProcessor);
+ explicit FixedBlockWriter(FixedBlockProcessor &fixedBlockProcessor);
virtual ~FixedBlockWriter() = default;
diff --git a/media/libaaudio/src/utility/MonotonicCounter.h b/media/libaaudio/src/utility/MonotonicCounter.h
index 63add4e..313ccbd 100644
--- a/media/libaaudio/src/utility/MonotonicCounter.h
+++ b/media/libaaudio/src/utility/MonotonicCounter.h
@@ -30,8 +30,8 @@
class MonotonicCounter {
public:
- MonotonicCounter() {};
- virtual ~MonotonicCounter() {};
+ MonotonicCounter() = default;
+ virtual ~MonotonicCounter() = default;
/**
* @return current value of the counter
diff --git a/media/libaaudio/tests/test_flowgraph.cpp b/media/libaaudio/tests/test_flowgraph.cpp
index d563a7e..611cbf7 100644
--- a/media/libaaudio/tests/test_flowgraph.cpp
+++ b/media/libaaudio/tests/test_flowgraph.cpp
@@ -76,31 +76,40 @@
}
TEST(test_flowgraph, module_ramp_linear) {
+ constexpr int singleNumOutput = 1;
constexpr int rampSize = 5;
constexpr int numOutput = 100;
constexpr float value = 1.0f;
- constexpr float target = 100.0f;
+ constexpr float initialTarget = 10.0f;
+ constexpr float finalTarget = 100.0f;
+ constexpr float tolerance = 0.0001f; // arbitrary
float output[numOutput] = {};
RampLinear rampLinear{1};
SinkFloat sinkFloat{1};
rampLinear.input.setValue(value);
rampLinear.setLengthInFrames(rampSize);
- rampLinear.setTarget(target);
- rampLinear.forceCurrent(0.0f);
-
rampLinear.output.connect(&sinkFloat.input);
+ // Check that the values go to the initial target instantly.
+ rampLinear.setTarget(initialTarget);
+ int32_t singleNumRead = sinkFloat.read(output, singleNumOutput);
+ ASSERT_EQ(singleNumRead, singleNumOutput);
+ EXPECT_NEAR(value * initialTarget, output[0], tolerance);
+
+ // Now set target and check that the linear ramp works as expected.
+ rampLinear.setTarget(finalTarget);
int32_t numRead = sinkFloat.read(output, numOutput);
+ const float incrementSize = (finalTarget - initialTarget) / rampSize;
ASSERT_EQ(numOutput, numRead);
- constexpr float tolerance = 0.0001f; // arbitrary
+
int i = 0;
for (; i < rampSize; i++) {
- float expected = i * value * target / rampSize;
+ float expected = value * (initialTarget + i * incrementSize);
EXPECT_NEAR(expected, output[i], tolerance);
}
for (; i < numOutput; i++) {
- float expected = value * target;
+ float expected = value * finalTarget;
EXPECT_NEAR(expected, output[i], tolerance);
}
}
diff --git a/media/libaudioclient/AidlConversion.cpp b/media/libaudioclient/AidlConversion.cpp
index 321e7f9..b0eb7bd 100644
--- a/media/libaudioclient/AidlConversion.cpp
+++ b/media/libaudioclient/AidlConversion.cpp
@@ -14,6 +14,11 @@
* limitations under the License.
*/
+#include <algorithm>
+#include <unordered_map>
+#include <utility>
+#include <vector>
+
#define LOG_TAG "AidlConversion"
//#define LOG_NDEBUG 0
#include <utils/Log.h>
@@ -21,6 +26,7 @@
#include "media/AidlConversion.h"
#include <media/ShmemCompat.h>
+#include <media/stagefright/foundation/MediaDefs.h>
////////////////////////////////////////////////////////////////////////////////////////////////////
// Utilities
@@ -273,21 +279,7 @@
enumToMask_index<int32_t, media::AudioPortConfigType>);
}
-ConversionResult<audio_channel_mask_t> aidl2legacy_int32_t_audio_channel_mask_t(int32_t aidl) {
- // TODO(ytai): should we convert bit-by-bit?
- // One problem here is that the representation is both opaque and is different based on the
- // context (input vs. output). Can determine based on type and role, as per useInChannelMask().
- return convertReinterpret<audio_channel_mask_t>(aidl);
-}
-
-ConversionResult<int32_t> legacy2aidl_audio_channel_mask_t_int32_t(audio_channel_mask_t legacy) {
- // TODO(ytai): should we convert bit-by-bit?
- // One problem here is that the representation is both opaque and is different based on the
- // context (input vs. output). Can determine based on type and role, as per useInChannelMask().
- return convertReinterpret<int32_t>(legacy);
-}
-
-ConversionResult<audio_io_config_event> aidl2legacy_AudioIoConfigEvent_audio_io_config_event(
+ConversionResult<audio_io_config_event_t> aidl2legacy_AudioIoConfigEvent_audio_io_config_event_t(
media::AudioIoConfigEvent aidl) {
switch (aidl) {
case media::AudioIoConfigEvent::OUTPUT_REGISTERED:
@@ -312,8 +304,8 @@
return unexpected(BAD_VALUE);
}
-ConversionResult<media::AudioIoConfigEvent> legacy2aidl_audio_io_config_event_AudioIoConfigEvent(
- audio_io_config_event legacy) {
+ConversionResult<media::AudioIoConfigEvent> legacy2aidl_audio_io_config_event_t_AudioIoConfigEvent(
+ audio_io_config_event_t legacy) {
switch (legacy) {
case AUDIO_OUTPUT_REGISTERED:
return media::AudioIoConfigEvent::OUTPUT_REGISTERED;
@@ -393,18 +385,814 @@
return unexpected(BAD_VALUE);
}
-ConversionResult<audio_format_t> aidl2legacy_AudioFormat_audio_format_t(
- media::audio::common::AudioFormat aidl) {
- // This relies on AudioFormat being kept in sync with audio_format_t.
- static_assert(sizeof(media::audio::common::AudioFormat) == sizeof(audio_format_t));
- return static_cast<audio_format_t>(aidl);
+namespace {
+
+namespace detail {
+using AudioChannelPair = std::pair<audio_channel_mask_t, media::AudioChannelLayout>;
+using AudioChannelPairs = std::vector<AudioChannelPair>;
+using AudioDevicePair = std::pair<audio_devices_t, media::AudioDeviceDescription>;
+using AudioDevicePairs = std::vector<AudioDevicePair>;
+using AudioFormatPair = std::pair<audio_format_t, media::AudioFormatDescription>;
+using AudioFormatPairs = std::vector<AudioFormatPair>;
}
-ConversionResult<media::audio::common::AudioFormat> legacy2aidl_audio_format_t_AudioFormat(
+const detail::AudioChannelPairs& getInAudioChannelPairs() {
+ static const detail::AudioChannelPairs pairs = {
+#define DEFINE_INPUT_LAYOUT(n) \
+ { \
+ AUDIO_CHANNEL_IN_##n, \
+ media::AudioChannelLayout::make<media::AudioChannelLayout::Tag::layoutMask>( \
+ media::AudioChannelLayout::LAYOUT_##n) \
+ }
+
+ DEFINE_INPUT_LAYOUT(MONO),
+ DEFINE_INPUT_LAYOUT(STEREO),
+ DEFINE_INPUT_LAYOUT(FRONT_BACK),
+ // AUDIO_CHANNEL_IN_6 not supported
+ DEFINE_INPUT_LAYOUT(2POINT0POINT2),
+ DEFINE_INPUT_LAYOUT(2POINT1POINT2),
+ DEFINE_INPUT_LAYOUT(3POINT0POINT2),
+ DEFINE_INPUT_LAYOUT(3POINT1POINT2),
+ DEFINE_INPUT_LAYOUT(5POINT1)
+#undef DEFINE_INPUT_LAYOUT
+ };
+ return pairs;
+}
+
+const detail::AudioChannelPairs& getOutAudioChannelPairs() {
+ static const detail::AudioChannelPairs pairs = {
+#define DEFINE_OUTPUT_LAYOUT(n) \
+ { \
+ AUDIO_CHANNEL_OUT_##n, \
+ media::AudioChannelLayout::make<media::AudioChannelLayout::Tag::layoutMask>( \
+ media::AudioChannelLayout::LAYOUT_##n) \
+ }
+
+ DEFINE_OUTPUT_LAYOUT(MONO),
+ DEFINE_OUTPUT_LAYOUT(STEREO),
+ DEFINE_OUTPUT_LAYOUT(2POINT1),
+ DEFINE_OUTPUT_LAYOUT(TRI),
+ DEFINE_OUTPUT_LAYOUT(TRI_BACK),
+ DEFINE_OUTPUT_LAYOUT(3POINT1),
+ DEFINE_OUTPUT_LAYOUT(2POINT0POINT2),
+ DEFINE_OUTPUT_LAYOUT(2POINT1POINT2),
+ DEFINE_OUTPUT_LAYOUT(3POINT0POINT2),
+ DEFINE_OUTPUT_LAYOUT(3POINT1POINT2),
+ DEFINE_OUTPUT_LAYOUT(QUAD),
+ DEFINE_OUTPUT_LAYOUT(QUAD_SIDE),
+ DEFINE_OUTPUT_LAYOUT(SURROUND),
+ DEFINE_OUTPUT_LAYOUT(PENTA),
+ DEFINE_OUTPUT_LAYOUT(5POINT1),
+ DEFINE_OUTPUT_LAYOUT(5POINT1_SIDE),
+ DEFINE_OUTPUT_LAYOUT(5POINT1POINT2),
+ DEFINE_OUTPUT_LAYOUT(5POINT1POINT4),
+ DEFINE_OUTPUT_LAYOUT(6POINT1),
+ DEFINE_OUTPUT_LAYOUT(7POINT1),
+ DEFINE_OUTPUT_LAYOUT(7POINT1POINT2),
+ DEFINE_OUTPUT_LAYOUT(7POINT1POINT4),
+ DEFINE_OUTPUT_LAYOUT(13POINT_360RA),
+ DEFINE_OUTPUT_LAYOUT(22POINT2),
+ DEFINE_OUTPUT_LAYOUT(MONO_HAPTIC_A),
+ DEFINE_OUTPUT_LAYOUT(STEREO_HAPTIC_A),
+ DEFINE_OUTPUT_LAYOUT(HAPTIC_AB),
+ DEFINE_OUTPUT_LAYOUT(MONO_HAPTIC_AB),
+ DEFINE_OUTPUT_LAYOUT(STEREO_HAPTIC_AB)
+#undef DEFINE_OUTPUT_LAYOUT
+ };
+ return pairs;
+}
+
+const detail::AudioChannelPairs& getVoiceAudioChannelPairs() {
+ static const detail::AudioChannelPairs pairs = {
+#define DEFINE_VOICE_LAYOUT(n) \
+ { \
+ AUDIO_CHANNEL_IN_VOICE_##n, \
+ media::AudioChannelLayout::make<media::AudioChannelLayout::Tag::voiceMask>( \
+ media::AudioChannelLayout::VOICE_##n) \
+ }
+ DEFINE_VOICE_LAYOUT(UPLINK_MONO),
+ DEFINE_VOICE_LAYOUT(DNLINK_MONO),
+ DEFINE_VOICE_LAYOUT(CALL_MONO)
+#undef DEFINE_VOICE_LAYOUT
+ };
+ return pairs;
+}
+
+media::AudioDeviceDescription make_AudioDeviceDescription(media::AudioDeviceType type,
+ const std::string& connection = "") {
+ media::AudioDeviceDescription result;
+ result.type = type;
+ result.connection = connection;
+ return result;
+}
+
+void append_AudioDeviceDescription(detail::AudioDevicePairs& pairs,
+ audio_devices_t inputType, audio_devices_t outputType,
+ media::AudioDeviceType inType, media::AudioDeviceType outType,
+ const std::string& connection = "") {
+ pairs.push_back(std::make_pair(inputType, make_AudioDeviceDescription(inType, connection)));
+ pairs.push_back(std::make_pair(outputType, make_AudioDeviceDescription(outType, connection)));
+}
+
+const detail::AudioDevicePairs& getAudioDevicePairs() {
+ static const detail::AudioDevicePairs pairs = []() {
+ detail::AudioDevicePairs pairs = {{
+ {
+ AUDIO_DEVICE_NONE, media::AudioDeviceDescription{}
+ },
+ {
+ AUDIO_DEVICE_OUT_EARPIECE, make_AudioDeviceDescription(
+ media::AudioDeviceType::OUT_SPEAKER_EARPIECE)
+ },
+ {
+ AUDIO_DEVICE_OUT_SPEAKER, make_AudioDeviceDescription(
+ media::AudioDeviceType::OUT_SPEAKER)
+ },
+ {
+ AUDIO_DEVICE_OUT_WIRED_HEADPHONE, make_AudioDeviceDescription(
+ media::AudioDeviceType::OUT_HEADPHONE,
+ media::AudioDeviceDescription::CONNECTION_ANALOG())
+ },
+ {
+ AUDIO_DEVICE_OUT_BLUETOOTH_SCO, make_AudioDeviceDescription(
+ media::AudioDeviceType::OUT_DEVICE,
+ media::AudioDeviceDescription::CONNECTION_BT_SCO())
+ },
+ {
+ AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT, make_AudioDeviceDescription(
+ media::AudioDeviceType::OUT_CARKIT,
+ media::AudioDeviceDescription::CONNECTION_BT_SCO())
+ },
+ {
+ AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES, make_AudioDeviceDescription(
+ media::AudioDeviceType::OUT_HEADPHONE,
+ media::AudioDeviceDescription::CONNECTION_BT_A2DP())
+ },
+ {
+ AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER, make_AudioDeviceDescription(
+ media::AudioDeviceType::OUT_SPEAKER,
+ media::AudioDeviceDescription::CONNECTION_BT_A2DP())
+ },
+ {
+ AUDIO_DEVICE_OUT_TELEPHONY_TX, make_AudioDeviceDescription(
+ media::AudioDeviceType::OUT_TELEPHONY_TX)
+ },
+ {
+ AUDIO_DEVICE_OUT_AUX_LINE, make_AudioDeviceDescription(
+ media::AudioDeviceType::OUT_LINE_AUX)
+ },
+ {
+ AUDIO_DEVICE_OUT_SPEAKER_SAFE, make_AudioDeviceDescription(
+ media::AudioDeviceType::OUT_SPEAKER_SAFE)
+ },
+ {
+ AUDIO_DEVICE_OUT_HEARING_AID, make_AudioDeviceDescription(
+ media::AudioDeviceType::OUT_HEARING_AID,
+ media::AudioDeviceDescription::CONNECTION_WIRELESS())
+ },
+ {
+ AUDIO_DEVICE_OUT_ECHO_CANCELLER, make_AudioDeviceDescription(
+ media::AudioDeviceType::OUT_ECHO_CANCELLER)
+ },
+ {
+ AUDIO_DEVICE_OUT_BLE_SPEAKER, make_AudioDeviceDescription(
+ media::AudioDeviceType::OUT_SPEAKER,
+ media::AudioDeviceDescription::CONNECTION_BT_LE())
+ },
+ // AUDIO_DEVICE_IN_AMBIENT and IN_COMMUNICATION are removed since they were deprecated.
+ {
+ AUDIO_DEVICE_IN_BUILTIN_MIC, make_AudioDeviceDescription(
+ media::AudioDeviceType::IN_MICROPHONE)
+ },
+ {
+ AUDIO_DEVICE_IN_BACK_MIC, make_AudioDeviceDescription(
+ media::AudioDeviceType::IN_MICROPHONE_BACK)
+ },
+ {
+ AUDIO_DEVICE_IN_TELEPHONY_RX, make_AudioDeviceDescription(
+ media::AudioDeviceType::IN_TELEPHONY_RX)
+ },
+ {
+ AUDIO_DEVICE_IN_TV_TUNER, make_AudioDeviceDescription(
+ media::AudioDeviceType::IN_TV_TUNER)
+ },
+ {
+ AUDIO_DEVICE_IN_LOOPBACK, make_AudioDeviceDescription(
+ media::AudioDeviceType::IN_LOOPBACK)
+ },
+ {
+ AUDIO_DEVICE_IN_BLUETOOTH_BLE, make_AudioDeviceDescription(
+ media::AudioDeviceType::IN_DEVICE,
+ media::AudioDeviceDescription::CONNECTION_BT_LE())
+ },
+ {
+ AUDIO_DEVICE_IN_ECHO_REFERENCE, make_AudioDeviceDescription(
+ media::AudioDeviceType::IN_ECHO_REFERENCE)
+ }
+ }};
+ append_AudioDeviceDescription(pairs,
+ AUDIO_DEVICE_IN_DEFAULT, AUDIO_DEVICE_OUT_DEFAULT,
+ media::AudioDeviceType::IN_DEFAULT, media::AudioDeviceType::OUT_DEFAULT);
+ append_AudioDeviceDescription(pairs,
+ AUDIO_DEVICE_IN_WIRED_HEADSET, AUDIO_DEVICE_OUT_WIRED_HEADSET,
+ media::AudioDeviceType::IN_HEADSET, media::AudioDeviceType::OUT_HEADSET,
+ media::AudioDeviceDescription::CONNECTION_ANALOG());
+ append_AudioDeviceDescription(pairs,
+ AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET, AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET,
+ media::AudioDeviceType::IN_HEADSET, media::AudioDeviceType::OUT_HEADSET,
+ media::AudioDeviceDescription::CONNECTION_BT_SCO());
+ append_AudioDeviceDescription(pairs,
+ AUDIO_DEVICE_IN_HDMI, AUDIO_DEVICE_OUT_HDMI,
+ media::AudioDeviceType::IN_DEVICE, media::AudioDeviceType::OUT_DEVICE,
+ media::AudioDeviceDescription::CONNECTION_HDMI());
+ append_AudioDeviceDescription(pairs,
+ AUDIO_DEVICE_IN_REMOTE_SUBMIX, AUDIO_DEVICE_OUT_REMOTE_SUBMIX,
+ media::AudioDeviceType::IN_SUBMIX, media::AudioDeviceType::OUT_SUBMIX);
+ append_AudioDeviceDescription(pairs,
+ AUDIO_DEVICE_IN_ANLG_DOCK_HEADSET, AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET,
+ media::AudioDeviceType::IN_HEADSET, media::AudioDeviceType::OUT_HEADSET,
+ media::AudioDeviceDescription::CONNECTION_ANALOG_DOCK());
+ append_AudioDeviceDescription(pairs,
+ AUDIO_DEVICE_IN_DGTL_DOCK_HEADSET, AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET,
+ media::AudioDeviceType::IN_HEADSET, media::AudioDeviceType::OUT_HEADSET,
+ media::AudioDeviceDescription::CONNECTION_DIGITAL_DOCK());
+ append_AudioDeviceDescription(pairs,
+ AUDIO_DEVICE_IN_USB_ACCESSORY, AUDIO_DEVICE_OUT_USB_ACCESSORY,
+ media::AudioDeviceType::IN_ACCESSORY, media::AudioDeviceType::OUT_ACCESSORY,
+ media::AudioDeviceDescription::CONNECTION_USB());
+ append_AudioDeviceDescription(pairs,
+ AUDIO_DEVICE_IN_USB_DEVICE, AUDIO_DEVICE_OUT_USB_DEVICE,
+ media::AudioDeviceType::IN_DEVICE, media::AudioDeviceType::OUT_DEVICE,
+ media::AudioDeviceDescription::CONNECTION_USB());
+ append_AudioDeviceDescription(pairs,
+ AUDIO_DEVICE_IN_FM_TUNER, AUDIO_DEVICE_OUT_FM,
+ media::AudioDeviceType::IN_FM_TUNER, media::AudioDeviceType::OUT_FM);
+ append_AudioDeviceDescription(pairs,
+ AUDIO_DEVICE_IN_LINE, AUDIO_DEVICE_OUT_LINE,
+ media::AudioDeviceType::IN_DEVICE, media::AudioDeviceType::OUT_DEVICE,
+ media::AudioDeviceDescription::CONNECTION_ANALOG());
+ append_AudioDeviceDescription(pairs,
+ AUDIO_DEVICE_IN_SPDIF, AUDIO_DEVICE_OUT_SPDIF,
+ media::AudioDeviceType::IN_DEVICE, media::AudioDeviceType::OUT_DEVICE,
+ media::AudioDeviceDescription::CONNECTION_SPDIF());
+ append_AudioDeviceDescription(pairs,
+ AUDIO_DEVICE_IN_BLUETOOTH_A2DP, AUDIO_DEVICE_OUT_BLUETOOTH_A2DP,
+ media::AudioDeviceType::IN_DEVICE, media::AudioDeviceType::OUT_DEVICE,
+ media::AudioDeviceDescription::CONNECTION_BT_A2DP());
+ append_AudioDeviceDescription(pairs,
+ AUDIO_DEVICE_IN_IP, AUDIO_DEVICE_OUT_IP,
+ media::AudioDeviceType::IN_DEVICE, media::AudioDeviceType::OUT_DEVICE,
+ media::AudioDeviceDescription::CONNECTION_IP_V4());
+ append_AudioDeviceDescription(pairs,
+ AUDIO_DEVICE_IN_BUS, AUDIO_DEVICE_OUT_BUS,
+ media::AudioDeviceType::IN_DEVICE, media::AudioDeviceType::OUT_DEVICE,
+ media::AudioDeviceDescription::CONNECTION_BUS());
+ append_AudioDeviceDescription(pairs,
+ AUDIO_DEVICE_IN_PROXY, AUDIO_DEVICE_OUT_PROXY,
+ media::AudioDeviceType::IN_AFE_PROXY, media::AudioDeviceType::OUT_AFE_PROXY);
+ append_AudioDeviceDescription(pairs,
+ AUDIO_DEVICE_IN_USB_HEADSET, AUDIO_DEVICE_OUT_USB_HEADSET,
+ media::AudioDeviceType::IN_HEADSET, media::AudioDeviceType::OUT_HEADSET,
+ media::AudioDeviceDescription::CONNECTION_USB());
+ append_AudioDeviceDescription(pairs,
+ AUDIO_DEVICE_IN_HDMI_ARC, AUDIO_DEVICE_OUT_HDMI_ARC,
+ media::AudioDeviceType::IN_DEVICE, media::AudioDeviceType::OUT_DEVICE,
+ media::AudioDeviceDescription::CONNECTION_HDMI_ARC());
+ append_AudioDeviceDescription(pairs,
+ AUDIO_DEVICE_IN_HDMI_EARC, AUDIO_DEVICE_OUT_HDMI_EARC,
+ media::AudioDeviceType::IN_DEVICE, media::AudioDeviceType::OUT_DEVICE,
+ media::AudioDeviceDescription::CONNECTION_HDMI_EARC());
+ append_AudioDeviceDescription(pairs,
+ AUDIO_DEVICE_IN_BLE_HEADSET, AUDIO_DEVICE_OUT_BLE_HEADSET,
+ media::AudioDeviceType::IN_HEADSET, media::AudioDeviceType::OUT_HEADSET,
+ media::AudioDeviceDescription::CONNECTION_BT_LE());
+ return pairs;
+ }();
+ return pairs;
+}
+
+media::AudioFormatDescription make_AudioFormatDescription(media::AudioFormatType type) {
+ media::AudioFormatDescription result;
+ result.type = type;
+ return result;
+}
+
+media::AudioFormatDescription make_AudioFormatDescription(media::PcmType pcm) {
+ auto result = make_AudioFormatDescription(media::AudioFormatType::PCM);
+ result.pcm = pcm;
+ return result;
+}
+
+media::AudioFormatDescription make_AudioFormatDescription(const std::string& encoding) {
+ media::AudioFormatDescription result;
+ result.encoding = encoding;
+ return result;
+}
+
+media::AudioFormatDescription make_AudioFormatDescription(media::PcmType transport,
+ const std::string& encoding) {
+ auto result = make_AudioFormatDescription(encoding);
+ result.pcm = transport;
+ return result;
+}
+
+const detail::AudioFormatPairs& getAudioFormatPairs() {
+ static const detail::AudioFormatPairs pairs = {{
+ {
+ AUDIO_FORMAT_INVALID,
+ make_AudioFormatDescription(media::AudioFormatType::SYS_RESERVED_INVALID)
+ },
+ {
+ AUDIO_FORMAT_DEFAULT, media::AudioFormatDescription{}
+ },
+ {
+ AUDIO_FORMAT_PCM_16_BIT, make_AudioFormatDescription(media::PcmType::INT_16_BIT)
+ },
+ {
+ AUDIO_FORMAT_PCM_8_BIT, make_AudioFormatDescription(media::PcmType::UINT_8_BIT)
+ },
+ {
+ AUDIO_FORMAT_PCM_32_BIT, make_AudioFormatDescription(media::PcmType::INT_32_BIT)
+ },
+ {
+ AUDIO_FORMAT_PCM_8_24_BIT, make_AudioFormatDescription(media::PcmType::FIXED_Q_8_24)
+ },
+ {
+ AUDIO_FORMAT_PCM_FLOAT, make_AudioFormatDescription(media::PcmType::FLOAT_32_BIT)
+ },
+ {
+ AUDIO_FORMAT_PCM_24_BIT_PACKED, make_AudioFormatDescription(media::PcmType::INT_24_BIT)
+ },
+ {
+ // See the comment in MediaDefs.h.
+ AUDIO_FORMAT_MP3, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_MPEG)
+ },
+ {
+ AUDIO_FORMAT_AMR_NB, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_AMR_NB)
+ },
+ {
+ AUDIO_FORMAT_AMR_WB, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_AMR_WB)
+ },
+ {
+ // Note: in MediaDefs.cpp MEDIA_MIMETYPE_AUDIO_AAC = "audio/mp4a-latm".
+ AUDIO_FORMAT_AAC, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_AAC_FORMAT)
+ },
+ {
+ // Note: not in the IANA registry.
+ AUDIO_FORMAT_AAC_MAIN, make_AudioFormatDescription("audio/aac.main")
+ },
+ {
+ // Note: not in the IANA registry.
+ AUDIO_FORMAT_AAC_LC, make_AudioFormatDescription("audio/aac.lc")
+ },
+ {
+ // Note: not in the IANA registry.
+ AUDIO_FORMAT_AAC_SSR, make_AudioFormatDescription("audio/aac.ssr")
+ },
+ {
+ // Note: not in the IANA registry.
+ AUDIO_FORMAT_AAC_LTP, make_AudioFormatDescription("audio/aac.ltp")
+ },
+ {
+ // Note: not in the IANA registry.
+ AUDIO_FORMAT_AAC_HE_V1, make_AudioFormatDescription("audio/aac.he.v1")
+ },
+ {
+ // Note: not in the IANA registry.
+ AUDIO_FORMAT_AAC_SCALABLE, make_AudioFormatDescription("audio/aac.scalable")
+ },
+ {
+ // Note: not in the IANA registry.
+ AUDIO_FORMAT_AAC_ERLC, make_AudioFormatDescription("audio/aac.erlc")
+ },
+ {
+ // Note: not in the IANA registry.
+ AUDIO_FORMAT_AAC_LD, make_AudioFormatDescription("audio/aac.ld")
+ },
+ {
+ // Note: not in the IANA registry.
+ AUDIO_FORMAT_AAC_HE_V2, make_AudioFormatDescription("audio/aac.he.v2")
+ },
+ {
+ // Note: not in the IANA registry.
+ AUDIO_FORMAT_AAC_ELD, make_AudioFormatDescription("audio/aac.eld")
+ },
+ {
+ // Note: not in the IANA registry.
+ AUDIO_FORMAT_AAC_XHE, make_AudioFormatDescription("audio/aac.xhe")
+ },
+ // AUDIO_FORMAT_HE_AAC_V1 and HE_AAC_V2 are removed since they were deprecated long time
+ // ago.
+ {
+ AUDIO_FORMAT_VORBIS, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_VORBIS)
+ },
+ {
+ AUDIO_FORMAT_OPUS, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_OPUS)
+ },
+ {
+ AUDIO_FORMAT_AC3, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_AC3)
+ },
+ {
+ AUDIO_FORMAT_E_AC3, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_EAC3)
+ },
+ {
+ // Note: not in the IANA registry.
+ AUDIO_FORMAT_E_AC3_JOC, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_EAC3_JOC)
+ },
+ {
+ AUDIO_FORMAT_DTS, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_DTS)
+ },
+ {
+ AUDIO_FORMAT_DTS_HD, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_DTS_HD)
+ },
+ // In the future, we would like to represent encapsulated bitstreams as
+ // nested AudioFormatDescriptions. The legacy 'AUDIO_FORMAT_IEC61937' type doesn't
+ // specify the format of the encapsulated bitstream.
+ {
+ // Note: not in the IANA registry.
+ AUDIO_FORMAT_IEC61937,
+ make_AudioFormatDescription(media::PcmType::INT_16_BIT, "audio/x-iec61937")
+ },
+ {
+ // Note: not in the IANA registry.
+ AUDIO_FORMAT_DOLBY_TRUEHD, make_AudioFormatDescription("audio/vnd.dolby.truehd")
+ },
+ {
+ AUDIO_FORMAT_EVRC, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_EVRC)
+ },
+ {
+ AUDIO_FORMAT_EVRCB, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_EVRCB)
+ },
+ {
+ AUDIO_FORMAT_EVRCWB, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_EVRCWB)
+ },
+ {
+ AUDIO_FORMAT_EVRCNW, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_EVRCNW)
+ },
+ {
+ // Note: not in the IANA registry.
+ AUDIO_FORMAT_AAC_ADIF, make_AudioFormatDescription("audio/aac.adif")
+ },
+ {
+ // Note: not in the IANA registry.
+ AUDIO_FORMAT_WMA, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_WMA)
+ },
+ {
+ // Note: not in the IANA registry.
+ AUDIO_FORMAT_WMA_PRO, make_AudioFormatDescription("audio/x-ms-wma.pro")
+ },
+ {
+ AUDIO_FORMAT_AMR_WB_PLUS, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_AMR_WB_PLUS)
+ },
+ {
+ // Note: not in the IANA registry.
+ AUDIO_FORMAT_MP2, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_MPEG_LAYER_II)
+ },
+ {
+ AUDIO_FORMAT_QCELP, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_QCELP)
+ },
+ {
+ // Note: not in the IANA registry.
+ AUDIO_FORMAT_DSD, make_AudioFormatDescription("audio/vnd.sony.dsd")
+ },
+ {
+ AUDIO_FORMAT_FLAC, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_FLAC)
+ },
+ {
+ // Note: not in the IANA registry.
+ AUDIO_FORMAT_ALAC, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_ALAC)
+ },
+ {
+ // Note: not in the IANA registry.
+ AUDIO_FORMAT_APE, make_AudioFormatDescription("audio/x-ape")
+ },
+ {
+ // Note: not in the IANA registry.
+ AUDIO_FORMAT_AAC_ADTS, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_AAC_ADTS)
+ },
+ {
+ // Note: not in the IANA registry.
+ AUDIO_FORMAT_AAC_ADTS_MAIN, make_AudioFormatDescription("audio/aac-adts.main")
+ },
+ {
+ // Note: not in the IANA registry.
+ AUDIO_FORMAT_AAC_ADTS_LC, make_AudioFormatDescription("audio/aac-adts.lc")
+ },
+ {
+ // Note: not in the IANA registry.
+ AUDIO_FORMAT_AAC_ADTS_SSR, make_AudioFormatDescription("audio/aac-adts.ssr")
+ },
+ {
+ // Note: not in the IANA registry.
+ AUDIO_FORMAT_AAC_ADTS_LTP, make_AudioFormatDescription("audio/aac-adts.ltp")
+ },
+ {
+ // Note: not in the IANA registry.
+ AUDIO_FORMAT_AAC_ADTS_HE_V1, make_AudioFormatDescription("audio/aac-adts.he.v1")
+ },
+ {
+ // Note: not in the IANA registry.
+ AUDIO_FORMAT_AAC_ADTS_SCALABLE, make_AudioFormatDescription("audio/aac-adts.scalable")
+ },
+ {
+ // Note: not in the IANA registry.
+ AUDIO_FORMAT_AAC_ADTS_ERLC, make_AudioFormatDescription("audio/aac-adts.erlc")
+ },
+ {
+ // Note: not in the IANA registry.
+ AUDIO_FORMAT_AAC_ADTS_LD, make_AudioFormatDescription("audio/aac-adts.ld")
+ },
+ {
+ // Note: not in the IANA registry.
+ AUDIO_FORMAT_AAC_ADTS_HE_V2, make_AudioFormatDescription("audio/aac-adts.he.v2")
+ },
+ {
+ // Note: not in the IANA registry.
+ AUDIO_FORMAT_AAC_ADTS_ELD, make_AudioFormatDescription("audio/aac-adts.eld")
+ },
+ {
+ // Note: not in the IANA registry.
+ AUDIO_FORMAT_AAC_ADTS_XHE, make_AudioFormatDescription("audio/aac-adts.xhe")
+ },
+ {
+ // Note: not in the IANA registry. "vnd.octel.sbc" is not BT SBC.
+ AUDIO_FORMAT_SBC, make_AudioFormatDescription("audio/x-sbc")
+ },
+ {
+ AUDIO_FORMAT_APTX, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_APTX)
+ },
+ {
+ // Note: not in the IANA registry.
+ AUDIO_FORMAT_APTX_HD, make_AudioFormatDescription("audio/vnd.qcom.aptx.hd")
+ },
+ {
+ // Note: not in the IANA registry. Matches MediaDefs.cpp.
+ AUDIO_FORMAT_AC4, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_AC4)
+ },
+ {
+ // Note: not in the IANA registry.
+ AUDIO_FORMAT_LDAC, make_AudioFormatDescription("audio/vnd.sony.ldac")
+ },
+ {
+ // Note: not in the IANA registry.
+ AUDIO_FORMAT_MAT, make_AudioFormatDescription("audio/vnd.dolby.mat")
+ },
+ {
+ // Note: not in the IANA registry.
+ AUDIO_FORMAT_MAT_1_0, make_AudioFormatDescription("audio/vnd.dolby.mat.1.0")
+ },
+ {
+ // Note: not in the IANA registry.
+ AUDIO_FORMAT_MAT_2_0, make_AudioFormatDescription("audio/vnd.dolby.mat.2.0")
+ },
+ {
+ // Note: not in the IANA registry.
+ AUDIO_FORMAT_MAT_2_1, make_AudioFormatDescription("audio/vnd.dolby.mat.2.1")
+ },
+ {
+ AUDIO_FORMAT_AAC_LATM, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_AAC)
+ },
+ {
+ // Note: not in the IANA registry.
+ AUDIO_FORMAT_AAC_LATM_LC, make_AudioFormatDescription("audio/mp4a-latm.lc")
+ },
+ {
+ // Note: not in the IANA registry.
+ AUDIO_FORMAT_AAC_LATM_HE_V1, make_AudioFormatDescription("audio/mp4a-latm.he.v1")
+ },
+ {
+ // Note: not in the IANA registry.
+ AUDIO_FORMAT_AAC_LATM_HE_V2, make_AudioFormatDescription("audio/mp4a-latm.he.v2")
+ },
+ {
+ // Note: not in the IANA registry.
+ AUDIO_FORMAT_CELT, make_AudioFormatDescription("audio/x-celt")
+ },
+ {
+ // Note: not in the IANA registry.
+ AUDIO_FORMAT_APTX_ADAPTIVE, make_AudioFormatDescription("audio/vnd.qcom.aptx.adaptive")
+ },
+ {
+ // Note: not in the IANA registry.
+ AUDIO_FORMAT_LHDC, make_AudioFormatDescription("audio/vnd.savitech.lhdc")
+ },
+ {
+ // Note: not in the IANA registry.
+ AUDIO_FORMAT_LHDC_LL, make_AudioFormatDescription("audio/vnd.savitech.lhdc.ll")
+ },
+ {
+ // Note: not in the IANA registry.
+ AUDIO_FORMAT_APTX_TWSP, make_AudioFormatDescription("audio/vnd.qcom.aptx.twsp")
+ },
+ {
+ // Note: not in the IANA registry.
+ AUDIO_FORMAT_LC3, make_AudioFormatDescription("audio/x-lc3")
+ },
+ {
+ // Note: not in the IANA registry.
+ AUDIO_FORMAT_MPEGH, make_AudioFormatDescription("audio/x-mpegh")
+ },
+ {
+ // Note: not in the IANA registry.
+ AUDIO_FORMAT_MPEGH_BL_L3, make_AudioFormatDescription("audio/x-mpegh.bl.l3")
+ },
+ {
+ // Note: not in the IANA registry.
+ AUDIO_FORMAT_MPEGH_BL_L4, make_AudioFormatDescription("audio/x-mpegh.bl.l4")
+ },
+ {
+ // Note: not in the IANA registry.
+ AUDIO_FORMAT_MPEGH_LC_L3, make_AudioFormatDescription("audio/x-mpegh.lc.l3")
+ },
+ {
+ // Note: not in the IANA registry.
+ AUDIO_FORMAT_MPEGH_LC_L4, make_AudioFormatDescription("audio/x-mpegh.lc.l4")
+ },
+ {
+ // Note: not in the IANA registry.
+ AUDIO_FORMAT_IEC60958,
+ make_AudioFormatDescription(media::PcmType::INT_24_BIT, "audio/x-iec60958")
+ },
+ {
+ AUDIO_FORMAT_DTS_UHD, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_DTS_UHD)
+ },
+ {
+ AUDIO_FORMAT_DRA, make_AudioFormatDescription(MEDIA_MIMETYPE_AUDIO_DRA)
+ },
+ }};
+ return pairs;
+}
+
+template<typename S, typename T>
+std::unordered_map<S, T> make_DirectMap(const std::vector<std::pair<S, T>>& v) {
+ std::unordered_map<S, T> result(v.begin(), v.end());
+ LOG_ALWAYS_FATAL_IF(result.size() != v.size(), "Duplicate key elements detected");
+ return result;
+}
+
+template<typename S, typename T>
+std::unordered_map<S, T> make_DirectMap(
+ const std::vector<std::pair<S, T>>& v1, const std::vector<std::pair<S, T>>& v2) {
+ std::unordered_map<S, T> result(v1.begin(), v1.end());
+ LOG_ALWAYS_FATAL_IF(result.size() != v1.size(), "Duplicate key elements detected in v1");
+ result.insert(v2.begin(), v2.end());
+ LOG_ALWAYS_FATAL_IF(result.size() != v1.size() + v2.size(),
+ "Duplicate key elements detected in v1+v2");
+ return result;
+}
+
+template<typename S, typename T>
+std::unordered_map<T, S> make_ReverseMap(const std::vector<std::pair<S, T>>& v) {
+ std::unordered_map<T, S> result;
+ std::transform(v.begin(), v.end(), std::inserter(result, result.begin()),
+ [](const std::pair<S, T>& p) {
+ return std::make_pair(p.second, p.first);
+ });
+ LOG_ALWAYS_FATAL_IF(result.size() != v.size(), "Duplicate key elements detected");
+ return result;
+}
+
+} // namespace
+
+ConversionResult<audio_channel_mask_t> aidl2legacy_AudioChannelLayout_audio_channel_mask_t(
+ const media::AudioChannelLayout& aidl, bool isInput) {
+ using ReverseMap = std::unordered_map<media::AudioChannelLayout, audio_channel_mask_t>;
+ using Tag = media::AudioChannelLayout::Tag;
+ static const ReverseMap mIn = make_ReverseMap(getInAudioChannelPairs());
+ static const ReverseMap mOut = make_ReverseMap(getOutAudioChannelPairs());
+ static const ReverseMap mVoice = make_ReverseMap(getVoiceAudioChannelPairs());
+
+ auto convert = [](const media::AudioChannelLayout& aidl, const ReverseMap& m,
+ const char* func, const char* type) -> ConversionResult<audio_channel_mask_t> {
+ if (auto it = m.find(aidl); it != m.end()) {
+ return it->second;
+ } else {
+ ALOGE("%s: no legacy %s audio_channel_mask_t found for %s", func, type,
+ aidl.toString().c_str());
+ return unexpected(BAD_VALUE);
+ }
+ };
+
+ switch (aidl.getTag()) {
+ case Tag::none:
+ return AUDIO_CHANNEL_NONE;
+ case Tag::invalid:
+ return AUDIO_CHANNEL_INVALID;
+ case Tag::indexMask: {
+ // Index masks do not have pre-defined values.
+ const int bits = aidl.get<Tag::indexMask>();
+ if (__builtin_popcount(bits) != 0 &&
+ __builtin_popcount(bits) <= AUDIO_CHANNEL_COUNT_MAX) {
+ return audio_channel_mask_from_representation_and_bits(
+ AUDIO_CHANNEL_REPRESENTATION_INDEX, bits);
+ } else {
+ ALOGE("%s: invalid indexMask value 0x%x in %s",
+ __func__, bits, aidl.toString().c_str());
+ return unexpected(BAD_VALUE);
+ }
+ }
+ case Tag::layoutMask:
+ return convert(aidl, isInput ? mIn : mOut, __func__, isInput ? "input" : "output");
+ case Tag::voiceMask:
+ return convert(aidl, mVoice, __func__, "voice");
+ }
+ ALOGE("%s: unexpected tag value %d", __func__, aidl.getTag());
+ return unexpected(BAD_VALUE);
+}
+
+ConversionResult<media::AudioChannelLayout> legacy2aidl_audio_channel_mask_t_AudioChannelLayout(
+ audio_channel_mask_t legacy, bool isInput) {
+ using DirectMap = std::unordered_map<audio_channel_mask_t, media::AudioChannelLayout>;
+ using Tag = media::AudioChannelLayout::Tag;
+ static const DirectMap mInAndVoice = make_DirectMap(
+ getInAudioChannelPairs(), getVoiceAudioChannelPairs());
+ static const DirectMap mOut = make_DirectMap(getOutAudioChannelPairs());
+
+ auto convert = [](const audio_channel_mask_t legacy, const DirectMap& m,
+ const char* func, const char* type) -> ConversionResult<media::AudioChannelLayout> {
+ if (auto it = m.find(legacy); it != m.end()) {
+ return it->second;
+ } else {
+ ALOGE("%s: no AudioChannelLayout found for legacy %s audio_channel_mask_t value 0x%x",
+ func, type, legacy);
+ return unexpected(BAD_VALUE);
+ }
+ };
+
+ if (legacy == AUDIO_CHANNEL_NONE) {
+ return media::AudioChannelLayout{};
+ } else if (legacy == AUDIO_CHANNEL_INVALID) {
+ return media::AudioChannelLayout::make<Tag::invalid>(0);
+ }
+
+ const audio_channel_representation_t repr = audio_channel_mask_get_representation(legacy);
+ if (repr == AUDIO_CHANNEL_REPRESENTATION_INDEX) {
+ if (audio_channel_mask_is_valid(legacy)) {
+ const int indexMask = VALUE_OR_RETURN(
+ convertIntegral<int>(audio_channel_mask_get_bits(legacy)));
+ return media::AudioChannelLayout::make<Tag::indexMask>(indexMask);
+ } else {
+ ALOGE("%s: legacy audio_channel_mask_t value 0x%x is invalid", __func__, legacy);
+ return unexpected(BAD_VALUE);
+ }
+ } else if (repr == AUDIO_CHANNEL_REPRESENTATION_POSITION) {
+ return convert(legacy, isInput ? mInAndVoice : mOut, __func__,
+ isInput ? "input / voice" : "output");
+ }
+
+ ALOGE("%s: unknown representation %d in audio_channel_mask_t value 0x%x",
+ __func__, repr, legacy);
+ return unexpected(BAD_VALUE);
+}
+
+ConversionResult<audio_devices_t> aidl2legacy_AudioDeviceDescription_audio_devices_t(
+ const media::AudioDeviceDescription& aidl) {
+ static const std::unordered_map<media::AudioDeviceDescription, audio_devices_t> m =
+ make_ReverseMap(getAudioDevicePairs());
+ if (auto it = m.find(aidl); it != m.end()) {
+ return it->second;
+ } else {
+ ALOGE("%s: no legacy audio_devices_t found for %s", __func__, aidl.toString().c_str());
+ return unexpected(BAD_VALUE);
+ }
+}
+
+ConversionResult<media::AudioDeviceDescription> legacy2aidl_audio_devices_t_AudioDeviceDescription(
+ audio_devices_t legacy) {
+ static const std::unordered_map<audio_devices_t, media::AudioDeviceDescription> m =
+ make_DirectMap(getAudioDevicePairs());
+ if (auto it = m.find(legacy); it != m.end()) {
+ return it->second;
+ } else {
+ ALOGE("%s: no AudioDeviceDescription found for legacy audio_devices_t value 0x%x",
+ __func__, legacy);
+ return unexpected(BAD_VALUE);
+ }
+}
+
+ConversionResult<audio_format_t> aidl2legacy_AudioFormatDescription_audio_format_t(
+ const media::AudioFormatDescription& aidl) {
+ static const std::unordered_map<media::AudioFormatDescription, audio_format_t> m =
+ make_ReverseMap(getAudioFormatPairs());
+ if (auto it = m.find(aidl); it != m.end()) {
+ return it->second;
+ } else {
+ ALOGE("%s: no legacy audio_format_t found for %s", __func__, aidl.toString().c_str());
+ return unexpected(BAD_VALUE);
+ }
+}
+
+ConversionResult<media::AudioFormatDescription> legacy2aidl_audio_format_t_AudioFormatDescription(
audio_format_t legacy) {
- // This relies on AudioFormat being kept in sync with audio_format_t.
- static_assert(sizeof(media::audio::common::AudioFormat) == sizeof(audio_format_t));
- return static_cast<media::audio::common::AudioFormat>(legacy);
+ static const std::unordered_map<audio_format_t, media::AudioFormatDescription> m =
+ make_DirectMap(getAudioFormatPairs());
+ if (auto it = m.find(legacy); it != m.end()) {
+ return it->second;
+ } else {
+ ALOGE("%s: no AudioFormatDescription found for legacy audio_format_t value 0x%x",
+ __func__, legacy);
+ return unexpected(BAD_VALUE);
+ }
}
ConversionResult<audio_gain_mode_t> aidl2legacy_AudioGainMode_audio_gain_mode_t(media::AudioGainMode aidl) {
@@ -449,24 +1237,14 @@
enumToMask_index<int32_t, media::AudioGainMode>);
}
-ConversionResult<audio_devices_t> aidl2legacy_int32_t_audio_devices_t(int32_t aidl) {
- // TODO(ytai): bitfield?
- return convertReinterpret<audio_devices_t>(aidl);
-}
-
-ConversionResult<int32_t> legacy2aidl_audio_devices_t_int32_t(audio_devices_t legacy) {
- // TODO(ytai): bitfield?
- return convertReinterpret<int32_t>(legacy);
-}
-
ConversionResult<audio_gain_config> aidl2legacy_AudioGainConfig_audio_gain_config(
const media::AudioGainConfig& aidl, media::AudioPortRole role, media::AudioPortType type) {
audio_gain_config legacy;
legacy.index = VALUE_OR_RETURN(convertIntegral<int>(aidl.index));
legacy.mode = VALUE_OR_RETURN(aidl2legacy_int32_t_audio_gain_mode_t_mask(aidl.mode));
- legacy.channel_mask =
- VALUE_OR_RETURN(aidl2legacy_int32_t_audio_channel_mask_t(aidl.channelMask));
const bool isInput = VALUE_OR_RETURN(direction(role, type)) == Direction::INPUT;
+ legacy.channel_mask = VALUE_OR_RETURN(
+ aidl2legacy_AudioChannelLayout_audio_channel_mask_t(aidl.channelMask, isInput));
const bool isJoint = bitmaskIsSet(aidl.mode, media::AudioGainMode::JOINT);
size_t numValues = isJoint ? 1
: isInput ? audio_channel_count_from_in_mask(legacy.channel_mask)
@@ -486,9 +1264,9 @@
media::AudioGainConfig aidl;
aidl.index = VALUE_OR_RETURN(convertIntegral<int32_t>(legacy.index));
aidl.mode = VALUE_OR_RETURN(legacy2aidl_audio_gain_mode_t_int32_t_mask(legacy.mode));
- aidl.channelMask =
- VALUE_OR_RETURN(legacy2aidl_audio_channel_mask_t_int32_t(legacy.channel_mask));
const bool isInput = VALUE_OR_RETURN(direction(role, type)) == Direction::INPUT;
+ aidl.channelMask = VALUE_OR_RETURN(
+ legacy2aidl_audio_channel_mask_t_AudioChannelLayout(legacy.channel_mask, isInput));
const bool isJoint = (legacy.mode & AUDIO_GAIN_MODE_JOINT) != 0;
size_t numValues = isJoint ? 1
: isInput ? audio_channel_count_from_in_mask(legacy.channel_mask)
@@ -722,7 +1500,7 @@
const media::AudioPortConfigDeviceExt& aidl) {
audio_port_config_device_ext legacy;
legacy.hw_module = VALUE_OR_RETURN(aidl2legacy_int32_t_audio_module_handle_t(aidl.hwModule));
- legacy.type = VALUE_OR_RETURN(aidl2legacy_int32_t_audio_devices_t(aidl.type));
+ legacy.type = VALUE_OR_RETURN(aidl2legacy_AudioDeviceDescription_audio_devices_t(aidl.type));
RETURN_IF_ERROR(aidl2legacy_string(aidl.address, legacy.address, AUDIO_DEVICE_MAX_ADDRESS_LEN));
return legacy;
}
@@ -732,7 +1510,7 @@
const audio_port_config_device_ext& legacy) {
media::AudioPortConfigDeviceExt aidl;
aidl.hwModule = VALUE_OR_RETURN(legacy2aidl_audio_module_handle_t_int32_t(legacy.hw_module));
- aidl.type = VALUE_OR_RETURN(legacy2aidl_audio_devices_t_int32_t(legacy.type));
+ aidl.type = VALUE_OR_RETURN(legacy2aidl_audio_devices_t_AudioDeviceDescription(legacy.type));
aidl.address = VALUE_OR_RETURN(
legacy2aidl_string(legacy.address, AUDIO_DEVICE_MAX_ADDRESS_LEN));
return aidl;
@@ -1053,11 +1831,15 @@
legacy.sample_rate = VALUE_OR_RETURN(convertIntegral<unsigned int>(aidl.sampleRate));
}
if (bitmaskIsSet(aidl.configMask, media::AudioPortConfigType::CHANNEL_MASK)) {
+ const bool isInput = VALUE_OR_RETURN(direction(aidl.role, aidl.type)) == Direction::INPUT;
legacy.channel_mask =
- VALUE_OR_RETURN(aidl2legacy_int32_t_audio_channel_mask_t(aidl.channelMask));
+ VALUE_OR_RETURN(
+ aidl2legacy_AudioChannelLayout_audio_channel_mask_t(
+ aidl.channelMask, isInput));
}
if (bitmaskIsSet(aidl.configMask, media::AudioPortConfigType::FORMAT)) {
- legacy.format = VALUE_OR_RETURN(aidl2legacy_AudioFormat_audio_format_t(aidl.format));
+ legacy.format = VALUE_OR_RETURN(
+ aidl2legacy_AudioFormatDescription_audio_format_t(aidl.format));
}
if (bitmaskIsSet(aidl.configMask, media::AudioPortConfigType::GAIN)) {
legacy.gain = VALUE_OR_RETURN(
@@ -1082,11 +1864,14 @@
aidl.sampleRate = VALUE_OR_RETURN(convertIntegral<int32_t>(legacy.sample_rate));
}
if (legacy.config_mask & AUDIO_PORT_CONFIG_CHANNEL_MASK) {
- aidl.channelMask =
- VALUE_OR_RETURN(legacy2aidl_audio_channel_mask_t_int32_t(legacy.channel_mask));
+ const bool isInput = VALUE_OR_RETURN(
+ direction(legacy.role, legacy.type)) == Direction::INPUT;
+ aidl.channelMask = VALUE_OR_RETURN(
+ legacy2aidl_audio_channel_mask_t_AudioChannelLayout(legacy.channel_mask, isInput));
}
if (legacy.config_mask & AUDIO_PORT_CONFIG_FORMAT) {
- aidl.format = VALUE_OR_RETURN(legacy2aidl_audio_format_t_AudioFormat(legacy.format));
+ aidl.format = VALUE_OR_RETURN(
+ legacy2aidl_audio_format_t_AudioFormatDescription(legacy.format));
}
if (legacy.config_mask & AUDIO_PORT_CONFIG_GAIN) {
aidl.gain = VALUE_OR_RETURN(legacy2aidl_audio_gain_config_AudioGainConfig(
@@ -1148,33 +1933,40 @@
ConversionResult<sp<AudioIoDescriptor>> aidl2legacy_AudioIoDescriptor_AudioIoDescriptor(
const media::AudioIoDescriptor& aidl) {
- sp<AudioIoDescriptor> legacy(new AudioIoDescriptor());
- legacy->mIoHandle = VALUE_OR_RETURN(aidl2legacy_int32_t_audio_io_handle_t(aidl.ioHandle));
- legacy->mPatch = VALUE_OR_RETURN(aidl2legacy_AudioPatch_audio_patch(aidl.patch));
- legacy->mSamplingRate = VALUE_OR_RETURN(convertIntegral<uint32_t>(aidl.samplingRate));
- legacy->mFormat = VALUE_OR_RETURN(aidl2legacy_AudioFormat_audio_format_t(aidl.format));
- legacy->mChannelMask =
- VALUE_OR_RETURN(aidl2legacy_int32_t_audio_channel_mask_t(aidl.channelMask));
- legacy->mFrameCount = VALUE_OR_RETURN(convertIntegral<size_t>(aidl.frameCount));
- legacy->mFrameCountHAL = VALUE_OR_RETURN(convertIntegral<size_t>(aidl.frameCountHAL));
- legacy->mLatency = VALUE_OR_RETURN(convertIntegral<uint32_t>(aidl.latency));
- legacy->mPortId = VALUE_OR_RETURN(aidl2legacy_int32_t_audio_port_handle_t(aidl.portId));
- return legacy;
+ const audio_io_handle_t io_handle = VALUE_OR_RETURN(
+ aidl2legacy_int32_t_audio_io_handle_t(aidl.ioHandle));
+ const struct audio_patch patch = VALUE_OR_RETURN(
+ aidl2legacy_AudioPatch_audio_patch(aidl.patch));
+ const bool isInput = aidl.isInput;
+ const uint32_t sampling_rate = VALUE_OR_RETURN(convertIntegral<uint32_t>(aidl.samplingRate));
+ const audio_format_t format = VALUE_OR_RETURN(
+ aidl2legacy_AudioFormatDescription_audio_format_t(aidl.format));
+ const audio_channel_mask_t channel_mask = VALUE_OR_RETURN(
+ aidl2legacy_AudioChannelLayout_audio_channel_mask_t(aidl.channelMask, isInput));
+ const size_t frame_count = VALUE_OR_RETURN(convertIntegral<size_t>(aidl.frameCount));
+ const size_t frame_count_hal = VALUE_OR_RETURN(convertIntegral<size_t>(aidl.frameCountHAL));
+ const uint32_t latency = VALUE_OR_RETURN(convertIntegral<uint32_t>(aidl.latency));
+ const audio_port_handle_t port_id = VALUE_OR_RETURN(
+ aidl2legacy_int32_t_audio_port_handle_t(aidl.portId));
+ return sp<AudioIoDescriptor>::make(io_handle, patch, isInput, sampling_rate, format,
+ channel_mask, frame_count, frame_count_hal, latency, port_id);
}
ConversionResult<media::AudioIoDescriptor> legacy2aidl_AudioIoDescriptor_AudioIoDescriptor(
const sp<AudioIoDescriptor>& legacy) {
media::AudioIoDescriptor aidl;
- aidl.ioHandle = VALUE_OR_RETURN(legacy2aidl_audio_io_handle_t_int32_t(legacy->mIoHandle));
- aidl.patch = VALUE_OR_RETURN(legacy2aidl_audio_patch_AudioPatch(legacy->mPatch));
- aidl.samplingRate = VALUE_OR_RETURN(convertIntegral<int32_t>(legacy->mSamplingRate));
- aidl.format = VALUE_OR_RETURN(legacy2aidl_audio_format_t_AudioFormat(legacy->mFormat));
- aidl.channelMask = VALUE_OR_RETURN(
- legacy2aidl_audio_channel_mask_t_int32_t(legacy->mChannelMask));
- aidl.frameCount = VALUE_OR_RETURN(convertIntegral<int64_t>(legacy->mFrameCount));
- aidl.frameCountHAL = VALUE_OR_RETURN(convertIntegral<int64_t>(legacy->mFrameCountHAL));
- aidl.latency = VALUE_OR_RETURN(convertIntegral<int32_t>(legacy->mLatency));
- aidl.portId = VALUE_OR_RETURN(legacy2aidl_audio_port_handle_t_int32_t(legacy->mPortId));
+ aidl.ioHandle = VALUE_OR_RETURN(legacy2aidl_audio_io_handle_t_int32_t(legacy->getIoHandle()));
+ aidl.patch = VALUE_OR_RETURN(legacy2aidl_audio_patch_AudioPatch(legacy->getPatch()));
+ aidl.isInput = legacy->getIsInput();
+ aidl.samplingRate = VALUE_OR_RETURN(convertIntegral<int32_t>(legacy->getSamplingRate()));
+ aidl.format = VALUE_OR_RETURN(
+ legacy2aidl_audio_format_t_AudioFormatDescription(legacy->getFormat()));
+ aidl.channelMask = VALUE_OR_RETURN(legacy2aidl_audio_channel_mask_t_AudioChannelLayout(
+ legacy->getChannelMask(), legacy->getIsInput()));
+ aidl.frameCount = VALUE_OR_RETURN(convertIntegral<int64_t>(legacy->getFrameCount()));
+ aidl.frameCountHAL = VALUE_OR_RETURN(convertIntegral<int64_t>(legacy->getFrameCountHAL()));
+ aidl.latency = VALUE_OR_RETURN(convertIntegral<int32_t>(legacy->getLatency()));
+ aidl.portId = VALUE_OR_RETURN(legacy2aidl_audio_port_handle_t_int32_t(legacy->getPortId()));
return aidl;
}
@@ -1473,7 +2265,7 @@
legacy.version = VALUE_OR_RETURN(convertIntegral<uint16_t>(aidl.version));
legacy.size = sizeof(audio_offload_info_t);
audio_config_base_t config = VALUE_OR_RETURN(
- aidl2legacy_AudioConfigBase_audio_config_base_t(aidl.config));
+ aidl2legacy_AudioConfigBase_audio_config_base_t(aidl.config, false /*isInput*/));
legacy.sample_rate = config.sample_rate;
legacy.channel_mask = config.channel_mask;
legacy.format = config.format;
@@ -1502,9 +2294,10 @@
}
aidl.version = VALUE_OR_RETURN(convertIntegral<int32_t>(legacy.version));
aidl.config.sampleRate = VALUE_OR_RETURN(convertIntegral<int32_t>(legacy.sample_rate));
- aidl.config.channelMask = VALUE_OR_RETURN(
- legacy2aidl_audio_channel_mask_t_int32_t(legacy.channel_mask));
- aidl.config.format = VALUE_OR_RETURN(legacy2aidl_audio_format_t_AudioFormat(legacy.format));
+ aidl.config.channelMask = VALUE_OR_RETURN(legacy2aidl_audio_channel_mask_t_AudioChannelLayout(
+ legacy.channel_mask, false /*isInput*/));
+ aidl.config.format = VALUE_OR_RETURN(
+ legacy2aidl_audio_format_t_AudioFormatDescription(legacy.format));
aidl.streamType = VALUE_OR_RETURN(
legacy2aidl_audio_stream_type_t_AudioStreamType(legacy.stream_type));
aidl.bitRate = VALUE_OR_RETURN(convertIntegral<int32_t>(legacy.bit_rate));
@@ -1531,12 +2324,12 @@
}
ConversionResult<audio_config_t>
-aidl2legacy_AudioConfig_audio_config_t(const media::AudioConfig& aidl) {
+aidl2legacy_AudioConfig_audio_config_t(const media::AudioConfig& aidl, bool isInput) {
audio_config_t legacy;
legacy.sample_rate = VALUE_OR_RETURN(convertIntegral<uint32_t>(aidl.sampleRate));
legacy.channel_mask = VALUE_OR_RETURN(
- aidl2legacy_int32_t_audio_channel_mask_t(aidl.channelMask));
- legacy.format = VALUE_OR_RETURN(aidl2legacy_AudioFormat_audio_format_t(aidl.format));
+ aidl2legacy_AudioChannelLayout_audio_channel_mask_t(aidl.channelMask, isInput));
+ legacy.format = VALUE_OR_RETURN(aidl2legacy_AudioFormatDescription_audio_format_t(aidl.format));
legacy.offload_info = VALUE_OR_RETURN(
aidl2legacy_AudioOffloadInfo_audio_offload_info_t(aidl.offloadInfo));
legacy.frame_count = VALUE_OR_RETURN(convertIntegral<uint32_t>(aidl.frameCount));
@@ -1544,12 +2337,12 @@
}
ConversionResult<media::AudioConfig>
-legacy2aidl_audio_config_t_AudioConfig(const audio_config_t& legacy) {
+legacy2aidl_audio_config_t_AudioConfig(const audio_config_t& legacy, bool isInput) {
media::AudioConfig aidl;
aidl.sampleRate = VALUE_OR_RETURN(convertIntegral<int32_t>(legacy.sample_rate));
aidl.channelMask = VALUE_OR_RETURN(
- legacy2aidl_audio_channel_mask_t_int32_t(legacy.channel_mask));
- aidl.format = VALUE_OR_RETURN(legacy2aidl_audio_format_t_AudioFormat(legacy.format));
+ legacy2aidl_audio_channel_mask_t_AudioChannelLayout(legacy.channel_mask, isInput));
+ aidl.format = VALUE_OR_RETURN(legacy2aidl_audio_format_t_AudioFormatDescription(legacy.format));
aidl.offloadInfo = VALUE_OR_RETURN(
legacy2aidl_audio_offload_info_t_AudioOffloadInfo(legacy.offload_info));
aidl.frameCount = VALUE_OR_RETURN(convertIntegral<int64_t>(legacy.frame_count));
@@ -1557,22 +2350,22 @@
}
ConversionResult<audio_config_base_t>
-aidl2legacy_AudioConfigBase_audio_config_base_t(const media::AudioConfigBase& aidl) {
+aidl2legacy_AudioConfigBase_audio_config_base_t(const media::AudioConfigBase& aidl, bool isInput) {
audio_config_base_t legacy;
legacy.sample_rate = VALUE_OR_RETURN(convertIntegral<uint32_t>(aidl.sampleRate));
legacy.channel_mask = VALUE_OR_RETURN(
- aidl2legacy_int32_t_audio_channel_mask_t(aidl.channelMask));
- legacy.format = VALUE_OR_RETURN(aidl2legacy_AudioFormat_audio_format_t(aidl.format));
+ aidl2legacy_AudioChannelLayout_audio_channel_mask_t(aidl.channelMask, isInput));
+ legacy.format = VALUE_OR_RETURN(aidl2legacy_AudioFormatDescription_audio_format_t(aidl.format));
return legacy;
}
ConversionResult<media::AudioConfigBase>
-legacy2aidl_audio_config_base_t_AudioConfigBase(const audio_config_base_t& legacy) {
+legacy2aidl_audio_config_base_t_AudioConfigBase(const audio_config_base_t& legacy, bool isInput) {
media::AudioConfigBase aidl;
aidl.sampleRate = VALUE_OR_RETURN(convertIntegral<int32_t>(legacy.sample_rate));
aidl.channelMask = VALUE_OR_RETURN(
- legacy2aidl_audio_channel_mask_t_int32_t(legacy.channel_mask));
- aidl.format = VALUE_OR_RETURN(legacy2aidl_audio_format_t_AudioFormat(legacy.format));
+ legacy2aidl_audio_channel_mask_t_AudioChannelLayout(legacy.channel_mask, isInput));
+ aidl.format = VALUE_OR_RETURN(legacy2aidl_audio_format_t_AudioFormatDescription(legacy.format));
return aidl;
}
@@ -1785,7 +2578,8 @@
aidl2legacy_AudioPortDeviceExt_audio_port_device_ext(const media::AudioPortDeviceExt& aidl) {
audio_port_device_ext legacy;
legacy.hw_module = VALUE_OR_RETURN(aidl2legacy_int32_t_audio_module_handle_t(aidl.hwModule));
- legacy.type = VALUE_OR_RETURN(aidl2legacy_int32_t_audio_devices_t(aidl.device.type));
+ legacy.type = VALUE_OR_RETURN(
+ aidl2legacy_AudioDeviceDescription_audio_devices_t(aidl.device.type));
RETURN_IF_ERROR(
aidl2legacy_string(aidl.device.address, legacy.address, sizeof(legacy.address)));
legacy.encapsulation_modes = VALUE_OR_RETURN(
@@ -1799,7 +2593,8 @@
legacy2aidl_audio_port_device_ext_AudioPortDeviceExt(const audio_port_device_ext& legacy) {
media::AudioPortDeviceExt aidl;
aidl.hwModule = VALUE_OR_RETURN(legacy2aidl_audio_module_handle_t_int32_t(legacy.hw_module));
- aidl.device.type = VALUE_OR_RETURN(legacy2aidl_audio_devices_t_int32_t(legacy.type));
+ aidl.device.type = VALUE_OR_RETURN(
+ legacy2aidl_audio_devices_t_AudioDeviceDescription(legacy.type));
aidl.device.address = VALUE_OR_RETURN(
legacy2aidl_string(legacy.address, sizeof(legacy.address)));
aidl.encapsulationModes = VALUE_OR_RETURN(
@@ -1899,9 +2694,9 @@
}
ConversionResult<audio_profile>
-aidl2legacy_AudioProfile_audio_profile(const media::AudioProfile& aidl) {
+aidl2legacy_AudioProfile_audio_profile(const media::AudioProfile& aidl, bool isInput) {
audio_profile legacy;
- legacy.format = VALUE_OR_RETURN(aidl2legacy_AudioFormat_audio_format_t(aidl.format));
+ legacy.format = VALUE_OR_RETURN(aidl2legacy_AudioFormatDescription_audio_format_t(aidl.format));
if (aidl.samplingRates.size() > std::size(legacy.sample_rates)) {
return unexpected(BAD_VALUE);
@@ -1916,7 +2711,9 @@
}
RETURN_IF_ERROR(
convertRange(aidl.channelMasks.begin(), aidl.channelMasks.end(), legacy.channel_masks,
- aidl2legacy_int32_t_audio_channel_mask_t));
+ [isInput](const media::AudioChannelLayout& l) {
+ return aidl2legacy_AudioChannelLayout_audio_channel_mask_t(l, isInput);
+ }));
legacy.num_channel_masks = aidl.channelMasks.size();
legacy.encapsulation_type = VALUE_OR_RETURN(
@@ -1925,9 +2722,9 @@
}
ConversionResult<media::AudioProfile>
-legacy2aidl_audio_profile_AudioProfile(const audio_profile& legacy) {
+legacy2aidl_audio_profile_AudioProfile(const audio_profile& legacy, bool isInput) {
media::AudioProfile aidl;
- aidl.format = VALUE_OR_RETURN(legacy2aidl_audio_format_t_AudioFormat(legacy.format));
+ aidl.format = VALUE_OR_RETURN(legacy2aidl_audio_format_t_AudioFormatDescription(legacy.format));
if (legacy.num_sample_rates > std::size(legacy.sample_rates)) {
return unexpected(BAD_VALUE);
@@ -1943,7 +2740,9 @@
RETURN_IF_ERROR(
convertRange(legacy.channel_masks, legacy.channel_masks + legacy.num_channel_masks,
std::back_inserter(aidl.channelMasks),
- legacy2aidl_audio_channel_mask_t_int32_t));
+ [isInput](audio_channel_mask_t m) {
+ return legacy2aidl_audio_channel_mask_t_AudioChannelLayout(m, isInput);
+ }));
aidl.encapsulationType = VALUE_OR_RETURN(
legacy2aidl_audio_encapsulation_type_t_AudioEncapsulationType(
@@ -1955,8 +2754,8 @@
aidl2legacy_AudioGain_audio_gain(const media::AudioGain& aidl) {
audio_gain legacy;
legacy.mode = VALUE_OR_RETURN(aidl2legacy_int32_t_audio_gain_mode_t_mask(aidl.mode));
- legacy.channel_mask = VALUE_OR_RETURN(
- aidl2legacy_int32_t_audio_channel_mask_t(aidl.channelMask));
+ legacy.channel_mask = VALUE_OR_RETURN(aidl2legacy_AudioChannelLayout_audio_channel_mask_t(
+ aidl.channelMask, aidl.isInput));
legacy.min_value = VALUE_OR_RETURN(convertIntegral<int>(aidl.minValue));
legacy.max_value = VALUE_OR_RETURN(convertIntegral<int>(aidl.maxValue));
legacy.default_value = VALUE_OR_RETURN(convertIntegral<int>(aidl.defaultValue));
@@ -1967,11 +2766,12 @@
}
ConversionResult<media::AudioGain>
-legacy2aidl_audio_gain_AudioGain(const audio_gain& legacy) {
+legacy2aidl_audio_gain_AudioGain(const audio_gain& legacy, bool isInput) {
media::AudioGain aidl;
aidl.mode = VALUE_OR_RETURN(legacy2aidl_audio_gain_mode_t_int32_t_mask(legacy.mode));
+ aidl.isInput = isInput;
aidl.channelMask = VALUE_OR_RETURN(
- legacy2aidl_audio_channel_mask_t_int32_t(legacy.channel_mask));
+ legacy2aidl_audio_channel_mask_t_AudioChannelLayout(legacy.channel_mask, isInput));
aidl.minValue = VALUE_OR_RETURN(convertIntegral<int32_t>(legacy.min_value));
aidl.maxValue = VALUE_OR_RETURN(convertIntegral<int32_t>(legacy.max_value));
aidl.defaultValue = VALUE_OR_RETURN(convertIntegral<int32_t>(legacy.default_value));
@@ -1992,8 +2792,11 @@
if (aidl.profiles.size() > std::size(legacy.audio_profiles)) {
return unexpected(BAD_VALUE);
}
+ const bool isInput = VALUE_OR_RETURN(direction(aidl.role, aidl.type)) == Direction::INPUT;
RETURN_IF_ERROR(convertRange(aidl.profiles.begin(), aidl.profiles.end(), legacy.audio_profiles,
- aidl2legacy_AudioProfile_audio_profile));
+ [isInput](const media::AudioProfile& p) {
+ return aidl2legacy_AudioProfile_audio_profile(p, isInput);
+ }));
legacy.num_audio_profiles = aidl.profiles.size();
if (aidl.extraAudioDescriptors.size() > std::size(legacy.extra_audio_descriptors)) {
@@ -2029,10 +2832,13 @@
if (legacy.num_audio_profiles > std::size(legacy.audio_profiles)) {
return unexpected(BAD_VALUE);
}
+ const bool isInput = VALUE_OR_RETURN(direction(legacy.role, legacy.type)) == Direction::INPUT;
RETURN_IF_ERROR(
convertRange(legacy.audio_profiles, legacy.audio_profiles + legacy.num_audio_profiles,
std::back_inserter(aidl.profiles),
- legacy2aidl_audio_profile_AudioProfile));
+ [isInput](const audio_profile& p) {
+ return legacy2aidl_audio_profile_AudioProfile(p, isInput);
+ }));
if (legacy.num_extra_audio_descriptors > std::size(legacy.extra_audio_descriptors)) {
return unexpected(BAD_VALUE);
@@ -2049,7 +2855,9 @@
RETURN_IF_ERROR(
convertRange(legacy.gains, legacy.gains + legacy.num_gains,
std::back_inserter(aidl.gains),
- legacy2aidl_audio_gain_AudioGain));
+ [isInput](const audio_gain& g) {
+ return legacy2aidl_audio_gain_AudioGain(g, isInput);
+ }));
aidl.activeConfig = VALUE_OR_RETURN(
legacy2aidl_audio_port_config_AudioPortConfig(legacy.active_config));
diff --git a/media/libaudioclient/Android.bp b/media/libaudioclient/Android.bp
index 4ab9b28..9b9ceea 100644
--- a/media/libaudioclient/Android.bp
+++ b/media/libaudioclient/Android.bp
@@ -229,6 +229,7 @@
"libbinder",
"liblog",
"libshmemcompat",
+ "libstagefright_foundation",
"libutils",
"shared-file-region-aidl-cpp",
"framework-permission-aidl-cpp",
@@ -302,15 +303,20 @@
local_include_dir: "aidl",
srcs: [
"aidl/android/media/AudioAttributesInternal.aidl",
+ "aidl/android/media/AudioChannelLayout.aidl",
"aidl/android/media/AudioClient.aidl",
"aidl/android/media/AudioConfig.aidl",
"aidl/android/media/AudioConfigBase.aidl",
"aidl/android/media/AudioContentType.aidl",
"aidl/android/media/AudioDevice.aidl",
+ "aidl/android/media/AudioDeviceDescription.aidl",
+ "aidl/android/media/AudioDeviceType.aidl",
"aidl/android/media/AudioDualMonoMode.aidl",
"aidl/android/media/AudioEncapsulationMode.aidl",
"aidl/android/media/AudioEncapsulationMetadataType.aidl",
"aidl/android/media/AudioEncapsulationType.aidl",
+ "aidl/android/media/AudioFormatDescription.aidl",
+ "aidl/android/media/AudioFormatType.aidl",
"aidl/android/media/AudioFlag.aidl",
"aidl/android/media/AudioGain.aidl",
"aidl/android/media/AudioGainConfig.aidl",
@@ -350,10 +356,11 @@
"aidl/android/media/AudioVibratorInfo.aidl",
"aidl/android/media/EffectDescriptor.aidl",
"aidl/android/media/ExtraAudioDescriptor.aidl",
+ "aidl/android/media/PcmType.aidl",
"aidl/android/media/TrackSecondaryOutputInfo.aidl",
],
imports: [
- "audio_common-aidl",
+ "android.media.audio.common.types",
"framework-permission-aidl",
],
backend: {
@@ -364,6 +371,9 @@
"com.android.media",
],
},
+ java: {
+ sdk_version: "module_current",
+ },
},
}
aidl_interface {
@@ -393,7 +403,6 @@
"aidl/android/media/SpatializationLevel.aidl",
],
imports: [
- "audio_common-aidl",
"audioclient-types-aidl",
],
backend: {
@@ -404,6 +413,9 @@
"com.android.media",
],
},
+ java: {
+ sdk_version: "module_current",
+ },
},
}
@@ -433,7 +445,6 @@
"aidl/android/media/IAudioTrackCallback.aidl",
],
imports: [
- "audio_common-aidl",
"audioclient-types-aidl",
"av-types-aidl",
"effect-aidl",
@@ -449,6 +460,9 @@
"com.android.media",
],
},
+ java: {
+ sdk_version: "module_current",
+ },
},
}
@@ -470,7 +484,6 @@
"aidl/android/media/ISpatializer.aidl",
],
imports: [
- "audio_common-aidl",
"audioclient-types-aidl",
"audiopolicy-types-aidl",
"capture_state_listener-aidl",
@@ -486,5 +499,8 @@
"com.android.media",
],
},
+ java: {
+ sdk_version: "module_current",
+ },
},
}
diff --git a/media/libaudioclient/AudioRecord.cpp b/media/libaudioclient/AudioRecord.cpp
index a1d3bdb..d3c5231 100644
--- a/media/libaudioclient/AudioRecord.cpp
+++ b/media/libaudioclient/AudioRecord.cpp
@@ -22,6 +22,7 @@
#include <android-base/macros.h>
#include <sys/resource.h>
+#include <audio_utils/format.h>
#include <audiomanager/AudioManager.h>
#include <audiomanager/IAudioManager.h>
#include <binder/Binder.h>
@@ -668,6 +669,8 @@
// ---- Explicit Routing ---------------------------------------------------
status_t AudioRecord::setInputDevice(audio_port_handle_t deviceId) {
AutoMutex lock(mLock);
+ ALOGV("%s(%d): deviceId=%d mSelectedDeviceId=%d",
+ __func__, mPortId, deviceId, mSelectedDeviceId);
if (mSelectedDeviceId != deviceId) {
mSelectedDeviceId = deviceId;
if (mStatus == NO_ERROR) {
@@ -856,6 +859,10 @@
mRoutedDeviceId = output.selectedDeviceId;
mSessionId = output.sessionId;
mSampleRate = output.sampleRate;
+ mServerConfig = output.serverConfig;
+ mServerFrameSize = audio_bytes_per_frame(
+ audio_channel_count_from_in_mask(mServerConfig.channel_mask), mServerConfig.format);
+ mServerSampleSize = audio_bytes_per_sample(mServerConfig.format);
if (output.cblk == 0) {
ALOGE("%s(%d): Could not get control block", __func__, mPortId);
@@ -919,6 +926,10 @@
mNotificationFramesReq, output.notificationFrameCount, output.frameCount);
}
mNotificationFramesAct = (uint32_t)output.notificationFrameCount;
+ if (mServerConfig.format != mFormat && mCbf != nullptr) {
+ mFormatConversionBufRaw = std::make_unique<uint8_t[]>(mNotificationFramesAct * mFrameSize);
+ mFormatConversionBuffer.raw = mFormatConversionBufRaw.get();
+ }
//mInput != input includes the case where mInput == AUDIO_IO_HANDLE_NONE for first creation
if (mDeviceCallback != 0) {
@@ -945,7 +956,7 @@
}
// update proxy
- mProxy = new AudioRecordClientProxy(cblk, buffers, mFrameCount, mFrameSize);
+ mProxy = new AudioRecordClientProxy(cblk, buffers, mFrameCount, mServerFrameSize);
mProxy->setEpoch(epoch);
mProxy->setMinimum(mNotificationFramesAct);
@@ -1075,7 +1086,7 @@
} while ((status == DEAD_OBJECT) && (tryCounter-- > 0));
audioBuffer->frameCount = buffer.mFrameCount;
- audioBuffer->size = buffer.mFrameCount * mFrameSize;
+ audioBuffer->size = buffer.mFrameCount * mServerFrameSize;
audioBuffer->raw = buffer.mRaw;
audioBuffer->sequence = oldSequence;
if (nonContig != NULL) {
@@ -1088,7 +1099,7 @@
{
// FIXME add error checking on mode, by adding an internal version
- size_t stepCount = audioBuffer->size / mFrameSize;
+ size_t stepCount = audioBuffer->frameCount;
if (stepCount == 0) {
return;
}
@@ -1150,8 +1161,9 @@
return ssize_t(err);
}
- size_t bytesRead = audioBuffer.size;
- memcpy(buffer, audioBuffer.i8, bytesRead);
+ size_t bytesRead = audioBuffer.frameCount * mFrameSize;
+ memcpy_by_audio_format(buffer, mFormat, audioBuffer.raw, mServerConfig.format,
+ audioBuffer.size / mServerSampleSize);
buffer = ((char *) buffer) + bytesRead;
userSize -= bytesRead;
read += bytesRead;
@@ -1348,9 +1360,19 @@
}
}
- size_t reqSize = audioBuffer.size;
- mCbf(EVENT_MORE_DATA, mUserData, &audioBuffer);
- size_t readSize = audioBuffer.size;
+ Buffer* buffer = &audioBuffer;
+ if (mServerConfig.format != mFormat) {
+ buffer = &mFormatConversionBuffer;
+ buffer->frameCount = audioBuffer.frameCount;
+ buffer->size = buffer->frameCount * mFrameSize;
+ buffer->sequence = audioBuffer.sequence;
+ memcpy_by_audio_format(buffer->raw, mFormat, audioBuffer.raw,
+ mServerConfig.format, audioBuffer.size / mServerSampleSize);
+ }
+
+ size_t reqSize = buffer->size;
+ mCbf(EVENT_MORE_DATA, mUserData, buffer);
+ size_t readSize = buffer->size;
// Validate on returned size
if (ssize_t(readSize) < 0 || readSize > reqSize) {
diff --git a/media/libaudioclient/AudioSystem.cpp b/media/libaudioclient/AudioSystem.cpp
index c7967e5..65bf97d 100644
--- a/media/libaudioclient/AudioSystem.cpp
+++ b/media/libaudioclient/AudioSystem.cpp
@@ -336,7 +336,7 @@
if (desc == 0) {
*samplingRate = af->sampleRate(ioHandle);
} else {
- *samplingRate = desc->mSamplingRate;
+ *samplingRate = desc->getSamplingRate();
}
if (*samplingRate == 0) {
ALOGE("AudioSystem::getSamplingRate failed for ioHandle %d", ioHandle);
@@ -371,7 +371,7 @@
if (desc == 0) {
*frameCount = af->frameCount(ioHandle);
} else {
- *frameCount = desc->mFrameCount;
+ *frameCount = desc->getFrameCount();
}
if (*frameCount == 0) {
ALOGE("AudioSystem::getFrameCount failed for ioHandle %d", ioHandle);
@@ -406,7 +406,7 @@
if (outputDesc == 0) {
*latency = af->latency(output);
} else {
- *latency = outputDesc->mLatency;
+ *latency = outputDesc->getLatency();
}
ALOGV("getLatency() output %d, latency %d", output, *latency);
@@ -494,7 +494,7 @@
if (desc == 0) {
*frameCount = af->frameCountHAL(ioHandle);
} else {
- *frameCount = desc->mFrameCountHAL;
+ *frameCount = desc->getFrameCountHAL();
}
if (*frameCount == 0) {
ALOGE("AudioSystem::getFrameCountHAL failed for ioHandle %d", ioHandle);
@@ -535,15 +535,15 @@
Status AudioSystem::AudioFlingerClient::ioConfigChanged(
media::AudioIoConfigEvent _event,
const media::AudioIoDescriptor& _ioDesc) {
- audio_io_config_event event = VALUE_OR_RETURN_BINDER_STATUS(
- aidl2legacy_AudioIoConfigEvent_audio_io_config_event(_event));
+ audio_io_config_event_t event = VALUE_OR_RETURN_BINDER_STATUS(
+ aidl2legacy_AudioIoConfigEvent_audio_io_config_event_t(_event));
sp<AudioIoDescriptor> ioDesc(
VALUE_OR_RETURN_BINDER_STATUS(
aidl2legacy_AudioIoDescriptor_AudioIoDescriptor(_ioDesc)));
ALOGV("ioConfigChanged() event %d", event);
- if (ioDesc->mIoHandle == AUDIO_IO_HANDLE_NONE) return Status::ok();
+ if (ioDesc->getIoHandle() == AUDIO_IO_HANDLE_NONE) return Status::ok();
audio_port_handle_t deviceId = AUDIO_PORT_HANDLE_NONE;
std::vector<sp<AudioDeviceCallback>> callbacksToCall;
@@ -556,93 +556,88 @@
case AUDIO_OUTPUT_REGISTERED:
case AUDIO_INPUT_OPENED:
case AUDIO_INPUT_REGISTERED: {
- sp<AudioIoDescriptor> oldDesc = getIoDescriptor_l(ioDesc->mIoHandle);
+ sp<AudioIoDescriptor> oldDesc = getIoDescriptor_l(ioDesc->getIoHandle());
if (oldDesc == 0) {
- mIoDescriptors.add(ioDesc->mIoHandle, ioDesc);
+ mIoDescriptors.add(ioDesc->getIoHandle(), ioDesc);
} else {
deviceId = oldDesc->getDeviceId();
- mIoDescriptors.replaceValueFor(ioDesc->mIoHandle, ioDesc);
+ mIoDescriptors.replaceValueFor(ioDesc->getIoHandle(), ioDesc);
}
if (ioDesc->getDeviceId() != AUDIO_PORT_HANDLE_NONE) {
deviceId = ioDesc->getDeviceId();
if (event == AUDIO_OUTPUT_OPENED || event == AUDIO_INPUT_OPENED) {
- auto it = mAudioDeviceCallbacks.find(ioDesc->mIoHandle);
+ auto it = mAudioDeviceCallbacks.find(ioDesc->getIoHandle());
if (it != mAudioDeviceCallbacks.end()) {
callbacks = it->second;
}
}
}
- ALOGV("ioConfigChanged() new %s %s %d samplingRate %u, format %#x channel mask %#x "
- "frameCount %zu deviceId %d",
+ ALOGV("ioConfigChanged() new %s %s %s",
event == AUDIO_OUTPUT_OPENED || event == AUDIO_OUTPUT_REGISTERED ?
"output" : "input",
event == AUDIO_OUTPUT_OPENED || event == AUDIO_INPUT_OPENED ?
"opened" : "registered",
- ioDesc->mIoHandle, ioDesc->mSamplingRate, ioDesc->mFormat,
- ioDesc->mChannelMask,
- ioDesc->mFrameCount, ioDesc->getDeviceId());
+ ioDesc->toDebugString().c_str());
}
break;
case AUDIO_OUTPUT_CLOSED:
case AUDIO_INPUT_CLOSED: {
- if (getIoDescriptor_l(ioDesc->mIoHandle) == 0) {
+ if (getIoDescriptor_l(ioDesc->getIoHandle()) == 0) {
ALOGW("ioConfigChanged() closing unknown %s %d",
- event == AUDIO_OUTPUT_CLOSED ? "output" : "input", ioDesc->mIoHandle);
+ event == AUDIO_OUTPUT_CLOSED ? "output" : "input", ioDesc->getIoHandle());
break;
}
ALOGV("ioConfigChanged() %s %d closed",
- event == AUDIO_OUTPUT_CLOSED ? "output" : "input", ioDesc->mIoHandle);
+ event == AUDIO_OUTPUT_CLOSED ? "output" : "input", ioDesc->getIoHandle());
- mIoDescriptors.removeItem(ioDesc->mIoHandle);
- mAudioDeviceCallbacks.erase(ioDesc->mIoHandle);
+ mIoDescriptors.removeItem(ioDesc->getIoHandle());
+ mAudioDeviceCallbacks.erase(ioDesc->getIoHandle());
}
break;
case AUDIO_OUTPUT_CONFIG_CHANGED:
case AUDIO_INPUT_CONFIG_CHANGED: {
- sp<AudioIoDescriptor> oldDesc = getIoDescriptor_l(ioDesc->mIoHandle);
+ sp<AudioIoDescriptor> oldDesc = getIoDescriptor_l(ioDesc->getIoHandle());
if (oldDesc == 0) {
ALOGW("ioConfigChanged() modifying unknown %s! %d",
event == AUDIO_OUTPUT_CONFIG_CHANGED ? "output" : "input",
- ioDesc->mIoHandle);
+ ioDesc->getIoHandle());
break;
}
deviceId = oldDesc->getDeviceId();
- mIoDescriptors.replaceValueFor(ioDesc->mIoHandle, ioDesc);
+ mIoDescriptors.replaceValueFor(ioDesc->getIoHandle(), ioDesc);
if (deviceId != ioDesc->getDeviceId()) {
deviceId = ioDesc->getDeviceId();
- auto it = mAudioDeviceCallbacks.find(ioDesc->mIoHandle);
+ auto it = mAudioDeviceCallbacks.find(ioDesc->getIoHandle());
if (it != mAudioDeviceCallbacks.end()) {
callbacks = it->second;
}
}
- ALOGV("ioConfigChanged() new config for %s %d samplingRate %u, format %#x "
- "channel mask %#x frameCount %zu frameCountHAL %zu deviceId %d",
+ ALOGV("ioConfigChanged() new config for %s %s",
event == AUDIO_OUTPUT_CONFIG_CHANGED ? "output" : "input",
- ioDesc->mIoHandle, ioDesc->mSamplingRate, ioDesc->mFormat,
- ioDesc->mChannelMask, ioDesc->mFrameCount, ioDesc->mFrameCountHAL,
- ioDesc->getDeviceId());
+ ioDesc->toDebugString().c_str());
}
break;
case AUDIO_CLIENT_STARTED: {
- sp<AudioIoDescriptor> oldDesc = getIoDescriptor_l(ioDesc->mIoHandle);
+ sp<AudioIoDescriptor> oldDesc = getIoDescriptor_l(ioDesc->getIoHandle());
if (oldDesc == 0) {
- ALOGW("ioConfigChanged() start client on unknown io! %d", ioDesc->mIoHandle);
+ ALOGW("ioConfigChanged() start client on unknown io! %d",
+ ioDesc->getIoHandle());
break;
}
ALOGV("ioConfigChanged() AUDIO_CLIENT_STARTED io %d port %d num callbacks %zu",
- ioDesc->mIoHandle, ioDesc->mPortId, mAudioDeviceCallbacks.size());
- oldDesc->mPatch = ioDesc->mPatch;
- auto it = mAudioDeviceCallbacks.find(ioDesc->mIoHandle);
+ ioDesc->getIoHandle(), ioDesc->getPortId(), mAudioDeviceCallbacks.size());
+ oldDesc->setPatch(ioDesc->getPatch());
+ auto it = mAudioDeviceCallbacks.find(ioDesc->getIoHandle());
if (it != mAudioDeviceCallbacks.end()) {
auto cbks = it->second;
- auto it2 = cbks.find(ioDesc->mPortId);
+ auto it2 = cbks.find(ioDesc->getPortId());
if (it2 != cbks.end()) {
- callbacks.emplace(ioDesc->mPortId, it2->second);
+ callbacks.emplace(ioDesc->getPortId(), it2->second);
deviceId = oldDesc->getDeviceId();
}
}
@@ -661,8 +656,8 @@
// Callbacks must be called without mLock held. May lead to dead lock if calling for
// example getRoutedDevice that updates the device and tries to acquire mLock.
for (auto cb : callbacksToCall) {
- // If callbacksToCall is not empty, it implies ioDesc->mIoHandle and deviceId are valid
- cb->onAudioDeviceUpdate(ioDesc->mIoHandle, deviceId);
+ // If callbacksToCall is not empty, it implies ioDesc->getIoHandle() and deviceId are valid
+ cb->onAudioDeviceUpdate(ioDesc->getIoHandle(), deviceId);
}
return Status::ok();
@@ -852,7 +847,8 @@
}
media::AudioDevice deviceAidl;
- deviceAidl.type = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_devices_t_int32_t(device));
+ deviceAidl.type = VALUE_OR_RETURN_STATUS(
+ legacy2aidl_audio_devices_t_AudioDeviceDescription(device));
deviceAidl.address = address;
return statusTFromBinderStatus(
@@ -861,7 +857,8 @@
VALUE_OR_RETURN_STATUS(
legacy2aidl_audio_policy_dev_state_t_AudioPolicyDeviceState(state)),
name,
- VALUE_OR_RETURN_STATUS(legacy2aidl_audio_format_t_AudioFormat(encodedFormat))));
+ VALUE_OR_RETURN_STATUS(
+ legacy2aidl_audio_format_t_AudioFormatDescription(encodedFormat))));
}
audio_policy_dev_state_t AudioSystem::getDeviceConnectionState(audio_devices_t device,
@@ -871,7 +868,8 @@
auto result = [&]() -> ConversionResult<audio_policy_dev_state_t> {
media::AudioDevice deviceAidl;
- deviceAidl.type = VALUE_OR_RETURN(legacy2aidl_audio_devices_t_int32_t(device));
+ deviceAidl.type = VALUE_OR_RETURN(
+ legacy2aidl_audio_devices_t_AudioDeviceDescription(device));
deviceAidl.address = device_address;
media::AudioPolicyDeviceState result;
@@ -901,12 +899,13 @@
}
media::AudioDevice deviceAidl;
- deviceAidl.type = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_devices_t_int32_t(device));
+ deviceAidl.type = VALUE_OR_RETURN_STATUS(
+ legacy2aidl_audio_devices_t_AudioDeviceDescription(device));
deviceAidl.address = address;
return statusTFromBinderStatus(
aps->handleDeviceConfigChange(deviceAidl, name, VALUE_OR_RETURN_STATUS(
- legacy2aidl_audio_format_t_AudioFormat(encodedFormat))));
+ legacy2aidl_audio_format_t_AudioFormatDescription(encodedFormat))));
}
status_t AudioSystem::setPhoneState(audio_mode_t state, uid_t uid) {
@@ -1004,7 +1003,7 @@
legacy2aidl_audio_attributes_t_AudioAttributesInternal(*attr));
int32_t sessionAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_session_t_int32_t(session));
media::AudioConfig configAidl = VALUE_OR_RETURN_STATUS(
- legacy2aidl_audio_config_t_AudioConfig(*config));
+ legacy2aidl_audio_config_t_AudioConfig(*config, false /*isInput*/));
int32_t flagsAidl = VALUE_OR_RETURN_STATUS(
legacy2aidl_audio_output_flags_t_int32_t_mask(flags));
int32_t selectedDeviceIdAidl = VALUE_OR_RETURN_STATUS(
@@ -1098,7 +1097,7 @@
int32_t riidAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_unique_id_t_int32_t(riid));
int32_t sessionAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_session_t_int32_t(session));
media::AudioConfigBase configAidl = VALUE_OR_RETURN_STATUS(
- legacy2aidl_audio_config_base_t_AudioConfigBase(*config));
+ legacy2aidl_audio_config_base_t_AudioConfigBase(*config, true /*isInput*/));
int32_t flagsAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_input_flags_t_int32_t_mask(flags));
int32_t selectedDeviceIdAidl = VALUE_OR_RETURN_STATUS(
legacy2aidl_audio_port_handle_t_int32_t(*selectedDeviceId));
@@ -1171,7 +1170,8 @@
media::AudioStreamType streamAidl = VALUE_OR_RETURN_STATUS(
legacy2aidl_audio_stream_type_t_AudioStreamType(stream));
int32_t indexAidl = VALUE_OR_RETURN_STATUS(convertIntegral<int32_t>(index));
- int32_t deviceAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_devices_t_int32_t(device));
+ media::AudioDeviceDescription deviceAidl = VALUE_OR_RETURN_STATUS(
+ legacy2aidl_audio_devices_t_AudioDeviceDescription(device));
return statusTFromBinderStatus(
aps->setStreamVolumeIndex(streamAidl, deviceAidl, indexAidl));
}
@@ -1184,7 +1184,8 @@
media::AudioStreamType streamAidl = VALUE_OR_RETURN_STATUS(
legacy2aidl_audio_stream_type_t_AudioStreamType(stream));
- int32_t deviceAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_devices_t_int32_t(device));
+ media::AudioDeviceDescription deviceAidl = VALUE_OR_RETURN_STATUS(
+ legacy2aidl_audio_devices_t_AudioDeviceDescription(device));
int32_t indexAidl;
RETURN_STATUS_IF_ERROR(statusTFromBinderStatus(
aps->getStreamVolumeIndex(streamAidl, deviceAidl, &indexAidl)));
@@ -1203,7 +1204,8 @@
media::AudioAttributesInternal attrAidl = VALUE_OR_RETURN_STATUS(
legacy2aidl_audio_attributes_t_AudioAttributesInternal(attr));
int32_t indexAidl = VALUE_OR_RETURN_STATUS(convertIntegral<int32_t>(index));
- int32_t deviceAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_devices_t_int32_t(device));
+ media::AudioDeviceDescription deviceAidl = VALUE_OR_RETURN_STATUS(
+ legacy2aidl_audio_devices_t_AudioDeviceDescription(device));
return statusTFromBinderStatus(
aps->setVolumeIndexForAttributes(attrAidl, deviceAidl, indexAidl));
}
@@ -1216,7 +1218,8 @@
media::AudioAttributesInternal attrAidl = VALUE_OR_RETURN_STATUS(
legacy2aidl_audio_attributes_t_AudioAttributesInternal(attr));
- int32_t deviceAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_devices_t_int32_t(device));
+ media::AudioDeviceDescription deviceAidl = VALUE_OR_RETURN_STATUS(
+ legacy2aidl_audio_devices_t_AudioDeviceDescription(device));
int32_t indexAidl;
RETURN_STATUS_IF_ERROR(statusTFromBinderStatus(
aps->getVolumeIndexForAttributes(attrAidl, deviceAidl, &indexAidl)));
@@ -1265,19 +1268,20 @@
return result.value_or(PRODUCT_STRATEGY_NONE);
}
-audio_devices_t AudioSystem::getDevicesForStream(audio_stream_type_t stream) {
+DeviceTypeSet AudioSystem::getDevicesForStream(audio_stream_type_t stream) {
const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
- if (aps == 0) return AUDIO_DEVICE_NONE;
+ if (aps == 0) return DeviceTypeSet{};
- auto result = [&]() -> ConversionResult<audio_devices_t> {
+ auto result = [&]() -> ConversionResult<DeviceTypeSet> {
media::AudioStreamType streamAidl = VALUE_OR_RETURN(
legacy2aidl_audio_stream_type_t_AudioStreamType(stream));
- int32_t resultAidl;
+ std::vector<media::AudioDeviceDescription> resultAidl;
RETURN_IF_ERROR(statusTFromBinderStatus(
aps->getDevicesForStream(streamAidl, &resultAidl)));
- return aidl2legacy_int32_t_audio_devices_t(resultAidl);
+ return convertContainer<DeviceTypeSet>(resultAidl,
+ aidl2legacy_AudioDeviceDescription_audio_devices_t);
}();
- return result.value_or(AUDIO_DEVICE_NONE);
+ return result.value_or(DeviceTypeSet{});
}
status_t AudioSystem::getDevicesForAttributes(const AudioAttributes& aa,
@@ -1696,7 +1700,8 @@
statusTFromBinderStatus(aps->acquireSoundTriggerSession(&retAidl)));
*session = VALUE_OR_RETURN_STATUS(aidl2legacy_int32_t_audio_session_t(retAidl.session));
*ioHandle = VALUE_OR_RETURN_STATUS(aidl2legacy_int32_t_audio_io_handle_t(retAidl.ioHandle));
- *device = VALUE_OR_RETURN_STATUS(aidl2legacy_int32_t_audio_devices_t(retAidl.device));
+ *device = VALUE_OR_RETURN_STATUS(
+ aidl2legacy_AudioDeviceDescription_audio_devices_t(retAidl.device));
return OK;
}
@@ -1836,7 +1841,8 @@
media::AudioStreamType streamAidl = VALUE_OR_RETURN(
legacy2aidl_audio_stream_type_t_AudioStreamType(stream));
int32_t indexAidl = VALUE_OR_RETURN(convertIntegral<int32_t>(index));
- int32_t deviceAidl = VALUE_OR_RETURN(legacy2aidl_audio_devices_t_int32_t(device));
+ media::AudioDeviceDescription deviceAidl = VALUE_OR_RETURN(
+ legacy2aidl_audio_devices_t_AudioDeviceDescription(device));
float retAidl;
RETURN_IF_ERROR(statusTFromBinderStatus(
aps->getStreamVolumeDB(streamAidl, indexAidl, deviceAidl, &retAidl)));
@@ -1871,7 +1877,7 @@
media::Int numSurroundFormatsAidl;
numSurroundFormatsAidl.value =
VALUE_OR_RETURN_STATUS(convertIntegral<int32_t>(*numSurroundFormats));
- std::vector<media::audio::common::AudioFormat> surroundFormatsAidl;
+ std::vector<media::AudioFormatDescription> surroundFormatsAidl;
std::vector<bool> surroundFormatsEnabledAidl;
RETURN_STATUS_IF_ERROR(statusTFromBinderStatus(
aps->getSurroundFormats(&numSurroundFormatsAidl, &surroundFormatsAidl,
@@ -1881,7 +1887,7 @@
convertIntegral<unsigned int>(numSurroundFormatsAidl.value));
RETURN_STATUS_IF_ERROR(
convertRange(surroundFormatsAidl.begin(), surroundFormatsAidl.end(), surroundFormats,
- aidl2legacy_AudioFormat_audio_format_t));
+ aidl2legacy_AudioFormatDescription_audio_format_t));
std::copy(surroundFormatsEnabledAidl.begin(), surroundFormatsEnabledAidl.end(),
surroundFormatsEnabled);
return OK;
@@ -1898,7 +1904,7 @@
media::Int numSurroundFormatsAidl;
numSurroundFormatsAidl.value =
VALUE_OR_RETURN_STATUS(convertIntegral<int32_t>(*numSurroundFormats));
- std::vector<media::audio::common::AudioFormat> surroundFormatsAidl;
+ std::vector<media::AudioFormatDescription> surroundFormatsAidl;
RETURN_STATUS_IF_ERROR(statusTFromBinderStatus(
aps->getReportedSurroundFormats(&numSurroundFormatsAidl, &surroundFormatsAidl)));
@@ -1906,7 +1912,7 @@
convertIntegral<unsigned int>(numSurroundFormatsAidl.value));
RETURN_STATUS_IF_ERROR(
convertRange(surroundFormatsAidl.begin(), surroundFormatsAidl.end(), surroundFormats,
- aidl2legacy_AudioFormat_audio_format_t));
+ aidl2legacy_AudioFormatDescription_audio_format_t));
return OK;
}
@@ -1914,8 +1920,8 @@
const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
if (aps == 0) return PERMISSION_DENIED;
- media::audio::common::AudioFormat audioFormatAidl = VALUE_OR_RETURN_STATUS(
- legacy2aidl_audio_format_t_AudioFormat(audioFormat));
+ media::AudioFormatDescription audioFormatAidl = VALUE_OR_RETURN_STATUS(
+ legacy2aidl_audio_format_t_AudioFormatDescription(audioFormat));
return statusTFromBinderStatus(
aps->setSurroundFormatEnabled(audioFormatAidl, enabled));
}
@@ -1976,12 +1982,13 @@
& aps = AudioSystem::get_audio_policy_service();
if (aps == 0) return PERMISSION_DENIED;
- std::vector<media::audio::common::AudioFormat> formatsAidl;
+ std::vector<media::AudioFormatDescription> formatsAidl;
RETURN_STATUS_IF_ERROR(statusTFromBinderStatus(
aps->getHwOffloadEncodingFormatsSupportedForA2DP(&formatsAidl)));
*formats = VALUE_OR_RETURN_STATUS(
- convertContainer<std::vector<audio_format_t>>(formatsAidl,
- aidl2legacy_AudioFormat_audio_format_t));
+ convertContainer<std::vector<audio_format_t>>(
+ formatsAidl,
+ aidl2legacy_AudioFormatDescription_audio_format_t));
return OK;
}
@@ -2271,7 +2278,7 @@
std::optional<media::AudioAttributesInternal> attrAidl = VALUE_OR_RETURN_STATUS(
legacy2aidl_audio_attributes_t_AudioAttributesInternal(attributes));
std::optional<media::AudioConfig> configAidl = VALUE_OR_RETURN_STATUS(
- legacy2aidl_audio_config_t_AudioConfig(configuration));
+ legacy2aidl_audio_config_t_AudioConfig(configuration, false /*isInput*/));
std::vector<media::AudioDevice> devicesAidl = VALUE_OR_RETURN_STATUS(
convertContainer<std::vector<media::AudioDevice>>(devices,
legacy2aidl_AudioDeviceTypeAddress));
@@ -2473,13 +2480,13 @@
record_client_info_t clientInfoLegacy = VALUE_OR_RETURN_BINDER_STATUS(
aidl2legacy_RecordClientInfo_record_client_info_t(clientInfo));
audio_config_base_t clientConfigLegacy = VALUE_OR_RETURN_BINDER_STATUS(
- aidl2legacy_AudioConfigBase_audio_config_base_t(clientConfig));
+ aidl2legacy_AudioConfigBase_audio_config_base_t(clientConfig, true /*isInput*/));
std::vector<effect_descriptor_t> clientEffectsLegacy = VALUE_OR_RETURN_BINDER_STATUS(
convertContainer<std::vector<effect_descriptor_t>>(
clientEffects,
aidl2legacy_EffectDescriptor_effect_descriptor_t));
audio_config_base_t deviceConfigLegacy = VALUE_OR_RETURN_BINDER_STATUS(
- aidl2legacy_AudioConfigBase_audio_config_base_t(deviceConfig));
+ aidl2legacy_AudioConfigBase_audio_config_base_t(deviceConfig, true /*isInput*/));
std::vector<effect_descriptor_t> effectsLegacy = VALUE_OR_RETURN_BINDER_STATUS(
convertContainer<std::vector<effect_descriptor_t>>(
effects,
diff --git a/media/libaudioclient/AudioTrack.cpp b/media/libaudioclient/AudioTrack.cpp
index 5f802de..5b7760b 100644
--- a/media/libaudioclient/AudioTrack.cpp
+++ b/media/libaudioclient/AudioTrack.cpp
@@ -171,7 +171,7 @@
auto result = [&]() -> ConversionResult<bool> {
media::AudioConfigBase configAidl = VALUE_OR_RETURN(
- legacy2aidl_audio_config_base_t_AudioConfigBase(config));
+ legacy2aidl_audio_config_base_t_AudioConfigBase(config, false /*isInput*/));
media::AudioAttributesInternal attributesAidl = VALUE_OR_RETURN(
legacy2aidl_audio_attributes_t_AudioAttributesInternal(attributes));
bool retAidl;
@@ -1275,10 +1275,6 @@
if (mOutput == AUDIO_IO_HANDLE_NONE || mProxy.get() == 0) {
return NO_INIT;
}
- // Reject if timed track or compressed audio.
- if (!audio_is_linear_pcm(mFormat)) {
- return INVALID_OPERATION;
- }
ssize_t originalBufferSize = mProxy->getBufferSizeInFrames();
ssize_t finalBufferSize = mProxy->setBufferSizeInFrames((uint32_t) bufferSizeInFrames);
@@ -1555,6 +1551,8 @@
status_t AudioTrack::setOutputDevice(audio_port_handle_t deviceId) {
AutoMutex lock(mLock);
+ ALOGV("%s(%d): deviceId=%d mSelectedDeviceId=%d",
+ __func__, mPortId, deviceId, mSelectedDeviceId);
if (mSelectedDeviceId != deviceId) {
mSelectedDeviceId = deviceId;
if (mStatus == NO_ERROR) {
diff --git a/media/libaudioclient/IAudioFlinger.cpp b/media/libaudioclient/IAudioFlinger.cpp
index 2af1c50..6d2ec93 100644
--- a/media/libaudioclient/IAudioFlinger.cpp
+++ b/media/libaudioclient/IAudioFlinger.cpp
@@ -55,7 +55,9 @@
ConversionResult<media::CreateTrackRequest> IAudioFlinger::CreateTrackInput::toAidl() const {
media::CreateTrackRequest aidl;
aidl.attr = VALUE_OR_RETURN(legacy2aidl_audio_attributes_t_AudioAttributesInternal(attr));
- aidl.config = VALUE_OR_RETURN(legacy2aidl_audio_config_t_AudioConfig(config));
+ // Do not be mislead by 'Input'--this is an input to 'createTrack', which creates output tracks.
+ aidl.config = VALUE_OR_RETURN(legacy2aidl_audio_config_t_AudioConfig(
+ config, false /*isInput*/));
aidl.clientInfo = VALUE_OR_RETURN(legacy2aidl_AudioClient_AudioClient(clientInfo));
aidl.sharedBuffer = VALUE_OR_RETURN(legacy2aidl_NullableIMemory_SharedFileRegion(sharedBuffer));
aidl.notificationsPerBuffer = VALUE_OR_RETURN(convertIntegral<int32_t>(notificationsPerBuffer));
@@ -74,7 +76,9 @@
IAudioFlinger::CreateTrackInput::fromAidl(const media::CreateTrackRequest& aidl) {
IAudioFlinger::CreateTrackInput legacy;
legacy.attr = VALUE_OR_RETURN(aidl2legacy_AudioAttributesInternal_audio_attributes_t(aidl.attr));
- legacy.config = VALUE_OR_RETURN(aidl2legacy_AudioConfig_audio_config_t(aidl.config));
+ // Do not be mislead by 'Input'--this is an input to 'createTrack', which creates output tracks.
+ legacy.config = VALUE_OR_RETURN(
+ aidl2legacy_AudioConfig_audio_config_t(aidl.config, false /*isInput*/));
legacy.clientInfo = VALUE_OR_RETURN(aidl2legacy_AudioClient_AudioClient(aidl.clientInfo));
legacy.sharedBuffer = VALUE_OR_RETURN(aidl2legacy_NullableSharedFileRegion_IMemory(aidl.sharedBuffer));
legacy.notificationsPerBuffer = VALUE_OR_RETURN(
@@ -139,7 +143,8 @@
IAudioFlinger::CreateRecordInput::toAidl() const {
media::CreateRecordRequest aidl;
aidl.attr = VALUE_OR_RETURN(legacy2aidl_audio_attributes_t_AudioAttributesInternal(attr));
- aidl.config = VALUE_OR_RETURN(legacy2aidl_audio_config_base_t_AudioConfigBase(config));
+ aidl.config = VALUE_OR_RETURN(
+ legacy2aidl_audio_config_base_t_AudioConfigBase(config, true /*isInput*/));
aidl.clientInfo = VALUE_OR_RETURN(legacy2aidl_AudioClient_AudioClient(clientInfo));
aidl.riid = VALUE_OR_RETURN(legacy2aidl_audio_unique_id_t_int32_t(riid));
aidl.maxSharedAudioHistoryMs = VALUE_OR_RETURN(
@@ -159,7 +164,8 @@
IAudioFlinger::CreateRecordInput legacy;
legacy.attr = VALUE_OR_RETURN(
aidl2legacy_AudioAttributesInternal_audio_attributes_t(aidl.attr));
- legacy.config = VALUE_OR_RETURN(aidl2legacy_AudioConfigBase_audio_config_base_t(aidl.config));
+ legacy.config = VALUE_OR_RETURN(
+ aidl2legacy_AudioConfigBase_audio_config_base_t(aidl.config, true /*isInput*/));
legacy.clientInfo = VALUE_OR_RETURN(aidl2legacy_AudioClient_AudioClient(aidl.clientInfo));
legacy.riid = VALUE_OR_RETURN(aidl2legacy_int32_t_audio_unique_id_t(aidl.riid));
legacy.maxSharedAudioHistoryMs = VALUE_OR_RETURN(
@@ -189,6 +195,8 @@
aidl.buffers = VALUE_OR_RETURN(legacy2aidl_NullableIMemory_SharedFileRegion(buffers));
aidl.portId = VALUE_OR_RETURN(legacy2aidl_audio_port_handle_t_int32_t(portId));
aidl.audioRecord = audioRecord;
+ aidl.serverConfig = VALUE_OR_RETURN(
+ legacy2aidl_audio_config_base_t_AudioConfigBase(serverConfig, true /*isInput*/));
return aidl;
}
@@ -209,6 +217,8 @@
legacy.buffers = VALUE_OR_RETURN(aidl2legacy_NullableSharedFileRegion_IMemory(aidl.buffers));
legacy.portId = VALUE_OR_RETURN(aidl2legacy_int32_t_audio_port_handle_t(aidl.portId));
legacy.audioRecord = aidl.audioRecord;
+ legacy.serverConfig = VALUE_OR_RETURN(
+ aidl2legacy_AudioConfigBase_audio_config_base_t(aidl.serverConfig, true /*isInput*/));
return legacy;
}
@@ -242,9 +252,9 @@
audio_format_t AudioFlingerClientAdapter::format(audio_io_handle_t output) const {
auto result = [&]() -> ConversionResult<audio_format_t> {
int32_t outputAidl = VALUE_OR_RETURN(legacy2aidl_audio_io_handle_t_int32_t(output));
- media::audio::common::AudioFormat aidlRet;
+ media::AudioFormatDescription aidlRet;
RETURN_IF_ERROR(statusTFromBinderStatus(mDelegate->format(outputAidl, &aidlRet)));
- return aidl2legacy_AudioFormat_audio_format_t(aidlRet);
+ return aidl2legacy_AudioFormatDescription_audio_format_t(aidlRet);
}();
return result.value_or(AUDIO_FORMAT_INVALID);
}
@@ -410,10 +420,10 @@
audio_channel_mask_t channelMask) const {
auto result = [&]() -> ConversionResult<size_t> {
int32_t sampleRateAidl = VALUE_OR_RETURN(convertIntegral<int32_t>(sampleRate));
- media::audio::common::AudioFormat formatAidl = VALUE_OR_RETURN(
- legacy2aidl_audio_format_t_AudioFormat(format));
- int32_t channelMaskAidl = VALUE_OR_RETURN(
- legacy2aidl_audio_channel_mask_t_int32_t(channelMask));
+ media::AudioFormatDescription formatAidl = VALUE_OR_RETURN(
+ legacy2aidl_audio_format_t_AudioFormatDescription(format));
+ media::AudioChannelLayout channelMaskAidl = VALUE_OR_RETURN(
+ legacy2aidl_audio_channel_mask_t_AudioChannelLayout(channelMask, true /*isInput*/));
int64_t aidlRet;
RETURN_IF_ERROR(statusTFromBinderStatus(
mDelegate->getInputBufferSize(sampleRateAidl, formatAidl, channelMaskAidl,
@@ -810,11 +820,11 @@
}
Status AudioFlingerServerAdapter::format(int32_t output,
- media::audio::common::AudioFormat* _aidl_return) {
+ media::AudioFormatDescription* _aidl_return) {
audio_io_handle_t outputLegacy = VALUE_OR_RETURN_BINDER(
aidl2legacy_int32_t_audio_io_handle_t(output));
*_aidl_return = VALUE_OR_RETURN_BINDER(
- legacy2aidl_audio_format_t_AudioFormat(mDelegate->format(outputLegacy)));
+ legacy2aidl_audio_format_t_AudioFormatDescription(mDelegate->format(outputLegacy)));
return Status::ok();
}
@@ -938,13 +948,14 @@
}
Status AudioFlingerServerAdapter::getInputBufferSize(int32_t sampleRate,
- media::audio::common::AudioFormat format,
- int32_t channelMask, int64_t* _aidl_return) {
+ const media::AudioFormatDescription& format,
+ const media::AudioChannelLayout& channelMask,
+ int64_t* _aidl_return) {
uint32_t sampleRateLegacy = VALUE_OR_RETURN_BINDER(convertIntegral<uint32_t>(sampleRate));
audio_format_t formatLegacy = VALUE_OR_RETURN_BINDER(
- aidl2legacy_AudioFormat_audio_format_t(format));
+ aidl2legacy_AudioFormatDescription_audio_format_t(format));
audio_channel_mask_t channelMaskLegacy = VALUE_OR_RETURN_BINDER(
- aidl2legacy_int32_t_audio_channel_mask_t(channelMask));
+ aidl2legacy_AudioChannelLayout_audio_channel_mask_t(channelMask, true /*isInput*/));
size_t size = mDelegate->getInputBufferSize(sampleRateLegacy, formatLegacy, channelMaskLegacy);
*_aidl_return = VALUE_OR_RETURN_BINDER(convertIntegral<int64_t>(size));
return Status::ok();
diff --git a/media/libaudioclient/PolicyAidlConversion.cpp b/media/libaudioclient/PolicyAidlConversion.cpp
index 25fdb49..676bb37 100644
--- a/media/libaudioclient/PolicyAidlConversion.cpp
+++ b/media/libaudioclient/PolicyAidlConversion.cpp
@@ -232,10 +232,14 @@
std::back_inserter(legacy.mCriteria),
aidl2legacy_AudioMixMatchCriterion));
legacy.mMixType = VALUE_OR_RETURN(aidl2legacy_AudioMixType_uint32_t(aidl.mixType));
- legacy.mFormat = VALUE_OR_RETURN(aidl2legacy_AudioConfig_audio_config_t(aidl.format));
+ // See 'convertAudioMixToNative' in 'android_media_AudioSystem.cpp' -- only
+ // an output mask is expected here.
+ legacy.mFormat = VALUE_OR_RETURN(aidl2legacy_AudioConfig_audio_config_t(
+ aidl.format, false /*isInput*/));
legacy.mRouteFlags = VALUE_OR_RETURN(
aidl2legacy_AudioMixRouteFlag_uint32_t_mask(aidl.routeFlags));
- legacy.mDeviceType = VALUE_OR_RETURN(aidl2legacy_int32_t_audio_devices_t(aidl.device.type));
+ legacy.mDeviceType = VALUE_OR_RETURN(
+ aidl2legacy_AudioDeviceDescription_audio_devices_t(aidl.device.type));
legacy.mDeviceAddress = VALUE_OR_RETURN(aidl2legacy_string_view_String8(aidl.device.address));
legacy.mCbFlags = VALUE_OR_RETURN(aidl2legacy_AudioMixCallbackFlag_uint32_t_mask(aidl.cbFlags));
legacy.mAllowPrivilegedMediaPlaybackCapture = aidl.allowPrivilegedMediaPlaybackCapture;
@@ -251,10 +255,14 @@
legacy.mCriteria,
legacy2aidl_AudioMixMatchCriterion));
aidl.mixType = VALUE_OR_RETURN(legacy2aidl_uint32_t_AudioMixType(legacy.mMixType));
- aidl.format = VALUE_OR_RETURN(legacy2aidl_audio_config_t_AudioConfig(legacy.mFormat));
+ // See 'convertAudioMixToNative' in 'android_media_AudioSystem.cpp' -- only
+ // an output mask is expected here.
+ aidl.format = VALUE_OR_RETURN(legacy2aidl_audio_config_t_AudioConfig(
+ legacy.mFormat, false /*isInput*/));
aidl.routeFlags = VALUE_OR_RETURN(
legacy2aidl_uint32_t_AudioMixRouteFlag_mask(legacy.mRouteFlags));
- aidl.device.type = VALUE_OR_RETURN(legacy2aidl_audio_devices_t_int32_t(legacy.mDeviceType));
+ aidl.device.type = VALUE_OR_RETURN(
+ legacy2aidl_audio_devices_t_AudioDeviceDescription(legacy.mDeviceType));
aidl.device.address = VALUE_OR_RETURN(legacy2aidl_String8_string(legacy.mDeviceAddress));
aidl.cbFlags = VALUE_OR_RETURN(legacy2aidl_uint32_t_AudioMixCallbackFlag_mask(legacy.mCbFlags));
aidl.allowPrivilegedMediaPlaybackCapture = legacy.mAllowPrivilegedMediaPlaybackCapture;
diff --git a/media/libaudioclient/TEST_MAPPING b/media/libaudioclient/TEST_MAPPING
new file mode 100644
index 0000000..d8c18c0
--- /dev/null
+++ b/media/libaudioclient/TEST_MAPPING
@@ -0,0 +1,7 @@
+{
+ "presubmit": [
+ {
+ "name": "audio_aidl_conversion_tests"
+ }
+ ]
+}
diff --git a/media/libaudioclient/aidl/android/media/AudioChannelLayout.aidl b/media/libaudioclient/aidl/android/media/AudioChannelLayout.aidl
new file mode 100644
index 0000000..3259105
--- /dev/null
+++ b/media/libaudioclient/aidl/android/media/AudioChannelLayout.aidl
@@ -0,0 +1,274 @@
+/*
+ * Copyright (C) 2021 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.media;
+
+/**
+ * This structure describes a layout of a multi-channel stream.
+ * There are two possible ways for representing a layout:
+ *
+ * - indexed mask, which tells what channels of an audio frame are used, but
+ * doesn't label them in any way, thus a correspondence between channels in
+ * the same position of frames originating from different streams must be
+ * established externally;
+ *
+ * - layout mask, which gives a label to each channel, thus allowing to
+ * match channels between streams of different layouts.
+ *
+ * Both representations are agnostic of the direction of audio transfer. Also,
+ * by construction, the number of bits set to '1' in the mask indicates the
+ * number of channels in the audio frame. A channel mask per se only defines the
+ * presence or absence of a channel, not the order. Please see 'INTERLEAVE_*'
+ * constants for the platform convention of order.
+ *
+ * The structure also defines a "voice mask" which is a special case of
+ * layout mask, intended for processing voice audio from telecommunication
+ * use cases.
+ */
+union AudioChannelLayout {
+ /**
+ * This variant is used for representing the "null" ("none") value
+ * for the channel layout. The field value must always be '0'.
+ */
+ int none = 0;
+ /**
+ * This variant is used for indicating an "invalid" layout for use by the
+ * framework only. HAL implementations must not accept or emit
+ * AudioChannelLayout values for this variant. The field value must always
+ * be '0'.
+ */
+ int invalid = 0;
+ /**
+ * This variant is used for representing indexed masks. The mask indicates
+ * what channels are used. For example, the mask that specifies to use only
+ * channels 1 and 3 when interacting with a multi-channel device is defined
+ * as a combination of the 1st and the 3rd bits and thus is equal to 5. See
+ * also the 'INDEX_MASK_*' constants. The 'indexMask' field must have at
+ * least one bit set.
+ */
+ int indexMask;
+ /**
+ * This variant is used for representing layout masks.
+ * It is recommended to use one of 'LAYOUT_*' values. The 'layoutMask' field
+ * must have at least one bit set.
+ */
+ int layoutMask;
+ /**
+ * This variant is used for processing of voice audio input and output.
+ * It is recommended to use one of 'VOICE_*' values. The 'voiceMask' field
+ * must have at least one bit set.
+ */
+ int voiceMask;
+
+ /**
+ * 'INDEX_MASK_*' constants define how many channels are used.
+ * The mask constants below are 'canonical' masks. Each 'INDEX_MASK_N'
+ * constant declares that all N channels are used and arranges
+ * them starting from the LSB.
+ */
+ const int INDEX_MASK_1 = (1 << 1) - 1;
+ const int INDEX_MASK_2 = (1 << 2) - 1;
+ const int INDEX_MASK_3 = (1 << 3) - 1;
+ const int INDEX_MASK_4 = (1 << 4) - 1;
+ const int INDEX_MASK_5 = (1 << 5) - 1;
+ const int INDEX_MASK_6 = (1 << 6) - 1;
+ const int INDEX_MASK_7 = (1 << 7) - 1;
+ const int INDEX_MASK_8 = (1 << 8) - 1;
+ const int INDEX_MASK_9 = (1 << 9) - 1;
+ const int INDEX_MASK_10 = (1 << 10) - 1;
+ const int INDEX_MASK_11 = (1 << 11) - 1;
+ const int INDEX_MASK_12 = (1 << 12) - 1;
+ const int INDEX_MASK_13 = (1 << 13) - 1;
+ const int INDEX_MASK_14 = (1 << 14) - 1;
+ const int INDEX_MASK_15 = (1 << 15) - 1;
+ const int INDEX_MASK_16 = (1 << 16) - 1;
+ const int INDEX_MASK_17 = (1 << 17) - 1;
+ const int INDEX_MASK_18 = (1 << 18) - 1;
+ const int INDEX_MASK_19 = (1 << 19) - 1;
+ const int INDEX_MASK_20 = (1 << 20) - 1;
+ const int INDEX_MASK_21 = (1 << 21) - 1;
+ const int INDEX_MASK_22 = (1 << 22) - 1;
+ const int INDEX_MASK_23 = (1 << 23) - 1;
+ const int INDEX_MASK_24 = (1 << 24) - 1;
+
+ /**
+ * 'LAYOUT_*' constants define channel layouts recognized by
+ * the audio system. The order of the channels in the frame is assumed
+ * to be from the LSB to MSB for all the bits set to '1'.
+ */
+ const int LAYOUT_MONO = CHANNEL_FRONT_LEFT;
+ const int LAYOUT_STEREO =
+ CHANNEL_FRONT_LEFT | CHANNEL_FRONT_RIGHT;
+ const int LAYOUT_2POINT1 =
+ CHANNEL_FRONT_LEFT | CHANNEL_FRONT_RIGHT | CHANNEL_LOW_FREQUENCY;
+ const int LAYOUT_TRI =
+ CHANNEL_FRONT_LEFT | CHANNEL_FRONT_RIGHT | CHANNEL_FRONT_CENTER;
+ const int LAYOUT_TRI_BACK =
+ CHANNEL_FRONT_LEFT | CHANNEL_FRONT_RIGHT | CHANNEL_BACK_CENTER;
+ const int LAYOUT_3POINT1 =
+ CHANNEL_FRONT_LEFT | CHANNEL_FRONT_RIGHT | CHANNEL_FRONT_CENTER |
+ CHANNEL_LOW_FREQUENCY;
+ const int LAYOUT_2POINT0POINT2 =
+ CHANNEL_FRONT_LEFT | CHANNEL_FRONT_RIGHT |
+ CHANNEL_TOP_SIDE_LEFT | CHANNEL_TOP_SIDE_RIGHT;
+ const int LAYOUT_2POINT1POINT2 =
+ LAYOUT_2POINT0POINT2 | CHANNEL_LOW_FREQUENCY;
+ const int LAYOUT_3POINT0POINT2 =
+ CHANNEL_FRONT_LEFT | CHANNEL_FRONT_RIGHT |
+ CHANNEL_FRONT_CENTER |
+ CHANNEL_TOP_SIDE_LEFT | CHANNEL_TOP_SIDE_RIGHT;
+ const int LAYOUT_3POINT1POINT2 =
+ LAYOUT_3POINT0POINT2 | CHANNEL_LOW_FREQUENCY;
+ const int LAYOUT_QUAD =
+ CHANNEL_FRONT_LEFT | CHANNEL_FRONT_RIGHT |
+ CHANNEL_BACK_LEFT | CHANNEL_BACK_RIGHT;
+ const int LAYOUT_QUAD_SIDE =
+ CHANNEL_FRONT_LEFT | CHANNEL_FRONT_RIGHT |
+ CHANNEL_SIDE_LEFT | CHANNEL_SIDE_RIGHT;
+ const int LAYOUT_SURROUND =
+ CHANNEL_FRONT_LEFT | CHANNEL_FRONT_RIGHT |
+ CHANNEL_FRONT_CENTER | CHANNEL_BACK_CENTER;
+ const int LAYOUT_PENTA = LAYOUT_QUAD | CHANNEL_FRONT_CENTER;
+ const int LAYOUT_5POINT1 =
+ CHANNEL_FRONT_LEFT | CHANNEL_FRONT_RIGHT |
+ CHANNEL_FRONT_CENTER | CHANNEL_LOW_FREQUENCY |
+ CHANNEL_BACK_LEFT | CHANNEL_BACK_RIGHT;
+ const int LAYOUT_5POINT1_SIDE =
+ CHANNEL_FRONT_LEFT | CHANNEL_FRONT_RIGHT |
+ CHANNEL_FRONT_CENTER | CHANNEL_LOW_FREQUENCY |
+ CHANNEL_SIDE_LEFT | CHANNEL_SIDE_RIGHT;
+ const int LAYOUT_5POINT1POINT2 = LAYOUT_5POINT1 |
+ CHANNEL_TOP_SIDE_LEFT | CHANNEL_TOP_SIDE_RIGHT;
+ const int LAYOUT_5POINT1POINT4 = LAYOUT_5POINT1 |
+ CHANNEL_TOP_FRONT_LEFT | CHANNEL_TOP_FRONT_RIGHT |
+ CHANNEL_TOP_BACK_LEFT | CHANNEL_TOP_BACK_RIGHT;
+ const int LAYOUT_6POINT1 =
+ CHANNEL_FRONT_LEFT | CHANNEL_FRONT_RIGHT |
+ CHANNEL_FRONT_CENTER | CHANNEL_LOW_FREQUENCY |
+ CHANNEL_BACK_LEFT | CHANNEL_BACK_RIGHT | CHANNEL_BACK_CENTER;
+ const int LAYOUT_7POINT1 = LAYOUT_5POINT1 |
+ CHANNEL_SIDE_LEFT | CHANNEL_SIDE_RIGHT;
+ const int LAYOUT_7POINT1POINT2 = LAYOUT_7POINT1 |
+ CHANNEL_TOP_SIDE_LEFT | CHANNEL_TOP_SIDE_RIGHT;
+ const int LAYOUT_7POINT1POINT4 = LAYOUT_7POINT1 |
+ CHANNEL_TOP_FRONT_LEFT | CHANNEL_TOP_FRONT_RIGHT |
+ CHANNEL_TOP_BACK_LEFT | CHANNEL_TOP_BACK_RIGHT;
+ const int LAYOUT_9POINT1POINT4 = LAYOUT_7POINT1POINT4 |
+ CHANNEL_FRONT_WIDE_LEFT | CHANNEL_FRONT_WIDE_RIGHT;
+ const int LAYOUT_9POINT1POINT6 = LAYOUT_9POINT1POINT4 |
+ CHANNEL_TOP_SIDE_LEFT | CHANNEL_TOP_SIDE_RIGHT;
+ const int LAYOUT_13POINT_360RA =
+ CHANNEL_FRONT_LEFT | CHANNEL_FRONT_RIGHT |
+ CHANNEL_FRONT_CENTER |
+ CHANNEL_SIDE_LEFT | CHANNEL_SIDE_RIGHT |
+ CHANNEL_TOP_FRONT_LEFT | CHANNEL_TOP_FRONT_RIGHT |
+ CHANNEL_TOP_FRONT_CENTER |
+ CHANNEL_TOP_BACK_LEFT | CHANNEL_TOP_BACK_RIGHT |
+ CHANNEL_BOTTOM_FRONT_LEFT | CHANNEL_BOTTOM_FRONT_RIGHT |
+ CHANNEL_BOTTOM_FRONT_CENTER;
+ const int LAYOUT_22POINT2 = LAYOUT_7POINT1POINT4 |
+ CHANNEL_FRONT_LEFT_OF_CENTER | CHANNEL_FRONT_RIGHT_OF_CENTER |
+ CHANNEL_BACK_CENTER | CHANNEL_TOP_CENTER |
+ CHANNEL_TOP_FRONT_CENTER | CHANNEL_TOP_BACK_CENTER |
+ CHANNEL_TOP_SIDE_LEFT | CHANNEL_TOP_SIDE_RIGHT |
+ CHANNEL_BOTTOM_FRONT_LEFT | CHANNEL_BOTTOM_FRONT_RIGHT |
+ CHANNEL_BOTTOM_FRONT_CENTER |
+ CHANNEL_LOW_FREQUENCY_2;
+ const int LAYOUT_MONO_HAPTIC_A =
+ LAYOUT_MONO | CHANNEL_HAPTIC_A;
+ const int LAYOUT_STEREO_HAPTIC_A =
+ LAYOUT_STEREO | CHANNEL_HAPTIC_A;
+ const int LAYOUT_HAPTIC_AB =
+ CHANNEL_HAPTIC_A | CHANNEL_HAPTIC_B;
+ const int LAYOUT_MONO_HAPTIC_AB =
+ LAYOUT_MONO | LAYOUT_HAPTIC_AB;
+ const int LAYOUT_STEREO_HAPTIC_AB =
+ LAYOUT_STEREO | LAYOUT_HAPTIC_AB;
+ const int LAYOUT_FRONT_BACK =
+ CHANNEL_FRONT_CENTER | CHANNEL_BACK_CENTER;
+
+ /**
+ * Expresses the convention when stereo audio samples are stored interleaved
+ * in an array. This should improve readability by allowing code to use
+ * symbolic indices instead of hard-coded [0] and [1].
+ *
+ * For multi-channel beyond stereo, the platform convention is that channels
+ * are interleaved in order from least significant channel mask bit to most
+ * significant channel mask bit, with unused bits skipped. Any exceptions
+ * to this convention will be noted at the appropriate API.
+ */
+ const int INTERLEAVE_LEFT = 0;
+ const int INTERLEAVE_RIGHT = 1;
+
+ /**
+ * 'CHANNEL_*' constants are used to build 'LAYOUT_*' masks. Each constant
+ * must have exactly one bit set. The values do not match
+ * 'android.media.AudioFormat.CHANNEL_OUT_*' constants from the SDK
+ * for better efficiency in masks processing.
+ */
+ const int CHANNEL_FRONT_LEFT = 1 << 0;
+ const int CHANNEL_FRONT_RIGHT = 1 << 1;
+ const int CHANNEL_FRONT_CENTER = 1 << 2;
+ const int CHANNEL_LOW_FREQUENCY = 1 << 3;
+ const int CHANNEL_BACK_LEFT = 1 << 4;
+ const int CHANNEL_BACK_RIGHT = 1 << 5;
+ const int CHANNEL_FRONT_LEFT_OF_CENTER = 1 << 6;
+ const int CHANNEL_FRONT_RIGHT_OF_CENTER = 1 << 7;
+ const int CHANNEL_BACK_CENTER = 1 << 8;
+ const int CHANNEL_SIDE_LEFT = 1 << 9;
+ const int CHANNEL_SIDE_RIGHT = 1 << 10;
+ const int CHANNEL_TOP_CENTER = 1 << 11;
+ const int CHANNEL_TOP_FRONT_LEFT = 1 << 12;
+ const int CHANNEL_TOP_FRONT_CENTER = 1 << 13;
+ const int CHANNEL_TOP_FRONT_RIGHT = 1 << 14;
+ const int CHANNEL_TOP_BACK_LEFT = 1 << 15;
+ const int CHANNEL_TOP_BACK_CENTER = 1 << 16;
+ const int CHANNEL_TOP_BACK_RIGHT = 1 << 17;
+ const int CHANNEL_TOP_SIDE_LEFT = 1 << 18;
+ const int CHANNEL_TOP_SIDE_RIGHT = 1 << 19;
+ const int CHANNEL_BOTTOM_FRONT_LEFT = 1 << 20;
+ const int CHANNEL_BOTTOM_FRONT_CENTER = 1 << 21;
+ const int CHANNEL_BOTTOM_FRONT_RIGHT = 1 << 22;
+ const int CHANNEL_LOW_FREQUENCY_2 = 1 << 23;
+ const int CHANNEL_FRONT_WIDE_LEFT = 1 << 24;
+ const int CHANNEL_FRONT_WIDE_RIGHT = 1 << 25;
+ /**
+ * Haptic channels are not part of multichannel standards, however they
+ * enhance user experience when playing so they are packed together with the
+ * channels of the program. To avoid collision with positional channels the
+ * values for haptic channels start at the MSB of an integer (after the sign
+ * bit) and move down to LSB.
+ */
+ const int CHANNEL_HAPTIC_B = 1 << 29;
+ const int CHANNEL_HAPTIC_A = 1 << 30;
+
+ /**
+ * 'VOICE_*' constants define layouts for voice audio. The order of the
+ * channels in the frame is assumed to be from the LSB to MSB for all the
+ * bits set to '1'.
+ */
+ const int VOICE_UPLINK_MONO = CHANNEL_VOICE_UPLINK;
+ const int VOICE_DNLINK_MONO = CHANNEL_VOICE_DNLINK;
+ const int VOICE_CALL_MONO = CHANNEL_VOICE_UPLINK | CHANNEL_VOICE_DNLINK;
+
+ /**
+ * 'CHANNEL_VOICE_*' constants are used to build 'VOICE_*' masks. Each
+ * constant must have exactly one bit set. Use the same values as
+ * 'android.media.AudioFormat.CHANNEL_IN_VOICE_*' constants from the SDK.
+ */
+ const int CHANNEL_VOICE_UPLINK = 0x4000;
+ const int CHANNEL_VOICE_DNLINK = 0x8000;
+}
diff --git a/media/libaudioclient/aidl/android/media/AudioConfig.aidl b/media/libaudioclient/aidl/android/media/AudioConfig.aidl
index 8dc97d3..6996d42 100644
--- a/media/libaudioclient/aidl/android/media/AudioConfig.aidl
+++ b/media/libaudioclient/aidl/android/media/AudioConfig.aidl
@@ -16,20 +16,17 @@
package android.media;
+import android.media.AudioChannelLayout;
+import android.media.AudioFormatDescription;
import android.media.AudioOffloadInfo;
-import android.media.audio.common.AudioFormat;
/**
* {@hide}
*/
parcelable AudioConfig {
int sampleRate;
- /**
- * Interpreted as audio_channel_mask_t.
- * TODO(ytai): Create a designated type.
- */
- int channelMask;
- AudioFormat format;
+ AudioChannelLayout channelMask;
+ AudioFormatDescription format;
AudioOffloadInfo offloadInfo;
long frameCount;
}
diff --git a/media/libaudioclient/aidl/android/media/AudioConfigBase.aidl b/media/libaudioclient/aidl/android/media/AudioConfigBase.aidl
index 8353c0d..e84161b 100644
--- a/media/libaudioclient/aidl/android/media/AudioConfigBase.aidl
+++ b/media/libaudioclient/aidl/android/media/AudioConfigBase.aidl
@@ -16,14 +16,14 @@
package android.media;
-import android.media.audio.common.AudioFormat;
+import android.media.AudioChannelLayout;
+import android.media.AudioFormatDescription;
/**
* {@hide}
*/
parcelable AudioConfigBase {
int sampleRate;
- /** Interpreted as audio_channel_mask_t. */
- int channelMask;
- AudioFormat format;
+ AudioChannelLayout channelMask;
+ AudioFormatDescription format;
}
diff --git a/media/libaudioclient/aidl/android/media/AudioDevice.aidl b/media/libaudioclient/aidl/android/media/AudioDevice.aidl
index b200697..a815874 100644
--- a/media/libaudioclient/aidl/android/media/AudioDevice.aidl
+++ b/media/libaudioclient/aidl/android/media/AudioDevice.aidl
@@ -16,11 +16,12 @@
package android.media;
+import android.media.AudioDeviceDescription;
+
/**
* {@hide}
*/
parcelable AudioDevice {
- /** Interpreted as audio_devices_t. */
- int type;
+ AudioDeviceDescription type;
@utf8InCpp String address;
}
diff --git a/media/libaudioclient/aidl/android/media/AudioDeviceDescription.aidl b/media/libaudioclient/aidl/android/media/AudioDeviceDescription.aidl
new file mode 100644
index 0000000..f7548b9
--- /dev/null
+++ b/media/libaudioclient/aidl/android/media/AudioDeviceDescription.aidl
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) 2021 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.media;
+
+import android.media.AudioDeviceType;
+
+parcelable AudioDeviceDescription {
+ /**
+ * Type and directionality of the device. For bidirectional audio devices
+ * two descriptions need to be created, having the same value for
+ * the 'connection' field.
+ *
+ * See 'AudioDeviceType' for the list of supported values.
+ */
+ AudioDeviceType type = AudioDeviceType.NONE;
+ /**
+ * Specifies the type of the connection of the device to the audio system.
+ * Usually it's some kind of a communication protocol, e.g. Bluetooth SCO or
+ * USB. There is a list of connection types recognized by the framework,
+ * defined using 'CONNECTION_' constants. Vendors can add their own
+ * connection types with "vx.<vendor>." prefix.
+ *
+ * When the 'connection' field is left empty and 'type != NONE | DEFAULT',
+ * it is assumed that the device is permanently attached to the audio
+ * system, e.g. a built-in speaker or microphone.
+ *
+ * The 'connection' field must be left empty if 'type' is 'NONE' or
+ * '{IN|OUT}_DEFAULT'.
+ */
+ @utf8InCpp String connection;
+ /**
+ * Analog connection, for example, via 3.5 mm analog jack.
+ */
+ const @utf8InCpp String CONNECTION_ANALOG = "analog";
+ /**
+ * Low-End (Analog) Desk Dock.
+ */
+ const @utf8InCpp String CONNECTION_ANALOG_DOCK = "analog-dock";
+ /**
+ * Bluetooth A2DP connection.
+ */
+ const @utf8InCpp String CONNECTION_BT_A2DP = "bt-a2dp";
+ /**
+ * Bluetooth Low Energy (LE) connection.
+ */
+ const @utf8InCpp String CONNECTION_BT_LE = "bt-le";
+ /**
+ * Bluetooth SCO connection.
+ */
+ const @utf8InCpp String CONNECTION_BT_SCO = "bt-sco";
+ /**
+ * Bus connection. Mostly used in automotive scenarios.
+ */
+ const @utf8InCpp String CONNECTION_BUS = "bus";
+ /**
+ * High-End (Digital) Desk Dock.
+ */
+ const @utf8InCpp String CONNECTION_DIGITAL_DOCK = "digital-dock";
+ /**
+ * HDMI connection.
+ */
+ const @utf8InCpp String CONNECTION_HDMI = "hdmi";
+ /**
+ * HDMI ARC connection.
+ */
+ const @utf8InCpp String CONNECTION_HDMI_ARC = "hdmi-arc";
+ /**
+ * HDMI eARC connection.
+ */
+ const @utf8InCpp String CONNECTION_HDMI_EARC = "hdmi-earc";
+ /**
+ * IP v4 connection.
+ */
+ const @utf8InCpp String CONNECTION_IP_V4 = "ip-v4";
+ /**
+ * SPDIF connection.
+ */
+ const @utf8InCpp String CONNECTION_SPDIF = "spdif";
+ /**
+ * A wireless connection when the actual protocol is unspecified.
+ */
+ const @utf8InCpp String CONNECTION_WIRELESS = "wireless";
+ /**
+ * USB connection.
+ */
+ const @utf8InCpp String CONNECTION_USB = "usb";
+}
diff --git a/media/libaudioclient/aidl/android/media/AudioDeviceType.aidl b/media/libaudioclient/aidl/android/media/AudioDeviceType.aidl
new file mode 100644
index 0000000..4da9fd6
--- /dev/null
+++ b/media/libaudioclient/aidl/android/media/AudioDeviceType.aidl
@@ -0,0 +1,158 @@
+/*
+ * Copyright (C) 2021 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.media;
+
+/**
+ * The type of the audio device. Only used as part of 'AudioDeviceDescription'
+ * structure.
+ *
+ * Types are divided into "input" and "output" categories. Audio devices that
+ * have both audio input and output, for example, headsets, are represented by a
+ * pair of input and output device types.
+ *
+ * The 'AudioDeviceType' intentionally binds together directionality and 'kind'
+ * of the device to avoid making them fully orthogonal. This is because not all
+ * types of devices are bidirectional, for example, speakers can only be used
+ * for output and microphones can only be used for input (at least, in the
+ * context of the audio framework).
+ */
+@Backing(type="int")
+enum AudioDeviceType {
+ /**
+ * "None" type is a "null" value. All fields of 'AudioDeviceDescription'
+ * must have default / empty / null values.
+ */
+ NONE = 0,
+ /**
+ * The "default" device is used when the client does not have any
+ * preference for a particular device.
+ */
+ IN_DEFAULT = 1,
+ /**
+ * A device implementing Android Open Accessory protocol.
+ */
+ IN_ACCESSORY = 2,
+ /**
+ * Input from a DSP front-end proxy device.
+ */
+ IN_AFE_PROXY = 3,
+ /**
+ * Used when only the connection protocol is known, e.g. a "HDMI Device."
+ */
+ IN_DEVICE = 4,
+ /**
+ * A device providing reference input for echo canceller.
+ */
+ IN_ECHO_REFERENCE = 5,
+ /**
+ * FM Tuner input.
+ */
+ IN_FM_TUNER = 6,
+ /**
+ * A microphone of a headset.
+ */
+ IN_HEADSET = 7,
+ /**
+ * Loopback input.
+ */
+ IN_LOOPBACK = 8,
+ /**
+ * The main microphone (the frontal mic on mobile devices).
+ */
+ IN_MICROPHONE = 9,
+ /**
+ * The secondary microphone (the back mic on mobile devices).
+ */
+ IN_MICROPHONE_BACK = 10,
+ /**
+ * Input from a submix of other streams.
+ */
+ IN_SUBMIX = 11,
+ /**
+ * Audio received via the telephone line.
+ */
+ IN_TELEPHONY_RX = 12,
+ /**
+ * TV Tuner audio input.
+ */
+ IN_TV_TUNER = 13,
+ /**
+ * The "default" device is used when the client does not have any
+ * preference for a particular device.
+ */
+ OUT_DEFAULT = 129,
+ /**
+ * A device implementing Android Open Accessory protocol.
+ */
+ OUT_ACCESSORY = 130,
+ /**
+ * Output from a DSP front-end proxy device.
+ */
+ OUT_AFE_PROXY = 131,
+ /**
+ * Car audio system.
+ */
+ OUT_CARKIT = 132,
+ /**
+ * Used when only the connection protocol is known, e.g. a "HDMI Device."
+ */
+ OUT_DEVICE = 133,
+ /**
+ * The echo canceller device.
+ */
+ OUT_ECHO_CANCELLER = 134,
+ /**
+ * The FM Tuner device.
+ */
+ OUT_FM = 135,
+ /**
+ * Headphones.
+ */
+ OUT_HEADPHONE = 136,
+ /**
+ * Headphones of a headset.
+ */
+ OUT_HEADSET = 137,
+ /**
+ * Hearing aid.
+ */
+ OUT_HEARING_AID = 138,
+ /**
+ * Secondary line level output.
+ */
+ OUT_LINE_AUX = 139,
+ /**
+ * The main speaker.
+ */
+ OUT_SPEAKER = 140,
+ /**
+ * The speaker of a mobile device in the case when it is close to the ear.
+ */
+ OUT_SPEAKER_EARPIECE = 141,
+ /**
+ * The main speaker with overload / overheating protection.
+ */
+ OUT_SPEAKER_SAFE = 142,
+ /**
+ * Output into a submix.
+ */
+ OUT_SUBMIX = 143,
+ /**
+ * Output into a telephone line.
+ */
+ OUT_TELEPHONY_TX = 144,
+}
diff --git a/media/libaudioclient/aidl/android/media/AudioFormatDescription.aidl b/media/libaudioclient/aidl/android/media/AudioFormatDescription.aidl
new file mode 100644
index 0000000..a656348
--- /dev/null
+++ b/media/libaudioclient/aidl/android/media/AudioFormatDescription.aidl
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2021 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.media;
+
+import android.media.AudioFormatType;
+import android.media.PcmType;
+
+/**
+ * An extensible type for specifying audio formats. All formats are largely
+ * divided into two classes: PCM and non-PCM (bitstreams). Bitstreams can
+ * be encapsulated into PCM streams.
+ *
+ * The type defined in a way to make each format uniquely identifiable, so
+ * that if the framework and the HAL construct a value for the same type
+ * (e.g. PCM 16 bit), they will produce identical parcelables which will have
+ * identical hashes. This makes possible deduplicating type descriptions
+ * by the framework when they are received from different HAL modules without
+ * relying on having some centralized registry of enumeration values.
+ *
+ * {@hide}
+ */
+parcelable AudioFormatDescription {
+ /**
+ * The type of the audio format. See the 'AudioFormatType' for the
+ * list of supported values.
+ */
+ AudioFormatType type = AudioFormatType.DEFAULT;
+ /**
+ * The type of the PCM stream or the transport stream for PCM
+ * encapsulations. See 'PcmType' for the list of supported values.
+ */
+ PcmType pcm = PcmType.DEFAULT;
+ /**
+ * Optional encoding specification. Must be left empty when:
+ *
+ * - 'type == DEFAULT && pcm == DEFAULT' -- that means "default" type;
+ * - 'type == PCM' -- that means a regular PCM stream (not an encapsulation
+ * of an encoded bitstream).
+ *
+ * For PCM encapsulations of encoded bitstreams (e.g. an encapsulation
+ * according to IEC-61937 standard), the value of the 'pcm' field must
+ * be set accordingly, as an example, PCM_INT_16_BIT must be used for
+ * IEC-61937. Note that 'type == NON_PCM' in this case.
+ *
+ * Encoding names mostly follow IANA standards for media types (MIME), and
+ * frameworks/av/media/libstagefright/foundation/MediaDefs.cpp with the
+ * latter having priority. Since there are still many audio types not found
+ * in any of these lists, the following rules are applied:
+ *
+ * - If there is a direct MIME type for the encoding, the MIME type name
+ * is used as is, e.g. "audio/eac3" for the EAC-3 format.
+ * - If the encoding is a "subformat" of a MIME-registered format,
+ * the latter is augmented with a suffix, e.g. "audio/eac3-joc" for the
+ * JOC extension of EAC-3.
+ * - If it's a proprietary format, a "vnd." prefix is added, similar to
+ * IANA rules, e.g. "audio/vnd.dolby.truehd".
+ * - Otherwise, "x-" prefix is added, e.g. "audio/x-iec61937".
+ * - All MIME types not found in the IANA formats list have an associated
+ * comment.
+ *
+ * For PCM encapsulations with a known bitstream format, the latter
+ * is added to the encapsulation encoding as a suffix, after a "+" char.
+ * For example, an IEC61937 encapsulation of AC3 has the following
+ * representation:
+ * type = NON_PCM,
+ * pcm = PcmType.INT_16_BIT,
+ * encoding = "audio/x-iec61937+audio/ac3"
+ */
+ @utf8InCpp String encoding;
+}
diff --git a/media/libaudioclient/aidl/android/media/AudioFormatType.aidl b/media/libaudioclient/aidl/android/media/AudioFormatType.aidl
new file mode 100644
index 0000000..31ed2be
--- /dev/null
+++ b/media/libaudioclient/aidl/android/media/AudioFormatType.aidl
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2021 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.media;
+
+/**
+ * The type of the audio format. Only used as part of 'AudioFormatDescription'
+ * structure.
+ */
+@Backing(type="byte")
+enum AudioFormatType {
+ /**
+ * "Default" type is used when the client does not care about the actual
+ * format. All fields of 'AudioFormatDescription' must have default / empty
+ * / null values.
+ */
+ DEFAULT = 0,
+ /**
+ * When the 'encoding' field of 'AudioFormatDescription' is not empty, it
+ * specifies the codec used for bitstream (non-PCM) data. It is also used
+ * in the case when the bitstream data is encapsulated into a PCM stream,
+ * see the documentation for 'AudioFormatDescription'.
+ */
+ NON_PCM = DEFAULT,
+ /**
+ * PCM type. The 'pcm' field of 'AudioFormatDescription' is used to specify
+ * the actual sample size and representation.
+ */
+ PCM = 1,
+ /**
+ * Value reserved for system use only. HALs must never return this value to
+ * the system or accept it from the system.
+ */
+ SYS_RESERVED_INVALID = -1,
+}
diff --git a/media/libaudioclient/aidl/android/media/AudioGain.aidl b/media/libaudioclient/aidl/android/media/AudioGain.aidl
index 048b295..4cfa96e 100644
--- a/media/libaudioclient/aidl/android/media/AudioGain.aidl
+++ b/media/libaudioclient/aidl/android/media/AudioGain.aidl
@@ -16,17 +16,18 @@
package android.media;
+import android.media.AudioChannelLayout;
+
/**
* {@hide}
*/
parcelable AudioGain {
int index;
- boolean useInChannelMask;
+ boolean isInput;
boolean useForVolume;
/** Bitmask, indexed by AudioGainMode. */
int mode;
- /** Interpreted as audio_channel_mask_t. */
- int channelMask;
+ AudioChannelLayout channelMask;
int minValue;
int maxValue;
int defaultValue;
diff --git a/media/libaudioclient/aidl/android/media/AudioGainConfig.aidl b/media/libaudioclient/aidl/android/media/AudioGainConfig.aidl
index b93c2dc..afa3aca 100644
--- a/media/libaudioclient/aidl/android/media/AudioGainConfig.aidl
+++ b/media/libaudioclient/aidl/android/media/AudioGainConfig.aidl
@@ -16,6 +16,8 @@
package android.media;
+import android.media.AudioChannelLayout;
+
/**
* {@hide}
*/
@@ -28,9 +30,8 @@
/**
* Channels which gain value follows. N/A in joint mode.
- * Interpreted as audio_channel_mask_t.
*/
- int channelMask;
+ AudioChannelLayout channelMask;
/**
* Gain values in millibels.
diff --git a/media/libaudioclient/aidl/android/media/AudioIoDescriptor.aidl b/media/libaudioclient/aidl/android/media/AudioIoDescriptor.aidl
index 876ef9b..efdf99b 100644
--- a/media/libaudioclient/aidl/android/media/AudioIoDescriptor.aidl
+++ b/media/libaudioclient/aidl/android/media/AudioIoDescriptor.aidl
@@ -16,8 +16,9 @@
package android.media;
+import android.media.AudioChannelLayout;
+import android.media.AudioFormatDescription;
import android.media.AudioPatch;
-import android.media.audio.common.AudioFormat;
/**
* {@hide}
@@ -26,10 +27,10 @@
/** Interpreted as audio_io_handle_t. */
int ioHandle;
AudioPatch patch;
+ boolean isInput;
int samplingRate;
- AudioFormat format;
- /** Interpreted as audio_channel_mask_t. */
- int channelMask;
+ AudioFormatDescription format;
+ AudioChannelLayout channelMask;
long frameCount;
long frameCountHAL;
/** Only valid for output. */
diff --git a/media/libaudioclient/aidl/android/media/AudioOffloadInfo.aidl b/media/libaudioclient/aidl/android/media/AudioOffloadInfo.aidl
index c86b3f0..f326305 100644
--- a/media/libaudioclient/aidl/android/media/AudioOffloadInfo.aidl
+++ b/media/libaudioclient/aidl/android/media/AudioOffloadInfo.aidl
@@ -20,7 +20,6 @@
import android.media.AudioEncapsulationMode;
import android.media.AudioStreamType;
import android.media.AudioUsage;
-import android.media.audio.common.AudioFormat;
/**
* {@hide}
diff --git a/media/libaudioclient/aidl/android/media/AudioPortConfig.aidl b/media/libaudioclient/aidl/android/media/AudioPortConfig.aidl
index 2dd30a4..be32a69 100644
--- a/media/libaudioclient/aidl/android/media/AudioPortConfig.aidl
+++ b/media/libaudioclient/aidl/android/media/AudioPortConfig.aidl
@@ -16,13 +16,14 @@
package android.media;
+import android.media.AudioChannelLayout;
import android.media.AudioGainConfig;
import android.media.AudioIoFlags;
import android.media.AudioPortConfigExt;
import android.media.AudioPortConfigType;
import android.media.AudioPortRole;
import android.media.AudioPortType;
-import android.media.audio.common.AudioFormat;
+import android.media.AudioFormatDescription;
/**
* {@hide}
@@ -43,14 +44,12 @@
int sampleRate;
/**
* Channel mask, if applicable.
- * Interpreted as audio_channel_mask_t.
- * TODO: bitmask?
*/
- int channelMask;
+ AudioChannelLayout channelMask;
/**
* Format, if applicable.
*/
- AudioFormat format;
+ AudioFormatDescription format;
/** Gain to apply, if applicable. */
AudioGainConfig gain;
/** Framework only: HW_AV_SYNC, DIRECT, ... */
diff --git a/media/libaudioclient/aidl/android/media/AudioPortConfigDeviceExt.aidl b/media/libaudioclient/aidl/android/media/AudioPortConfigDeviceExt.aidl
index a99aa9b..31e5330 100644
--- a/media/libaudioclient/aidl/android/media/AudioPortConfigDeviceExt.aidl
+++ b/media/libaudioclient/aidl/android/media/AudioPortConfigDeviceExt.aidl
@@ -16,6 +16,8 @@
package android.media;
+import android.media.AudioDeviceDescription;
+
/**
* {@hide}
*/
@@ -26,11 +28,9 @@
*/
int hwModule;
/**
- * Device type (e.g AUDIO_DEVICE_OUT_SPEAKER).
- * Interpreted as audio_devices_t.
- * TODO: Convert to a standalone AIDL representation.
+ * Device type.
*/
- int type;
+ AudioDeviceDescription type;
/** Device address. "" if N/A. */
@utf8InCpp String address;
}
diff --git a/media/libaudioclient/aidl/android/media/AudioProfile.aidl b/media/libaudioclient/aidl/android/media/AudioProfile.aidl
index afb288f..9fb8d49 100644
--- a/media/libaudioclient/aidl/android/media/AudioProfile.aidl
+++ b/media/libaudioclient/aidl/android/media/AudioProfile.aidl
@@ -16,8 +16,9 @@
package android.media;
+import android.media.AudioChannelLayout;
import android.media.AudioEncapsulationType;
-import android.media.audio.common.AudioFormat;
+import android.media.AudioFormatDescription;
/**
* {@hide}
@@ -25,9 +26,8 @@
parcelable AudioProfile {
@utf8InCpp String name;
/** The format for an audio profile should only be set when initialized. */
- AudioFormat format;
- /** Interpreted as audio_channel_mask_t. */
- int[] channelMasks;
+ AudioFormatDescription format;
+ AudioChannelLayout[] channelMasks;
int[] samplingRates;
boolean isDynamicFormat;
boolean isDynamicChannels;
diff --git a/media/libaudioclient/aidl/android/media/CreateRecordResponse.aidl b/media/libaudioclient/aidl/android/media/CreateRecordResponse.aidl
index d78b3fc..61195d0 100644
--- a/media/libaudioclient/aidl/android/media/CreateRecordResponse.aidl
+++ b/media/libaudioclient/aidl/android/media/CreateRecordResponse.aidl
@@ -16,6 +16,7 @@
package android.media;
+import android.media.AudioConfigBase;
import android.media.IAudioRecord;
import android.media.SharedFileRegion;
@@ -43,4 +44,5 @@
int portId;
/** The newly created record. */
@nullable IAudioRecord audioRecord;
+ AudioConfigBase serverConfig;
}
diff --git a/media/libaudioclient/aidl/android/media/IAudioFlingerService.aidl b/media/libaudioclient/aidl/android/media/IAudioFlingerService.aidl
index 7ffcc33..16f70c1 100644
--- a/media/libaudioclient/aidl/android/media/IAudioFlingerService.aidl
+++ b/media/libaudioclient/aidl/android/media/IAudioFlingerService.aidl
@@ -16,6 +16,7 @@
package android.media;
+import android.media.AudioChannelLayout;
import android.media.AudioMode;
import android.media.AudioPatch;
import android.media.AudioPort;
@@ -41,7 +42,7 @@
import android.media.MicrophoneInfoData;
import android.media.RenderPosition;
import android.media.TrackSecondaryOutputInfo;
-import android.media.audio.common.AudioFormat;
+import android.media.AudioFormatDescription;
/**
* {@hide}
@@ -62,7 +63,7 @@
*/
int sampleRate(int /* audio_io_handle_t */ ioHandle);
- AudioFormat format(int /* audio_io_handle_t */ output);
+ AudioFormatDescription format(int /* audio_io_handle_t */ output);
long frameCount(int /* audio_io_handle_t */ ioHandle);
@@ -115,8 +116,8 @@
// Retrieve the audio recording buffer size in bytes.
// FIXME This API assumes a route, and so should be deprecated.
long getInputBufferSize(int sampleRate,
- AudioFormat format,
- int /* audio_channel_mask_t */ channelMask);
+ in AudioFormatDescription format,
+ in AudioChannelLayout channelMask);
OpenOutputResponse openOutput(in OpenOutputRequest request);
int /* audio_io_handle_t */ openDuplicateOutput(int /* audio_io_handle_t */ output1,
diff --git a/media/libaudioclient/aidl/android/media/IAudioPolicyService.aidl b/media/libaudioclient/aidl/android/media/IAudioPolicyService.aidl
index 5f0a1de..7022b9d 100644
--- a/media/libaudioclient/aidl/android/media/IAudioPolicyService.aidl
+++ b/media/libaudioclient/aidl/android/media/IAudioPolicyService.aidl
@@ -16,15 +16,15 @@
package android.media;
+import android.media.AudioFormatDescription;
import android.content.AttributionSourceState;
-import android.media.audio.common.AudioFormat;
-
import android.media.AudioAttributesEx;
import android.media.AudioAttributesInternal;
import android.media.AudioConfig;
import android.media.AudioConfigBase;
import android.media.AudioDevice;
+import android.media.AudioDeviceDescription;
import android.media.AudioMix;
import android.media.AudioMode;
import android.media.AudioOffloadInfo;
@@ -65,13 +65,13 @@
void setDeviceConnectionState(in AudioDevice device,
in AudioPolicyDeviceState state,
@utf8InCpp String deviceName,
- in AudioFormat encodedFormat);
+ in AudioFormatDescription encodedFormat);
AudioPolicyDeviceState getDeviceConnectionState(in AudioDevice device);
void handleDeviceConfigChange(in AudioDevice device,
@utf8InCpp String deviceName,
- in AudioFormat encodedFormat);
+ in AudioFormatDescription encodedFormat);
void setPhoneState(AudioMode state, int /* uid_t */ uid);
@@ -116,18 +116,18 @@
int indexMax);
void setStreamVolumeIndex(AudioStreamType stream,
- int /* audio_devices_t */ device,
+ in AudioDeviceDescription device,
int index);
int getStreamVolumeIndex(AudioStreamType stream,
- int /* audio_devices_t */ device);
+ in AudioDeviceDescription device);
void setVolumeIndexForAttributes(in AudioAttributesInternal attr,
- int /* audio_devices_t */ device,
+ in AudioDeviceDescription device,
int index);
int getVolumeIndexForAttributes(in AudioAttributesInternal attr,
- int /* audio_devices_t */ device);
+ in AudioDeviceDescription device);
int getMaxVolumeIndexForAttributes(in AudioAttributesInternal attr);
@@ -135,7 +135,7 @@
int /* product_strategy_t */ getStrategyForStream(AudioStreamType stream);
- int /* bitmask of audio_devices_t */ getDevicesForStream(AudioStreamType stream);
+ AudioDeviceDescription[] getDevicesForStream(AudioStreamType stream);
AudioDevice[] getDevicesForAttributes(in AudioAttributesEx attr);
@@ -270,7 +270,7 @@
boolean getMasterMono();
- float getStreamVolumeDB(AudioStreamType stream, int index, int /* audio_devices_t */ device);
+ float getStreamVolumeDB(AudioStreamType stream, int index, in AudioDeviceDescription device);
/**
* Populates supported surround formats and their enabled state in formats and formatsEnabled.
@@ -281,7 +281,7 @@
* number of elements without actually retrieving them.
*/
void getSurroundFormats(inout Int count,
- out AudioFormat[] formats,
+ out AudioFormatDescription[] formats,
out boolean[] formatsEnabled);
/**
@@ -293,11 +293,11 @@
* number of elements without actually retrieving them.
*/
void getReportedSurroundFormats(inout Int count,
- out AudioFormat[] formats);
+ out AudioFormatDescription[] formats);
- AudioFormat[] getHwOffloadEncodingFormatsSupportedForA2DP();
+ AudioFormatDescription[] getHwOffloadEncodingFormatsSupportedForA2DP();
- void setSurroundFormatEnabled(AudioFormat audioFormat, boolean enabled);
+ void setSurroundFormatEnabled(in AudioFormatDescription audioFormat, boolean enabled);
void setAssistantUid(int /* uid_t */ uid);
diff --git a/media/libaudioclient/aidl/android/media/PcmType.aidl b/media/libaudioclient/aidl/android/media/PcmType.aidl
new file mode 100644
index 0000000..c9e327c
--- /dev/null
+++ b/media/libaudioclient/aidl/android/media/PcmType.aidl
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2021 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.media;
+
+/**
+ * The type of the encoding used for representing PCM samples. Only used as
+ * part of 'AudioFormatDescription' structure.
+ */
+@Backing(type="byte")
+enum PcmType {
+ /**
+ * "Default" value used when the type 'AudioFormatDescription' is "default".
+ */
+ DEFAULT = 0,
+ /**
+ * Unsigned 8-bit integer.
+ */
+ UINT_8_BIT = DEFAULT,
+ /**
+ * Signed 16-bit integer.
+ */
+ INT_16_BIT = 1,
+ /**
+ * Signed 32-bit integer.
+ */
+ INT_32_BIT = 2,
+ /**
+ * Q8.24 fixed point format.
+ */
+ FIXED_Q_8_24 = 3,
+ /**
+ * IEEE 754 32-bit floating point format.
+ */
+ FLOAT_32_BIT = 4,
+ /**
+ * Signed 24-bit integer.
+ */
+ INT_24_BIT = 5,
+}
diff --git a/media/libaudioclient/aidl/android/media/SoundTriggerSession.aidl b/media/libaudioclient/aidl/android/media/SoundTriggerSession.aidl
index a829e59..b9708b2 100644
--- a/media/libaudioclient/aidl/android/media/SoundTriggerSession.aidl
+++ b/media/libaudioclient/aidl/android/media/SoundTriggerSession.aidl
@@ -16,6 +16,8 @@
package android.media;
+import android.media.AudioDeviceDescription;
+
/**
* {@hide}
*/
@@ -24,6 +26,6 @@
int session;
/** Interpreted as audio_io_handle_t. */
int ioHandle;
- /** Interpreted as audio_devices_t. */
- int device;
+ /** Device type. */
+ AudioDeviceDescription device;
}
diff --git a/media/libaudioclient/fuzzer/audioflinger_fuzzer.cpp b/media/libaudioclient/fuzzer/audioflinger_fuzzer.cpp
index bd9e158..52868d9 100644
--- a/media/libaudioclient/fuzzer/audioflinger_fuzzer.cpp
+++ b/media/libaudioclient/fuzzer/audioflinger_fuzzer.cpp
@@ -601,7 +601,8 @@
media::OpenInputRequest request{};
request.module = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_module_handle_t_int32_t(module));
request.input = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_io_handle_t_int32_t(input));
- request.config = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_config_t_AudioConfig(config));
+ request.config = VALUE_OR_RETURN_STATUS(
+ legacy2aidl_audio_config_t_AudioConfig(config, true /*isInput*/));
request.device = VALUE_OR_RETURN_STATUS(legacy2aidl_AudioDeviceTypeAddress(deviceTypeAddr));
request.source = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_source_t_AudioSourceType(source));
request.flags = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_input_flags_t_int32_t_mask(flags));
@@ -658,9 +659,10 @@
media::OpenOutputResponse response{};
request.module = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_module_handle_t_int32_t(module));
- request.halConfig = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_config_t_AudioConfig(config));
- request.mixerConfig =
- VALUE_OR_RETURN_STATUS(legacy2aidl_audio_config_base_t_AudioConfigBase(mixerConfig));
+ request.halConfig = VALUE_OR_RETURN_STATUS(
+ legacy2aidl_audio_config_t_AudioConfig(config, false /*isInput*/));
+ request.mixerConfig = VALUE_OR_RETURN_STATUS(
+ legacy2aidl_audio_config_base_t_AudioConfigBase(mixerConfig, false /*isInput*/));
request.device = VALUE_OR_RETURN_STATUS(legacy2aidl_DeviceDescriptorBase(device));
request.flags = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_output_flags_t_int32_t_mask(flags));
diff --git a/media/libaudioclient/include/media/AidlConversion.h b/media/libaudioclient/include/media/AidlConversion.h
index 4ec69c7..2cf127c 100644
--- a/media/libaudioclient/include/media/AidlConversion.h
+++ b/media/libaudioclient/include/media/AidlConversion.h
@@ -22,14 +22,17 @@
#include <system/audio.h>
#include <android/media/AudioAttributesInternal.h>
+#include <android/media/AudioChannelLayout.h>
#include <android/media/AudioClient.h>
#include <android/media/AudioConfig.h>
#include <android/media/AudioConfigBase.h>
+#include <android/media/AudioDeviceDescription.h>
#include <android/media/AudioDualMonoMode.h>
#include <android/media/AudioEncapsulationMode.h>
#include <android/media/AudioEncapsulationMetadataType.h>
#include <android/media/AudioEncapsulationType.h>
#include <android/media/AudioFlag.h>
+#include <android/media/AudioFormatDescription.h>
#include <android/media/AudioGain.h>
#include <android/media/AudioGainMode.h>
#include <android/media/AudioInputFlags.h>
@@ -96,9 +99,6 @@
ConversionResult<unsigned int> aidl2legacy_int32_t_config_mask(int32_t aidl);
ConversionResult<int32_t> legacy2aidl_config_mask_int32_t(unsigned int legacy);
-ConversionResult<audio_channel_mask_t> aidl2legacy_int32_t_audio_channel_mask_t(int32_t aidl);
-ConversionResult<int32_t> legacy2aidl_audio_channel_mask_t_int32_t(audio_channel_mask_t legacy);
-
ConversionResult<pid_t> aidl2legacy_int32_t_pid_t(int32_t aidl);
ConversionResult<int32_t> legacy2aidl_pid_t_int32_t(pid_t legacy);
@@ -116,10 +116,10 @@
ConversionResult<std::optional<std::string_view>>
legacy2aidl_optional_String16_optional_string(std::optional<String16> legacy);
-ConversionResult<audio_io_config_event> aidl2legacy_AudioIoConfigEvent_audio_io_config_event(
+ConversionResult<audio_io_config_event_t> aidl2legacy_AudioIoConfigEvent_audio_io_config_event_t(
media::AudioIoConfigEvent aidl);
-ConversionResult<media::AudioIoConfigEvent> legacy2aidl_audio_io_config_event_AudioIoConfigEvent(
- audio_io_config_event legacy);
+ConversionResult<media::AudioIoConfigEvent> legacy2aidl_audio_io_config_event_t_AudioIoConfigEvent(
+ audio_io_config_event_t legacy);
ConversionResult<audio_port_role_t> aidl2legacy_AudioPortRole_audio_port_role_t(
media::AudioPortRole aidl);
@@ -131,9 +131,19 @@
ConversionResult<media::AudioPortType> legacy2aidl_audio_port_type_t_AudioPortType(
audio_port_type_t legacy);
-ConversionResult<audio_format_t> aidl2legacy_AudioFormat_audio_format_t(
- media::audio::common::AudioFormat aidl);
-ConversionResult<media::audio::common::AudioFormat> legacy2aidl_audio_format_t_AudioFormat(
+ConversionResult<audio_channel_mask_t> aidl2legacy_AudioChannelLayout_audio_channel_mask_t(
+ const media::AudioChannelLayout& aidl, bool isInput);
+ConversionResult<media::AudioChannelLayout> legacy2aidl_audio_channel_mask_t_AudioChannelLayout(
+ audio_channel_mask_t legacy, bool isInput);
+
+ConversionResult<audio_devices_t> aidl2legacy_AudioDeviceDescription_audio_devices_t(
+ const media::AudioDeviceDescription& aidl);
+ConversionResult<media::AudioDeviceDescription> legacy2aidl_audio_devices_t_AudioDeviceDescription(
+ audio_devices_t legacy);
+
+ConversionResult<audio_format_t> aidl2legacy_AudioFormatDescription_audio_format_t(
+ const media::AudioFormatDescription& aidl);
+ConversionResult<media::AudioFormatDescription> legacy2aidl_audio_format_t_AudioFormatDescription(
audio_format_t legacy);
ConversionResult<audio_gain_mode_t>
@@ -144,9 +154,6 @@
ConversionResult<audio_gain_mode_t> aidl2legacy_int32_t_audio_gain_mode_t_mask(int32_t aidl);
ConversionResult<int32_t> legacy2aidl_audio_gain_mode_t_int32_t_mask(audio_gain_mode_t legacy);
-ConversionResult<audio_devices_t> aidl2legacy_int32_t_audio_devices_t(int32_t aidl);
-ConversionResult<int32_t> legacy2aidl_audio_devices_t_int32_t(audio_devices_t legacy);
-
ConversionResult<audio_gain_config> aidl2legacy_AudioGainConfig_audio_gain_config(
const media::AudioGainConfig& aidl, media::AudioPortRole role, media::AudioPortType type);
ConversionResult<media::AudioGainConfig> legacy2aidl_audio_gain_config_AudioGainConfig(
@@ -221,7 +228,6 @@
ConversionResult<sp<AudioIoDescriptor>> aidl2legacy_AudioIoDescriptor_AudioIoDescriptor(
const media::AudioIoDescriptor& aidl);
-
ConversionResult<media::AudioIoDescriptor> legacy2aidl_AudioIoDescriptor_AudioIoDescriptor(
const sp<AudioIoDescriptor>& legacy);
@@ -266,14 +272,14 @@
legacy2aidl_audio_offload_info_t_AudioOffloadInfo(const audio_offload_info_t& legacy);
ConversionResult<audio_config_t>
-aidl2legacy_AudioConfig_audio_config_t(const media::AudioConfig& aidl);
+aidl2legacy_AudioConfig_audio_config_t(const media::AudioConfig& aidl, bool isInput);
ConversionResult<media::AudioConfig>
-legacy2aidl_audio_config_t_AudioConfig(const audio_config_t& legacy);
+legacy2aidl_audio_config_t_AudioConfig(const audio_config_t& legacy, bool isInput);
ConversionResult<audio_config_base_t>
-aidl2legacy_AudioConfigBase_audio_config_base_t(const media::AudioConfigBase& aidl);
+aidl2legacy_AudioConfigBase_audio_config_base_t(const media::AudioConfigBase& aidl, bool isInput);
ConversionResult<media::AudioConfigBase>
-legacy2aidl_audio_config_base_t_AudioConfigBase(const audio_config_base_t& legacy);
+legacy2aidl_audio_config_base_t_AudioConfigBase(const audio_config_base_t& legacy, bool isInput);
ConversionResult<sp<IMemory>>
aidl2legacy_SharedFileRegion_IMemory(const media::SharedFileRegion& aidl);
@@ -340,14 +346,15 @@
legacy2aidl_audio_port_session_ext_AudioPortSessionExt(const audio_port_session_ext& legacy);
ConversionResult<audio_profile>
-aidl2legacy_AudioProfile_audio_profile(const media::AudioProfile& aidl);
+aidl2legacy_AudioProfile_audio_profile(const media::AudioProfile& aidl, bool isInput);
ConversionResult<media::AudioProfile>
-legacy2aidl_audio_profile_AudioProfile(const audio_profile& legacy);
+legacy2aidl_audio_profile_AudioProfile(const audio_profile& legacy, bool isInput);
ConversionResult<audio_gain>
aidl2legacy_AudioGain_audio_gain(const media::AudioGain& aidl);
+// The AIDL structure provides a flag for direction indication while the legacy type doesn't.
ConversionResult<media::AudioGain>
-legacy2aidl_audio_gain_AudioGain(const audio_gain& legacy);
+legacy2aidl_audio_gain_AudioGain(const audio_gain& legacy, bool isInput);
ConversionResult<audio_port_v7>
aidl2legacy_AudioPort_audio_port_v7(const media::AudioPort& aidl);
diff --git a/media/libaudioclient/include/media/AudioCommonTypes.h b/media/libaudioclient/include/media/AudioCommonTypes.h
index 5f0c590..bd341e3 100644
--- a/media/libaudioclient/include/media/AudioCommonTypes.h
+++ b/media/libaudioclient/include/media/AudioCommonTypes.h
@@ -17,9 +17,72 @@
#pragma once
+#include <functional>
+
+#include <android/media/AudioChannelLayout.h>
+#include <android/media/AudioDeviceDescription.h>
+#include <android/media/AudioFormatDescription.h>
+#include <binder/Parcelable.h>
#include <system/audio.h>
#include <system/audio_policy.h>
-#include <binder/Parcelable.h>
+
+namespace {
+// see boost::hash_combine
+#if defined(__clang__)
+__attribute__((no_sanitize("unsigned-integer-overflow")))
+#endif
+static size_t hash_combine(size_t seed, size_t v) {
+ return std::hash<size_t>{}(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
+}
+}
+
+namespace std {
+
+// Note: when extending the types hashed below we need to account for the
+// possibility of processing types belonging to different versions of the type,
+// e.g. a HAL may be using a previous version of the AIDL interface.
+
+template<> struct hash<android::media::AudioChannelLayout>
+{
+ std::size_t operator()(const android::media::AudioChannelLayout& acl) const noexcept {
+ using Tag = android::media::AudioChannelLayout::Tag;
+ const size_t seed = std::hash<Tag>{}(acl.getTag());
+ switch (acl.getTag()) {
+ case Tag::none:
+ return hash_combine(seed, std::hash<int32_t>{}(acl.get<Tag::none>()));
+ case Tag::invalid:
+ return hash_combine(seed, std::hash<int32_t>{}(acl.get<Tag::invalid>()));
+ case Tag::indexMask:
+ return hash_combine(seed, std::hash<int32_t>{}(acl.get<Tag::indexMask>()));
+ case Tag::layoutMask:
+ return hash_combine(seed, std::hash<int32_t>{}(acl.get<Tag::layoutMask>()));
+ case Tag::voiceMask:
+ return hash_combine(seed, std::hash<int32_t>{}(acl.get<Tag::voiceMask>()));
+ }
+ return seed;
+ }
+};
+
+template<> struct hash<android::media::AudioDeviceDescription>
+{
+ std::size_t operator()(const android::media::AudioDeviceDescription& add) const noexcept {
+ return hash_combine(
+ std::hash<android::media::AudioDeviceType>{}(add.type),
+ std::hash<std::string>{}(add.connection));
+ }
+};
+
+template<> struct hash<android::media::AudioFormatDescription>
+{
+ std::size_t operator()(const android::media::AudioFormatDescription& afd) const noexcept {
+ return hash_combine(
+ std::hash<android::media::AudioFormatType>{}(afd.type),
+ hash_combine(
+ std::hash<android::media::PcmType>{}(afd.pcm),
+ std::hash<std::string>{}(afd.encoding)));
+ }
+};
+} // namespace std
namespace android {
@@ -81,4 +144,3 @@
static const volume_group_t VOLUME_GROUP_NONE = static_cast<volume_group_t>(-1);
} // namespace android
-
diff --git a/media/libaudioclient/include/media/AudioIoDescriptor.h b/media/libaudioclient/include/media/AudioIoDescriptor.h
index 981d33a..ef729ed 100644
--- a/media/libaudioclient/include/media/AudioIoDescriptor.h
+++ b/media/libaudioclient/include/media/AudioIoDescriptor.h
@@ -17,9 +17,15 @@
#ifndef ANDROID_AUDIO_IO_DESCRIPTOR_H
#define ANDROID_AUDIO_IO_DESCRIPTOR_H
+#include <sstream>
+#include <string>
+
+#include <system/audio.h>
+#include <utils/RefBase.h>
+
namespace android {
-enum audio_io_config_event {
+enum audio_io_config_event_t {
AUDIO_OUTPUT_REGISTERED,
AUDIO_OUTPUT_OPENED,
AUDIO_OUTPUT_CLOSED,
@@ -35,39 +41,68 @@
// frequent calls through IAudioFlinger
class AudioIoDescriptor : public RefBase {
public:
- AudioIoDescriptor() :
- mIoHandle(AUDIO_IO_HANDLE_NONE),
- mSamplingRate(0), mFormat(AUDIO_FORMAT_DEFAULT), mChannelMask(AUDIO_CHANNEL_NONE),
- mFrameCount(0), mFrameCountHAL(0), mLatency(0), mPortId(AUDIO_PORT_HANDLE_NONE)
- {
- memset(&mPatch, 0, sizeof(struct audio_patch));
- }
+ AudioIoDescriptor() = default;
+ // For AUDIO_{INPUT|OUTPUT}_CLOSED events.
+ AudioIoDescriptor(audio_io_handle_t ioHandle) : mIoHandle(ioHandle) {}
+ // For AUDIO_CLIENT_STARTED events.
+ AudioIoDescriptor(
+ audio_io_handle_t ioHandle, const audio_patch& patch, audio_port_handle_t portId) :
+ mIoHandle(ioHandle), mPatch(patch), mPortId(portId) {}
+ // For everything else.
+ AudioIoDescriptor(
+ audio_io_handle_t ioHandle, const audio_patch& patch, bool isInput,
+ uint32_t samplingRate, audio_format_t format, audio_channel_mask_t channelMask,
+ size_t frameCount, size_t frameCountHal, uint32_t latency = 0,
+ audio_port_handle_t portId = AUDIO_PORT_HANDLE_NONE) :
+ mIoHandle(ioHandle), mPatch(patch), mIsInput(isInput),
+ mSamplingRate(samplingRate), mFormat(format), mChannelMask(channelMask),
+ mFrameCount(frameCount), mFrameCountHAL(frameCountHal), mLatency(latency),
+ mPortId(portId) {}
- virtual ~AudioIoDescriptor() {}
-
- audio_port_handle_t getDeviceId() {
+ audio_io_handle_t getIoHandle() const { return mIoHandle; }
+ const audio_patch& getPatch() const { return mPatch; }
+ bool getIsInput() const { return mIsInput; }
+ uint32_t getSamplingRate() const { return mSamplingRate; }
+ audio_format_t getFormat() const { return mFormat; }
+ audio_channel_mask_t getChannelMask() const { return mChannelMask; }
+ size_t getFrameCount() const { return mFrameCount; }
+ size_t getFrameCountHAL() const { return mFrameCountHAL; }
+ uint32_t getLatency() const { return mLatency; }
+ audio_port_handle_t getPortId() const { return mPortId; }
+ audio_port_handle_t getDeviceId() const {
if (mPatch.num_sources != 0 && mPatch.num_sinks != 0) {
- if (mPatch.sources[0].type == AUDIO_PORT_TYPE_MIX) {
- // this is an output mix
- // FIXME: the API only returns the first device in case of multiple device selection
- return mPatch.sinks[0].id;
- } else {
- // this is an input mix
- return mPatch.sources[0].id;
- }
+ // FIXME: the API only returns the first device in case of multiple device selection
+ return mIsInput ? mPatch.sources[0].id : mPatch.sinks[0].id;
}
return AUDIO_PORT_HANDLE_NONE;
}
+ void setPatch(const audio_patch& patch) { mPatch = patch; }
- audio_io_handle_t mIoHandle;
- struct audio_patch mPatch;
- uint32_t mSamplingRate;
- audio_format_t mFormat;
- audio_channel_mask_t mChannelMask;
- size_t mFrameCount;
- size_t mFrameCountHAL;
- uint32_t mLatency; // only valid for output
- audio_port_handle_t mPortId; // valid for event AUDIO_CLIENT_STARTED
+ std::string toDebugString() const {
+ std::ostringstream ss;
+ ss << mIoHandle << ", samplingRate " << mSamplingRate << ", "
+ << audio_format_to_string(mFormat) << ", "
+ << (audio_channel_mask_get_representation(mChannelMask) ==
+ AUDIO_CHANNEL_REPRESENTATION_INDEX ?
+ audio_channel_index_mask_to_string(mChannelMask) :
+ (mIsInput ? audio_channel_in_mask_to_string(mChannelMask) :
+ audio_channel_out_mask_to_string(mChannelMask)))
+ << ", frameCount " << mFrameCount << ", frameCountHAL " << mFrameCountHAL
+ << ", deviceId " << getDeviceId();
+ return ss.str();
+ }
+
+ private:
+ const audio_io_handle_t mIoHandle = AUDIO_IO_HANDLE_NONE;
+ struct audio_patch mPatch = {};
+ const bool mIsInput = false;
+ const uint32_t mSamplingRate = 0;
+ const audio_format_t mFormat = AUDIO_FORMAT_DEFAULT;
+ const audio_channel_mask_t mChannelMask = AUDIO_CHANNEL_NONE;
+ const size_t mFrameCount = 0;
+ const size_t mFrameCountHAL = 0;
+ const uint32_t mLatency = 0;
+ const audio_port_handle_t mPortId = AUDIO_PORT_HANDLE_NONE;
};
diff --git a/media/libaudioclient/include/media/AudioRecord.h b/media/libaudioclient/include/media/AudioRecord.h
index f17ee3a..a32c595 100644
--- a/media/libaudioclient/include/media/AudioRecord.h
+++ b/media/libaudioclient/include/media/AudioRecord.h
@@ -760,6 +760,13 @@
bool mTimestampRetrogradePositionReported = false; // reduce log spam
bool mTimestampRetrogradeTimeReported = false; // reduce log spam
+ // Format conversion. Maybe needed for adding fast tracks whose format is different from server.
+ audio_config_base_t mServerConfig;
+ size_t mServerFrameSize;
+ size_t mServerSampleSize;
+ std::unique_ptr<uint8_t[]> mFormatConversionBufRaw;
+ Buffer mFormatConversionBuffer;
+
private:
class DeathNotifier : public IBinder::DeathRecipient {
public:
diff --git a/media/libaudioclient/include/media/AudioSystem.h b/media/libaudioclient/include/media/AudioSystem.h
index 869bd6e..50ab42a 100644
--- a/media/libaudioclient/include/media/AudioSystem.h
+++ b/media/libaudioclient/include/media/AudioSystem.h
@@ -26,6 +26,7 @@
#include <android/media/ISpatializer.h>
#include <android/content/AttributionSourceState.h>
#include <media/AidlConversionUtil.h>
+#include <media/AudioContainers.h>
#include <media/AudioDeviceTypeAddr.h>
#include <media/AudioPolicy.h>
#include <media/AudioProductStrategy.h>
@@ -323,7 +324,7 @@
static status_t getMinVolumeIndexForAttributes(const audio_attributes_t &attr, int &index);
static product_strategy_t getStrategyForStream(audio_stream_type_t stream);
- static audio_devices_t getDevicesForStream(audio_stream_type_t stream);
+ static DeviceTypeSet getDevicesForStream(audio_stream_type_t stream);
static status_t getDevicesForAttributes(const AudioAttributes &aa,
AudioDeviceTypeAddrVector *devices);
diff --git a/media/libaudioclient/include/media/AudioTrack.h b/media/libaudioclient/include/media/AudioTrack.h
index 5fea637..a2cd12f 100644
--- a/media/libaudioclient/include/media/AudioTrack.h
+++ b/media/libaudioclient/include/media/AudioTrack.h
@@ -428,8 +428,7 @@
* less than or equal to the getBufferCapacityInFrames().
* It may also be adjusted slightly for internal reasons.
*
- * Return the final size or a negative error if the track is unitialized
- * or does not support variable sizes.
+ * Return the final size or a negative value (NO_INIT) if the track is uninitialized.
*/
ssize_t setBufferSizeInFrames(size_t size);
diff --git a/media/libaudioclient/include/media/IAudioFlinger.h b/media/libaudioclient/include/media/IAudioFlinger.h
index 9e5019e..a2ce145 100644
--- a/media/libaudioclient/include/media/IAudioFlinger.h
+++ b/media/libaudioclient/include/media/IAudioFlinger.h
@@ -166,6 +166,7 @@
sp<IMemory> buffers;
audio_port_handle_t portId;
sp<media::IAudioRecord> audioRecord;
+ audio_config_base_t serverConfig;
ConversionResult<media::CreateRecordResponse> toAidl() const;
static ConversionResult<CreateRecordOutput>
@@ -569,7 +570,7 @@
Status createRecord(const media::CreateRecordRequest& request,
media::CreateRecordResponse* _aidl_return) override;
Status sampleRate(int32_t ioHandle, int32_t* _aidl_return) override;
- Status format(int32_t output, media::audio::common::AudioFormat* _aidl_return) override;
+ Status format(int32_t output, media::AudioFormatDescription* _aidl_return) override;
Status frameCount(int32_t ioHandle, int64_t* _aidl_return) override;
Status latency(int32_t output, int32_t* _aidl_return) override;
Status setMasterVolume(float value) override;
@@ -591,8 +592,9 @@
Status
getParameters(int32_t ioHandle, const std::string& keys, std::string* _aidl_return) override;
Status registerClient(const sp<media::IAudioFlingerClient>& client) override;
- Status getInputBufferSize(int32_t sampleRate, media::audio::common::AudioFormat format,
- int32_t channelMask, int64_t* _aidl_return) override;
+ Status getInputBufferSize(int32_t sampleRate, const media::AudioFormatDescription& format,
+ const media::AudioChannelLayout& channelMask,
+ int64_t* _aidl_return) override;
Status openOutput(const media::OpenOutputRequest& request,
media::OpenOutputResponse* _aidl_return) override;
Status openDuplicateOutput(int32_t output1, int32_t output2, int32_t* _aidl_return) override;
diff --git a/media/libaudioclient/tests/Android.bp b/media/libaudioclient/tests/Android.bp
index def7ca6..2279244 100644
--- a/media/libaudioclient/tests/Android.bp
+++ b/media/libaudioclient/tests/Android.bp
@@ -9,10 +9,34 @@
cc_defaults {
name: "libaudioclient_tests_defaults",
+ test_suites: ["device-tests"],
cflags: [
"-Wall",
"-Werror",
],
+ sanitize: {
+ misc_undefined: [
+ "unsigned-integer-overflow",
+ "signed-integer-overflow",
+ ],
+ },
+}
+
+cc_test {
+ name: "audio_aidl_conversion_tests",
+ defaults: ["libaudioclient_tests_defaults"],
+ srcs: ["audio_aidl_legacy_conversion_tests.cpp"],
+ shared_libs: [
+ "libbinder",
+ "libcutils",
+ "liblog",
+ "libutils",
+ ],
+ static_libs: [
+ "audioclient-types-aidl-cpp",
+ "libaudioclient_aidl_conversion",
+ "libstagefright_foundation",
+ ],
}
cc_test {
@@ -30,8 +54,10 @@
cc_test {
name: "test_create_audiotrack",
defaults: ["libaudioclient_tests_defaults"],
- srcs: ["test_create_audiotrack.cpp",
- "test_create_utils.cpp"],
+ srcs: [
+ "test_create_audiotrack.cpp",
+ "test_create_utils.cpp",
+ ],
header_libs: [
"libmedia_headers",
"libmediametrics_headers",
@@ -49,8 +75,10 @@
cc_test {
name: "test_create_audiorecord",
defaults: ["libaudioclient_tests_defaults"],
- srcs: ["test_create_audiorecord.cpp",
- "test_create_utils.cpp"],
+ srcs: [
+ "test_create_audiorecord.cpp",
+ "test_create_utils.cpp",
+ ],
header_libs: [
"libmedia_headers",
"libmediametrics_headers",
diff --git a/media/libaudioclient/tests/audio_aidl_legacy_conversion_tests.cpp b/media/libaudioclient/tests/audio_aidl_legacy_conversion_tests.cpp
new file mode 100644
index 0000000..424b387
--- /dev/null
+++ b/media/libaudioclient/tests/audio_aidl_legacy_conversion_tests.cpp
@@ -0,0 +1,230 @@
+/*
+ * Copyright (C) 2021 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.
+ */
+
+#include <gtest/gtest.h>
+
+#include <media/AudioCommonTypes.h>
+#include <media/AidlConversion.h>
+
+using namespace android;
+using namespace android::aidl_utils;
+
+namespace {
+
+template<typename T> size_t hash(const T& t) {
+ return std::hash<T>{}(t);
+}
+
+media::AudioChannelLayout make_ACL_None() {
+ return media::AudioChannelLayout{};
+}
+
+media::AudioChannelLayout make_ACL_Invalid() {
+ return media::AudioChannelLayout::make<media::AudioChannelLayout::Tag::invalid>(0);
+}
+
+media::AudioChannelLayout make_ACL_Stereo() {
+ return media::AudioChannelLayout::make<media::AudioChannelLayout::Tag::layoutMask>(
+ media::AudioChannelLayout::LAYOUT_STEREO);
+}
+
+media::AudioChannelLayout make_ACL_ChannelIndex2() {
+ return media::AudioChannelLayout::make<media::AudioChannelLayout::Tag::indexMask>(
+ media::AudioChannelLayout::INDEX_MASK_2);
+}
+
+media::AudioChannelLayout make_ACL_ChannelIndexArbitrary() {
+ // Use channels 1 and 3.
+ return media::AudioChannelLayout::make<media::AudioChannelLayout::Tag::indexMask>(5);
+}
+
+media::AudioChannelLayout make_ACL_VoiceCall() {
+ return media::AudioChannelLayout::make<media::AudioChannelLayout::Tag::voiceMask>(
+ media::AudioChannelLayout::VOICE_CALL_MONO);
+}
+
+media::AudioDeviceDescription make_AudioDeviceDescription(media::AudioDeviceType type,
+ const std::string& connection = "") {
+ media::AudioDeviceDescription result;
+ result.type = type;
+ result.connection = connection;
+ return result;
+}
+
+media::AudioDeviceDescription make_ADD_None() {
+ return media::AudioDeviceDescription{};
+}
+
+media::AudioDeviceDescription make_ADD_DefaultIn() {
+ return make_AudioDeviceDescription(media::AudioDeviceType::IN_DEFAULT);
+}
+
+media::AudioDeviceDescription make_ADD_DefaultOut() {
+ return make_AudioDeviceDescription(media::AudioDeviceType::OUT_DEFAULT);
+}
+
+media::AudioDeviceDescription make_ADD_WiredHeadset() {
+ return make_AudioDeviceDescription(media::AudioDeviceType::OUT_HEADSET,
+ media::AudioDeviceDescription::CONNECTION_ANALOG());
+}
+
+media::AudioDeviceDescription make_ADD_BtScoHeadset() {
+ return make_AudioDeviceDescription(media::AudioDeviceType::OUT_HEADSET,
+ media::AudioDeviceDescription::CONNECTION_BT_SCO());
+}
+
+media::AudioFormatDescription make_AudioFormatDescription(media::AudioFormatType type) {
+ media::AudioFormatDescription result;
+ result.type = type;
+ return result;
+}
+
+media::AudioFormatDescription make_AudioFormatDescription(media::PcmType pcm) {
+ auto result = make_AudioFormatDescription(media::AudioFormatType::PCM);
+ result.pcm = pcm;
+ return result;
+}
+
+media::AudioFormatDescription make_AudioFormatDescription(const std::string& encoding) {
+ media::AudioFormatDescription result;
+ result.encoding = encoding;
+ return result;
+}
+
+media::AudioFormatDescription make_AudioFormatDescription(media::PcmType transport,
+ const std::string& encoding) {
+ auto result = make_AudioFormatDescription(encoding);
+ result.pcm = transport;
+ return result;
+}
+
+media::AudioFormatDescription make_AFD_Default() {
+ return media::AudioFormatDescription{};
+}
+
+media::AudioFormatDescription make_AFD_Invalid() {
+ return make_AudioFormatDescription(media::AudioFormatType::SYS_RESERVED_INVALID);
+}
+
+media::AudioFormatDescription make_AFD_Pcm16Bit() {
+ return make_AudioFormatDescription(media::PcmType::INT_16_BIT);
+}
+
+media::AudioFormatDescription make_AFD_Bitstream() {
+ return make_AudioFormatDescription("example");
+}
+
+media::AudioFormatDescription make_AFD_Encap() {
+ return make_AudioFormatDescription(media::PcmType::INT_16_BIT, "example.encap");
+}
+
+media::AudioFormatDescription make_AFD_Encap_with_Enc() {
+ auto afd = make_AFD_Encap();
+ afd.encoding += "+example";
+ return afd;
+}
+
+} // namespace
+
+// Verify that two independently constructed ADDs/AFDs have the same hash.
+// This ensures that regardless of whether the ADD/AFD instance originates
+// from, it can be correctly compared to other ADD/AFD instance. Thus,
+// for example, a 16-bit integer format description provided by HAL
+// is identical to the same format description constructed by the framework.
+class HashIdentityTest : public ::testing::Test {
+ public:
+ template<typename T> void verifyHashIdentity(const std::vector<std::function<T()>>& valueGens) {
+ for (size_t i = 0; i < valueGens.size(); ++i) {
+ for (size_t j = 0; j < valueGens.size(); ++j) {
+ if (i == j) {
+ EXPECT_EQ(hash(valueGens[i]()), hash(valueGens[i]())) << i;
+ } else {
+ EXPECT_NE(hash(valueGens[i]()), hash(valueGens[j]())) << i << ", " << j;
+ }
+ }
+ }
+ }
+};
+
+TEST_F(HashIdentityTest, AudioChannelLayoutHashIdentity) {
+ verifyHashIdentity<media::AudioChannelLayout>({
+ make_ACL_None, make_ACL_Invalid, make_ACL_Stereo, make_ACL_ChannelIndex2,
+ make_ACL_ChannelIndexArbitrary, make_ACL_VoiceCall});
+}
+
+TEST_F(HashIdentityTest, AudioDeviceDescriptionHashIdentity) {
+ verifyHashIdentity<media::AudioDeviceDescription>({
+ make_ADD_None, make_ADD_DefaultIn, make_ADD_DefaultOut, make_ADD_WiredHeadset,
+ make_ADD_BtScoHeadset});
+}
+
+TEST_F(HashIdentityTest, AudioFormatDescriptionHashIdentity) {
+ verifyHashIdentity<media::AudioFormatDescription>({
+ make_AFD_Default, make_AFD_Invalid, make_AFD_Pcm16Bit, make_AFD_Bitstream,
+ make_AFD_Encap, make_AFD_Encap_with_Enc});
+}
+
+using ChannelLayoutParam = std::tuple<media::AudioChannelLayout, bool /*isInput*/>;
+class AudioChannelLayoutRoundTripTest :
+ public testing::TestWithParam<ChannelLayoutParam> {};
+TEST_P(AudioChannelLayoutRoundTripTest, Aidl2Legacy2Aidl) {
+ const auto initial = std::get<0>(GetParam());
+ const bool isInput = std::get<1>(GetParam());
+ auto conv = aidl2legacy_AudioChannelLayout_audio_channel_mask_t(initial, isInput);
+ ASSERT_TRUE(conv.ok());
+ auto convBack = legacy2aidl_audio_channel_mask_t_AudioChannelLayout(conv.value(), isInput);
+ ASSERT_TRUE(convBack.ok());
+ EXPECT_EQ(initial, convBack.value());
+}
+INSTANTIATE_TEST_SUITE_P(AudioChannelLayoutRoundTrip,
+ AudioChannelLayoutRoundTripTest,
+ testing::Combine(
+ testing::Values(media::AudioChannelLayout{}, make_ACL_Invalid(), make_ACL_Stereo(),
+ make_ACL_ChannelIndex2(), make_ACL_ChannelIndexArbitrary()),
+ testing::Values(false, true)));
+INSTANTIATE_TEST_SUITE_P(AudioChannelVoiceRoundTrip,
+ AudioChannelLayoutRoundTripTest,
+ // In legacy constants the voice call is only defined for input.
+ testing::Combine(testing::Values(make_ACL_VoiceCall()), testing::Values(true)));
+
+class AudioDeviceDescriptionRoundTripTest :
+ public testing::TestWithParam<media::AudioDeviceDescription> {};
+TEST_P(AudioDeviceDescriptionRoundTripTest, Aidl2Legacy2Aidl) {
+ const auto initial = GetParam();
+ auto conv = aidl2legacy_AudioDeviceDescription_audio_devices_t(initial);
+ ASSERT_TRUE(conv.ok());
+ auto convBack = legacy2aidl_audio_devices_t_AudioDeviceDescription(conv.value());
+ ASSERT_TRUE(convBack.ok());
+ EXPECT_EQ(initial, convBack.value());
+}
+INSTANTIATE_TEST_SUITE_P(AudioDeviceDescriptionRoundTrip,
+ AudioDeviceDescriptionRoundTripTest,
+ testing::Values(media::AudioDeviceDescription{}, make_ADD_DefaultIn(),
+ make_ADD_DefaultOut(), make_ADD_WiredHeadset(), make_ADD_BtScoHeadset()));
+
+class AudioFormatDescriptionRoundTripTest :
+ public testing::TestWithParam<media::AudioFormatDescription> {};
+TEST_P(AudioFormatDescriptionRoundTripTest, Aidl2Legacy2Aidl) {
+ const auto initial = GetParam();
+ auto conv = aidl2legacy_AudioFormatDescription_audio_format_t(initial);
+ ASSERT_TRUE(conv.ok());
+ auto convBack = legacy2aidl_audio_format_t_AudioFormatDescription(conv.value());
+ ASSERT_TRUE(convBack.ok());
+ EXPECT_EQ(initial, convBack.value());
+}
+INSTANTIATE_TEST_SUITE_P(AudioFormatDescriptionRoundTrip,
+ AudioFormatDescriptionRoundTripTest,
+ testing::Values(make_AFD_Invalid(), media::AudioFormatDescription{}, make_AFD_Pcm16Bit()));
diff --git a/media/libaudiofoundation/AudioDeviceTypeAddr.cpp b/media/libaudiofoundation/AudioDeviceTypeAddr.cpp
index c5d7da8..7f54474 100644
--- a/media/libaudiofoundation/AudioDeviceTypeAddr.cpp
+++ b/media/libaudiofoundation/AudioDeviceTypeAddr.cpp
@@ -158,14 +158,15 @@
ConversionResult<AudioDeviceTypeAddr>
aidl2legacy_AudioDeviceTypeAddress(const media::AudioDevice& aidl) {
- audio_devices_t type = VALUE_OR_RETURN(aidl2legacy_int32_t_audio_devices_t(aidl.type));
+ audio_devices_t type = VALUE_OR_RETURN(
+ aidl2legacy_AudioDeviceDescription_audio_devices_t(aidl.type));
return AudioDeviceTypeAddr(type, aidl.address);
}
ConversionResult<media::AudioDevice>
legacy2aidl_AudioDeviceTypeAddress(const AudioDeviceTypeAddr& legacy) {
media::AudioDevice aidl;
- aidl.type = VALUE_OR_RETURN(legacy2aidl_audio_devices_t_int32_t(legacy.mType));
+ aidl.type = VALUE_OR_RETURN(legacy2aidl_audio_devices_t_AudioDeviceDescription(legacy.mType));
aidl.address = legacy.getAddress();
return aidl;
}
diff --git a/media/libaudiofoundation/AudioGain.cpp b/media/libaudiofoundation/AudioGain.cpp
index 1dee938..ea0258a 100644
--- a/media/libaudiofoundation/AudioGain.cpp
+++ b/media/libaudiofoundation/AudioGain.cpp
@@ -34,10 +34,10 @@
namespace android {
-AudioGain::AudioGain(int index, bool useInChannelMask)
+AudioGain::AudioGain(int index, bool isInput)
{
mIndex = index;
- mUseInChannelMask = useInChannelMask;
+ mIsInput = isInput;
memset(&mGain, 0, sizeof(struct audio_gain));
}
@@ -49,12 +49,9 @@
if ((mGain.mode & AUDIO_GAIN_MODE_JOINT) == AUDIO_GAIN_MODE_JOINT) {
config->values[0] = mGain.default_value;
} else {
- uint32_t numValues;
- if (mUseInChannelMask) {
- numValues = audio_channel_count_from_in_mask(mGain.channel_mask);
- } else {
- numValues = audio_channel_count_from_out_mask(mGain.channel_mask);
- }
+ const uint32_t numValues = mIsInput ?
+ audio_channel_count_from_in_mask(mGain.channel_mask) :
+ audio_channel_count_from_out_mask(mGain.channel_mask);
for (size_t i = 0; i < numValues; i++) {
config->values[i] = mGain.default_value;
}
@@ -78,12 +75,9 @@
if ((config->channel_mask & ~mGain.channel_mask) != 0) {
return BAD_VALUE;
}
- uint32_t numValues;
- if (mUseInChannelMask) {
- numValues = audio_channel_count_from_in_mask(config->channel_mask);
- } else {
- numValues = audio_channel_count_from_out_mask(config->channel_mask);
- }
+ const uint32_t numValues = mIsInput ?
+ audio_channel_count_from_in_mask(config->channel_mask) :
+ audio_channel_count_from_out_mask(config->channel_mask);
for (size_t i = 0; i < numValues; i++) {
if ((config->values[i] < mGain.min_value) ||
(config->values[i] > mGain.max_value)) {
@@ -116,7 +110,7 @@
bool AudioGain::equals(const sp<AudioGain>& other) const
{
return other != nullptr &&
- mUseInChannelMask == other->mUseInChannelMask &&
+ mIsInput == other->mIsInput &&
mUseForVolume == other->mUseForVolume &&
// Compare audio gain
mGain.mode == other->mGain.mode &&
@@ -137,12 +131,13 @@
status_t AudioGain::writeToParcelable(media::AudioGain* parcelable) const {
parcelable->index = VALUE_OR_RETURN_STATUS(convertIntegral<int32_t>(mIndex));
- parcelable->useInChannelMask = mUseInChannelMask;
+ parcelable->isInput = mIsInput;
parcelable->useForVolume = mUseForVolume;
parcelable->mode = VALUE_OR_RETURN_STATUS(
legacy2aidl_audio_gain_mode_t_int32_t_mask(mGain.mode));
parcelable->channelMask = VALUE_OR_RETURN_STATUS(
- legacy2aidl_audio_channel_mask_t_int32_t(mGain.channel_mask));
+ legacy2aidl_audio_channel_mask_t_AudioChannelLayout(
+ mGain.channel_mask, mIsInput));
parcelable->minValue = VALUE_OR_RETURN_STATUS(convertIntegral<int32_t>(mGain.min_value));
parcelable->maxValue = VALUE_OR_RETURN_STATUS(convertIntegral<int32_t>(mGain.max_value));
parcelable->defaultValue = VALUE_OR_RETURN_STATUS(
@@ -161,12 +156,13 @@
status_t AudioGain::readFromParcelable(const media::AudioGain& parcelable) {
mIndex = VALUE_OR_RETURN_STATUS(convertIntegral<int>(parcelable.index));
- mUseInChannelMask = parcelable.useInChannelMask;
+ mIsInput = parcelable.isInput;
mUseForVolume = parcelable.useForVolume;
mGain.mode = VALUE_OR_RETURN_STATUS(
aidl2legacy_int32_t_audio_gain_mode_t_mask(parcelable.mode));
mGain.channel_mask = VALUE_OR_RETURN_STATUS(
- aidl2legacy_int32_t_audio_channel_mask_t(parcelable.channelMask));
+ aidl2legacy_AudioChannelLayout_audio_channel_mask_t(
+ parcelable.channelMask, parcelable.isInput));
mGain.min_value = VALUE_OR_RETURN_STATUS(convertIntegral<int>(parcelable.minValue));
mGain.max_value = VALUE_OR_RETURN_STATUS(convertIntegral<int>(parcelable.maxValue));
mGain.default_value = VALUE_OR_RETURN_STATUS(convertIntegral<int>(parcelable.defaultValue));
diff --git a/media/libaudiofoundation/AudioPort.cpp b/media/libaudiofoundation/AudioPort.cpp
index fafabd9..c70a6c2 100644
--- a/media/libaudiofoundation/AudioPort.cpp
+++ b/media/libaudiofoundation/AudioPort.cpp
@@ -210,7 +210,8 @@
parcelable->name = mName;
parcelable->type = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_port_type_t_AudioPortType(mType));
parcelable->role = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_port_role_t_AudioPortRole(mRole));
- parcelable->profiles = VALUE_OR_RETURN_STATUS(legacy2aidl_AudioProfileVector(mProfiles));
+ parcelable->profiles = VALUE_OR_RETURN_STATUS(
+ legacy2aidl_AudioProfileVector(mProfiles, useInputChannelMask()));
parcelable->extraAudioDescriptors = mExtraAudioDescriptors;
parcelable->gains = VALUE_OR_RETURN_STATUS(legacy2aidl_AudioGains(mGains));
return OK;
@@ -226,7 +227,8 @@
mName = parcelable.name;
mType = VALUE_OR_RETURN_STATUS(aidl2legacy_AudioPortType_audio_port_type_t(parcelable.type));
mRole = VALUE_OR_RETURN_STATUS(aidl2legacy_AudioPortRole_audio_port_role_t(parcelable.role));
- mProfiles = VALUE_OR_RETURN_STATUS(aidl2legacy_AudioProfileVector(parcelable.profiles));
+ mProfiles = VALUE_OR_RETURN_STATUS(
+ aidl2legacy_AudioProfileVector(parcelable.profiles, useInputChannelMask()));
mExtraAudioDescriptors = parcelable.extraAudioDescriptors;
mGains = VALUE_OR_RETURN_STATUS(aidl2legacy_AudioGains(parcelable.gains));
return OK;
@@ -330,23 +332,19 @@
mGain.ramp_duration_ms == other->mGain.ramp_duration_ms;
}
-status_t AudioPortConfig::writeToParcel(Parcel *parcel) const {
- media::AudioPortConfig parcelable;
- return writeToParcelable(&parcelable)
- ?: parcelable.writeToParcel(parcel);
-}
-
-status_t AudioPortConfig::writeToParcelable(media::AudioPortConfig* parcelable) const {
+status_t AudioPortConfig::writeToParcelable(
+ media::AudioPortConfig* parcelable, bool isInput) const {
parcelable->sampleRate = VALUE_OR_RETURN_STATUS(convertIntegral<int32_t>(mSamplingRate));
- parcelable->format = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_format_t_AudioFormat(mFormat));
+ parcelable->format = VALUE_OR_RETURN_STATUS(
+ legacy2aidl_audio_format_t_AudioFormatDescription(mFormat));
parcelable->channelMask = VALUE_OR_RETURN_STATUS(
- legacy2aidl_audio_channel_mask_t_int32_t(mChannelMask));
+ legacy2aidl_audio_channel_mask_t_AudioChannelLayout(mChannelMask, isInput));
parcelable->id = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_port_handle_t_int32_t(mId));
parcelable->gain.index = VALUE_OR_RETURN_STATUS(convertIntegral<int32_t>(mGain.index));
parcelable->gain.mode = VALUE_OR_RETURN_STATUS(
legacy2aidl_audio_gain_mode_t_int32_t_mask(mGain.mode));
parcelable->gain.channelMask = VALUE_OR_RETURN_STATUS(
- legacy2aidl_audio_channel_mask_t_int32_t(mGain.channel_mask));
+ legacy2aidl_audio_channel_mask_t_AudioChannelLayout(mGain.channel_mask, isInput));
parcelable->gain.rampDurationMs = VALUE_OR_RETURN_STATUS(
convertIntegral<int32_t>(mGain.ramp_duration_ms));
parcelable->gain.values = VALUE_OR_RETURN_STATUS(convertContainer<std::vector<int32_t>>(
@@ -354,23 +352,20 @@
return OK;
}
-status_t AudioPortConfig::readFromParcel(const Parcel *parcel) {
- media::AudioPortConfig parcelable;
- return parcelable.readFromParcel(parcel)
- ?: readFromParcelable(parcelable);
-}
-
-status_t AudioPortConfig::readFromParcelable(const media::AudioPortConfig& parcelable) {
+status_t AudioPortConfig::readFromParcelable(
+ const media::AudioPortConfig& parcelable, bool isInput) {
mSamplingRate = VALUE_OR_RETURN_STATUS(convertIntegral<unsigned int>(parcelable.sampleRate));
- mFormat = VALUE_OR_RETURN_STATUS(aidl2legacy_AudioFormat_audio_format_t(parcelable.format));
+ mFormat = VALUE_OR_RETURN_STATUS(
+ aidl2legacy_AudioFormatDescription_audio_format_t(parcelable.format));
mChannelMask = VALUE_OR_RETURN_STATUS(
- aidl2legacy_int32_t_audio_channel_mask_t(parcelable.channelMask));
+ aidl2legacy_AudioChannelLayout_audio_channel_mask_t(parcelable.channelMask, isInput));
mId = VALUE_OR_RETURN_STATUS(aidl2legacy_int32_t_audio_port_handle_t(parcelable.id));
mGain.index = VALUE_OR_RETURN_STATUS(convertIntegral<int>(parcelable.gain.index));
mGain.mode = VALUE_OR_RETURN_STATUS(
aidl2legacy_int32_t_audio_gain_mode_t_mask(parcelable.gain.mode));
mGain.channel_mask = VALUE_OR_RETURN_STATUS(
- aidl2legacy_int32_t_audio_channel_mask_t(parcelable.gain.channelMask));
+ aidl2legacy_AudioChannelLayout_audio_channel_mask_t(
+ parcelable.gain.channelMask, isInput));
mGain.ramp_duration_ms = VALUE_OR_RETURN_STATUS(
convertIntegral<unsigned int>(parcelable.gain.rampDurationMs));
if (parcelable.gain.values.size() > std::size(mGain.values)) {
diff --git a/media/libaudiofoundation/AudioProfile.cpp b/media/libaudiofoundation/AudioProfile.cpp
index 8ac3f73..47b2d54 100644
--- a/media/libaudiofoundation/AudioProfile.cpp
+++ b/media/libaudiofoundation/AudioProfile.cpp
@@ -154,19 +154,17 @@
return *this;
}
-status_t AudioProfile::writeToParcel(Parcel *parcel) const {
- media::AudioProfile parcelable = VALUE_OR_RETURN_STATUS(toParcelable());
- return parcelable.writeToParcel(parcel);
- }
-
ConversionResult<media::AudioProfile>
-AudioProfile::toParcelable() const {
+AudioProfile::toParcelable(bool isInput) const {
media::AudioProfile parcelable;
parcelable.name = mName;
- parcelable.format = VALUE_OR_RETURN(legacy2aidl_audio_format_t_AudioFormat(mFormat));
+ parcelable.format = VALUE_OR_RETURN(legacy2aidl_audio_format_t_AudioFormatDescription(mFormat));
parcelable.channelMasks = VALUE_OR_RETURN(
- convertContainer<std::vector<int32_t>>(mChannelMasks,
- legacy2aidl_audio_channel_mask_t_int32_t));
+ convertContainer<std::vector<media::AudioChannelLayout>>(
+ mChannelMasks,
+ [isInput](audio_channel_mask_t m) {
+ return legacy2aidl_audio_channel_mask_t_AudioChannelLayout(m, isInput);
+ }));
parcelable.samplingRates = VALUE_OR_RETURN(
convertContainer<std::vector<int32_t>>(mSamplingRates,
convertIntegral<int32_t, uint32_t>));
@@ -178,23 +176,17 @@
return parcelable;
}
-status_t AudioProfile::readFromParcel(const Parcel *parcel) {
- media::AudioProfile parcelable;
- if (status_t status = parcelable.readFromParcel(parcel); status != OK) {
- return status;
- }
- *this = *VALUE_OR_RETURN_STATUS(fromParcelable(parcelable));
- return OK;
-}
-
ConversionResult<sp<AudioProfile>>
-AudioProfile::fromParcelable(const media::AudioProfile& parcelable) {
+AudioProfile::fromParcelable(const media::AudioProfile& parcelable, bool isInput) {
sp<AudioProfile> legacy = new AudioProfile();
legacy->mName = parcelable.name;
- legacy->mFormat = VALUE_OR_RETURN(aidl2legacy_AudioFormat_audio_format_t(parcelable.format));
+ legacy->mFormat = VALUE_OR_RETURN(
+ aidl2legacy_AudioFormatDescription_audio_format_t(parcelable.format));
legacy->mChannelMasks = VALUE_OR_RETURN(
convertContainer<ChannelMaskSet>(parcelable.channelMasks,
- aidl2legacy_int32_t_audio_channel_mask_t));
+ [isInput](const media::AudioChannelLayout& l) {
+ return aidl2legacy_AudioChannelLayout_audio_channel_mask_t(l, isInput);
+ }));
legacy->mSamplingRates = VALUE_OR_RETURN(
convertContainer<SampleRateSet>(parcelable.samplingRates,
convertIntegral<uint32_t, int32_t>));
@@ -208,13 +200,13 @@
}
ConversionResult<sp<AudioProfile>>
-aidl2legacy_AudioProfile(const media::AudioProfile& aidl) {
- return AudioProfile::fromParcelable(aidl);
+aidl2legacy_AudioProfile(const media::AudioProfile& aidl, bool isInput) {
+ return AudioProfile::fromParcelable(aidl, isInput);
}
ConversionResult<media::AudioProfile>
-legacy2aidl_AudioProfile(const sp<AudioProfile>& legacy) {
- return legacy->toParcelable();
+legacy2aidl_AudioProfile(const sp<AudioProfile>& legacy, bool isInput) {
+ return legacy->toParcelable(isInput);
}
ssize_t AudioProfileVector::add(const sp<AudioProfile> &profile)
@@ -328,33 +320,6 @@
}
}
-status_t AudioProfileVector::writeToParcel(Parcel *parcel) const
-{
- status_t status = NO_ERROR;
- if ((status = parcel->writeVectorSize(*this)) != NO_ERROR) return status;
- for (const auto &audioProfile : *this) {
- if ((status = parcel->writeParcelable(*audioProfile)) != NO_ERROR) {
- break;
- }
- }
- return status;
-}
-
-status_t AudioProfileVector::readFromParcel(const Parcel *parcel)
-{
- status_t status = NO_ERROR;
- this->clear();
- if ((status = parcel->resizeOutVector(this)) != NO_ERROR) return status;
- for (size_t i = 0; i < this->size(); ++i) {
- this->at(i) = new AudioProfile(AUDIO_FORMAT_DEFAULT, AUDIO_CHANNEL_NONE, 0 /*sampleRate*/);
- if ((status = parcel->readParcelable(this->at(i).get())) != NO_ERROR) {
- this->clear();
- break;
- }
- }
- return status;
-}
-
bool AudioProfileVector::equals(const AudioProfileVector& other) const
{
return std::equal(begin(), end(), other.begin(), other.end(),
@@ -364,13 +329,19 @@
}
ConversionResult<AudioProfileVector>
-aidl2legacy_AudioProfileVector(const std::vector<media::AudioProfile>& aidl) {
- return convertContainer<AudioProfileVector>(aidl, aidl2legacy_AudioProfile);
+aidl2legacy_AudioProfileVector(const std::vector<media::AudioProfile>& aidl, bool isInput) {
+ return convertContainer<AudioProfileVector>(aidl,
+ [isInput](const media::AudioProfile& p) {
+ return aidl2legacy_AudioProfile(p, isInput);
+ });
}
ConversionResult<std::vector<media::AudioProfile>>
-legacy2aidl_AudioProfileVector(const AudioProfileVector& legacy) {
- return convertContainer<std::vector<media::AudioProfile>>(legacy, legacy2aidl_AudioProfile);
+legacy2aidl_AudioProfileVector(const AudioProfileVector& legacy, bool isInput) {
+ return convertContainer<std::vector<media::AudioProfile>>(legacy,
+ [isInput](const sp<AudioProfile>& p) {
+ return legacy2aidl_AudioProfile(p, isInput);
+ });
}
AudioProfileVector intersectAudioProfiles(const AudioProfileVector& profiles1,
diff --git a/media/libaudiofoundation/DeviceDescriptorBase.cpp b/media/libaudiofoundation/DeviceDescriptorBase.cpp
index 5cfea81..3cce722 100644
--- a/media/libaudiofoundation/DeviceDescriptorBase.cpp
+++ b/media/libaudiofoundation/DeviceDescriptorBase.cpp
@@ -166,7 +166,7 @@
status_t DeviceDescriptorBase::writeToParcelable(media::AudioPort* parcelable) const {
AudioPort::writeToParcelable(parcelable);
- AudioPortConfig::writeToParcelable(&parcelable->activeConfig);
+ AudioPortConfig::writeToParcelable(&parcelable->activeConfig, useInputChannelMask());
parcelable->id = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_port_handle_t_int32_t(mId));
media::AudioPortDeviceExt ext;
@@ -190,7 +190,7 @@
return BAD_VALUE;
}
status_t status = AudioPort::readFromParcelable(parcelable)
- ?: AudioPortConfig::readFromParcelable(parcelable.activeConfig);
+ ?: AudioPortConfig::readFromParcelable(parcelable.activeConfig, useInputChannelMask());
if (status != OK) {
return status;
}
diff --git a/media/libaudiofoundation/include/media/AudioGain.h b/media/libaudiofoundation/include/media/AudioGain.h
index a06b686..28769d2 100644
--- a/media/libaudiofoundation/include/media/AudioGain.h
+++ b/media/libaudiofoundation/include/media/AudioGain.h
@@ -31,7 +31,7 @@
class AudioGain: public RefBase, public Parcelable
{
public:
- AudioGain(int index, bool useInChannelMask);
+ AudioGain(int index, bool isInput);
virtual ~AudioGain() {}
void setMode(audio_gain_mode_t mode) { mGain.mode = mode; }
@@ -80,7 +80,7 @@
private:
int mIndex;
struct audio_gain mGain;
- bool mUseInChannelMask;
+ bool mIsInput;
bool mUseForVolume = false;
};
diff --git a/media/libaudiofoundation/include/media/AudioPort.h b/media/libaudiofoundation/include/media/AudioPort.h
index 1cee1c9..6e1d032 100644
--- a/media/libaudiofoundation/include/media/AudioPort.h
+++ b/media/libaudiofoundation/include/media/AudioPort.h
@@ -130,7 +130,7 @@
};
-class AudioPortConfig : public virtual RefBase, public virtual Parcelable
+class AudioPortConfig : public virtual RefBase
{
public:
virtual ~AudioPortConfig() = default;
@@ -152,10 +152,8 @@
bool equals(const sp<AudioPortConfig>& other) const;
- status_t writeToParcel(Parcel* parcel) const override;
- status_t readFromParcel(const Parcel* parcel) override;
- status_t writeToParcelable(media::AudioPortConfig* parcelable) const;
- status_t readFromParcelable(const media::AudioPortConfig& parcelable);
+ status_t writeToParcelable(media::AudioPortConfig* parcelable, bool isInput) const;
+ status_t readFromParcelable(const media::AudioPortConfig& parcelable, bool isInput);
protected:
unsigned int mSamplingRate = 0u;
diff --git a/media/libaudiofoundation/include/media/AudioProfile.h b/media/libaudiofoundation/include/media/AudioProfile.h
index 6a36e78..e34a49f 100644
--- a/media/libaudiofoundation/include/media/AudioProfile.h
+++ b/media/libaudiofoundation/include/media/AudioProfile.h
@@ -29,7 +29,7 @@
namespace android {
-class AudioProfile final : public RefBase, public Parcelable
+class AudioProfile final : public RefBase
{
public:
static sp<AudioProfile> createFullDynamic(audio_format_t dynamicFormat = AUDIO_FORMAT_DEFAULT);
@@ -81,11 +81,9 @@
bool equals(const sp<AudioProfile>& other) const;
- status_t writeToParcel(Parcel* parcel) const override;
- status_t readFromParcel(const Parcel* parcel) override;
-
- ConversionResult<media::AudioProfile> toParcelable() const;
- static ConversionResult<sp<AudioProfile>> fromParcelable(const media::AudioProfile& parcelable);
+ ConversionResult<media::AudioProfile> toParcelable(bool isInput) const;
+ static ConversionResult<sp<AudioProfile>> fromParcelable(
+ const media::AudioProfile& parcelable, bool isInput);
private:
@@ -106,11 +104,11 @@
// Conversion routines, according to AidlConversion.h conventions.
ConversionResult<sp<AudioProfile>>
-aidl2legacy_AudioProfile(const media::AudioProfile& aidl);
+aidl2legacy_AudioProfile(const media::AudioProfile& aidl, bool isInput);
ConversionResult<media::AudioProfile>
-legacy2aidl_AudioProfile(const sp<AudioProfile>& legacy);
+legacy2aidl_AudioProfile(const sp<AudioProfile>& legacy, bool isInput);
-class AudioProfileVector : public std::vector<sp<AudioProfile>>, public Parcelable
+class AudioProfileVector : public std::vector<sp<AudioProfile>>
{
public:
virtual ~AudioProfileVector() = default;
@@ -136,18 +134,15 @@
virtual void dump(std::string *dst, int spaces) const;
bool equals(const AudioProfileVector& other) const;
-
- status_t writeToParcel(Parcel* parcel) const override;
- status_t readFromParcel(const Parcel* parcel) override;
};
bool operator == (const AudioProfile &left, const AudioProfile &right);
// Conversion routines, according to AidlConversion.h conventions.
ConversionResult<AudioProfileVector>
-aidl2legacy_AudioProfileVector(const std::vector<media::AudioProfile>& aidl);
+aidl2legacy_AudioProfileVector(const std::vector<media::AudioProfile>& aidl, bool isInput);
ConversionResult<std::vector<media::AudioProfile>>
-legacy2aidl_AudioProfileVector(const AudioProfileVector& legacy);
+legacy2aidl_AudioProfileVector(const AudioProfileVector& legacy, bool isInput);
AudioProfileVector intersectAudioProfiles(const AudioProfileVector& profiles1,
const AudioProfileVector& profiles2);
diff --git a/media/libaudiofoundation/tests/Android.bp b/media/libaudiofoundation/tests/Android.bp
index bb9a5f2..f3cd446 100644
--- a/media/libaudiofoundation/tests/Android.bp
+++ b/media/libaudiofoundation/tests/Android.bp
@@ -11,12 +11,19 @@
name: "audiofoundation_parcelable_test",
shared_libs: [
- "libaudiofoundation",
+ "libbase",
"libbinder",
"liblog",
"libutils",
],
+ static_libs: [
+ "audioclient-types-aidl-cpp",
+ "libaudioclient_aidl_conversion",
+ "libaudiofoundation",
+ "libstagefright_foundation",
+ ],
+
header_libs: [
"libaudio_system_headers",
],
diff --git a/media/libaudiofoundation/tests/audiofoundation_parcelable_test.cpp b/media/libaudiofoundation/tests/audiofoundation_parcelable_test.cpp
index 068b5d8..1696980 100644
--- a/media/libaudiofoundation/tests/audiofoundation_parcelable_test.cpp
+++ b/media/libaudiofoundation/tests/audiofoundation_parcelable_test.cpp
@@ -53,7 +53,7 @@
AudioGains getAudioGainsForTest() {
AudioGains audioGains;
- sp<AudioGain> audioGain = new AudioGain(0 /*index*/, false /*useInChannelMask*/);
+ sp<AudioGain> audioGain = new AudioGain(0 /*index*/, false /*isInput*/);
audioGain->setMode(AUDIO_GAIN_MODE_JOINT);
audioGain->setChannelMask(AUDIO_CHANNEL_OUT_STEREO);
audioGain->setMinValueInMb(-3200);
@@ -86,17 +86,6 @@
ASSERT_TRUE(audioGainsFromParcel.equals(audioGains));
}
-TEST(AudioFoundationParcelableTest, ParcelingAudioProfileVector) {
- Parcel data;
- AudioProfileVector audioProfiles = getAudioProfileVectorForTest();
-
- ASSERT_EQ(data.writeParcelable(audioProfiles), NO_ERROR);
- data.setDataPosition(0);
- AudioProfileVector audioProfilesFromParcel;
- ASSERT_EQ(data.readParcelable(&audioProfilesFromParcel), NO_ERROR);
- ASSERT_TRUE(audioProfilesFromParcel.equals(audioProfiles));
-}
-
TEST(AudioFoundationParcelableTest, ParcelingAudioPort) {
Parcel data;
sp<AudioPort> audioPort = new AudioPort(
@@ -116,11 +105,15 @@
Parcel data;
sp<AudioPortConfig> audioPortConfig = new AudioPortConfigTestStub();
audioPortConfig->applyAudioPortConfig(&TEST_AUDIO_PORT_CONFIG);
-
- ASSERT_EQ(data.writeParcelable(*audioPortConfig), NO_ERROR);
+ media::AudioPortConfig parcelable{};
+ ASSERT_EQ(NO_ERROR, audioPortConfig->writeToParcelable(&parcelable, false /*isInput*/));
+ ASSERT_EQ(NO_ERROR, data.writeParcelable(parcelable));
data.setDataPosition(0);
+ media::AudioPortConfig parcelableFromParcel{};
+ ASSERT_EQ(NO_ERROR, data.readParcelable(&parcelableFromParcel));
sp<AudioPortConfig> audioPortConfigFromParcel = new AudioPortConfigTestStub();
- ASSERT_EQ(data.readParcelable(audioPortConfigFromParcel.get()), NO_ERROR);
+ ASSERT_EQ(NO_ERROR, audioPortConfigFromParcel->readFromParcelable(
+ parcelableFromParcel, false /*isInput*/));
ASSERT_TRUE(audioPortConfigFromParcel->equals(audioPortConfig));
}
diff --git a/media/libmedia/IMediaPlayer.cpp b/media/libmedia/IMediaPlayer.cpp
index c89c023..c9f361e 100644
--- a/media/libmedia/IMediaPlayer.cpp
+++ b/media/libmedia/IMediaPlayer.cpp
@@ -17,7 +17,6 @@
#include <arpa/inet.h>
#include <stdint.h>
-#include <sys/types.h>
#include <android/IDataSource.h>
#include <binder/IPCThreadState.h>
diff --git a/media/libmedia/tests/codeclist/Android.bp b/media/libmedia/tests/codeclist/Android.bp
index 7dd0caa..57af9a9 100644
--- a/media/libmedia/tests/codeclist/Android.bp
+++ b/media/libmedia/tests/codeclist/Android.bp
@@ -25,7 +25,7 @@
cc_test {
name: "CodecListTest",
- test_suites: ["device-tests"],
+ test_suites: ["device-tests", "mts"],
gtest: true,
srcs: [
@@ -41,7 +41,7 @@
"libstagefright_xmlparser",
"libutils",
],
-
+ compile_multilib: "first",
cflags: [
"-Werror",
"-Wall",
diff --git a/media/libmediaplayerservice/StagefrightRecorder.h b/media/libmediaplayerservice/StagefrightRecorder.h
index d6de47f..d7785da 100644
--- a/media/libmediaplayerservice/StagefrightRecorder.h
+++ b/media/libmediaplayerservice/StagefrightRecorder.h
@@ -26,6 +26,7 @@
#include <system/audio.h>
#include <media/hardware/MetadataBufferType.h>
+#include <media/stagefright/foundation/AString.h>
#include <android/content/AttributionSourceState.h>
namespace android {
diff --git a/media/libnbaio/include/media/nbaio/AudioStreamOutSink.h b/media/libnbaio/include/media/nbaio/AudioStreamOutSink.h
index 348b4f8..635f67f 100644
--- a/media/libnbaio/include/media/nbaio/AudioStreamOutSink.h
+++ b/media/libnbaio/include/media/nbaio/AudioStreamOutSink.h
@@ -42,10 +42,6 @@
//virtual size_t framesUnderrun() const;
//virtual size_t underruns() const;
- // This is an over-estimate, and could dupe the caller into making a blocking write()
- // FIXME Use an audio HAL API to query the buffer emptying status when it's available.
- virtual ssize_t availableToWrite() { return mStreamBufferSizeBytes / mFrameSize; }
-
virtual ssize_t write(const void *buffer, size_t count);
virtual status_t getTimestamp(ExtendedTimestamp ×tamp);
diff --git a/media/libstagefright/MediaCodec.cpp b/media/libstagefright/MediaCodec.cpp
index c03236a..a366506 100644
--- a/media/libstagefright/MediaCodec.cpp
+++ b/media/libstagefright/MediaCodec.cpp
@@ -4775,8 +4775,8 @@
}
const CryptoPlugin::SubSample *subSamples;
size_t numSubSamples;
- const uint8_t *key;
- const uint8_t *iv;
+ const uint8_t *key = NULL;
+ const uint8_t *iv = NULL;
CryptoPlugin::Mode mode = CryptoPlugin::kMode_Unencrypted;
// We allow the simpler queueInputBuffer API to be used even in
@@ -4791,8 +4791,6 @@
subSamples = &ss;
numSubSamples = 1;
- key = NULL;
- iv = NULL;
pattern.mEncryptBlocks = 0;
pattern.mSkipBlocks = 0;
}
diff --git a/media/libstagefright/foundation/MediaDefs.cpp b/media/libstagefright/foundation/MediaDefs.cpp
index ada5d81..0ec5ad5 100644
--- a/media/libstagefright/foundation/MediaDefs.cpp
+++ b/media/libstagefright/foundation/MediaDefs.cpp
@@ -65,7 +65,17 @@
const char *MEDIA_MIMETYPE_AUDIO_WMA = "audio/x-ms-wma";
const char *MEDIA_MIMETYPE_AUDIO_MS_ADPCM = "audio/x-adpcm-ms";
const char *MEDIA_MIMETYPE_AUDIO_DVI_IMA_ADPCM = "audio/x-adpcm-dvi-ima";
-
+const char *MEDIA_MIMETYPE_AUDIO_DTS = "audio/vnd.dts";
+const char *MEDIA_MIMETYPE_AUDIO_DTS_HD = "audio/vnd.dts.hd";
+const char *MEDIA_MIMETYPE_AUDIO_DTS_UHD = "audio/vnd.dts.uhd";
+const char *MEDIA_MIMETYPE_AUDIO_EVRC = "audio/evrc";
+const char *MEDIA_MIMETYPE_AUDIO_EVRCB = "audio/evrcb";
+const char *MEDIA_MIMETYPE_AUDIO_EVRCWB = "audio/evrcwb";
+const char *MEDIA_MIMETYPE_AUDIO_EVRCNW = "audio/evrcnw";
+const char *MEDIA_MIMETYPE_AUDIO_AMR_WB_PLUS = "audio/amr-wb+";
+const char *MEDIA_MIMETYPE_AUDIO_APTX = "audio/aptx";
+const char *MEDIA_MIMETYPE_AUDIO_DRA = "audio/vnd.dra";
+const char *MEDIA_MIMETYPE_AUDIO_AAC_FORMAT = "audio/aac";
const char *MEDIA_MIMETYPE_CONTAINER_MPEG4 = "video/mp4";
const char *MEDIA_MIMETYPE_CONTAINER_WAV = "audio/x-wav";
diff --git a/media/libstagefright/foundation/include/media/stagefright/foundation/MediaDefs.h b/media/libstagefright/foundation/include/media/stagefright/foundation/MediaDefs.h
index f5cecef..afa0c6d 100644
--- a/media/libstagefright/foundation/include/media/stagefright/foundation/MediaDefs.h
+++ b/media/libstagefright/foundation/include/media/stagefright/foundation/MediaDefs.h
@@ -67,7 +67,17 @@
extern const char *MEDIA_MIMETYPE_AUDIO_WMA;
extern const char *MEDIA_MIMETYPE_AUDIO_MS_ADPCM;
extern const char *MEDIA_MIMETYPE_AUDIO_DVI_IMA_ADPCM;
-
+extern const char *MEDIA_MIMETYPE_AUDIO_DTS;
+extern const char *MEDIA_MIMETYPE_AUDIO_DTS_HD;
+extern const char *MEDIA_MIMETYPE_AUDIO_DTS_UHD;
+extern const char *MEDIA_MIMETYPE_AUDIO_EVRC;
+extern const char *MEDIA_MIMETYPE_AUDIO_EVRCB;
+extern const char *MEDIA_MIMETYPE_AUDIO_EVRCWB;
+extern const char *MEDIA_MIMETYPE_AUDIO_EVRCNW;
+extern const char *MEDIA_MIMETYPE_AUDIO_AMR_WB_PLUS;
+extern const char *MEDIA_MIMETYPE_AUDIO_APTX;
+extern const char *MEDIA_MIMETYPE_AUDIO_DRA;
+extern const char *MEDIA_MIMETYPE_AUDIO_AAC_FORMAT;
extern const char *MEDIA_MIMETYPE_CONTAINER_MPEG4;
extern const char *MEDIA_MIMETYPE_CONTAINER_WAV;
diff --git a/media/libstagefright/rtsp/MyTransmitter.h b/media/libstagefright/rtsp/MyTransmitter.h
deleted file mode 100644
index bf44aff..0000000
--- a/media/libstagefright/rtsp/MyTransmitter.h
+++ /dev/null
@@ -1,984 +0,0 @@
-/*
- * Copyright (C) 2010 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.
- */
-
-#ifndef MY_TRANSMITTER_H_
-
-#define MY_TRANSMITTER_H_
-
-#include "ARTPConnection.h"
-
-#include <arpa/inet.h>
-#include <sys/socket.h>
-
-#include <openssl/md5.h>
-
-#include <media/stagefright/foundation/ADebug.h>
-#include <media/stagefright/foundation/base64.h>
-#include <media/stagefright/foundation/hexdump.h>
-
-#ifdef ANDROID
-#include "VideoSource.h"
-#include <media/stagefright/foundation/ABuffer.h>
-#include <media/stagefright/foundation/ALooper.h>
-#include <media/stagefright/foundation/AMessage.h>
-#include <media/stagefright/MediaCodecSource.h>
-#endif
-
-namespace android {
-
-#define TRACK_SUFFIX "trackid=1"
-#define PT 96
-#define PT_STR "96"
-
-#define USERNAME "bcast"
-#define PASSWORD "test"
-
-static int uniformRand(int limit) {
- return ((double)rand() * limit) / RAND_MAX;
-}
-
-static bool GetAttribute(const char *s, const char *key, AString *value) {
- value->clear();
-
- size_t keyLen = strlen(key);
-
- for (;;) {
- const char *colonPos = strchr(s, ';');
-
- size_t len =
- (colonPos == NULL) ? strlen(s) : colonPos - s;
-
- if (len >= keyLen + 1 && s[keyLen] == '=' && !strncmp(s, key, keyLen)) {
- value->setTo(&s[keyLen + 1], len - keyLen - 1);
- return true;
- }
-
- if (colonPos == NULL) {
- return false;
- }
-
- s = colonPos + 1;
- }
-}
-
-struct MyTransmitter : public AHandler {
- MyTransmitter(const char *url, const sp<ALooper> &looper)
- : mServerURL(url),
- mLooper(looper),
- mConn(new ARTSPConnection),
- mConnected(false),
- mAuthType(NONE),
- mRTPSocket(-1),
- mRTCPSocket(-1),
- mSourceID(rand()),
- mSeqNo(uniformRand(65536)),
- mRTPTimeBase(rand()),
- mNumSamplesSent(0),
- mNumRTPSent(0),
- mNumRTPOctetsSent(0),
- mLastRTPTime(0),
- mLastNTPTime(0) {
- mStreamURL = mServerURL;
- mStreamURL.append("/bazong.sdp");
-
- mTrackURL = mStreamURL;
- mTrackURL.append("/");
- mTrackURL.append(TRACK_SUFFIX);
-
- mLooper->registerHandler(this);
- mLooper->registerHandler(mConn);
-
- sp<AMessage> reply = new AMessage('conn', this);
- mConn->connect(mServerURL.c_str(), reply);
-
-#ifdef ANDROID
- int width = 640;
- int height = 480;
-
- sp<MediaSource> source = new VideoSource(width, height);
-
- sp<AMessage> encMeta = new AMessage;
- encMeta->setString("mime", MEDIA_MIMETYPE_VIDEO_AVC);
- encMeta->setInt32("width", width);
- encMeta->setInt32("height", height);
- encMeta->setInt32("frame-rate", 30);
- encMeta->setInt32("bitrate", 256000);
- encMeta->setInt32("i-frame-interval", 10);
-
- sp<ALooper> encLooper = new ALooper;
- encLooper->setName("rtsp_transmitter");
- encLooper->start();
-
- mEncoder = MediaCodecSource::Create(encLooper, encMeta, source);
-
- mEncoder->start();
-
- MediaBuffer *buffer;
- CHECK_EQ(mEncoder->read(&buffer), (status_t)OK);
- CHECK(buffer != NULL);
-
- makeH264SPropParamSets(buffer);
-
- buffer->release();
- buffer = NULL;
-#endif
- }
-
- uint64_t ntpTime() {
- struct timeval tv;
- gettimeofday(&tv, NULL);
-
- uint64_t nowUs = tv.tv_sec * 1000000ll + tv.tv_usec;
-
- nowUs += ((70ll * 365 + 17) * 24) * 60 * 60 * 1000000ll;
-
- uint64_t hi = nowUs / 1000000ll;
- uint64_t lo = ((1ll << 32) * (nowUs % 1000000ll)) / 1000000ll;
-
- return (hi << 32) | lo;
- }
-
- void issueAnnounce() {
- AString sdp;
- sdp = "v=0\r\n";
-
- sdp.append("o=- ");
-
- uint64_t ntp = ntpTime();
- sdp.append(ntp);
- sdp.append(" ");
- sdp.append(ntp);
- sdp.append(" IN IP4 127.0.0.0\r\n");
-
- sdp.append(
- "s=Sample\r\n"
- "i=Playing around with ANNOUNCE\r\n"
- "c=IN IP4 ");
-
- struct in_addr addr;
- addr.s_addr = htonl(mServerIP);
-
- sdp.append(inet_ntoa(addr));
-
- sdp.append(
- "\r\n"
- "t=0 0\r\n"
- "a=range:npt=now-\r\n");
-
-#ifdef ANDROID
- sp<MetaData> meta = mEncoder->getFormat();
- int32_t width, height;
- CHECK(meta->findInt32(kKeyWidth, &width));
- CHECK(meta->findInt32(kKeyHeight, &height));
-
- sdp.append(
- "m=video 0 RTP/AVP " PT_STR "\r\n"
- "b=AS 320000\r\n"
- "a=rtpmap:" PT_STR " H264/90000\r\n");
-
- sdp.append("a=cliprect 0,0,");
- sdp.append(height);
- sdp.append(",");
- sdp.append(width);
- sdp.append("\r\n");
-
- sdp.append(
- "a=framesize:" PT_STR " ");
- sdp.append(width);
- sdp.append("-");
- sdp.append(height);
- sdp.append("\r\n");
-
- sdp.append(
- "a=fmtp:" PT_STR " profile-level-id=42C015;sprop-parameter-sets=");
-
- sdp.append(mSeqParamSet);
- sdp.append(",");
- sdp.append(mPicParamSet);
- sdp.append(";packetization-mode=1\r\n");
-#else
- sdp.append(
- "m=audio 0 RTP/AVP " PT_STR "\r\n"
- "a=rtpmap:" PT_STR " L8/8000/1\r\n");
-#endif
-
- sdp.append("a=control:" TRACK_SUFFIX "\r\n");
-
- AString request;
- request.append("ANNOUNCE ");
- request.append(mStreamURL);
- request.append(" RTSP/1.0\r\n");
-
- addAuthentication(&request, "ANNOUNCE", mStreamURL.c_str());
-
- request.append("Content-Type: application/sdp\r\n");
- request.append("Content-Length: ");
- request.append(sdp.size());
- request.append("\r\n");
-
- request.append("\r\n");
- request.append(sdp);
-
- sp<AMessage> reply = new AMessage('anno', this);
- mConn->sendRequest(request.c_str(), reply);
- }
-
- void H(const AString &s, AString *out) {
- out->clear();
-
- MD5_CTX m;
- MD5_Init(&m);
- MD5_Update(&m, s.c_str(), s.size());
-
- uint8_t key[16];
- MD5_Final(key, &m);
-
- for (size_t i = 0; i < 16; ++i) {
- char nibble = key[i] >> 4;
- if (nibble <= 9) {
- nibble += '0';
- } else {
- nibble += 'a' - 10;
- }
- out->append(&nibble, 1);
-
- nibble = key[i] & 0x0f;
- if (nibble <= 9) {
- nibble += '0';
- } else {
- nibble += 'a' - 10;
- }
- out->append(&nibble, 1);
- }
- }
-
- void authenticate(const sp<ARTSPResponse> &response) {
- ssize_t i = response->mHeaders.indexOfKey("www-authenticate");
- CHECK_GE(i, 0);
-
- AString value = response->mHeaders.valueAt(i);
-
- if (!strncmp(value.c_str(), "Basic", 5)) {
- mAuthType = BASIC;
- } else {
- CHECK(!strncmp(value.c_str(), "Digest", 6));
- mAuthType = DIGEST;
-
- i = value.find("nonce=");
- CHECK_GE(i, 0);
- CHECK_EQ(value.c_str()[i + 6], '\"');
- ssize_t j = value.find("\"", i + 7);
- CHECK_GE(j, 0);
-
- mNonce.setTo(value, i + 7, j - i - 7);
- }
-
- issueAnnounce();
- }
-
- void addAuthentication(
- AString *request, const char *method, const char *url) {
- if (mAuthType == NONE) {
- return;
- }
-
- if (mAuthType == BASIC) {
- request->append("Authorization: Basic YmNhc3Q6dGVzdAo=\r\n");
- return;
- }
-
- CHECK_EQ((int)mAuthType, (int)DIGEST);
-
- AString A1;
- A1.append(USERNAME);
- A1.append(":");
- A1.append("Streaming Server");
- A1.append(":");
- A1.append(PASSWORD);
-
- AString A2;
- A2.append(method);
- A2.append(":");
- A2.append(url);
-
- AString HA1, HA2;
- H(A1, &HA1);
- H(A2, &HA2);
-
- AString tmp;
- tmp.append(HA1);
- tmp.append(":");
- tmp.append(mNonce);
- tmp.append(":");
- tmp.append(HA2);
-
- AString digest;
- H(tmp, &digest);
-
- request->append("Authorization: Digest ");
- request->append("nonce=\"");
- request->append(mNonce);
- request->append("\", ");
- request->append("username=\"" USERNAME "\", ");
- request->append("uri=\"");
- request->append(url);
- request->append("\", ");
- request->append("response=\"");
- request->append(digest);
- request->append("\"");
- request->append("\r\n");
- }
-
- virtual void onMessageReceived(const sp<AMessage> &msg) {
- switch (msg->what()) {
- case 'conn':
- {
- int32_t result;
- CHECK(msg->findInt32("result", &result));
-
- LOG(INFO) << "connection request completed with result "
- << result << " (" << strerror(-result) << ")";
-
- if (result != OK) {
- (new AMessage('quit', this))->post();
- break;
- }
-
- mConnected = true;
-
- CHECK(msg->findInt32("server-ip", (int32_t *)&mServerIP));
-
- issueAnnounce();
- break;
- }
-
- case 'anno':
- {
- int32_t result;
- CHECK(msg->findInt32("result", &result));
-
- LOG(INFO) << "ANNOUNCE completed with result "
- << result << " (" << strerror(-result) << ")";
-
- sp<RefBase> obj;
- CHECK(msg->findObject("response", &obj));
- sp<ARTSPResponse> response;
-
- if (result == OK) {
- response = static_cast<ARTSPResponse *>(obj.get());
- CHECK(response != NULL);
-
- if (response->mStatusCode == 401) {
- if (mAuthType != NONE) {
- LOG(INFO) << "FAILED to authenticate";
- (new AMessage('quit', this))->post();
- break;
- }
-
- authenticate(response);
- break;
- }
- }
-
- if (result != OK || response->mStatusCode != 200) {
- (new AMessage('quit', this))->post();
- break;
- }
-
- unsigned rtpPort;
- ARTPConnection::MakePortPair(&mRTPSocket, &mRTCPSocket, &rtpPort);
-
- // (new AMessage('poll', this))->post();
-
- AString request;
- request.append("SETUP ");
- request.append(mTrackURL);
- request.append(" RTSP/1.0\r\n");
-
- addAuthentication(&request, "SETUP", mTrackURL.c_str());
-
- request.append("Transport: RTP/AVP;unicast;client_port=");
- request.append(rtpPort);
- request.append("-");
- request.append(rtpPort + 1);
- request.append(";mode=record\r\n");
- request.append("\r\n");
-
- sp<AMessage> reply = new AMessage('setu', this);
- mConn->sendRequest(request.c_str(), reply);
- break;
- }
-
-#if 0
- case 'poll':
- {
- fd_set rs;
- FD_ZERO(&rs);
- FD_SET(mRTCPSocket, &rs);
-
- struct timeval tv;
- tv.tv_sec = 0;
- tv.tv_usec = 0;
-
- int res = select(mRTCPSocket + 1, &rs, NULL, NULL, &tv);
-
- if (res == 1) {
- sp<ABuffer> buffer = new ABuffer(65536);
- ssize_t n = recv(mRTCPSocket, buffer->data(), buffer->size(), 0);
-
- if (n <= 0) {
- LOG(ERROR) << "recv returned " << n;
- } else {
- LOG(INFO) << "recv returned " << n << " bytes of data.";
-
- hexdump(buffer->data(), n);
- }
- }
-
- msg->post(50000);
- break;
- }
-#endif
-
- case 'setu':
- {
- int32_t result;
- CHECK(msg->findInt32("result", &result));
-
- LOG(INFO) << "SETUP completed with result "
- << result << " (" << strerror(-result) << ")";
-
- sp<RefBase> obj;
- CHECK(msg->findObject("response", &obj));
- sp<ARTSPResponse> response;
-
- if (result == OK) {
- response = static_cast<ARTSPResponse *>(obj.get());
- CHECK(response != NULL);
- }
-
- if (result != OK || response->mStatusCode != 200) {
- (new AMessage('quit', this))->post();
- break;
- }
-
- ssize_t i = response->mHeaders.indexOfKey("session");
- CHECK_GE(i, 0);
- mSessionID = response->mHeaders.valueAt(i);
- i = mSessionID.find(";");
- if (i >= 0) {
- // Remove options, i.e. ";timeout=90"
- mSessionID.erase(i, mSessionID.size() - i);
- }
-
- i = response->mHeaders.indexOfKey("transport");
- CHECK_GE(i, 0);
- AString transport = response->mHeaders.valueAt(i);
-
- LOG(INFO) << "transport = '" << transport << "'";
-
- AString value;
- CHECK(GetAttribute(transport.c_str(), "server_port", &value));
-
- unsigned rtpPort, rtcpPort;
- CHECK_EQ(sscanf(value.c_str(), "%u-%u", &rtpPort, &rtcpPort), 2);
-
- CHECK(GetAttribute(transport.c_str(), "source", &value));
-
- memset(mRemoteAddr.sin_zero, 0, sizeof(mRemoteAddr.sin_zero));
- mRemoteAddr.sin_family = AF_INET;
- mRemoteAddr.sin_addr.s_addr = inet_addr(value.c_str());
- mRemoteAddr.sin_port = htons(rtpPort);
-
- mRemoteRTCPAddr = mRemoteAddr;
- mRemoteRTCPAddr.sin_port = htons(rtpPort + 1);
-
- CHECK_EQ(0, connect(mRTPSocket,
- (const struct sockaddr *)&mRemoteAddr,
- sizeof(mRemoteAddr)));
-
- CHECK_EQ(0, connect(mRTCPSocket,
- (const struct sockaddr *)&mRemoteRTCPAddr,
- sizeof(mRemoteRTCPAddr)));
-
- uint32_t x = ntohl(mRemoteAddr.sin_addr.s_addr);
- LOG(INFO) << "sending data to "
- << (x >> 24)
- << "."
- << ((x >> 16) & 0xff)
- << "."
- << ((x >> 8) & 0xff)
- << "."
- << (x & 0xff)
- << ":"
- << rtpPort;
-
- AString request;
- request.append("RECORD ");
- request.append(mStreamURL);
- request.append(" RTSP/1.0\r\n");
-
- addAuthentication(&request, "RECORD", mStreamURL.c_str());
-
- request.append("Session: ");
- request.append(mSessionID);
- request.append("\r\n");
- request.append("\r\n");
-
- sp<AMessage> reply = new AMessage('reco', this);
- mConn->sendRequest(request.c_str(), reply);
- break;
- }
-
- case 'reco':
- {
- int32_t result;
- CHECK(msg->findInt32("result", &result));
-
- LOG(INFO) << "RECORD completed with result "
- << result << " (" << strerror(-result) << ")";
-
- sp<RefBase> obj;
- CHECK(msg->findObject("response", &obj));
- sp<ARTSPResponse> response;
-
- if (result == OK) {
- response = static_cast<ARTSPResponse *>(obj.get());
- CHECK(response != NULL);
- }
-
- if (result != OK) {
- (new AMessage('quit', this))->post();
- break;
- }
-
- (new AMessage('more', this))->post();
- (new AMessage('sr ', this))->post();
- (new AMessage('aliv', this))->post(30000000ll);
- break;
- }
-
- case 'aliv':
- {
- if (!mConnected) {
- break;
- }
-
- AString request;
- request.append("OPTIONS ");
- request.append(mStreamURL);
- request.append(" RTSP/1.0\r\n");
-
- addAuthentication(&request, "RECORD", mStreamURL.c_str());
-
- request.append("Session: ");
- request.append(mSessionID);
- request.append("\r\n");
- request.append("\r\n");
-
- sp<AMessage> reply = new AMessage('opts', this);
- mConn->sendRequest(request.c_str(), reply);
- break;
- }
-
- case 'opts':
- {
- int32_t result;
- CHECK(msg->findInt32("result", &result));
-
- LOG(INFO) << "OPTIONS completed with result "
- << result << " (" << strerror(-result) << ")";
-
- if (!mConnected) {
- break;
- }
-
- (new AMessage('aliv', this))->post(30000000ll);
- break;
- }
-
- case 'more':
- {
- if (!mConnected) {
- break;
- }
-
- sp<ABuffer> buffer = new ABuffer(65536);
- uint8_t *data = buffer->data();
- data[0] = 0x80;
- data[1] = (1 << 7) | PT; // M-bit
- data[2] = (mSeqNo >> 8) & 0xff;
- data[3] = mSeqNo & 0xff;
- data[8] = mSourceID >> 24;
- data[9] = (mSourceID >> 16) & 0xff;
- data[10] = (mSourceID >> 8) & 0xff;
- data[11] = mSourceID & 0xff;
-
-#ifdef ANDROID
- MediaBuffer *mediaBuf = NULL;
- for (;;) {
- CHECK_EQ(mEncoder->read(&mediaBuf), (status_t)OK);
- if (mediaBuf->range_length() > 0) {
- break;
- }
- mediaBuf->release();
- mediaBuf = NULL;
- }
-
- int64_t timeUs;
- CHECK(mediaBuf->meta_data()->findInt64(kKeyTime, &timeUs));
-
- uint32_t rtpTime = mRTPTimeBase + (timeUs * 9 / 100ll);
-
- const uint8_t *mediaData =
- (const uint8_t *)mediaBuf->data() + mediaBuf->range_offset();
-
- CHECK(!memcmp("\x00\x00\x00\x01", mediaData, 4));
-
- CHECK_LE(mediaBuf->range_length() - 4 + 12, buffer->size());
-
- memcpy(&data[12],
- mediaData + 4, mediaBuf->range_length() - 4);
-
- buffer->setRange(0, mediaBuf->range_length() - 4 + 12);
-
- mediaBuf->release();
- mediaBuf = NULL;
-#else
- uint32_t rtpTime = mRTPTimeBase + mNumRTPSent * 128;
- memset(&data[12], 0, 128);
- buffer->setRange(0, 12 + 128);
-#endif
-
- data[4] = rtpTime >> 24;
- data[5] = (rtpTime >> 16) & 0xff;
- data[6] = (rtpTime >> 8) & 0xff;
- data[7] = rtpTime & 0xff;
-
- ssize_t n = send(
- mRTPSocket, data, buffer->size(), 0);
- if (n < 0) {
- LOG(ERROR) << "send failed (" << strerror(errno) << ")";
- }
- CHECK_EQ(n, (ssize_t)buffer->size());
-
- ++mSeqNo;
-
- ++mNumRTPSent;
- mNumRTPOctetsSent += buffer->size() - 12;
-
- mLastRTPTime = rtpTime;
- mLastNTPTime = ntpTime();
-
-#ifdef ANDROID
- if (mNumRTPSent < 60 * 25) { // 60 secs worth
- msg->post(40000);
-#else
- if (mNumRTPOctetsSent < 8000 * 60) {
- msg->post(1000000ll * 128 / 8000);
-#endif
- } else {
- LOG(INFO) << "That's enough, pausing.";
-
- AString request;
- request.append("PAUSE ");
- request.append(mStreamURL);
- request.append(" RTSP/1.0\r\n");
-
- addAuthentication(&request, "PAUSE", mStreamURL.c_str());
-
- request.append("Session: ");
- request.append(mSessionID);
- request.append("\r\n");
- request.append("\r\n");
-
- sp<AMessage> reply = new AMessage('paus', this);
- mConn->sendRequest(request.c_str(), reply);
- }
- break;
- }
-
- case 'sr ':
- {
- if (!mConnected) {
- break;
- }
-
- sp<ABuffer> buffer = new ABuffer(65536);
- buffer->setRange(0, 0);
-
- addSR(buffer);
- addSDES(buffer);
-
- uint8_t *data = buffer->data();
- ssize_t n = send(
- mRTCPSocket, data, buffer->size(), 0);
- CHECK_EQ(n, (ssize_t)buffer->size());
-
- msg->post(3000000);
- break;
- }
-
- case 'paus':
- {
- int32_t result;
- CHECK(msg->findInt32("result", &result));
-
- LOG(INFO) << "PAUSE completed with result "
- << result << " (" << strerror(-result) << ")";
-
- sp<RefBase> obj;
- CHECK(msg->findObject("response", &obj));
- sp<ARTSPResponse> response;
-
- AString request;
- request.append("TEARDOWN ");
- request.append(mStreamURL);
- request.append(" RTSP/1.0\r\n");
-
- addAuthentication(&request, "TEARDOWN", mStreamURL.c_str());
-
- request.append("Session: ");
- request.append(mSessionID);
- request.append("\r\n");
- request.append("\r\n");
-
- sp<AMessage> reply = new AMessage('tear', this);
- mConn->sendRequest(request.c_str(), reply);
- break;
- }
-
- case 'tear':
- {
- int32_t result;
- CHECK(msg->findInt32("result", &result));
-
- LOG(INFO) << "TEARDOWN completed with result "
- << result << " (" << strerror(-result) << ")";
-
- sp<RefBase> obj;
- CHECK(msg->findObject("response", &obj));
- sp<ARTSPResponse> response;
-
- if (result == OK) {
- response = static_cast<ARTSPResponse *>(obj.get());
- CHECK(response != NULL);
- }
-
- (new AMessage('quit', this))->post();
- break;
- }
-
- case 'disc':
- {
- LOG(INFO) << "disconnect completed";
-
- mConnected = false;
- (new AMessage('quit', this))->post();
- break;
- }
-
- case 'quit':
- {
- if (mConnected) {
- mConn->disconnect(new AMessage('disc', this));
- break;
- }
-
- if (mRTPSocket >= 0) {
- close(mRTPSocket);
- mRTPSocket = -1;
- }
-
- if (mRTCPSocket >= 0) {
- close(mRTCPSocket);
- mRTCPSocket = -1;
- }
-
-#ifdef ANDROID
- mEncoder->stop();
- mEncoder.clear();
-#endif
-
- mLooper->stop();
- break;
- }
-
- default:
- TRESPASS();
- }
- }
-
-protected:
- virtual ~MyTransmitter() {
- }
-
-private:
- enum AuthType {
- NONE,
- BASIC,
- DIGEST
- };
-
- AString mServerURL;
- AString mTrackURL;
- AString mStreamURL;
-
- sp<ALooper> mLooper;
- sp<ARTSPConnection> mConn;
- bool mConnected;
- uint32_t mServerIP;
- AuthType mAuthType;
- AString mNonce;
- AString mSessionID;
- int mRTPSocket, mRTCPSocket;
- uint32_t mSourceID;
- uint32_t mSeqNo;
- uint32_t mRTPTimeBase;
- struct sockaddr_in mRemoteAddr;
- struct sockaddr_in mRemoteRTCPAddr;
- size_t mNumSamplesSent;
- uint32_t mNumRTPSent;
- uint32_t mNumRTPOctetsSent;
- uint32_t mLastRTPTime;
- uint64_t mLastNTPTime;
-
-#ifdef ANDROID
- sp<MediaSource> mEncoder;
- AString mSeqParamSet;
- AString mPicParamSet;
-
- void makeH264SPropParamSets(MediaBuffer *buffer) {
- static const char kStartCode[] = "\x00\x00\x00\x01";
-
- const uint8_t *data =
- (const uint8_t *)buffer->data() + buffer->range_offset();
- size_t size = buffer->range_length();
-
- CHECK_GE(size, 0u);
- CHECK(!memcmp(kStartCode, data, 4));
-
- data += 4;
- size -= 4;
-
- size_t startCodePos = 0;
- while (startCodePos + 3 < size
- && memcmp(kStartCode, &data[startCodePos], 4)) {
- ++startCodePos;
- }
-
- CHECK_LT(startCodePos + 3, size);
-
- encodeBase64(data, startCodePos, &mSeqParamSet);
-
- encodeBase64(&data[startCodePos + 4], size - startCodePos - 4,
- &mPicParamSet);
- }
-#endif
-
- void addSR(const sp<ABuffer> &buffer) {
- uint8_t *data = buffer->data() + buffer->size();
-
- data[0] = 0x80 | 0;
- data[1] = 200; // SR
- data[2] = 0;
- data[3] = 6;
- data[4] = mSourceID >> 24;
- data[5] = (mSourceID >> 16) & 0xff;
- data[6] = (mSourceID >> 8) & 0xff;
- data[7] = mSourceID & 0xff;
-
- data[8] = mLastNTPTime >> (64 - 8);
- data[9] = (mLastNTPTime >> (64 - 16)) & 0xff;
- data[10] = (mLastNTPTime >> (64 - 24)) & 0xff;
- data[11] = (mLastNTPTime >> 32) & 0xff;
- data[12] = (mLastNTPTime >> 24) & 0xff;
- data[13] = (mLastNTPTime >> 16) & 0xff;
- data[14] = (mLastNTPTime >> 8) & 0xff;
- data[15] = mLastNTPTime & 0xff;
-
- data[16] = (mLastRTPTime >> 24) & 0xff;
- data[17] = (mLastRTPTime >> 16) & 0xff;
- data[18] = (mLastRTPTime >> 8) & 0xff;
- data[19] = mLastRTPTime & 0xff;
-
- data[20] = mNumRTPSent >> 24;
- data[21] = (mNumRTPSent >> 16) & 0xff;
- data[22] = (mNumRTPSent >> 8) & 0xff;
- data[23] = mNumRTPSent & 0xff;
-
- data[24] = mNumRTPOctetsSent >> 24;
- data[25] = (mNumRTPOctetsSent >> 16) & 0xff;
- data[26] = (mNumRTPOctetsSent >> 8) & 0xff;
- data[27] = mNumRTPOctetsSent & 0xff;
-
- buffer->setRange(buffer->offset(), buffer->size() + 28);
- }
-
- void addSDES(const sp<ABuffer> &buffer) {
- uint8_t *data = buffer->data() + buffer->size();
- data[0] = 0x80 | 1;
- data[1] = 202; // SDES
- data[4] = mSourceID >> 24;
- data[5] = (mSourceID >> 16) & 0xff;
- data[6] = (mSourceID >> 8) & 0xff;
- data[7] = mSourceID & 0xff;
-
- size_t offset = 8;
-
- data[offset++] = 1; // CNAME
-
- static const char *kCNAME = "andih@laptop";
- data[offset++] = strlen(kCNAME);
-
- memcpy(&data[offset], kCNAME, strlen(kCNAME));
- offset += strlen(kCNAME);
-
- data[offset++] = 7; // NOTE
-
- static const char *kNOTE = "Hell's frozen over.";
- data[offset++] = strlen(kNOTE);
-
- memcpy(&data[offset], kNOTE, strlen(kNOTE));
- offset += strlen(kNOTE);
-
- data[offset++] = 0;
-
- if ((offset % 4) > 0) {
- size_t count = 4 - (offset % 4);
- switch (count) {
- case 3:
- data[offset++] = 0;
- case 2:
- data[offset++] = 0;
- case 1:
- data[offset++] = 0;
- }
- }
-
- size_t numWords = (offset / 4) - 1;
- data[2] = numWords >> 8;
- data[3] = numWords & 0xff;
-
- buffer->setRange(buffer->offset(), buffer->size() + offset);
- }
-
- DISALLOW_EVIL_CONSTRUCTORS(MyTransmitter);
-};
-
-} // namespace android
-
-#endif // MY_TRANSMITTER_H_
diff --git a/media/utils/fuzzers/ServiceUtilitiesFuzz.cpp b/media/utils/fuzzers/ServiceUtilitiesFuzz.cpp
index 6e52512..51e8d7a 100644
--- a/media/utils/fuzzers/ServiceUtilitiesFuzz.cpp
+++ b/media/utils/fuzzers/ServiceUtilitiesFuzz.cpp
@@ -17,7 +17,7 @@
#include <fcntl.h>
#include <functional>
-#include <type_traits>
+#include <type_traits>
#include <android/content/AttributionSourceState.h>
#include "fuzzer/FuzzedDataProvider.h"
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index 51d775d..8a32b72 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -1874,13 +1874,13 @@
}
}
-void AudioFlinger::ioConfigChanged(audio_io_config_event event,
+void AudioFlinger::ioConfigChanged(audio_io_config_event_t event,
const sp<AudioIoDescriptor>& ioDesc,
pid_t pid) {
+ media::AudioIoConfigEvent eventAidl = VALUE_OR_FATAL(
+ legacy2aidl_audio_io_config_event_t_AudioIoConfigEvent(event));
media::AudioIoDescriptor descAidl = VALUE_OR_FATAL(
legacy2aidl_AudioIoDescriptor_AudioIoDescriptor(ioDesc));
- media::AudioIoConfigEvent eventAidl = VALUE_OR_FATAL(
- legacy2aidl_audio_io_config_event_AudioIoConfigEvent(event));
Mutex::Autolock _l(mClientLock);
size_t size = mNotificationClients.size();
@@ -2143,6 +2143,20 @@
goto Exit;
}
+ if (recordTrack->isFastTrack()) {
+ output.serverConfig = {
+ thread->sampleRate(),
+ thread->channelMask(),
+ thread->format()
+ };
+ } else {
+ output.serverConfig = {
+ recordTrack->sampleRate(),
+ recordTrack->channelMask(),
+ recordTrack->format()
+ };
+ }
+
// Check if one effect chain was awaiting for an AudioRecord to be created on this
// session and move it to this thread.
sp<EffectChain> chain = getOrphanEffectChain_l(sessionId);
@@ -2611,9 +2625,9 @@
audio_module_handle_t module = VALUE_OR_RETURN_STATUS(
aidl2legacy_int32_t_audio_module_handle_t(request.module));
audio_config_t halConfig = VALUE_OR_RETURN_STATUS(
- aidl2legacy_AudioConfig_audio_config_t(request.halConfig));
+ aidl2legacy_AudioConfig_audio_config_t(request.halConfig, false /*isInput*/));
audio_config_base_t mixerConfig = VALUE_OR_RETURN_STATUS(
- aidl2legacy_AudioConfigBase_audio_config_base_t(request.mixerConfig));
+ aidl2legacy_AudioConfigBase_audio_config_base_t(request.mixerConfig, false/*isInput*/));
sp<DeviceDescriptorBase> device = VALUE_OR_RETURN_STATUS(
aidl2legacy_DeviceDescriptorBase(request.device));
audio_output_flags_t flags = VALUE_OR_RETURN_STATUS(
@@ -2666,8 +2680,8 @@
mmapThread->ioConfigChanged(AUDIO_OUTPUT_OPENED);
}
response->output = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_io_handle_t_int32_t(output));
- response->config =
- VALUE_OR_RETURN_STATUS(legacy2aidl_audio_config_t_AudioConfig(halConfig));
+ response->config = VALUE_OR_RETURN_STATUS(
+ legacy2aidl_audio_config_t_AudioConfig(halConfig, false /*isInput*/));
response->latencyMs = VALUE_OR_RETURN_STATUS(convertIntegral<int32_t>(latencyMs));
response->flags = VALUE_OR_RETURN_STATUS(
legacy2aidl_audio_output_flags_t_int32_t_mask(flags));
@@ -2753,9 +2767,7 @@
mMmapThreads.removeItem(output);
ALOGD("closing mmapThread %p", mmapThread.get());
}
- const sp<AudioIoDescriptor> ioDesc = new AudioIoDescriptor();
- ioDesc->mIoHandle = output;
- ioConfigChanged(AUDIO_OUTPUT_CLOSED, ioDesc);
+ ioConfigChanged(AUDIO_OUTPUT_CLOSED, sp<AudioIoDescriptor>::make(output));
mPatchPanel.notifyStreamClosed(output);
}
// The thread entity (active unit of execution) is no longer running here,
@@ -2828,16 +2840,16 @@
{
Mutex::Autolock _l(mLock);
- if (request.device.type == AUDIO_DEVICE_NONE) {
+ AudioDeviceTypeAddr device = VALUE_OR_RETURN_STATUS(
+ aidl2legacy_AudioDeviceTypeAddress(request.device));
+ if (device.mType == AUDIO_DEVICE_NONE) {
return BAD_VALUE;
}
audio_io_handle_t input = VALUE_OR_RETURN_STATUS(
aidl2legacy_int32_t_audio_io_handle_t(request.input));
audio_config_t config = VALUE_OR_RETURN_STATUS(
- aidl2legacy_AudioConfig_audio_config_t(request.config));
- AudioDeviceTypeAddr device = VALUE_OR_RETURN_STATUS(
- aidl2legacy_AudioDeviceTypeAddress(request.device));
+ aidl2legacy_AudioConfig_audio_config_t(request.config, true /*isInput*/));
sp<ThreadBase> thread = openInput_l(
VALUE_OR_RETURN_STATUS(aidl2legacy_int32_t_audio_module_handle_t(request.module)),
@@ -2851,7 +2863,8 @@
String8{});
response->input = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_io_handle_t_int32_t(input));
- response->config = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_config_t_AudioConfig(config));
+ response->config = VALUE_OR_RETURN_STATUS(
+ legacy2aidl_audio_config_t_AudioConfig(config, true /*isInput*/));
response->device = request.device;
if (thread != 0) {
@@ -3013,9 +3026,7 @@
dumpToThreadLog_l(mmapThread);
mMmapThreads.removeItem(input);
}
- const sp<AudioIoDescriptor> ioDesc = new AudioIoDescriptor();
- ioDesc->mIoHandle = input;
- ioConfigChanged(AUDIO_INPUT_CLOSED, ioDesc);
+ ioConfigChanged(AUDIO_INPUT_CLOSED, sp<AudioIoDescriptor>::make(input));
}
// FIXME: calling thread->exit() without mLock held should not be needed anymore now that
// we have a different lock for notification client
diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h
index 8fcd6e4..d6bf0ae 100644
--- a/services/audioflinger/AudioFlinger.h
+++ b/services/audioflinger/AudioFlinger.h
@@ -750,7 +750,7 @@
// no range check, AudioFlinger::mLock held
bool streamMute_l(audio_stream_type_t stream) const
{ return mStreamTypes[stream].mute; }
- void ioConfigChanged(audio_io_config_event event,
+ void ioConfigChanged(audio_io_config_event_t event,
const sp<AudioIoDescriptor>& ioDesc,
pid_t pid = 0);
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index 1d9f82c..4474cd1 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -626,7 +626,7 @@
return status;
}
-void AudioFlinger::ThreadBase::sendIoConfigEvent(audio_io_config_event event, pid_t pid,
+void AudioFlinger::ThreadBase::sendIoConfigEvent(audio_io_config_event_t event, pid_t pid,
audio_port_handle_t portId)
{
Mutex::Autolock _l(mLock);
@@ -634,7 +634,7 @@
}
// sendIoConfigEvent_l() must be called with ThreadBase::mLock held
-void AudioFlinger::ThreadBase::sendIoConfigEvent_l(audio_io_config_event event, pid_t pid,
+void AudioFlinger::ThreadBase::sendIoConfigEvent_l(audio_io_config_event_t event, pid_t pid,
audio_port_handle_t portId)
{
// The audio statistics history is exponentially weighted to forget events
@@ -644,6 +644,7 @@
mIoJitterMs.reset();
mLatencyMs.reset();
mProcessTimeMs.reset();
+ mMonopipePipeDepthStats.reset();
mTimestampVerifier.discontinuity(mTimestampVerifier.DISCONTINUITY_MODE_CONTINUOUS);
sp<ConfigEvent> configEvent = (ConfigEvent *)new IoConfigEvent(event, pid, portId);
@@ -988,6 +989,12 @@
isOutput() ? "write" : "read",
mLatencyMs.toString().c_str());
}
+
+ if (mMonopipePipeDepthStats.getN() > 0) {
+ dprintf(fd, " Monopipe %s pipe depth stats: %s\n",
+ isOutput() ? "write" : "read",
+ mMonopipePipeDepthStats.toString().c_str());
+ }
}
void AudioFlinger::ThreadBase::dumpEffectChains_l(int fd, const Vector<String16>& args)
@@ -1918,6 +1925,12 @@
item->setDouble(MM_PREFIX "latencyMs.mean", mLatencyMs.getMean());
item->setDouble(MM_PREFIX "latencyMs.std", mLatencyMs.getStdDev());
}
+ if (mMonopipePipeDepthStats.getN() > 0) {
+ item->setDouble(MM_PREFIX "monopipePipeDepthStats.mean",
+ mMonopipePipeDepthStats.getMean());
+ item->setDouble(MM_PREFIX "monopipePipeDepthStats.std",
+ mMonopipePipeDepthStats.getStdDev());
+ }
item->selfrecord();
}
@@ -2274,7 +2287,7 @@
"AUDIO_OUTPUT_FLAG_FAST accepted: frameCount=%zu mFrameCount=%zu",
frameCount, mFrameCount);
} else {
- ALOGV("AUDIO_OUTPUT_FLAG_FAST denied: sharedBuffer=%p frameCount=%zu "
+ ALOGD("AUDIO_OUTPUT_FLAG_FAST denied: sharedBuffer=%p frameCount=%zu "
"mFrameCount=%zu format=%#x mFormat=%#x isLinear=%d channelMask=%#x "
"sampleRate=%u mSampleRate=%u "
"hasFastMixer=%d tid=%d fastTrackAvailMask=%#x",
@@ -2773,36 +2786,26 @@
return mOutput->stream->selectPresentation(presentationId, programId);
}
-void AudioFlinger::PlaybackThread::ioConfigChanged(audio_io_config_event event, pid_t pid,
+void AudioFlinger::PlaybackThread::ioConfigChanged(audio_io_config_event_t event, pid_t pid,
audio_port_handle_t portId) {
- sp<AudioIoDescriptor> desc = new AudioIoDescriptor();
ALOGV("PlaybackThread::ioConfigChanged, thread %p, event %d", this, event);
-
- desc->mIoHandle = mId;
- struct audio_patch patch = mPatch;
- if (isMsdDevice()) {
- patch = mDownStreamPatch;
- }
-
+ sp<AudioIoDescriptor> desc;
+ const struct audio_patch patch = isMsdDevice() ? mDownStreamPatch : mPatch;
switch (event) {
case AUDIO_OUTPUT_OPENED:
case AUDIO_OUTPUT_REGISTERED:
case AUDIO_OUTPUT_CONFIG_CHANGED:
- desc->mPatch = patch;
- desc->mChannelMask = mChannelMask;
- desc->mSamplingRate = mSampleRate;
- desc->mFormat = mFormat;
- desc->mFrameCount = mNormalFrameCount; // FIXME see
- // AudioFlinger::frameCount(audio_io_handle_t)
- desc->mFrameCountHAL = mFrameCount;
- desc->mLatency = latency_l();
+ desc = sp<AudioIoDescriptor>::make(mId, patch, false /*isInput*/,
+ mSampleRate, mFormat, mChannelMask,
+ // FIXME AudioFlinger::frameCount(audio_io_handle_t) instead of mNormalFrameCount?
+ mNormalFrameCount, mFrameCount, latency_l());
break;
case AUDIO_CLIENT_STARTED:
- desc->mPatch = patch;
- desc->mPortId = portId;
+ desc = sp<AudioIoDescriptor>::make(mId, patch, portId);
break;
case AUDIO_OUTPUT_CLOSED:
default:
+ desc = sp<AudioIoDescriptor>::make(mId);
break;
}
mAudioFlinger->ioConfigChanged(event, desc, pid);
@@ -3983,6 +3986,18 @@
Mutex::Autolock _l(mLock);
mIoJitterMs.add(jitterMs);
mProcessTimeMs.add(processMs);
+
+ if (mPipeSink.get() != nullptr) {
+ // Using the Monopipe availableToWrite, we estimate the current
+ // buffer size.
+ MonoPipe* monoPipe = static_cast<MonoPipe*>(mPipeSink.get());
+ const ssize_t
+ availableToWrite = mPipeSink->availableToWrite();
+ const size_t pipeFrames = monoPipe->maxFrames();
+ const size_t
+ remainingFrames = pipeFrames - max(availableToWrite, 0);
+ mMonopipePipeDepthStats.add(remainingFrames);
+ }
}
// write blocked detection
@@ -4580,12 +4595,7 @@
break;
case FastMixer_Static:
case FastMixer_Dynamic:
- // FastMixer was designed to operate with a HAL that pulls at a regular rate,
- // where the period is less than an experimentally determined threshold that can be
- // scheduled reliably with CFS. However, the BT A2DP HAL is
- // bursty (does not pull at a regular rate) and so cannot operate with FastMixer.
- initFastMixer = mFrameCount < mNormalFrameCount
- && Intersection(outDeviceTypes(), getAudioDeviceOutAllA2dpSet()).empty();
+ initFastMixer = mFrameCount < mNormalFrameCount;
break;
}
ALOGW_IF(initFastMixer == false && mFrameCount < mNormalFrameCount,
@@ -7599,6 +7609,7 @@
const ssize_t availableToRead = mPipeSource->availableToRead();
if (availableToRead >= 0) {
+ mMonopipePipeDepthStats.add(availableToRead);
// PipeSource is the primary clock. It is up to the AudioRecord client to keep up.
LOG_ALWAYS_FATAL_IF((size_t)availableToRead > mPipeFramesP2,
"more frames to read than fifo size, %zd > %zu",
@@ -8027,6 +8038,7 @@
if (
// we formerly checked for a callback handler (non-0 tid),
// but that is no longer required for TRANSFER_OBTAIN mode
+ // No need to match hardware format, format conversion will be done in client side.
//
// Frame count is not specified (0), or is less than or equal the pipe depth.
// It is OK to provide a higher capacity than requested.
@@ -8034,8 +8046,6 @@
(frameCount <= mPipeFramesP2) &&
// PCM data
audio_is_linear_pcm(format) &&
- // hardware format
- (format == mFormat) &&
// hardware channel mask
(channelMask == mChannelMask) &&
// hardware sample rate
@@ -8785,30 +8795,22 @@
return String8();
}
-void AudioFlinger::RecordThread::ioConfigChanged(audio_io_config_event event, pid_t pid,
+void AudioFlinger::RecordThread::ioConfigChanged(audio_io_config_event_t event, pid_t pid,
audio_port_handle_t portId) {
- sp<AudioIoDescriptor> desc = new AudioIoDescriptor();
-
- desc->mIoHandle = mId;
-
+ sp<AudioIoDescriptor> desc;
switch (event) {
case AUDIO_INPUT_OPENED:
case AUDIO_INPUT_REGISTERED:
case AUDIO_INPUT_CONFIG_CHANGED:
- desc->mPatch = mPatch;
- desc->mChannelMask = mChannelMask;
- desc->mSamplingRate = mSampleRate;
- desc->mFormat = mFormat;
- desc->mFrameCount = mFrameCount;
- desc->mFrameCountHAL = mFrameCount;
- desc->mLatency = 0;
+ desc = sp<AudioIoDescriptor>::make(mId, mPatch, true /*isInput*/,
+ mSampleRate, mFormat, mChannelMask, mFrameCount, mFrameCount);
break;
case AUDIO_CLIENT_STARTED:
- desc->mPatch = mPatch;
- desc->mPortId = portId;
+ desc = sp<AudioIoDescriptor>::make(mId, mPatch, portId);
break;
case AUDIO_INPUT_CLOSED:
default:
+ desc = sp<AudioIoDescriptor>::make(mId);
break;
}
mAudioFlinger->ioConfigChanged(event, desc, pid);
@@ -9651,31 +9653,26 @@
return String8();
}
-void AudioFlinger::MmapThread::ioConfigChanged(audio_io_config_event event, pid_t pid,
+void AudioFlinger::MmapThread::ioConfigChanged(audio_io_config_event_t event, pid_t pid,
audio_port_handle_t portId __unused) {
- sp<AudioIoDescriptor> desc = new AudioIoDescriptor();
-
- desc->mIoHandle = mId;
-
+ sp<AudioIoDescriptor> desc;
+ bool isInput = false;
switch (event) {
case AUDIO_INPUT_OPENED:
case AUDIO_INPUT_REGISTERED:
case AUDIO_INPUT_CONFIG_CHANGED:
+ isInput = true;
+ FALLTHROUGH_INTENDED;
case AUDIO_OUTPUT_OPENED:
case AUDIO_OUTPUT_REGISTERED:
case AUDIO_OUTPUT_CONFIG_CHANGED:
- desc->mPatch = mPatch;
- desc->mChannelMask = mChannelMask;
- desc->mSamplingRate = mSampleRate;
- desc->mFormat = mFormat;
- desc->mFrameCount = mFrameCount;
- desc->mFrameCountHAL = mFrameCount;
- desc->mLatency = 0;
+ desc = sp<AudioIoDescriptor>::make(mId, mPatch, isInput,
+ mSampleRate, mFormat, mChannelMask, mFrameCount, mFrameCount);
break;
-
case AUDIO_INPUT_CLOSED:
case AUDIO_OUTPUT_CLOSED:
default:
+ desc = sp<AudioIoDescriptor>::make(mId);
break;
}
mAudioFlinger->ioConfigChanged(event, desc, pid);
diff --git a/services/audioflinger/Threads.h b/services/audioflinger/Threads.h
index 33a83e1..f14cdc0 100644
--- a/services/audioflinger/Threads.h
+++ b/services/audioflinger/Threads.h
@@ -113,7 +113,7 @@
class IoConfigEventData : public ConfigEventData {
public:
- IoConfigEventData(audio_io_config_event event, pid_t pid,
+ IoConfigEventData(audio_io_config_event_t event, pid_t pid,
audio_port_handle_t portId) :
mEvent(event), mPid(pid), mPortId(portId) {}
@@ -121,14 +121,14 @@
snprintf(buffer, size, "- IO event: event %d\n", mEvent);
}
- const audio_io_config_event mEvent;
+ const audio_io_config_event_t mEvent;
const pid_t mPid;
const audio_port_handle_t mPortId;
};
class IoConfigEvent : public ConfigEvent {
public:
- IoConfigEvent(audio_io_config_event event, pid_t pid, audio_port_handle_t portId) :
+ IoConfigEvent(audio_io_config_event_t event, pid_t pid, audio_port_handle_t portId) :
ConfigEvent(CFG_EVENT_IO) {
mData = new IoConfigEventData(event, pid, portId);
}
@@ -332,15 +332,15 @@
status_t& status) = 0;
virtual status_t setParameters(const String8& keyValuePairs);
virtual String8 getParameters(const String8& keys) = 0;
- virtual void ioConfigChanged(audio_io_config_event event, pid_t pid = 0,
+ virtual void ioConfigChanged(audio_io_config_event_t event, pid_t pid = 0,
audio_port_handle_t portId = AUDIO_PORT_HANDLE_NONE) = 0;
// sendConfigEvent_l() must be called with ThreadBase::mLock held
// Can temporarily release the lock if waiting for a reply from
// processConfigEvents_l().
status_t sendConfigEvent_l(sp<ConfigEvent>& event);
- void sendIoConfigEvent(audio_io_config_event event, pid_t pid = 0,
+ void sendIoConfigEvent(audio_io_config_event_t event, pid_t pid = 0,
audio_port_handle_t portId = AUDIO_PORT_HANDLE_NONE);
- void sendIoConfigEvent_l(audio_io_config_event event, pid_t pid = 0,
+ void sendIoConfigEvent_l(audio_io_config_event_t event, pid_t pid = 0,
audio_port_handle_t portId = AUDIO_PORT_HANDLE_NONE);
void sendPrioConfigEvent(pid_t pid, pid_t tid, int32_t prio, bool forApp);
void sendPrioConfigEvent_l(pid_t pid, pid_t tid, int32_t prio, bool forApp);
@@ -685,6 +685,7 @@
audio_utils::Statistics<double> mIoJitterMs{0.995 /* alpha */};
audio_utils::Statistics<double> mProcessTimeMs{0.995 /* alpha */};
audio_utils::Statistics<double> mLatencyMs{0.995 /* alpha */};
+ audio_utils::Statistics<double> mMonopipePipeDepthStats{0.999 /* alpha */};
// Save the last count when we delivered statistics to mediametrics.
int64_t mLastRecordedTimestampVerifierN = 0;
@@ -973,7 +974,7 @@
{ return android_atomic_acquire_load(&mSuspended) > 0; }
virtual String8 getParameters(const String8& keys);
- virtual void ioConfigChanged(audio_io_config_event event, pid_t pid = 0,
+ virtual void ioConfigChanged(audio_io_config_event_t event, pid_t pid = 0,
audio_port_handle_t portId = AUDIO_PORT_HANDLE_NONE);
status_t getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames);
// Consider also removing and passing an explicit mMainBuffer initialization
@@ -1786,7 +1787,7 @@
status_t& status);
virtual void cacheParameters_l() {}
virtual String8 getParameters(const String8& keys);
- virtual void ioConfigChanged(audio_io_config_event event, pid_t pid = 0,
+ virtual void ioConfigChanged(audio_io_config_event_t event, pid_t pid = 0,
audio_port_handle_t portId = AUDIO_PORT_HANDLE_NONE);
virtual status_t createAudioPatch_l(const struct audio_patch *patch,
audio_patch_handle_t *handle);
@@ -1995,7 +1996,7 @@
virtual bool checkForNewParameter_l(const String8& keyValuePair,
status_t& status);
virtual String8 getParameters(const String8& keys);
- virtual void ioConfigChanged(audio_io_config_event event, pid_t pid = 0,
+ virtual void ioConfigChanged(audio_io_config_event_t event, pid_t pid = 0,
audio_port_handle_t portId = AUDIO_PORT_HANDLE_NONE);
void readHalParameters_l();
virtual void cacheParameters_l() {}
diff --git a/services/audiopolicy/AudioPolicyInterface.h b/services/audiopolicy/AudioPolicyInterface.h
index 4078278..8613b2e 100644
--- a/services/audiopolicy/AudioPolicyInterface.h
+++ b/services/audiopolicy/AudioPolicyInterface.h
@@ -18,6 +18,7 @@
#define ANDROID_AUDIOPOLICY_INTERFACE_H
#include <media/AudioCommonTypes.h>
+#include <media/AudioContainers.h>
#include <media/AudioDeviceTypeAddr.h>
#include <media/AudioSystem.h>
#include <media/AudioPolicy.h>
@@ -198,7 +199,7 @@
virtual product_strategy_t getStrategyForStream(audio_stream_type_t stream) = 0;
// return the enabled output devices for the given stream type
- virtual audio_devices_t getDevicesForStream(audio_stream_type_t stream) = 0;
+ virtual DeviceTypeSet getDevicesForStream(audio_stream_type_t stream) = 0;
// retrieves the list of enabled output devices for the given audio attributes
virtual status_t getDevicesForAttributes(const audio_attributes_t &attr,
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
index b53180f..334be8b 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
@@ -2164,8 +2164,9 @@
audio_port_handle_t *portId)
{
ALOGV("%s() source %d, sampling rate %d, format %#x, channel mask %#x, session %d, "
- "flags %#x attributes=%s", __func__, attr->source, config->sample_rate,
- config->format, config->channel_mask, session, flags, toString(*attr).c_str());
+ "flags %#x attributes=%s requested device ID %d",
+ __func__, attr->source, config->sample_rate, config->format, config->channel_mask,
+ session, flags, toString(*attr).c_str(), *selectedDeviceId);
status_t status = NO_ERROR;
audio_source_t halInputSource;
@@ -6092,13 +6093,13 @@
return (stream1 == stream2);
}
-audio_devices_t AudioPolicyManager::getDevicesForStream(audio_stream_type_t stream) {
+DeviceTypeSet AudioPolicyManager::getDevicesForStream(audio_stream_type_t stream) {
// By checking the range of stream before calling getStrategy, we avoid
// getOutputDevicesForStream's behavior for invalid streams.
// engine's getOutputDevicesForStream would fallback on its default behavior (most probably
// device for music stream), but we want to return the empty set.
if (stream < AUDIO_STREAM_MIN || stream >= AUDIO_STREAM_PUBLIC_CNT) {
- return AUDIO_DEVICE_NONE;
+ return DeviceTypeSet{};
}
DeviceVector activeDevices;
DeviceVector devices;
@@ -6129,8 +6130,7 @@
devices.merge(mAvailableOutputDevices.getDevicesFromType(AUDIO_DEVICE_OUT_SPEAKER));
devices.remove(speakerSafeDevices);
}
- // FIXME: use DeviceTypeSet when Java layer is ready for it.
- return deviceTypesToBitMask(devices.types());
+ return devices.types();
}
status_t AudioPolicyManager::getDevicesForAttributes(
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.h b/services/audiopolicy/managerdefault/AudioPolicyManager.h
index fd5c58f..2b3f3b4 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.h
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.h
@@ -193,7 +193,7 @@
}
// return the enabled output devices for the given stream type
- virtual audio_devices_t getDevicesForStream(audio_stream_type_t stream);
+ virtual DeviceTypeSet getDevicesForStream(audio_stream_type_t stream);
virtual status_t getDevicesForAttributes(
const audio_attributes_t &attributes,
diff --git a/services/audiopolicy/service/AudioPolicyClientImpl.cpp b/services/audiopolicy/service/AudioPolicyClientImpl.cpp
index 79252d4..c8db45b 100644
--- a/services/audiopolicy/service/AudioPolicyClientImpl.cpp
+++ b/services/audiopolicy/service/AudioPolicyClientImpl.cpp
@@ -56,17 +56,18 @@
media::OpenOutputResponse response;
request.module = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_module_handle_t_int32_t(module));
- request.halConfig = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_config_t_AudioConfig(*halConfig));
- request.mixerConfig =
- VALUE_OR_RETURN_STATUS(legacy2aidl_audio_config_base_t_AudioConfigBase(*mixerConfig));
+ request.halConfig = VALUE_OR_RETURN_STATUS(
+ legacy2aidl_audio_config_t_AudioConfig(*halConfig, false /*isInput*/));
+ request.mixerConfig = VALUE_OR_RETURN_STATUS(
+ legacy2aidl_audio_config_base_t_AudioConfigBase(*mixerConfig, false /*isInput*/));
request.device = VALUE_OR_RETURN_STATUS(legacy2aidl_DeviceDescriptorBase(device));
request.flags = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_output_flags_t_int32_t_mask(flags));
status_t status = af->openOutput(request, &response);
if (status == OK) {
*output = VALUE_OR_RETURN_STATUS(aidl2legacy_int32_t_audio_io_handle_t(response.output));
- *halConfig =
- VALUE_OR_RETURN_STATUS(aidl2legacy_AudioConfig_audio_config_t(response.config));
+ *halConfig = VALUE_OR_RETURN_STATUS(
+ aidl2legacy_AudioConfig_audio_config_t(response.config, false /*isInput*/));
*latencyMs = VALUE_OR_RETURN_STATUS(convertIntegral<uint32_t>(response.latencyMs));
}
return status;
@@ -135,7 +136,8 @@
media::OpenInputRequest request;
request.module = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_module_handle_t_int32_t(module));
request.input = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_io_handle_t_int32_t(*input));
- request.config = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_config_t_AudioConfig(*config));
+ request.config = VALUE_OR_RETURN_STATUS(
+ legacy2aidl_audio_config_t_AudioConfig(*config, true /*isInput*/));
request.device = VALUE_OR_RETURN_STATUS(legacy2aidl_AudioDeviceTypeAddress(deviceTypeAddr));
request.source = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_source_t_AudioSourceType(source));
request.flags = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_input_flags_t_int32_t_mask(flags));
diff --git a/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp b/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp
index 58359be..95c1bab 100644
--- a/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp
+++ b/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp
@@ -99,13 +99,13 @@
const media::AudioDevice& deviceAidl,
media::AudioPolicyDeviceState stateAidl,
const std::string& deviceNameAidl,
- media::audio::common::AudioFormat encodedFormatAidl) {
+ const media::AudioFormatDescription& encodedFormatAidl) {
audio_devices_t device = VALUE_OR_RETURN_BINDER_STATUS(
- aidl2legacy_int32_t_audio_devices_t(deviceAidl.type));
+ aidl2legacy_AudioDeviceDescription_audio_devices_t(deviceAidl.type));
audio_policy_dev_state_t state = VALUE_OR_RETURN_BINDER_STATUS(
aidl2legacy_AudioPolicyDeviceState_audio_policy_dev_state_t(stateAidl));
audio_format_t encodedFormat = VALUE_OR_RETURN_BINDER_STATUS(
- aidl2legacy_AudioFormat_audio_format_t(encodedFormatAidl));
+ aidl2legacy_AudioFormatDescription_audio_format_t(encodedFormatAidl));
if (mAudioPolicyManager == NULL) {
return binderStatusFromStatusT(NO_INIT);
@@ -131,7 +131,7 @@
Status AudioPolicyService::getDeviceConnectionState(const media::AudioDevice& deviceAidl,
media::AudioPolicyDeviceState* _aidl_return) {
audio_devices_t device = VALUE_OR_RETURN_BINDER_STATUS(
- aidl2legacy_int32_t_audio_devices_t(deviceAidl.type));
+ aidl2legacy_AudioDeviceDescription_audio_devices_t(deviceAidl.type));
if (mAudioPolicyManager == NULL) {
*_aidl_return = VALUE_OR_RETURN_BINDER_STATUS(
legacy2aidl_audio_policy_dev_state_t_AudioPolicyDeviceState(
@@ -149,11 +149,11 @@
Status AudioPolicyService::handleDeviceConfigChange(
const media::AudioDevice& deviceAidl,
const std::string& deviceNameAidl,
- media::audio::common::AudioFormat encodedFormatAidl) {
+ const media::AudioFormatDescription& encodedFormatAidl) {
audio_devices_t device = VALUE_OR_RETURN_BINDER_STATUS(
- aidl2legacy_int32_t_audio_devices_t(deviceAidl.type));
+ aidl2legacy_AudioDeviceDescription_audio_devices_t(deviceAidl.type));
audio_format_t encodedFormat = VALUE_OR_RETURN_BINDER_STATUS(
- aidl2legacy_AudioFormat_audio_format_t(encodedFormatAidl));
+ aidl2legacy_AudioFormatDescription_audio_format_t(encodedFormatAidl));
if (mAudioPolicyManager == NULL) {
return binderStatusFromStatusT(NO_INIT);
@@ -292,7 +292,7 @@
aidl2legacy_int32_t_audio_session_t(sessionAidl));
audio_stream_type_t stream = AUDIO_STREAM_DEFAULT;
audio_config_t config = VALUE_OR_RETURN_BINDER_STATUS(
- aidl2legacy_AudioConfig_audio_config_t(configAidl));
+ aidl2legacy_AudioConfig_audio_config_t(configAidl, false /*isInput*/));
audio_output_flags_t flags = VALUE_OR_RETURN_BINDER_STATUS(
aidl2legacy_int32_t_audio_output_flags_t_mask(flagsAidl));
audio_port_handle_t selectedDeviceId = VALUE_OR_RETURN_BINDER_STATUS(
@@ -523,7 +523,7 @@
audio_session_t session = VALUE_OR_RETURN_BINDER_STATUS(
aidl2legacy_int32_t_audio_session_t(sessionAidl));
audio_config_base_t config = VALUE_OR_RETURN_BINDER_STATUS(
- aidl2legacy_AudioConfigBase_audio_config_base_t(configAidl));
+ aidl2legacy_AudioConfigBase_audio_config_base_t(configAidl, true /*isInput*/));
audio_input_flags_t flags = VALUE_OR_RETURN_BINDER_STATUS(
aidl2legacy_int32_t_audio_input_flags_t_mask(flagsAidl));
audio_port_handle_t selectedDeviceId = VALUE_OR_RETURN_BINDER_STATUS(
@@ -925,12 +925,13 @@
}
Status AudioPolicyService::setStreamVolumeIndex(media::AudioStreamType streamAidl,
- int32_t deviceAidl, int32_t indexAidl) {
+ const media::AudioDeviceDescription& deviceAidl,
+ int32_t indexAidl) {
audio_stream_type_t stream = VALUE_OR_RETURN_BINDER_STATUS(
aidl2legacy_AudioStreamType_audio_stream_type_t(streamAidl));
int index = VALUE_OR_RETURN_BINDER_STATUS(convertIntegral<int>(indexAidl));
audio_devices_t device = VALUE_OR_RETURN_BINDER_STATUS(
- aidl2legacy_int32_t_audio_devices_t(deviceAidl));
+ aidl2legacy_AudioDeviceDescription_audio_devices_t(deviceAidl));
if (mAudioPolicyManager == NULL) {
return binderStatusFromStatusT(NO_INIT);
@@ -949,11 +950,12 @@
}
Status AudioPolicyService::getStreamVolumeIndex(media::AudioStreamType streamAidl,
- int32_t deviceAidl, int32_t* _aidl_return) {
+ const media::AudioDeviceDescription& deviceAidl,
+ int32_t* _aidl_return) {
audio_stream_type_t stream = VALUE_OR_RETURN_BINDER_STATUS(
aidl2legacy_AudioStreamType_audio_stream_type_t(streamAidl));
audio_devices_t device = VALUE_OR_RETURN_BINDER_STATUS(
- aidl2legacy_int32_t_audio_devices_t(deviceAidl));
+ aidl2legacy_AudioDeviceDescription_audio_devices_t(deviceAidl));
int index;
if (mAudioPolicyManager == NULL) {
@@ -971,12 +973,13 @@
}
Status AudioPolicyService::setVolumeIndexForAttributes(
- const media::AudioAttributesInternal& attrAidl, int32_t deviceAidl, int32_t indexAidl) {
+ const media::AudioAttributesInternal& attrAidl,
+ const media::AudioDeviceDescription& deviceAidl, int32_t indexAidl) {
audio_attributes_t attributes = VALUE_OR_RETURN_BINDER_STATUS(
aidl2legacy_AudioAttributesInternal_audio_attributes_t(attrAidl));
int index = VALUE_OR_RETURN_BINDER_STATUS(convertIntegral<int>(indexAidl));
audio_devices_t device = VALUE_OR_RETURN_BINDER_STATUS(
- aidl2legacy_int32_t_audio_devices_t(deviceAidl));
+ aidl2legacy_AudioDeviceDescription_audio_devices_t(deviceAidl));
RETURN_IF_BINDER_ERROR(binderStatusFromStatusT(
AudioValidator::validateAudioAttributes(attributes, "169572641")));
@@ -993,11 +996,12 @@
}
Status AudioPolicyService::getVolumeIndexForAttributes(
- const media::AudioAttributesInternal& attrAidl, int32_t deviceAidl, int32_t* _aidl_return) {
+ const media::AudioAttributesInternal& attrAidl,
+ const media::AudioDeviceDescription& deviceAidl, int32_t* _aidl_return) {
audio_attributes_t attributes = VALUE_OR_RETURN_BINDER_STATUS(
aidl2legacy_AudioAttributesInternal_audio_attributes_t(attrAidl));
audio_devices_t device = VALUE_OR_RETURN_BINDER_STATUS(
- aidl2legacy_int32_t_audio_devices_t(deviceAidl));
+ aidl2legacy_AudioDeviceDescription_audio_devices_t(deviceAidl));
int index;
RETURN_IF_BINDER_ERROR(binderStatusFromStatusT(
AudioValidator::validateAudioAttributes(attributes, "169572641")));
@@ -1075,14 +1079,14 @@
//audio policy: use audio_device_t appropriately
-Status AudioPolicyService::getDevicesForStream(media::AudioStreamType streamAidl,
- int32_t* _aidl_return) {
+Status AudioPolicyService::getDevicesForStream(
+ media::AudioStreamType streamAidl,
+ std::vector<media::AudioDeviceDescription>* _aidl_return) {
audio_stream_type_t stream = VALUE_OR_RETURN_BINDER_STATUS(
aidl2legacy_AudioStreamType_audio_stream_type_t(streamAidl));
if (uint32_t(stream) >= AUDIO_STREAM_PUBLIC_CNT) {
- *_aidl_return = VALUE_OR_RETURN_BINDER_STATUS(
- legacy2aidl_audio_devices_t_int32_t(AUDIO_DEVICE_NONE));
+ *_aidl_return = std::vector<media::AudioDeviceDescription>{};
return Status::ok();
}
if (mAudioPolicyManager == NULL) {
@@ -1091,7 +1095,9 @@
Mutex::Autolock _l(mLock);
AutoCallerClear acc;
*_aidl_return = VALUE_OR_RETURN_BINDER_STATUS(
- legacy2aidl_audio_devices_t_int32_t(mAudioPolicyManager->getDevicesForStream(stream)));
+ convertContainer<std::vector<media::AudioDeviceDescription>>(
+ mAudioPolicyManager->getDevicesForStream(stream),
+ legacy2aidl_audio_devices_t_AudioDeviceDescription));
return Status::ok();
}
@@ -1427,7 +1433,7 @@
const media::AudioAttributesInternal& attributesAidl,
bool* _aidl_return) {
audio_config_base_t config = VALUE_OR_RETURN_BINDER_STATUS(
- aidl2legacy_AudioConfigBase_audio_config_base_t(configAidl));
+ aidl2legacy_AudioConfigBase_audio_config_base_t(configAidl, false /*isInput*/));
audio_attributes_t attributes = VALUE_OR_RETURN_BINDER_STATUS(
aidl2legacy_AudioAttributesInternal_audio_attributes_t(attributesAidl));
RETURN_IF_BINDER_ERROR(binderStatusFromStatusT(
@@ -1602,7 +1608,7 @@
_aidl_return->ioHandle = VALUE_OR_RETURN_BINDER_STATUS(
legacy2aidl_audio_io_handle_t_int32_t(ioHandle));
_aidl_return->device = VALUE_OR_RETURN_BINDER_STATUS(
- legacy2aidl_audio_devices_t_int32_t(device));
+ legacy2aidl_audio_devices_t_AudioDeviceDescription(device));
return Status::ok();
}
@@ -1802,13 +1808,14 @@
}
-Status AudioPolicyService::getStreamVolumeDB(media::AudioStreamType streamAidl, int32_t indexAidl,
- int32_t deviceAidl, float* _aidl_return) {
+Status AudioPolicyService::getStreamVolumeDB(
+ media::AudioStreamType streamAidl, int32_t indexAidl,
+ const media::AudioDeviceDescription& deviceAidl, float* _aidl_return) {
audio_stream_type_t stream = VALUE_OR_RETURN_BINDER_STATUS(
aidl2legacy_AudioStreamType_audio_stream_type_t(streamAidl));
int index = VALUE_OR_RETURN_BINDER_STATUS(convertIntegral<int>(indexAidl));
audio_devices_t device = VALUE_OR_RETURN_BINDER_STATUS(
- aidl2legacy_int32_t_audio_devices_t(deviceAidl));
+ aidl2legacy_AudioDeviceDescription_audio_devices_t(deviceAidl));
if (mAudioPolicyManager == NULL) {
return binderStatusFromStatusT(NO_INIT);
@@ -1820,7 +1827,7 @@
}
Status AudioPolicyService::getSurroundFormats(media::Int* count,
- std::vector<media::audio::common::AudioFormat>* formats,
+ std::vector<media::AudioFormatDescription>* formats,
std::vector<bool>* formatsEnabled) {
unsigned int numSurroundFormats = VALUE_OR_RETURN_BINDER_STATUS(
convertIntegral<unsigned int>(count->value));
@@ -1842,7 +1849,8 @@
numSurroundFormatsReq = std::min(numSurroundFormats, numSurroundFormatsReq);
RETURN_IF_BINDER_ERROR(binderStatusFromStatusT(
convertRange(surroundFormats.get(), surroundFormats.get() + numSurroundFormatsReq,
- std::back_inserter(*formats), legacy2aidl_audio_format_t_AudioFormat)));
+ std::back_inserter(*formats),
+ legacy2aidl_audio_format_t_AudioFormatDescription)));
formatsEnabled->insert(
formatsEnabled->begin(),
surroundFormatsEnabled.get(),
@@ -1852,7 +1860,7 @@
}
Status AudioPolicyService::getReportedSurroundFormats(
- media::Int* count, std::vector<media::audio::common::AudioFormat>* formats) {
+ media::Int* count, std::vector<media::AudioFormatDescription>* formats) {
unsigned int numSurroundFormats = VALUE_OR_RETURN_BINDER_STATUS(
convertIntegral<unsigned int>(count->value));
if (numSurroundFormats > MAX_ITEMS_PER_LIST) {
@@ -1872,13 +1880,14 @@
numSurroundFormatsReq = std::min(numSurroundFormats, numSurroundFormatsReq);
RETURN_IF_BINDER_ERROR(binderStatusFromStatusT(
convertRange(surroundFormats.get(), surroundFormats.get() + numSurroundFormatsReq,
- std::back_inserter(*formats), legacy2aidl_audio_format_t_AudioFormat)));
+ std::back_inserter(*formats),
+ legacy2aidl_audio_format_t_AudioFormatDescription)));
count->value = VALUE_OR_RETURN_BINDER_STATUS(convertIntegral<uint32_t>(numSurroundFormats));
return Status::ok();
}
Status AudioPolicyService::getHwOffloadEncodingFormatsSupportedForA2DP(
- std::vector<media::audio::common::AudioFormat>* _aidl_return) {
+ std::vector<media::AudioFormatDescription>* _aidl_return) {
std::vector<audio_format_t> formats;
if (mAudioPolicyManager == NULL) {
@@ -1889,16 +1898,16 @@
RETURN_IF_BINDER_ERROR(binderStatusFromStatusT(
mAudioPolicyManager->getHwOffloadEncodingFormatsSupportedForA2DP(&formats)));
*_aidl_return = VALUE_OR_RETURN_BINDER_STATUS(
- convertContainer<std::vector<media::audio::common::AudioFormat>>(
+ convertContainer<std::vector<media::AudioFormatDescription>>(
formats,
- legacy2aidl_audio_format_t_AudioFormat));
+ legacy2aidl_audio_format_t_AudioFormatDescription));
return Status::ok();
}
Status AudioPolicyService::setSurroundFormatEnabled(
- media::audio::common::AudioFormat audioFormatAidl, bool enabled) {
+ const media::AudioFormatDescription& audioFormatAidl, bool enabled) {
audio_format_t audioFormat = VALUE_OR_RETURN_BINDER_STATUS(
- aidl2legacy_AudioFormat_audio_format_t(audioFormatAidl));
+ aidl2legacy_AudioFormatDescription_audio_format_t(audioFormatAidl));
if (mAudioPolicyManager == NULL) {
return binderStatusFromStatusT(NO_INIT);
}
@@ -2231,7 +2240,8 @@
audio_config_t config = AUDIO_CONFIG_INITIALIZER;
if (configAidl.has_value()) {
config = VALUE_OR_RETURN_BINDER_STATUS(
- aidl2legacy_AudioConfig_audio_config_t(configAidl.value()));
+ aidl2legacy_AudioConfig_audio_config_t(configAidl.value(),
+ false /*isInput*/));
}
AudioDeviceTypeAddrVector devices = VALUE_OR_RETURN_BINDER_STATUS(
convertContainer<AudioDeviceTypeAddrVector>(devicesAidl,
diff --git a/services/audiopolicy/service/AudioPolicyService.cpp b/services/audiopolicy/service/AudioPolicyService.cpp
index 56c472b..86994ed 100644
--- a/services/audiopolicy/service/AudioPolicyService.cpp
+++ b/services/audiopolicy/service/AudioPolicyService.cpp
@@ -496,13 +496,15 @@
media::RecordClientInfo clientInfoAidl = VALUE_OR_RETURN_STATUS(
legacy2aidl_record_client_info_t_RecordClientInfo(*clientInfo));
media::AudioConfigBase clientConfigAidl = VALUE_OR_RETURN_STATUS(
- legacy2aidl_audio_config_base_t_AudioConfigBase(*clientConfig));
+ legacy2aidl_audio_config_base_t_AudioConfigBase(
+ *clientConfig, true /*isInput*/));
std::vector<media::EffectDescriptor> clientEffectsAidl = VALUE_OR_RETURN_STATUS(
convertContainer<std::vector<media::EffectDescriptor>>(
clientEffects,
legacy2aidl_effect_descriptor_t_EffectDescriptor));
media::AudioConfigBase deviceConfigAidl = VALUE_OR_RETURN_STATUS(
- legacy2aidl_audio_config_base_t_AudioConfigBase(*deviceConfig));
+ legacy2aidl_audio_config_base_t_AudioConfigBase(
+ *deviceConfig, true /*isInput*/));
std::vector<media::EffectDescriptor> effectsAidl = VALUE_OR_RETURN_STATUS(
convertContainer<std::vector<media::EffectDescriptor>>(
effects,
diff --git a/services/audiopolicy/service/AudioPolicyService.h b/services/audiopolicy/service/AudioPolicyService.h
index b897a44..97d4c00 100644
--- a/services/audiopolicy/service/AudioPolicyService.h
+++ b/services/audiopolicy/service/AudioPolicyService.h
@@ -74,13 +74,13 @@
const media::AudioDevice& device,
media::AudioPolicyDeviceState state,
const std::string& deviceName,
- media::audio::common::AudioFormat encodedFormat) override;
+ const media::AudioFormatDescription& encodedFormat) override;
binder::Status getDeviceConnectionState(const media::AudioDevice& device,
media::AudioPolicyDeviceState* _aidl_return) override;
binder::Status handleDeviceConfigChange(
const media::AudioDevice& device,
const std::string& deviceName,
- media::audio::common::AudioFormat encodedFormat) override;
+ const media::AudioFormatDescription& encodedFormat) override;
binder::Status setPhoneState(media::AudioMode state, int32_t uid) override;
binder::Status setForceUse(media::AudioPolicyForceUse usage,
media::AudioPolicyForcedConfig config) override;
@@ -106,22 +106,27 @@
binder::Status releaseInput(int32_t portId) override;
binder::Status initStreamVolume(media::AudioStreamType stream, int32_t indexMin,
int32_t indexMax) override;
- binder::Status setStreamVolumeIndex(media::AudioStreamType stream, int32_t device,
+ binder::Status setStreamVolumeIndex(media::AudioStreamType stream,
+ const media::AudioDeviceDescription& device,
int32_t index) override;
- binder::Status getStreamVolumeIndex(media::AudioStreamType stream, int32_t device,
+ binder::Status getStreamVolumeIndex(media::AudioStreamType stream,
+ const media::AudioDeviceDescription& device,
int32_t* _aidl_return) override;
binder::Status setVolumeIndexForAttributes(const media::AudioAttributesInternal& attr,
- int32_t device, int32_t index) override;
+ const media::AudioDeviceDescription& device,
+ int32_t index) override;
binder::Status getVolumeIndexForAttributes(const media::AudioAttributesInternal& attr,
- int32_t device, int32_t* _aidl_return) override;
+ const media::AudioDeviceDescription& device,
+ int32_t* _aidl_return) override;
binder::Status getMaxVolumeIndexForAttributes(const media::AudioAttributesInternal& attr,
int32_t* _aidl_return) override;
binder::Status getMinVolumeIndexForAttributes(const media::AudioAttributesInternal& attr,
int32_t* _aidl_return) override;
binder::Status getStrategyForStream(media::AudioStreamType stream,
int32_t* _aidl_return) override;
- binder::Status getDevicesForStream(media::AudioStreamType stream,
- int32_t* _aidl_return) override;
+ binder::Status getDevicesForStream(
+ media::AudioStreamType stream,
+ std::vector<media::AudioDeviceDescription>* _aidl_return) override;
binder::Status getDevicesForAttributes(const media::AudioAttributesEx& attr,
std::vector<media::AudioDevice>* _aidl_return) override;
binder::Status getOutputForEffect(const media::EffectDescriptor& desc,
@@ -190,16 +195,17 @@
binder::Status stopAudioSource(int32_t portId) override;
binder::Status setMasterMono(bool mono) override;
binder::Status getMasterMono(bool* _aidl_return) override;
- binder::Status getStreamVolumeDB(media::AudioStreamType stream, int32_t index, int32_t device,
+ binder::Status getStreamVolumeDB(media::AudioStreamType stream, int32_t index,
+ const media::AudioDeviceDescription& device,
float* _aidl_return) override;
binder::Status getSurroundFormats(media::Int* count,
- std::vector<media::audio::common::AudioFormat>* formats,
+ std::vector<media::AudioFormatDescription>* formats,
std::vector<bool>* formatsEnabled) override;
binder::Status getReportedSurroundFormats(
- media::Int* count, std::vector<media::audio::common::AudioFormat>* formats) override;
+ media::Int* count, std::vector<media::AudioFormatDescription>* formats) override;
binder::Status getHwOffloadEncodingFormatsSupportedForA2DP(
- std::vector<media::audio::common::AudioFormat>* _aidl_return) override;
- binder::Status setSurroundFormatEnabled(media::audio::common::AudioFormat audioFormat,
+ std::vector<media::AudioFormatDescription>* _aidl_return) override;
+ binder::Status setSurroundFormatEnabled(const media::AudioFormatDescription& audioFormat,
bool enabled) override;
binder::Status setAssistantUid(int32_t uid) override;
binder::Status setHotwordDetectionServiceUid(int32_t uid) override;
diff --git a/services/audiopolicy/tests/Android.bp b/services/audiopolicy/tests/Android.bp
index b296fb0..8fbe8b2 100644
--- a/services/audiopolicy/tests/Android.bp
+++ b/services/audiopolicy/tests/Android.bp
@@ -25,7 +25,7 @@
"libmedia_helper",
"libutils",
"libxml2",
- "libpermission",
+ "framework-permission-aidl-cpp",
"libbinder",
],
diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp
index d0d3a9d..19a111d 100644
--- a/services/camera/libcameraservice/CameraService.cpp
+++ b/services/camera/libcameraservice/CameraService.cpp
@@ -613,8 +613,10 @@
broadcastTorchModeStatus(cameraId, newStatus, systemCameraKind);
}
-static bool hasPermissionsForSystemCamera(int callingPid, int callingUid) {
- return checkPermission(sSystemCameraPermission, callingPid, callingUid) &&
+static bool hasPermissionsForSystemCamera(int callingPid, int callingUid,
+ bool logPermissionFailure = false) {
+ return checkPermission(sSystemCameraPermission, callingPid, callingUid,
+ logPermissionFailure) &&
checkPermission(sCameraPermission, callingPid, callingUid);
}
@@ -693,8 +695,8 @@
const std::vector<std::string> *deviceIds = &mNormalDeviceIdsWithoutSystemCamera;
auto callingPid = CameraThreadState::getCallingPid();
auto callingUid = CameraThreadState::getCallingUid();
- if (checkPermission(sSystemCameraPermission, callingPid, callingUid) ||
- getpid() == callingPid) {
+ if (checkPermission(sSystemCameraPermission, callingPid, callingUid,
+ /*logPermissionFailure*/false) || getpid() == callingPid) {
deviceIds = &mNormalDeviceIds;
}
if (cameraIdInt < 0 || cameraIdInt >= static_cast<int>(deviceIds->size())) {
@@ -1597,7 +1599,7 @@
// same behavior for system camera devices.
if (getCurrentServingCall() != BinderCallType::HWBINDER &&
systemCameraKind == SystemCameraKind::SYSTEM_ONLY_CAMERA &&
- !hasPermissionsForSystemCamera(cPid, cUid)) {
+ !hasPermissionsForSystemCamera(cPid, cUid, /*logPermissionFailure*/true)) {
ALOGW("Rejecting access to system only camera %s, inadequete permissions",
cameraId.c_str());
return true;
@@ -1888,6 +1890,27 @@
CameraServiceProxyWrapper::logOpen(cameraId, facing, clientPackageName,
effectiveApiLevel, isNdk, openLatencyMs);
+ {
+ Mutex::Autolock lock(mInjectionParametersLock);
+ if (cameraId == mInjectionInternalCamId && mInjectionInitPending) {
+ mInjectionInitPending = false;
+ status_t res = NO_ERROR;
+ auto clientDescriptor = mActiveClientManager.get(mInjectionInternalCamId);
+ if (clientDescriptor != nullptr) {
+ BasicClient* baseClientPtr = clientDescriptor->getValue().get();
+ res = baseClientPtr->injectCamera(mInjectionExternalCamId, mCameraProviderManager);
+ if (res != OK) {
+ mInjectionStatusListener->notifyInjectionError(mInjectionExternalCamId, res);
+ }
+ } else {
+ ALOGE("%s: Internal camera ID = %s 's client does not exist!",
+ __FUNCTION__, mInjectionInternalCamId.string());
+ res = NO_INIT;
+ mInjectionStatusListener->notifyInjectionError(mInjectionExternalCamId, res);
+ }
+ }
+ }
+
return ret;
}
@@ -2336,7 +2359,7 @@
auto clientUid = CameraThreadState::getCallingUid();
auto clientPid = CameraThreadState::getCallingPid();
bool openCloseCallbackAllowed = checkPermission(sCameraOpenCloseListenerPermission,
- clientPid, clientUid);
+ clientPid, clientUid, /*logPermissionFailure*/false);
Mutex::Autolock lock(mServiceLock);
@@ -2548,7 +2571,7 @@
const String16& externalCamId,
const sp<ICameraInjectionCallback>& callback,
/*out*/
- sp<hardware::camera2::ICameraInjectionSession>* cameraInjectionSession) {
+ sp<ICameraInjectionSession>* cameraInjectionSession) {
ATRACE_CALL();
if (!checkCallingPermission(sCameraInjectExternalCameraPermission)) {
@@ -2565,18 +2588,30 @@
__FUNCTION__, String8(packageName).string(),
String8(internalCamId).string(), String8(externalCamId).string());
- binder::Status ret = binder::Status::ok();
- // TODO: Implement the injection camera function.
- // ret = internalInjectCamera(...);
- // if(!ret.isOk()) {
- // mInjectionStatusListener->notifyInjectionError(...);
- // return ret;
- // }
-
+ {
+ Mutex::Autolock lock(mInjectionParametersLock);
+ mInjectionInternalCamId = String8(internalCamId);
+ mInjectionExternalCamId = String8(externalCamId);
+ status_t res = NO_ERROR;
+ auto clientDescriptor = mActiveClientManager.get(mInjectionInternalCamId);
+ // If the client already exists, we can directly connect to the camera device through the
+ // client's injectCamera(), otherwise we need to wait until the client is established
+ // (execute connectHelper()) before injecting the camera to the camera device.
+ if (clientDescriptor != nullptr) {
+ mInjectionInitPending = false;
+ BasicClient* baseClientPtr = clientDescriptor->getValue().get();
+ res = baseClientPtr->injectCamera(mInjectionExternalCamId, mCameraProviderManager);
+ if(res != OK) {
+ mInjectionStatusListener->notifyInjectionError(mInjectionExternalCamId, res);
+ }
+ } else {
+ mInjectionInitPending = true;
+ }
+ }
mInjectionStatusListener->addListener(callback);
*cameraInjectionSession = new CameraInjectionSession(this);
- return ret;
+ return binder::Status::ok();
}
void CameraService::removeByClient(const BasicClient* client) {
@@ -3865,22 +3900,62 @@
}
void CameraService::InjectionStatusListener::notifyInjectionError(
- int errorCode) {
- Mutex::Autolock lock(mListenerLock);
+ String8 injectedCamId, status_t err) {
if (mCameraInjectionCallback == nullptr) {
ALOGW("InjectionStatusListener: mCameraInjectionCallback == nullptr");
return;
}
- mCameraInjectionCallback->onInjectionError(errorCode);
+
+ switch (err) {
+ case -ENODEV:
+ mCameraInjectionCallback->onInjectionError(
+ ICameraInjectionCallback::ERROR_INJECTION_SESSION);
+ ALOGE("No camera device with ID \"%s\" currently available!",
+ injectedCamId.string());
+ break;
+ case -EBUSY:
+ mCameraInjectionCallback->onInjectionError(
+ ICameraInjectionCallback::ERROR_INJECTION_SESSION);
+ ALOGE("Higher-priority client using camera, ID \"%s\" currently unavailable!",
+ injectedCamId.string());
+ break;
+ case DEAD_OBJECT:
+ mCameraInjectionCallback->onInjectionError(
+ ICameraInjectionCallback::ERROR_INJECTION_SESSION);
+ ALOGE("Camera ID \"%s\" object is dead!",
+ injectedCamId.string());
+ break;
+ case INVALID_OPERATION:
+ mCameraInjectionCallback->onInjectionError(
+ ICameraInjectionCallback::ERROR_INJECTION_SESSION);
+ ALOGE("Camera ID \"%s\" encountered an operating or internal error!",
+ injectedCamId.string());
+ break;
+ case UNKNOWN_TRANSACTION:
+ mCameraInjectionCallback->onInjectionError(
+ ICameraInjectionCallback::ERROR_INJECTION_UNSUPPORTED);
+ ALOGE("Camera ID \"%s\" method doesn't support!",
+ injectedCamId.string());
+ break;
+ default:
+ mCameraInjectionCallback->onInjectionError(
+ ICameraInjectionCallback::ERROR_INJECTION_INVALID_ERROR);
+ ALOGE("Unexpected error %s (%d) opening camera \"%s\"!",
+ strerror(-err), err, injectedCamId.string());
+ }
}
void CameraService::InjectionStatusListener::binderDied(
const wp<IBinder>& /*who*/) {
- Mutex::Autolock lock(mListenerLock);
ALOGV("InjectionStatusListener: ICameraInjectionCallback has died");
auto parent = mParent.promote();
if (parent != nullptr) {
- parent->stopInjectionImpl();
+ auto clientDescriptor = parent->mActiveClientManager.get(parent->mInjectionInternalCamId);
+ if (clientDescriptor != nullptr) {
+ BasicClient* baseClientPtr = clientDescriptor->getValue().get();
+ baseClientPtr->stopInjection();
+ }
+ parent->clearInjectionParameters();
}
}
@@ -3896,7 +3971,20 @@
return STATUS_ERROR(ICameraInjectionCallback::ERROR_INJECTION_SERVICE,
"Camera service encountered error");
}
- parent->stopInjectionImpl();
+
+ status_t res = NO_ERROR;
+ auto clientDescriptor = parent->mActiveClientManager.get(parent->mInjectionInternalCamId);
+ if (clientDescriptor != nullptr) {
+ BasicClient* baseClientPtr = clientDescriptor->getValue().get();
+ res = baseClientPtr->stopInjection();
+ if (res != OK) {
+ ALOGE("CameraInjectionSession: Failed to stop the injection camera!"
+ " ret != NO_ERROR: %d", res);
+ return STATUS_ERROR(ICameraInjectionCallback::ERROR_INJECTION_SESSION,
+ "Camera session encountered error");
+ }
+ }
+ parent->clearInjectionParameters();
return binder::Status::ok();
}
@@ -4605,10 +4693,14 @@
return mode;
}
-void CameraService::stopInjectionImpl() {
+void CameraService::clearInjectionParameters() {
+ {
+ Mutex::Autolock lock(mInjectionParametersLock);
+ mInjectionInitPending = true;
+ mInjectionInternalCamId = "";
+ }
+ mInjectionExternalCamId = "";
mInjectionStatusListener->removeListener();
-
- // TODO: Implement the stop injection function.
}
}; // namespace android
diff --git a/services/camera/libcameraservice/CameraService.h b/services/camera/libcameraservice/CameraService.h
index bc2e347..224287e 100644
--- a/services/camera/libcameraservice/CameraService.h
+++ b/services/camera/libcameraservice/CameraService.h
@@ -320,6 +320,14 @@
// Set/reset camera mute
virtual status_t setCameraMute(bool enabled) = 0;
+ // The injection camera session to replace the internal camera
+ // session.
+ virtual status_t injectCamera(const String8& injectedCamId,
+ sp<CameraProviderManager> manager) = 0;
+
+ // Stop the injection camera and restore to internal camera session.
+ virtual status_t stopInjection() = 0;
+
protected:
BasicClient(const sp<CameraService>& cameraService,
const sp<IBinder>& remoteCallback,
@@ -1194,7 +1202,7 @@
void addListener(const sp<hardware::camera2::ICameraInjectionCallback>& callback);
void removeListener();
- void notifyInjectionError(int errorCode);
+ void notifyInjectionError(String8 injectedCamId, status_t err);
// IBinder::DeathRecipient implementation
virtual void binderDied(const wp<IBinder>& who);
@@ -1221,7 +1229,15 @@
wp<CameraService> mParent;
};
- void stopInjectionImpl();
+ void clearInjectionParameters();
+
+ // This is the existing camera id being replaced.
+ String8 mInjectionInternalCamId;
+ // This is the external camera Id replacing the internalId.
+ String8 mInjectionExternalCamId;
+ bool mInjectionInitPending = true;
+ // Guard mInjectionInternalCamId and mInjectionInitPending.
+ Mutex mInjectionParametersLock;
};
} // namespace android
diff --git a/services/camera/libcameraservice/api2/CameraOfflineSessionClient.cpp b/services/camera/libcameraservice/api2/CameraOfflineSessionClient.cpp
index ef15f2d..652842b 100644
--- a/services/camera/libcameraservice/api2/CameraOfflineSessionClient.cpp
+++ b/services/camera/libcameraservice/api2/CameraOfflineSessionClient.cpp
@@ -330,5 +330,19 @@
CaptureResultExtras());
}
+status_t CameraOfflineSessionClient::injectCamera(const String8& injectedCamId,
+ sp<CameraProviderManager> manager) {
+ ALOGV("%s: This client doesn't support the injection camera. injectedCamId: %s providerPtr: %p",
+ __FUNCTION__, injectedCamId.string(), manager.get());
+
+ return OK;
+}
+
+status_t CameraOfflineSessionClient::stopInjection() {
+ ALOGV("%s: This client doesn't support the injection camera.", __FUNCTION__);
+
+ return OK;
+}
+
// ----------------------------------------------------------------------------
}; // namespace android
diff --git a/services/camera/libcameraservice/api2/CameraOfflineSessionClient.h b/services/camera/libcameraservice/api2/CameraOfflineSessionClient.h
index b219a4c..b5238b8 100644
--- a/services/camera/libcameraservice/api2/CameraOfflineSessionClient.h
+++ b/services/camera/libcameraservice/api2/CameraOfflineSessionClient.h
@@ -98,6 +98,9 @@
void notifyPrepared(int streamId) override;
void notifyRequestQueueEmpty() override;
void notifyRepeatingRequestError(long lastFrameNumber) override;
+ status_t injectCamera(const String8& injectedCamId,
+ sp<CameraProviderManager> manager) override;
+ status_t stopInjection() override;
private:
mutable Mutex mBinderSerializationLock;
diff --git a/services/camera/libcameraservice/common/Camera2ClientBase.cpp b/services/camera/libcameraservice/common/Camera2ClientBase.cpp
index 13d044a..1147e23 100644
--- a/services/camera/libcameraservice/common/Camera2ClientBase.cpp
+++ b/services/camera/libcameraservice/common/Camera2ClientBase.cpp
@@ -413,6 +413,17 @@
mRemoteCallback.clear();
}
+template <typename TClientBase>
+status_t Camera2ClientBase<TClientBase>::injectCamera(const String8& injectedCamId,
+ sp<CameraProviderManager> manager) {
+ return mDevice->injectCamera(injectedCamId, manager);
+}
+
+template <typename TClientBase>
+status_t Camera2ClientBase<TClientBase>::stopInjection() {
+ return mDevice->stopInjection();
+}
+
template class Camera2ClientBase<CameraService::Client>;
template class Camera2ClientBase<CameraDeviceClientBase>;
diff --git a/services/camera/libcameraservice/common/Camera2ClientBase.h b/services/camera/libcameraservice/common/Camera2ClientBase.h
index 6246f7b..b593bfa 100644
--- a/services/camera/libcameraservice/common/Camera2ClientBase.h
+++ b/services/camera/libcameraservice/common/Camera2ClientBase.h
@@ -114,6 +114,10 @@
mutable Mutex mRemoteCallbackLock;
} mSharedCameraCallbacks;
+ status_t injectCamera(const String8& injectedCamId,
+ sp<CameraProviderManager> manager) override;
+ status_t stopInjection() override;
+
protected:
// The PID provided in the constructor call
diff --git a/services/camera/libcameraservice/common/CameraDeviceBase.h b/services/camera/libcameraservice/common/CameraDeviceBase.h
index 85b0cc2..3c95ed3 100644
--- a/services/camera/libcameraservice/common/CameraDeviceBase.h
+++ b/services/camera/libcameraservice/common/CameraDeviceBase.h
@@ -427,6 +427,18 @@
*/
void setImageDumpMask(int mask) { mImageDumpMask = mask; }
+ /**
+ * The injection camera session to replace the internal camera
+ * session.
+ */
+ virtual status_t injectCamera(const String8& injectedCamId,
+ sp<CameraProviderManager> manager) = 0;
+
+ /**
+ * Stop the injection camera and restore to internal camera session.
+ */
+ virtual status_t stopInjection() = 0;
+
protected:
bool mImageDumpMask = 0;
};
diff --git a/services/camera/libcameraservice/device3/Camera3Device.cpp b/services/camera/libcameraservice/device3/Camera3Device.cpp
index fd645c7..7c3c6b7 100644
--- a/services/camera/libcameraservice/device3/Camera3Device.cpp
+++ b/services/camera/libcameraservice/device3/Camera3Device.cpp
@@ -2836,17 +2836,28 @@
mRequestBufferSM.onStreamsConfigured();
}
+ // First call injectCamera() and then run configureStreamsLocked() case:
// Since the streams configuration of the injection camera is based on the internal camera, we
- // must wait until the internal camera configure streams before calling injectCamera() to
+ // must wait until the internal camera configure streams before running the injection job to
// configure the injection streams.
if (mInjectionMethods->isInjecting()) {
- ALOGV("%s: Injection camera %s: Start to configure streams.",
+ ALOGD("%s: Injection camera %s: Start to configure streams.",
__FUNCTION__, mInjectionMethods->getInjectedCamId().string());
res = mInjectionMethods->injectCamera(config, bufferSizes);
if (res != OK) {
ALOGE("Can't finish inject camera process!");
return res;
}
+ } else {
+ // First run configureStreamsLocked() and then call injectCamera() case:
+ // If the stream configuration has been completed and camera deive is active, but the
+ // injection camera has not been injected yet, we need to store the stream configuration of
+ // the internal camera (because the stream configuration of the injection camera is based
+ // on the internal camera). When injecting occurs later, this configuration can be used by
+ // the injection camera.
+ ALOGV("%s: The stream configuration is complete and the camera device is active, but the"
+ " injection camera has not been injected yet.", __FUNCTION__);
+ mInjectionMethods->storeInjectionConfig(config, bufferSizes);
}
return OK;
@@ -3072,10 +3083,11 @@
void Camera3Device::monitorMetadata(TagMonitor::eventSource source,
int64_t frameNumber, nsecs_t timestamp, const CameraMetadata& metadata,
- const std::unordered_map<std::string, CameraMetadata>& physicalMetadata) {
+ const std::unordered_map<std::string, CameraMetadata>& physicalMetadata,
+ const std::set<int32_t> &outputStreamIds, int32_t inputStreamId) {
mTagMonitor.monitorMetadata(source, frameNumber, timestamp, metadata,
- physicalMetadata);
+ physicalMetadata, outputStreamIds, inputStreamId);
}
/**
@@ -4578,9 +4590,20 @@
sp<Camera3Device> parent = mParent.promote();
if (parent != NULL) {
+ std::set<int32_t> outputStreamIds;
+ for (size_t i = 0; i < halRequest.num_output_buffers; i++) {
+ const camera_stream_buffer_t *src = halRequest.output_buffers + i;
+ int32_t streamId = Camera3Stream::cast(src->stream)->getId();
+ outputStreamIds.emplace(streamId);
+ }
+ int32_t inputStreamId = -1;
+ if (halRequest.input_buffer != nullptr) {
+ inputStreamId = Camera3Stream::cast(halRequest.input_buffer->stream)->getId();
+ }
+
parent->monitorMetadata(TagMonitor::REQUEST,
halRequest.frame_number,
- 0, mLatestRequest, mLatestPhysicalRequest);
+ 0, mLatestRequest, mLatestPhysicalRequest, outputStreamIds, inputStreamId);
}
}
@@ -6582,6 +6605,13 @@
ALOGI("%s Injection camera: injectedCamId = %s", __FUNCTION__, injectedCamId.string());
ATRACE_CALL();
Mutex::Autolock il(mInterfaceLock);
+ // When the camera device is active, injectCamera() and stopInjection() will call
+ // internalPauseAndWaitLocked() and internalResumeLocked(), and then they will call
+ // mStatusChanged.waitRelative(mLock, timeout) of waitUntilStateThenRelock(). But
+ // mStatusChanged.waitRelative(mLock, timeout)'s parameter: mutex "mLock" must be in the locked
+ // state, so we need to add "Mutex::Autolock l(mLock)" to lock the "mLock" before calling
+ // waitUntilStateThenRelock().
+ Mutex::Autolock l(mLock);
status_t res = NO_ERROR;
if (mInjectionMethods->isInjecting()) {
@@ -6604,16 +6634,25 @@
return res;
}
- camera3::camera_stream_configuration injectionConfig;
- std::vector<uint32_t> injectionBufferSizes;
- mInjectionMethods->getInjectionConfig(&injectionConfig, &injectionBufferSizes);
// When the second display of android is cast to the remote device, and the opened camera is
// also cast to the second display, in this case, because the camera has configured the streams
// at this time, we can directly call injectCamera() to replace the internal camera with
// injection camera.
- if (mOperatingMode >= 0 && injectionConfig.num_streams > 0
- && injectionBufferSizes.size() > 0) {
- ALOGV("%s: The opened camera is directly cast to the remote device.", __FUNCTION__);
+ if (mInjectionMethods->isStreamConfigCompleteButNotInjected()) {
+ ALOGD("%s: The opened camera is directly cast to the remote device.", __FUNCTION__);
+
+ camera3::camera_stream_configuration injectionConfig;
+ std::vector<uint32_t> injectionBufferSizes;
+ mInjectionMethods->getInjectionConfig(&injectionConfig, &injectionBufferSizes);
+ if (mOperatingMode < 0 || injectionConfig.num_streams <= 0
+ || injectionBufferSizes.size() <= 0) {
+ ALOGE("Failed to inject camera due to abandoned configuration! "
+ "mOperatingMode: %d injectionConfig.num_streams: %d "
+ "injectionBufferSizes.size(): %zu", mOperatingMode,
+ injectionConfig.num_streams, injectionBufferSizes.size());
+ return DEAD_OBJECT;
+ }
+
res = mInjectionMethods->injectCamera(
injectionConfig, injectionBufferSizes);
if (res != OK) {
@@ -6628,6 +6667,7 @@
status_t Camera3Device::stopInjection() {
ALOGI("%s: Injection camera: stopInjection", __FUNCTION__);
Mutex::Autolock il(mInterfaceLock);
+ Mutex::Autolock l(mLock);
return mInjectionMethods->stopInjection();
}
diff --git a/services/camera/libcameraservice/device3/Camera3Device.h b/services/camera/libcameraservice/device3/Camera3Device.h
index 39714f0..c0dc6f8 100644
--- a/services/camera/libcameraservice/device3/Camera3Device.h
+++ b/services/camera/libcameraservice/device3/Camera3Device.h
@@ -1249,7 +1249,8 @@
void monitorMetadata(TagMonitor::eventSource source, int64_t frameNumber,
nsecs_t timestamp, const CameraMetadata& metadata,
- const std::unordered_map<std::string, CameraMetadata>& physicalMetadata);
+ const std::unordered_map<std::string, CameraMetadata>& physicalMetadata,
+ const std::set<int32_t> &outputStreamIds, int32_t inputStreamId);
metadata_vendor_id_t mVendorTagId;
@@ -1373,25 +1374,34 @@
// when device is IDLE and request thread is paused.
status_t injectCamera(
camera3::camera_stream_configuration& injectionConfig,
- std::vector<uint32_t>& injectionBufferSizes);
+ const std::vector<uint32_t>& injectionBufferSizes);
// Stop the injection camera and switch back to backup hal interface.
status_t stopInjection();
bool isInjecting();
+ bool isStreamConfigCompleteButNotInjected();
+
const String8& getInjectedCamId() const;
void getInjectionConfig(/*out*/ camera3::camera_stream_configuration* injectionConfig,
/*out*/ std::vector<uint32_t>* injectionBufferSizes);
+ // When the streaming configuration is completed and the camera device is active, but the
+ // injection camera has not yet been injected, the streaming configuration of the internal
+ // camera will be stored first.
+ void storeInjectionConfig(
+ const camera3::camera_stream_configuration& injectionConfig,
+ const std::vector<uint32_t>& injectionBufferSizes);
+
private:
// Configure the streams of injection camera, it need wait until the
// output streams are created and configured to the original camera before
// proceeding.
status_t injectionConfigureStreams(
camera3::camera_stream_configuration& injectionConfig,
- std::vector<uint32_t>& injectionBufferSizes);
+ const std::vector<uint32_t>& injectionBufferSizes);
// Disconnect the injection camera and delete the hal interface.
void injectionDisconnectImpl();
@@ -1409,9 +1419,23 @@
// Generated injection camera hal interface.
sp<HalInterface> mInjectedCamHalInterface;
+ // Backup of the original camera hal result FMQ.
+ std::unique_ptr<ResultMetadataQueue> mBackupResultMetadataQueue;
+
+ // FMQ writes the result for the injection camera. Must be guarded by
+ // mProcessCaptureResultLock.
+ std::unique_ptr<ResultMetadataQueue> mInjectionResultMetadataQueue;
+
+ // The flag indicates that the stream configuration is complete, the camera device is
+ // active, but the injection camera has not yet been injected.
+ bool mIsStreamConfigCompleteButNotInjected = false;
+
// Copy the configuration of the internal camera.
camera3::camera_stream_configuration mInjectionConfig;
+ // Copy the streams of the internal camera.
+ Vector<camera3::camera_stream_t*> mInjectionStreams;
+
// Copy the bufferSizes of the output streams of the internal camera.
std::vector<uint32_t> mInjectionBufferSizes;
diff --git a/services/camera/libcameraservice/device3/Camera3DeviceInjectionMethods.cpp b/services/camera/libcameraservice/device3/Camera3DeviceInjectionMethods.cpp
index f145dac..4744a6d 100644
--- a/services/camera/libcameraservice/device3/Camera3DeviceInjectionMethods.cpp
+++ b/services/camera/libcameraservice/device3/Camera3DeviceInjectionMethods.cpp
@@ -86,7 +86,7 @@
return DEAD_OBJECT;
}
- std::unique_ptr<ResultMetadataQueue>& resQueue = parent->mResultMetadataQueue;
+ std::unique_ptr<ResultMetadataQueue>& resQueue = mInjectionResultMetadataQueue;
auto resultQueueRet = session->getCaptureResultMetadataQueue(
[&resQueue](const auto& descriptor) {
resQueue = std::make_unique<ResultMetadataQueue>(descriptor);
@@ -127,10 +127,8 @@
status_t Camera3Device::Camera3DeviceInjectionMethods::injectCamera(
camera3::camera_stream_configuration& injectionConfig,
- std::vector<uint32_t>& injectionBufferSizes) {
+ const std::vector<uint32_t>& injectionBufferSizes) {
status_t res = NO_ERROR;
- mInjectionConfig = injectionConfig;
- mInjectionBufferSizes = injectionBufferSizes;
if (mInjectedCamHalInterface == nullptr) {
ALOGE("%s: mInjectedCamHalInterface does not exist!", __FUNCTION__);
@@ -148,7 +146,6 @@
if (parent->mStatus == STATUS_ACTIVE) {
ALOGV("%s: Let the device be IDLE and the request thread is paused",
__FUNCTION__);
- parent->mPauseStateNotify = true;
res = parent->internalPauseAndWaitLocked(maxExpectedDuration);
if (res != OK) {
ALOGE("%s: Can't pause captures to inject camera!", __FUNCTION__);
@@ -188,7 +185,7 @@
ALOGV("%s: Restarting activity to inject camera", __FUNCTION__);
// Reuse current operating mode and session parameters for new stream
// config.
- parent->internalUpdateStatusLocked(STATUS_ACTIVE);
+ parent->internalResumeLocked();
}
return OK;
@@ -208,7 +205,6 @@
if (parent->mStatus == STATUS_ACTIVE) {
ALOGV("%s: Let the device be IDLE and the request thread is paused",
__FUNCTION__);
- parent->mPauseStateNotify = true;
res = parent->internalPauseAndWaitLocked(maxExpectedDuration);
if (res != OK) {
ALOGE("%s: Can't pause captures to stop injection!", __FUNCTION__);
@@ -229,7 +225,7 @@
ALOGV("%s: Restarting activity to stop injection", __FUNCTION__);
// Reuse current operating mode and session parameters for new stream
// config.
- parent->internalUpdateStatusLocked(STATUS_ACTIVE);
+ parent->internalResumeLocked();
}
return OK;
@@ -243,6 +239,10 @@
}
}
+bool Camera3Device::Camera3DeviceInjectionMethods::isStreamConfigCompleteButNotInjected() {
+ return mIsStreamConfigCompleteButNotInjected;
+}
+
const String8& Camera3Device::Camera3DeviceInjectionMethods::getInjectedCamId()
const {
return mInjectedCamId;
@@ -260,10 +260,22 @@
*injectionBufferSizes = mInjectionBufferSizes;
}
+void Camera3Device::Camera3DeviceInjectionMethods::storeInjectionConfig(
+ const camera3::camera_stream_configuration& injectionConfig,
+ const std::vector<uint32_t>& injectionBufferSizes) {
+ mIsStreamConfigCompleteButNotInjected = true;
+ mInjectionConfig = injectionConfig;
+ mInjectionStreams.clear();
+ for (size_t i = 0; i < injectionConfig.num_streams; i++) {
+ mInjectionStreams.push_back(injectionConfig.streams[i]);
+ }
+ mInjectionConfig.streams = mInjectionStreams.editArray();
+ mInjectionBufferSizes = injectionBufferSizes;
+}
status_t Camera3Device::Camera3DeviceInjectionMethods::injectionConfigureStreams(
camera3::camera_stream_configuration& injectionConfig,
- std::vector<uint32_t>& injectionBufferSizes) {
+ const std::vector<uint32_t>& injectionBufferSizes) {
ATRACE_CALL();
status_t res = NO_ERROR;
@@ -326,7 +338,6 @@
mInjectedCamId.string());
auto rc = parent->mPreparerThread->resume();
-
if (rc != OK) {
ALOGE("%s: Injection camera %s: Preparer thread failed to resume!",
__FUNCTION__, mInjectedCamId.string());
@@ -339,6 +350,9 @@
void Camera3Device::Camera3DeviceInjectionMethods::injectionDisconnectImpl() {
ATRACE_CALL();
ALOGI("%s: Injection camera disconnect", __FUNCTION__);
+ mIsStreamConfigCompleteButNotInjected = false;
+ mInjectionStreams.clear();
+ mInjectionConfig.streams = nullptr;
mBackupHalInterface = nullptr;
HalInterface* interface = nullptr;
@@ -380,10 +394,18 @@
return INVALID_OPERATION;
}
- if (keepBackup && mBackupHalInterface == nullptr) {
- mBackupHalInterface = parent->mInterface;
- } else if (!keepBackup) {
+ if (keepBackup) {
+ if (mBackupHalInterface == nullptr) {
+ mBackupHalInterface = parent->mInterface;
+ }
+ if (mBackupResultMetadataQueue == nullptr) {
+ mBackupResultMetadataQueue = std::move(parent->mResultMetadataQueue);
+ parent->mResultMetadataQueue = std::move(mInjectionResultMetadataQueue);
+ }
+ } else {
mBackupHalInterface = nullptr;
+ parent->mResultMetadataQueue = std::move(mBackupResultMetadataQueue);
+ mBackupResultMetadataQueue = nullptr;
}
parent->mInterface = newHalInterface;
diff --git a/services/camera/libcameraservice/device3/Camera3IOStreamBase.cpp b/services/camera/libcameraservice/device3/Camera3IOStreamBase.cpp
index 0204d49..2f4d669 100644
--- a/services/camera/libcameraservice/device3/Camera3IOStreamBase.cpp
+++ b/services/camera/libcameraservice/device3/Camera3IOStreamBase.cpp
@@ -82,7 +82,7 @@
camera_stream::width, camera_stream::height,
camera_stream::format, camera_stream::data_space);
lines.appendFormat(" Max size: %zu\n", mMaxSize);
- lines.appendFormat(" Combined usage: %" PRIu64 ", max HAL buffers: %d\n",
+ lines.appendFormat(" Combined usage: 0x%" PRIx64 ", max HAL buffers: %d\n",
mUsage | consumerUsage, camera_stream::max_buffers);
if (strlen(camera_stream::physical_camera_id) > 0) {
lines.appendFormat(" Physical camera id: %s\n", camera_stream::physical_camera_id);
diff --git a/services/camera/libcameraservice/device3/Camera3OutputUtils.cpp b/services/camera/libcameraservice/device3/Camera3OutputUtils.cpp
index 9f225d0..ef51ada 100644
--- a/services/camera/libcameraservice/device3/Camera3OutputUtils.cpp
+++ b/services/camera/libcameraservice/device3/Camera3OutputUtils.cpp
@@ -368,7 +368,7 @@
}
states.tagMonitor.monitorMetadata(TagMonitor::RESULT,
frameNumber, sensorTimestamp, captureResult.mMetadata,
- monitoredPhysicalMetadata);
+ monitoredPhysicalMetadata, std::set<int32_t>());
insertResultLocked(states, &captureResult, frameNumber);
}
diff --git a/services/camera/libcameraservice/utils/TagMonitor.cpp b/services/camera/libcameraservice/utils/TagMonitor.cpp
index 262f962..53a92e9 100644
--- a/services/camera/libcameraservice/utils/TagMonitor.cpp
+++ b/services/camera/libcameraservice/utils/TagMonitor.cpp
@@ -112,11 +112,14 @@
mLastMonitoredResultValues.clear();
mLastMonitoredPhysicalRequestKeys.clear();
mLastMonitoredPhysicalResultKeys.clear();
+ mLastStreamIds.clear();
+ mLastInputStreamId = -1;
}
void TagMonitor::monitorMetadata(eventSource source, int64_t frameNumber, nsecs_t timestamp,
const CameraMetadata& metadata,
- const std::unordered_map<std::string, CameraMetadata>& physicalMetadata) {
+ const std::unordered_map<std::string, CameraMetadata>& physicalMetadata,
+ const std::set<int32_t> &outputStreamIds, int32_t inputStreamId) {
if (!mMonitoringEnabled) return;
std::lock_guard<std::mutex> lock(mMonitorMutex);
@@ -127,16 +130,19 @@
std::string emptyId;
for (auto tag : mMonitoredTagList) {
- monitorSingleMetadata(source, frameNumber, timestamp, emptyId, tag, metadata);
+ monitorSingleMetadata(source, frameNumber, timestamp, emptyId, tag, metadata,
+ outputStreamIds, inputStreamId);
for (auto& m : physicalMetadata) {
- monitorSingleMetadata(source, frameNumber, timestamp, m.first, tag, m.second);
+ monitorSingleMetadata(source, frameNumber, timestamp, m.first, tag, m.second,
+ outputStreamIds, inputStreamId);
}
}
}
void TagMonitor::monitorSingleMetadata(eventSource source, int64_t frameNumber, nsecs_t timestamp,
- const std::string& cameraId, uint32_t tag, const CameraMetadata& metadata) {
+ const std::string& cameraId, uint32_t tag, const CameraMetadata& metadata,
+ const std::set<int32_t> &outputStreamIds, int32_t inputStreamId) {
CameraMetadata &lastValues = (source == REQUEST) ?
(cameraId.empty() ? mLastMonitoredRequestValues :
@@ -177,13 +183,21 @@
// No last entry, so always consider to be different
isDifferent = true;
}
-
+ // Also monitor when the stream ids change, this helps visually see what
+ // monitored metadata values are for capture requests with different
+ // stream ids.
+ if (inputStreamId != mLastInputStreamId || outputStreamIds != mLastStreamIds) {
+ mLastInputStreamId = inputStreamId;
+ mLastStreamIds = outputStreamIds;
+ isDifferent = true;
+ }
if (isDifferent) {
ALOGV("%s: Tag %s changed", __FUNCTION__,
get_local_camera_metadata_tag_name_vendor_id(
tag, mVendorTagId));
lastValues.update(entry);
- mMonitoringEvents.emplace(source, frameNumber, timestamp, entry, cameraId);
+ mMonitoringEvents.emplace(source, frameNumber, timestamp, entry, cameraId,
+ outputStreamIds, inputStreamId);
}
} else if (lastEntry.count > 0) {
// Value has been removed
@@ -195,7 +209,10 @@
entry.type = get_local_camera_metadata_tag_type_vendor_id(tag,
mVendorTagId);
entry.count = 0;
- mMonitoringEvents.emplace(source, frameNumber, timestamp, entry, cameraId);
+ mLastInputStreamId = inputStreamId;
+ mLastStreamIds = outputStreamIds;
+ mMonitoringEvents.emplace(source, frameNumber, timestamp, entry, cameraId, outputStreamIds,
+ inputStreamId);
}
}
@@ -232,7 +249,7 @@
} else {
printData(fd, event.newData.data(), event.tag,
event.type, event.newData.size() / camera_metadata_type_size[event.type],
- indentation + 18);
+ indentation + 18, event.outputStreamIds, event.inputStreamId);
}
}
}
@@ -244,7 +261,8 @@
#define CAMERA_METADATA_ENUM_STRING_MAX_SIZE 29
void TagMonitor::printData(int fd, const uint8_t *data_ptr, uint32_t tag,
- int type, int count, int indentation) {
+ int type, int count, int indentation, const std::set<int32_t> &outputStreamIds,
+ int32_t inputStreamId) {
static int values_per_line[NUM_TYPES] = {
[TYPE_BYTE] = 16,
[TYPE_INT32] = 8,
@@ -319,20 +337,31 @@
dprintf(fd, "??? ");
}
}
- dprintf(fd, "]\n");
+ dprintf(fd, "] ");
+ if (outputStreamIds.size() > 0) {
+ dprintf(fd, "output stream ids: ");
+ for (const auto &id : outputStreamIds) {
+ dprintf(fd, " %d ", id);
+ }
+ }
+ if (inputStreamId != -1) {
+ dprintf(fd, "input stream id: %d", inputStreamId);
+ }
+ dprintf(fd, "\n");
}
}
template<typename T>
TagMonitor::MonitorEvent::MonitorEvent(eventSource src, uint32_t frameNumber, nsecs_t timestamp,
- const T &value, const std::string& cameraId) :
+ const T &value, const std::string& cameraId, const std::set<int32_t> &outputStreamIds,
+ int32_t inputStreamId) :
source(src),
frameNumber(frameNumber),
timestamp(timestamp),
tag(value.tag),
type(value.type),
newData(value.data.u8, value.data.u8 + camera_metadata_type_size[value.type] * value.count),
- cameraId(cameraId) {
+ cameraId(cameraId), outputStreamIds(outputStreamIds), inputStreamId(inputStreamId) {
}
TagMonitor::MonitorEvent::~MonitorEvent() {
diff --git a/services/camera/libcameraservice/utils/TagMonitor.h b/services/camera/libcameraservice/utils/TagMonitor.h
index 413f502..dfc424e 100644
--- a/services/camera/libcameraservice/utils/TagMonitor.h
+++ b/services/camera/libcameraservice/utils/TagMonitor.h
@@ -20,6 +20,7 @@
#include <vector>
#include <atomic>
#include <mutex>
+#include <set>
#include <unordered_map>
#include <utils/RefBase.h>
@@ -66,7 +67,8 @@
// Scan through the metadata and update the monitoring information
void monitorMetadata(eventSource source, int64_t frameNumber,
nsecs_t timestamp, const CameraMetadata& metadata,
- const std::unordered_map<std::string, CameraMetadata>& physicalMetadata);
+ const std::unordered_map<std::string, CameraMetadata>& physicalMetadata,
+ const std::set<int32_t> &outputStreamIds, int32_t inputStreamId = -1);
// Dump current event log to the provided fd
void dumpMonitoredMetadata(int fd);
@@ -74,11 +76,13 @@
private:
static void printData(int fd, const uint8_t *data_ptr, uint32_t tag,
- int type, int count, int indentation);
+ int type, int count, int indentation, const std::set<int32_t> &outputStreamIds,
+ int32_t inputStreamId);
void monitorSingleMetadata(TagMonitor::eventSource source, int64_t frameNumber,
nsecs_t timestamp, const std::string& cameraId, uint32_t tag,
- const CameraMetadata& metadata);
+ const CameraMetadata& metadata, const std::set<int32_t> &outputStreamIds,
+ int32_t inputStreamId);
std::atomic<bool> mMonitoringEnabled;
std::mutex mMonitorMutex;
@@ -93,6 +97,9 @@
std::unordered_map<std::string, CameraMetadata> mLastMonitoredPhysicalRequestKeys;
std::unordered_map<std::string, CameraMetadata> mLastMonitoredPhysicalResultKeys;
+ int32_t mLastInputStreamId = -1;
+ std::set<int32_t> mLastStreamIds;
+
/**
* A monitoring event
* Stores a new metadata field value and the timestamp at which it changed.
@@ -101,7 +108,8 @@
struct MonitorEvent {
template<typename T>
MonitorEvent(eventSource src, uint32_t frameNumber, nsecs_t timestamp,
- const T &newValue, const std::string& cameraId);
+ const T &newValue, const std::string& cameraId,
+ const std::set<int32_t> &outputStreamIds, int32_t inputStreamId);
~MonitorEvent();
eventSource source;
@@ -111,6 +119,8 @@
uint8_t type;
std::vector<uint8_t> newData;
std::string cameraId;
+ std::set<int32_t> outputStreamIds;
+ int32_t inputStreamId = 1;
};
// A ring buffer for tracking the last kMaxMonitorEvents metadata changes
diff --git a/services/tuner/.clang-format b/services/tuner/.clang-format
new file mode 100644
index 0000000..f14cc88
--- /dev/null
+++ b/services/tuner/.clang-format
@@ -0,0 +1,33 @@
+---
+BasedOnStyle: Google
+AllowShortFunctionsOnASingleLine: Inline
+AllowShortIfStatementsOnASingleLine: true
+AllowShortLoopsOnASingleLine: true
+BinPackArguments: true
+BinPackParameters: true
+CommentPragmas: NOLINT:.*
+ContinuationIndentWidth: 8
+DerivePointerAlignment: false
+IndentWidth: 4
+PointerAlignment: Left
+TabWidth: 4
+
+# Deviations from the above file:
+# "Don't indent the section label"
+AccessModifierOffset: -4
+# "Each line of text in your code should be at most 100 columns long."
+ColumnLimit: 100
+# "Constructor initializer lists can be all on one line or with subsequent
+# lines indented eight spaces.". clang-format does not support having the colon
+# on the same line as the constructor function name, so this is the best
+# approximation of that rule, which makes all entries in the list (except the
+# first one) have an eight space indentation.
+ConstructorInitializerIndentWidth: 6
+# There is nothing in go/droidcppstyle about case labels, but there seems to be
+# more code that does not indent the case labels in frameworks/base.
+IndentCaseLabels: false
+# There have been some bugs in which subsequent formatting operations introduce
+# weird comment jumps.
+ReflowComments: false
+# Android does support C++11 now.
+Standard: Cpp11
\ No newline at end of file
diff --git a/services/tuner/Android.bp b/services/tuner/Android.bp
index b12afde..8a1d45c 100644
--- a/services/tuner/Android.bp
+++ b/services/tuner/Android.bp
@@ -7,33 +7,15 @@
default_applicable_licenses: ["frameworks_av_license"],
}
-filegroup {
- name: "tv_tuner_aidl",
- srcs: [
- "aidl/android/media/tv/tuner/*.aidl",
- ],
- path: "aidl",
-}
-
-filegroup {
- name: "tv_tuner_frontend_info",
- srcs: [
- "aidl/android/media/tv/tuner/TunerFrontendInfo.aidl",
- "aidl/android/media/tv/tuner/TunerFrontend*Capabilities.aidl",
- ],
- path: "aidl",
-}
-
aidl_interface {
name: "tv_tuner_aidl_interface",
unstable: true,
local_include_dir: "aidl",
- srcs: [
- ":tv_tuner_aidl",
- ],
+ srcs: ["aidl/android/media/tv/tuner/*.aidl"],
imports: [
"android.hardware.common-V2",
"android.hardware.common.fmq-V1",
+ "android.hardware.tv.tuner-V1",
],
backend: {
@@ -49,27 +31,6 @@
},
}
-aidl_interface {
- name: "tv_tuner_frontend_info_aidl_interface",
- unstable: true,
- local_include_dir: "aidl",
- srcs: [
- ":tv_tuner_frontend_info",
- ],
-
- backend: {
- java: {
- enabled: true,
- },
- cpp: {
- enabled: true,
- },
- ndk: {
- enabled: true,
- },
- },
-}
-
cc_library {
name: "libtunerservice",
@@ -78,8 +39,7 @@
],
shared_libs: [
- "android.hardware.tv.tuner@1.0",
- "android.hardware.tv.tuner@1.1",
+ "android.hardware.tv.tuner-V1-ndk",
"libbase",
"libbinder",
"libbinder_ndk",
@@ -91,7 +51,6 @@
"libutils",
"tv_tuner_aidl_interface-ndk",
"tv_tuner_resource_manager_aidl_interface-ndk",
- "tv_tuner_resource_manager_aidl_interface-cpp",
],
static_libs: [
@@ -120,8 +79,7 @@
],
shared_libs: [
- "android.hardware.tv.tuner@1.0",
- "android.hardware.tv.tuner@1.1",
+ "android.hardware.tv.tuner-V1-ndk",
"libbase",
"libbinder",
"libfmq",
@@ -129,7 +87,6 @@
"libtunerservice",
"libutils",
"tv_tuner_resource_manager_aidl_interface-ndk",
- "tv_tuner_resource_manager_aidl_interface-cpp",
],
static_libs: [
diff --git a/services/tuner/OWNERS b/services/tuner/OWNERS
index 0ceb8e8..bf9fe34 100644
--- a/services/tuner/OWNERS
+++ b/services/tuner/OWNERS
@@ -1,2 +1,2 @@
-nchalko@google.com
+hgchen@google.com
quxiangfang@google.com
diff --git a/services/tuner/TunerDemux.cpp b/services/tuner/TunerDemux.cpp
index 1122368..34efe01 100644
--- a/services/tuner/TunerDemux.cpp
+++ b/services/tuner/TunerDemux.cpp
@@ -16,23 +16,32 @@
#define LOG_TAG "TunerDemux"
-#include "TunerDvr.h"
#include "TunerDemux.h"
+
+#include <aidl/android/hardware/tv/tuner/IDvr.h>
+#include <aidl/android/hardware/tv/tuner/IDvrCallback.h>
+#include <aidl/android/hardware/tv/tuner/IFilter.h>
+#include <aidl/android/hardware/tv/tuner/IFilterCallback.h>
+#include <aidl/android/hardware/tv/tuner/ITimeFilter.h>
+#include <aidl/android/hardware/tv/tuner/Result.h>
+
+#include "TunerDvr.h"
#include "TunerTimeFilter.h"
-using ::android::hardware::tv::tuner::V1_0::DemuxAlpFilterType;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterMainType;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterType;
-using ::android::hardware::tv::tuner::V1_0::DemuxIpFilterType;
-using ::android::hardware::tv::tuner::V1_0::DemuxMmtpFilterType;
-using ::android::hardware::tv::tuner::V1_0::DemuxTlvFilterType;
-using ::android::hardware::tv::tuner::V1_0::DemuxTsFilterType;
-using ::android::hardware::tv::tuner::V1_0::DvrType;
-using ::android::hardware::tv::tuner::V1_0::Result;
+using ::aidl::android::hardware::tv::tuner::IDvr;
+using ::aidl::android::hardware::tv::tuner::IDvrCallback;
+using ::aidl::android::hardware::tv::tuner::IFilter;
+using ::aidl::android::hardware::tv::tuner::IFilterCallback;
+using ::aidl::android::hardware::tv::tuner::ITimeFilter;
+using ::aidl::android::hardware::tv::tuner::Result;
+namespace aidl {
namespace android {
+namespace media {
+namespace tv {
+namespace tuner {
-TunerDemux::TunerDemux(sp<IDemux> demux, int id) {
+TunerDemux::TunerDemux(shared_ptr<IDemux> demux, int id) {
mDemux = demux;
mDemuxId = id;
}
@@ -41,192 +50,141 @@
mDemux = nullptr;
}
-Status TunerDemux::setFrontendDataSource(const std::shared_ptr<ITunerFrontend>& frontend) {
+::ndk::ScopedAStatus TunerDemux::setFrontendDataSource(
+ const shared_ptr<ITunerFrontend>& in_frontend) {
if (mDemux == nullptr) {
ALOGE("IDemux is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
int frontendId;
- frontend->getFrontendId(&frontendId);
- Result res = mDemux->setFrontendDataSource(frontendId);
- if (res != Result::SUCCESS) {
- return ::ndk::ScopedAStatus::fromServiceSpecificError(static_cast<int32_t>(res));
- }
- return Status::ok();
+ in_frontend->getFrontendId(&frontendId);
+
+ return mDemux->setFrontendDataSource(frontendId);
}
-Status TunerDemux::openFilter(
- int type, int subType, int bufferSize, const std::shared_ptr<ITunerFilterCallback>& cb,
- std::shared_ptr<ITunerFilter>* _aidl_return) {
+::ndk::ScopedAStatus TunerDemux::setFrontendDataSourceById(int frontendId) {
+ if (mDemux == nullptr) {
+ ALOGE("IDemux is not initialized");
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
+ }
+
+ return mDemux->setFrontendDataSource(frontendId);
+}
+
+::ndk::ScopedAStatus TunerDemux::openFilter(const DemuxFilterType& in_type, int32_t in_bufferSize,
+ const shared_ptr<ITunerFilterCallback>& in_cb,
+ shared_ptr<ITunerFilter>* _aidl_return) {
+ if (mDemux == nullptr) {
+ ALOGE("IDemux is not initialized");
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
+ }
+
+ shared_ptr<IFilter> filter;
+ shared_ptr<IFilterCallback> cb = ::ndk::SharedRefBase::make<TunerFilter::FilterCallback>(in_cb);
+ auto status = mDemux->openFilter(in_type, in_bufferSize, cb, &filter);
+ if (status.isOk()) {
+ *_aidl_return = ::ndk::SharedRefBase::make<TunerFilter>(filter, in_type);
+ }
+
+ return status;
+}
+
+::ndk::ScopedAStatus TunerDemux::openTimeFilter(shared_ptr<ITunerTimeFilter>* _aidl_return) {
if (mDemux == nullptr) {
ALOGE("IDemux is not initialized.");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- DemuxFilterMainType mainType = static_cast<DemuxFilterMainType>(type);
- DemuxFilterType filterType {
- .mainType = mainType,
- };
-
- switch(mainType) {
- case DemuxFilterMainType::TS:
- filterType.subType.tsFilterType(static_cast<DemuxTsFilterType>(subType));
- break;
- case DemuxFilterMainType::MMTP:
- filterType.subType.mmtpFilterType(static_cast<DemuxMmtpFilterType>(subType));
- break;
- case DemuxFilterMainType::IP:
- filterType.subType.ipFilterType(static_cast<DemuxIpFilterType>(subType));
- break;
- case DemuxFilterMainType::TLV:
- filterType.subType.tlvFilterType(static_cast<DemuxTlvFilterType>(subType));
- break;
- case DemuxFilterMainType::ALP:
- filterType.subType.alpFilterType(static_cast<DemuxAlpFilterType>(subType));
- break;
- }
- Result status;
- sp<IFilter> filterSp;
- sp<IFilterCallback> cbSp = new TunerFilter::FilterCallback(cb);
- mDemux->openFilter(filterType, bufferSize, cbSp,
- [&](Result r, const sp<IFilter>& filter) {
- filterSp = filter;
- status = r;
- });
- if (status != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(status));
+ shared_ptr<ITimeFilter> filter;
+ auto status = mDemux->openTimeFilter(&filter);
+ if (status.isOk()) {
+ *_aidl_return = ::ndk::SharedRefBase::make<TunerTimeFilter>(filter);
}
- *_aidl_return = ::ndk::SharedRefBase::make<TunerFilter>(filterSp, type, subType);
- return Status::ok();
+ return status;
}
-Status TunerDemux::openTimeFilter(shared_ptr<ITunerTimeFilter>* _aidl_return) {
+::ndk::ScopedAStatus TunerDemux::getAvSyncHwId(const shared_ptr<ITunerFilter>& tunerFilter,
+ int32_t* _aidl_return) {
if (mDemux == nullptr) {
ALOGE("IDemux is not initialized.");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result status;
- sp<ITimeFilter> filterSp;
- mDemux->openTimeFilter([&](Result r, const sp<ITimeFilter>& filter) {
- filterSp = filter;
- status = r;
- });
- if (status != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(status));
- }
-
- *_aidl_return = ::ndk::SharedRefBase::make<TunerTimeFilter>(filterSp);
- return Status::ok();
+ shared_ptr<IFilter> halFilter = (static_cast<TunerFilter*>(tunerFilter.get()))->getHalFilter();
+ return mDemux->getAvSyncHwId(halFilter, _aidl_return);
}
-Status TunerDemux::getAvSyncHwId(const shared_ptr<ITunerFilter>& tunerFilter, int* _aidl_return) {
+::ndk::ScopedAStatus TunerDemux::getAvSyncTime(int32_t avSyncHwId, int64_t* _aidl_return) {
if (mDemux == nullptr) {
ALOGE("IDemux is not initialized.");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- uint32_t avSyncHwId;
- Result res;
- sp<IFilter> halFilter = static_cast<TunerFilter*>(tunerFilter.get())->getHalFilter();
- mDemux->getAvSyncHwId(halFilter,
- [&](Result r, uint32_t id) {
- res = r;
- avSyncHwId = id;
- });
- if (res != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
- }
-
- *_aidl_return = (int)avSyncHwId;
- return Status::ok();
+ return mDemux->getAvSyncTime(avSyncHwId, _aidl_return);
}
-Status TunerDemux::getAvSyncTime(int avSyncHwId, int64_t* _aidl_return) {
+::ndk::ScopedAStatus TunerDemux::openDvr(DvrType in_dvbType, int32_t in_bufferSize,
+ const shared_ptr<ITunerDvrCallback>& in_cb,
+ shared_ptr<ITunerDvr>* _aidl_return) {
if (mDemux == nullptr) {
ALOGE("IDemux is not initialized.");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- uint64_t time;
- Result res;
- mDemux->getAvSyncTime(static_cast<uint32_t>(avSyncHwId),
- [&](Result r, uint64_t ts) {
- res = r;
- time = ts;
- });
- if (res != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
+ shared_ptr<IDvrCallback> callback = ::ndk::SharedRefBase::make<TunerDvr::DvrCallback>(in_cb);
+ shared_ptr<IDvr> halDvr;
+ auto res = mDemux->openDvr(in_dvbType, in_bufferSize, callback, &halDvr);
+ if (res.isOk()) {
+ *_aidl_return = ::ndk::SharedRefBase::make<TunerDvr>(halDvr, in_dvbType);
}
- *_aidl_return = (int64_t)time;
- return Status::ok();
+ return res;
}
-Status TunerDemux::openDvr(int dvrType, int bufferSize, const shared_ptr<ITunerDvrCallback>& cb,
- shared_ptr<ITunerDvr>* _aidl_return) {
+::ndk::ScopedAStatus TunerDemux::connectCiCam(int32_t ciCamId) {
if (mDemux == nullptr) {
ALOGE("IDemux is not initialized.");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result res;
- sp<IDvrCallback> callback = new TunerDvr::DvrCallback(cb);
- sp<IDvr> hidlDvr;
- mDemux->openDvr(static_cast<DvrType>(dvrType), bufferSize, callback,
- [&](Result r, const sp<IDvr>& dvr) {
- hidlDvr = dvr;
- res = r;
- });
- if (res != Result::SUCCESS) {
- *_aidl_return = NULL;
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
- }
-
- *_aidl_return = ::ndk::SharedRefBase::make<TunerDvr>(hidlDvr, dvrType);
- return Status::ok();
+ return mDemux->connectCiCam(ciCamId);
}
-Status TunerDemux::connectCiCam(int ciCamId) {
+::ndk::ScopedAStatus TunerDemux::disconnectCiCam() {
if (mDemux == nullptr) {
ALOGE("IDemux is not initialized.");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result res = mDemux->connectCiCam(static_cast<uint32_t>(ciCamId));
- if (res != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
- }
- return Status::ok();
+ return mDemux->disconnectCiCam();
}
-Status TunerDemux::disconnectCiCam() {
+::ndk::ScopedAStatus TunerDemux::close() {
if (mDemux == nullptr) {
ALOGE("IDemux is not initialized.");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result res = mDemux->disconnectCiCam();
- if (res != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
- }
- return Status::ok();
+ auto res = mDemux->close();
+ mDemux = nullptr;
+
+ return res;
}
-Status TunerDemux::close() {
- if (mDemux == nullptr) {
- ALOGE("IDemux is not initialized.");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
- }
-
- Result res = mDemux->close();
- mDemux = NULL;
-
- if (res != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
- }
- return Status::ok();
-}
+} // namespace tuner
+} // namespace tv
+} // namespace media
} // namespace android
+} // namespace aidl
diff --git a/services/tuner/TunerDemux.h b/services/tuner/TunerDemux.h
index 2a9836b..cdb3aa0 100644
--- a/services/tuner/TunerDemux.h
+++ b/services/tuner/TunerDemux.h
@@ -17,52 +17,55 @@
#ifndef ANDROID_MEDIA_TUNERDEMUX_H
#define ANDROID_MEDIA_TUNERDEMUX_H
+#include <aidl/android/hardware/tv/tuner/IDemux.h>
#include <aidl/android/media/tv/tuner/BnTunerDemux.h>
-#include <android/hardware/tv/tuner/1.0/ITuner.h>
-using Status = ::ndk::ScopedAStatus;
-using ::aidl::android::media::tv::tuner::BnTunerDemux;
-using ::aidl::android::media::tv::tuner::ITunerDvr;
-using ::aidl::android::media::tv::tuner::ITunerDvrCallback;
-using ::aidl::android::media::tv::tuner::ITunerFilter;
-using ::aidl::android::media::tv::tuner::ITunerFilterCallback;
-using ::aidl::android::media::tv::tuner::ITunerFrontend;
-using ::aidl::android::media::tv::tuner::ITunerTimeFilter;
-using ::android::hardware::tv::tuner::V1_0::IDemux;
-using ::android::hardware::tv::tuner::V1_0::IDvr;
-using ::android::hardware::tv::tuner::V1_0::IDvrCallback;
-using ::android::hardware::tv::tuner::V1_0::ITimeFilter;
+using ::aidl::android::hardware::tv::tuner::DemuxFilterType;
+using ::aidl::android::hardware::tv::tuner::DvrType;
+using ::aidl::android::hardware::tv::tuner::IDemux;
using namespace std;
+namespace aidl {
namespace android {
+namespace media {
+namespace tv {
+namespace tuner {
class TunerDemux : public BnTunerDemux {
public:
- TunerDemux(sp<IDemux> demux, int demuxId);
+ TunerDemux(shared_ptr<IDemux> demux, int demuxId);
virtual ~TunerDemux();
- Status setFrontendDataSource(const shared_ptr<ITunerFrontend>& frontend) override;
- Status openFilter(
- int mainType, int subtype, int bufferSize, const shared_ptr<ITunerFilterCallback>& cb,
- shared_ptr<ITunerFilter>* _aidl_return) override;
- Status openTimeFilter(shared_ptr<ITunerTimeFilter>* _aidl_return) override;
- Status getAvSyncHwId(const shared_ptr<ITunerFilter>& tunerFilter, int* _aidl_return) override;
- Status getAvSyncTime(int avSyncHwId, int64_t* _aidl_return) override;
- Status openDvr(
- int dvbType, int bufferSize, const shared_ptr<ITunerDvrCallback>& cb,
- shared_ptr<ITunerDvr>* _aidl_return) override;
- Status connectCiCam(int ciCamId) override;
- Status disconnectCiCam() override;
- Status close() override;
+
+ ::ndk::ScopedAStatus setFrontendDataSource(
+ const shared_ptr<ITunerFrontend>& in_frontend) override;
+ ::ndk::ScopedAStatus setFrontendDataSourceById(int frontendId) override;
+ ::ndk::ScopedAStatus openFilter(const DemuxFilterType& in_type, int32_t in_bufferSize,
+ const shared_ptr<ITunerFilterCallback>& in_cb,
+ shared_ptr<ITunerFilter>* _aidl_return) override;
+ ::ndk::ScopedAStatus openTimeFilter(shared_ptr<ITunerTimeFilter>* _aidl_return) override;
+ ::ndk::ScopedAStatus getAvSyncHwId(const shared_ptr<ITunerFilter>& in_tunerFilter,
+ int32_t* _aidl_return) override;
+ ::ndk::ScopedAStatus getAvSyncTime(int32_t in_avSyncHwId, int64_t* _aidl_return) override;
+ ::ndk::ScopedAStatus openDvr(DvrType in_dvbType, int32_t in_bufferSize,
+ const shared_ptr<ITunerDvrCallback>& in_cb,
+ shared_ptr<ITunerDvr>* _aidl_return) override;
+ ::ndk::ScopedAStatus connectCiCam(int32_t in_ciCamId) override;
+ ::ndk::ScopedAStatus disconnectCiCam() override;
+ ::ndk::ScopedAStatus close() override;
int getId() { return mDemuxId; }
private:
- sp<IDemux> mDemux;
+ shared_ptr<IDemux> mDemux;
int mDemuxId;
};
-} // namespace android
+} // namespace tuner
+} // namespace tv
+} // namespace media
+} // namespace android
+} // namespace aidl
#endif // ANDROID_MEDIA_TUNERDEMUX_H
diff --git a/services/tuner/TunerDescrambler.cpp b/services/tuner/TunerDescrambler.cpp
index b7ae167..8e2d6c7 100644
--- a/services/tuner/TunerDescrambler.cpp
+++ b/services/tuner/TunerDescrambler.cpp
@@ -16,17 +16,26 @@
#define LOG_TAG "TunerDescrambler"
-#include "TunerFilter.h"
-#include "TunerDemux.h"
#include "TunerDescrambler.h"
-using ::android::hardware::tv::tuner::V1_0::Result;
+#include <aidl/android/hardware/tv/tuner/IFilter.h>
+#include <aidl/android/hardware/tv/tuner/Result.h>
+
+#include "TunerDemux.h"
+#include "TunerFilter.h"
+
+using ::aidl::android::hardware::tv::tuner::IFilter;
+using ::aidl::android::hardware::tv::tuner::Result;
using namespace std;
+namespace aidl {
namespace android {
+namespace media {
+namespace tv {
+namespace tuner {
-TunerDescrambler::TunerDescrambler(sp<IDescrambler> descrambler) {
+TunerDescrambler::TunerDescrambler(shared_ptr<IDescrambler> descrambler) {
mDescrambler = descrambler;
}
@@ -34,91 +43,74 @@
mDescrambler = nullptr;
}
-Status TunerDescrambler::setDemuxSource(const std::shared_ptr<ITunerDemux>& demux) {
+::ndk::ScopedAStatus TunerDescrambler::setDemuxSource(
+ const shared_ptr<ITunerDemux>& in_tunerDemux) {
if (mDescrambler == nullptr) {
ALOGE("IDescrambler is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result res = mDescrambler->setDemuxSource(static_cast<TunerDemux*>(demux.get())->getId());
- if (res != Result::SUCCESS) {
- return ::ndk::ScopedAStatus::fromServiceSpecificError(static_cast<int32_t>(res));
- }
- return Status::ok();
+ return mDescrambler->setDemuxSource((static_cast<TunerDemux*>(in_tunerDemux.get()))->getId());
}
-Status TunerDescrambler::setKeyToken(const vector<uint8_t>& keyToken) {
+::ndk::ScopedAStatus TunerDescrambler::setKeyToken(const vector<uint8_t>& in_keyToken) {
if (mDescrambler == nullptr) {
ALOGE("IDescrambler is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result res = mDescrambler->setKeyToken(keyToken);
- if (res != Result::SUCCESS) {
- return ::ndk::ScopedAStatus::fromServiceSpecificError(static_cast<int32_t>(res));
- }
- return Status::ok();
+ return mDescrambler->setKeyToken(in_keyToken);
}
-Status TunerDescrambler::addPid(const TunerDemuxPid& pid,
- const shared_ptr<ITunerFilter>& optionalSourceFilter) {
+::ndk::ScopedAStatus TunerDescrambler::addPid(
+ const DemuxPid& in_pid, const shared_ptr<ITunerFilter>& in_optionalSourceFilter) {
if (mDescrambler == nullptr) {
ALOGE("IDescrambler is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- sp<IFilter> halFilter = (optionalSourceFilter == NULL)
- ? NULL : static_cast<TunerFilter*>(optionalSourceFilter.get())->getHalFilter();
- Result res = mDescrambler->addPid(getHidlDemuxPid(pid), halFilter);
- if (res != Result::SUCCESS) {
- return ::ndk::ScopedAStatus::fromServiceSpecificError(static_cast<int32_t>(res));
- }
- return Status::ok();
+ shared_ptr<IFilter> halFilter =
+ (in_optionalSourceFilter == nullptr)
+ ? nullptr
+ : static_cast<TunerFilter*>(in_optionalSourceFilter.get())->getHalFilter();
+
+ return mDescrambler->addPid(in_pid, halFilter);
}
-Status TunerDescrambler::removePid(const TunerDemuxPid& pid,
- const shared_ptr<ITunerFilter>& optionalSourceFilter) {
+::ndk::ScopedAStatus TunerDescrambler::removePid(
+ const DemuxPid& in_pid, const shared_ptr<ITunerFilter>& in_optionalSourceFilter) {
if (mDescrambler == nullptr) {
ALOGE("IDescrambler is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- sp<IFilter> halFilter = (optionalSourceFilter == NULL)
- ? NULL : static_cast<TunerFilter*>(optionalSourceFilter.get())->getHalFilter();
- Result res = mDescrambler->removePid(getHidlDemuxPid(pid), halFilter);
- if (res != Result::SUCCESS) {
- return ::ndk::ScopedAStatus::fromServiceSpecificError(static_cast<int32_t>(res));
- }
- return Status::ok();
+ shared_ptr<IFilter> halFilter =
+ (in_optionalSourceFilter == nullptr)
+ ? nullptr
+ : static_cast<TunerFilter*>(in_optionalSourceFilter.get())->getHalFilter();
+
+ return mDescrambler->removePid(in_pid, halFilter);
}
-Status TunerDescrambler::close() {
+::ndk::ScopedAStatus TunerDescrambler::close() {
if (mDescrambler == nullptr) {
ALOGE("IDescrambler is not initialized.");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result res = mDescrambler->close();
- mDescrambler = NULL;
+ auto res = mDescrambler->close();
+ mDescrambler = nullptr;
- if (res != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
- }
- return Status::ok();
+ return res;
}
-DemuxPid TunerDescrambler::getHidlDemuxPid(const TunerDemuxPid& pid) {
- DemuxPid hidlPid;
- switch (pid.getTag()) {
- case TunerDemuxPid::tPid: {
- hidlPid.tPid((uint16_t)pid.get<TunerDemuxPid::tPid>());
- break;
- }
- case TunerDemuxPid::mmtpPid: {
- hidlPid.mmtpPid((uint16_t)pid.get<TunerDemuxPid::mmtpPid>());
- break;
- }
- }
- return hidlPid;
-}
+} // namespace tuner
+} // namespace tv
+} // namespace media
} // namespace android
+} // namespace aidl
diff --git a/services/tuner/TunerDescrambler.h b/services/tuner/TunerDescrambler.h
index 1970fb7..b1d5fb9 100644
--- a/services/tuner/TunerDescrambler.h
+++ b/services/tuner/TunerDescrambler.h
@@ -17,38 +17,43 @@
#ifndef ANDROID_MEDIA_TUNERDESCRAMBLER_H
#define ANDROID_MEDIA_TUNERDESCRAMBLER_H
+#include <aidl/android/hardware/tv/tuner/IDescrambler.h>
#include <aidl/android/media/tv/tuner/BnTunerDescrambler.h>
-#include <android/hardware/tv/tuner/1.0/ITuner.h>
-using Status = ::ndk::ScopedAStatus;
-using ::aidl::android::media::tv::tuner::BnTunerDescrambler;
-using ::aidl::android::media::tv::tuner::ITunerDemux;
-using ::aidl::android::media::tv::tuner::ITunerFilter;
-using ::aidl::android::media::tv::tuner::TunerDemuxPid;
-using ::android::hardware::tv::tuner::V1_0::DemuxPid;
-using ::android::hardware::tv::tuner::V1_0::IDescrambler;
+using ::aidl::android::hardware::tv::tuner::DemuxPid;
+using ::aidl::android::hardware::tv::tuner::IDescrambler;
+using namespace std;
+
+namespace aidl {
namespace android {
+namespace media {
+namespace tv {
+namespace tuner {
class TunerDescrambler : public BnTunerDescrambler {
public:
- TunerDescrambler(sp<IDescrambler> descrambler);
+ TunerDescrambler(shared_ptr<IDescrambler> descrambler);
virtual ~TunerDescrambler();
- Status setDemuxSource(const shared_ptr<ITunerDemux>& demux) override;
- Status setKeyToken(const vector<uint8_t>& keyToken) override;
- Status addPid(const TunerDemuxPid& pid,
- const shared_ptr<ITunerFilter>& optionalSourceFilter) override;
- Status removePid(const TunerDemuxPid& pid,
- const shared_ptr<ITunerFilter>& optionalSourceFilter) override;
- Status close() override;
+
+ ::ndk::ScopedAStatus setDemuxSource(const shared_ptr<ITunerDemux>& in_tunerDemux) override;
+ ::ndk::ScopedAStatus setKeyToken(const vector<uint8_t>& in_keyToken) override;
+ ::ndk::ScopedAStatus addPid(const DemuxPid& in_pid,
+ const shared_ptr<ITunerFilter>& in_optionalSourceFilter) override;
+ ::ndk::ScopedAStatus removePid(
+ const DemuxPid& in_pid,
+ const shared_ptr<ITunerFilter>& in_optionalSourceFilter) override;
+ ::ndk::ScopedAStatus close() override;
private:
- DemuxPid getHidlDemuxPid(const TunerDemuxPid& pid);
-
- sp<IDescrambler> mDescrambler;
+ shared_ptr<IDescrambler> mDescrambler;
};
-} // namespace android
+} // namespace tuner
+} // namespace tv
+} // namespace media
+} // namespace android
+} // namespace aidl
#endif // ANDROID_MEDIA_TUNERDESCRAMBLER_H
diff --git a/services/tuner/TunerDvr.cpp b/services/tuner/TunerDvr.cpp
index db4e07b..fb03b06 100644
--- a/services/tuner/TunerDvr.cpp
+++ b/services/tuner/TunerDvr.cpp
@@ -16,194 +16,151 @@
#define LOG_TAG "TunerDvr"
-#include <fmq/ConvertMQDescriptors.h>
#include "TunerDvr.h"
+
+#include <aidl/android/hardware/tv/tuner/Result.h>
+
#include "TunerFilter.h"
-using ::android::hardware::tv::tuner::V1_0::DataFormat;
-using ::android::hardware::tv::tuner::V1_0::Result;
+using ::aidl::android::hardware::tv::tuner::Result;
+namespace aidl {
namespace android {
+namespace media {
+namespace tv {
+namespace tuner {
-TunerDvr::TunerDvr(sp<IDvr> dvr, int type) {
+TunerDvr::TunerDvr(shared_ptr<IDvr> dvr, DvrType type) {
mDvr = dvr;
- mType = static_cast<DvrType>(type);
+ mType = type;
}
TunerDvr::~TunerDvr() {
- mDvr = NULL;
+ mDvr = nullptr;
}
-Status TunerDvr::getQueueDesc(AidlMQDesc* _aidl_return) {
- if (mDvr == NULL) {
+::ndk::ScopedAStatus TunerDvr::getQueueDesc(AidlMQDesc* _aidl_return) {
+ if (mDvr == nullptr) {
ALOGE("IDvr is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- MQDesc dvrMQDesc;
- Result res;
- mDvr->getQueueDesc([&](Result r, const MQDesc& desc) {
- dvrMQDesc = desc;
- res = r;
- });
- if (res != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
- }
-
- AidlMQDesc aidlMQDesc;
- unsafeHidlToAidlMQDescriptor<uint8_t, int8_t, SynchronizedReadWrite>(
- dvrMQDesc, &aidlMQDesc);
- *_aidl_return = move(aidlMQDesc);
- return Status::ok();
+ return mDvr->getQueueDesc(_aidl_return);
}
-Status TunerDvr::configure(const TunerDvrSettings& settings) {
- if (mDvr == NULL) {
+::ndk::ScopedAStatus TunerDvr::configure(const DvrSettings& in_settings) {
+ if (mDvr == nullptr) {
ALOGE("IDvr is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result res = mDvr->configure(getHidlDvrSettingsFromAidl(settings));
- if (res != Result::SUCCESS) {
- return ::ndk::ScopedAStatus::fromServiceSpecificError(static_cast<int32_t>(res));
- }
- return Status::ok();
+ return mDvr->configure(in_settings);
}
-Status TunerDvr::attachFilter(const shared_ptr<ITunerFilter>& filter) {
- if (mDvr == NULL) {
+::ndk::ScopedAStatus TunerDvr::attachFilter(const shared_ptr<ITunerFilter>& in_filter) {
+ if (mDvr == nullptr) {
ALOGE("IDvr is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- ITunerFilter* tunerFilter = filter.get();
- sp<IFilter> hidlFilter = static_cast<TunerFilter*>(tunerFilter)->getHalFilter();
- if (hidlFilter == NULL) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::INVALID_ARGUMENT));
+ if (in_filter == nullptr) {
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::INVALID_ARGUMENT));
}
- Result res = mDvr->attachFilter(hidlFilter);
- if (res != Result::SUCCESS) {
- return ::ndk::ScopedAStatus::fromServiceSpecificError(static_cast<int32_t>(res));
+ shared_ptr<IFilter> halFilter = (static_cast<TunerFilter*>(in_filter.get()))->getHalFilter();
+ if (halFilter == nullptr) {
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::INVALID_ARGUMENT));
}
- return Status::ok();
+
+ return mDvr->attachFilter(halFilter);
}
-Status TunerDvr::detachFilter(const shared_ptr<ITunerFilter>& filter) {
- if (mDvr == NULL) {
+::ndk::ScopedAStatus TunerDvr::detachFilter(const shared_ptr<ITunerFilter>& in_filter) {
+ if (mDvr == nullptr) {
ALOGE("IDvr is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- ITunerFilter* tunerFilter = filter.get();
- sp<IFilter> hidlFilter = static_cast<TunerFilter*>(tunerFilter)->getHalFilter();
- if (hidlFilter == NULL) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::INVALID_ARGUMENT));
+ if (in_filter == nullptr) {
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::INVALID_ARGUMENT));
}
- Result res = mDvr->detachFilter(hidlFilter);
- if (res != Result::SUCCESS) {
- return ::ndk::ScopedAStatus::fromServiceSpecificError(static_cast<int32_t>(res));
+ shared_ptr<IFilter> halFilter = (static_cast<TunerFilter*>(in_filter.get()))->getHalFilter();
+ if (halFilter == nullptr) {
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::INVALID_ARGUMENT));
}
- return Status::ok();
+
+ return mDvr->detachFilter(halFilter);
}
-Status TunerDvr::start() {
- if (mDvr == NULL) {
+::ndk::ScopedAStatus TunerDvr::start() {
+ if (mDvr == nullptr) {
ALOGE("IDvr is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result res = mDvr->start();
- if (res != Result::SUCCESS) {
- return ::ndk::ScopedAStatus::fromServiceSpecificError(static_cast<int32_t>(res));
- }
- return Status::ok();
+ return mDvr->start();
}
-Status TunerDvr::stop() {
- if (mDvr == NULL) {
+::ndk::ScopedAStatus TunerDvr::stop() {
+ if (mDvr == nullptr) {
ALOGE("IDvr is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result res = mDvr->stop();
- if (res != Result::SUCCESS) {
- return ::ndk::ScopedAStatus::fromServiceSpecificError(static_cast<int32_t>(res));
- }
- return Status::ok();
+ return mDvr->stop();
}
-Status TunerDvr::flush() {
- if (mDvr == NULL) {
+::ndk::ScopedAStatus TunerDvr::flush() {
+ if (mDvr == nullptr) {
ALOGE("IDvr is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result res = mDvr->flush();
- if (res != Result::SUCCESS) {
- return ::ndk::ScopedAStatus::fromServiceSpecificError(static_cast<int32_t>(res));
- }
- return Status::ok();
+ return mDvr->flush();
}
-Status TunerDvr::close() {
- if (mDvr == NULL) {
+::ndk::ScopedAStatus TunerDvr::close() {
+ if (mDvr == nullptr) {
ALOGE("IDvr is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result res = mDvr->close();
- mDvr = NULL;
+ auto status = mDvr->close();
+ mDvr = nullptr;
- if (res != Result::SUCCESS) {
- return ::ndk::ScopedAStatus::fromServiceSpecificError(static_cast<int32_t>(res));
- }
- return Status::ok();
-}
-
-DvrSettings TunerDvr::getHidlDvrSettingsFromAidl(TunerDvrSettings settings) {
- DvrSettings s;
- switch (mType) {
- case DvrType::PLAYBACK: {
- s.playback({
- .statusMask = static_cast<uint8_t>(settings.statusMask),
- .lowThreshold = static_cast<uint32_t>(settings.lowThreshold),
- .highThreshold = static_cast<uint32_t>(settings.highThreshold),
- .dataFormat = static_cast<DataFormat>(settings.dataFormat),
- .packetSize = static_cast<uint8_t>(settings.packetSize),
- });
- return s;
- }
- case DvrType::RECORD: {
- s.record({
- .statusMask = static_cast<uint8_t>(settings.statusMask),
- .lowThreshold = static_cast<uint32_t>(settings.lowThreshold),
- .highThreshold = static_cast<uint32_t>(settings.highThreshold),
- .dataFormat = static_cast<DataFormat>(settings.dataFormat),
- .packetSize = static_cast<uint8_t>(settings.packetSize),
- });
- return s;
- }
- default:
- break;
- }
- return s;
+ return status;
}
/////////////// IDvrCallback ///////////////////////
-
-Return<void> TunerDvr::DvrCallback::onRecordStatus(const RecordStatus status) {
- if (mTunerDvrCallback != NULL) {
- mTunerDvrCallback->onRecordStatus(static_cast<int>(status));
+::ndk::ScopedAStatus TunerDvr::DvrCallback::onRecordStatus(const RecordStatus status) {
+ if (mTunerDvrCallback != nullptr) {
+ mTunerDvrCallback->onRecordStatus(status);
}
- return Void();
+ return ndk::ScopedAStatus::ok();
}
-Return<void> TunerDvr::DvrCallback::onPlaybackStatus(const PlaybackStatus status) {
- if (mTunerDvrCallback != NULL) {
- mTunerDvrCallback->onPlaybackStatus(static_cast<int>(status));
+::ndk::ScopedAStatus TunerDvr::DvrCallback::onPlaybackStatus(const PlaybackStatus status) {
+ if (mTunerDvrCallback != nullptr) {
+ mTunerDvrCallback->onPlaybackStatus(status);
}
- return Void();
+ return ndk::ScopedAStatus::ok();
}
+
+} // namespace tuner
+} // namespace tv
+} // namespace media
} // namespace android
+} // namespace aidl
diff --git a/services/tuner/TunerDvr.h b/services/tuner/TunerDvr.h
index a508e99..1854d08 100644
--- a/services/tuner/TunerDvr.h
+++ b/services/tuner/TunerDvr.h
@@ -17,81 +17,71 @@
#ifndef ANDROID_MEDIA_TUNERDVR_H
#define ANDROID_MEDIA_TUNERDVR_H
+#include <aidl/android/hardware/tv/tuner/BnDvrCallback.h>
+#include <aidl/android/hardware/tv/tuner/DvrSettings.h>
+#include <aidl/android/hardware/tv/tuner/DvrType.h>
+#include <aidl/android/hardware/tv/tuner/IDvr.h>
+#include <aidl/android/hardware/tv/tuner/PlaybackStatus.h>
+#include <aidl/android/hardware/tv/tuner/RecordStatus.h>
#include <aidl/android/media/tv/tuner/BnTunerDvr.h>
#include <aidl/android/media/tv/tuner/ITunerDvrCallback.h>
-#include <android/hardware/tv/tuner/1.0/ITuner.h>
-#include <fmq/MessageQueue.h>
-#include <TunerFilter.h>
+#include "TunerFilter.h"
-using Status = ::ndk::ScopedAStatus;
-using ::aidl::android::hardware::common::fmq::GrantorDescriptor;
using ::aidl::android::hardware::common::fmq::MQDescriptor;
using ::aidl::android::hardware::common::fmq::SynchronizedReadWrite;
-using ::aidl::android::media::tv::tuner::BnTunerDvr;
-using ::aidl::android::media::tv::tuner::ITunerDvrCallback;
-using ::aidl::android::media::tv::tuner::ITunerFilter;
-using ::aidl::android::media::tv::tuner::TunerDvrSettings;
-
-using ::android::hardware::MQDescriptorSync;
-using ::android::hardware::MessageQueue;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-
-using ::android::hardware::tv::tuner::V1_0::DvrSettings;
-using ::android::hardware::tv::tuner::V1_0::DvrType;
-using ::android::hardware::tv::tuner::V1_0::IDvr;
-using ::android::hardware::tv::tuner::V1_0::IDvrCallback;
-using ::android::hardware::tv::tuner::V1_0::PlaybackStatus;
-using ::android::hardware::tv::tuner::V1_0::RecordStatus;
+using ::aidl::android::hardware::tv::tuner::BnDvrCallback;
+using ::aidl::android::hardware::tv::tuner::DvrSettings;
+using ::aidl::android::hardware::tv::tuner::DvrType;
+using ::aidl::android::hardware::tv::tuner::IDvr;
+using ::aidl::android::hardware::tv::tuner::PlaybackStatus;
+using ::aidl::android::hardware::tv::tuner::RecordStatus;
using namespace std;
+namespace aidl {
namespace android {
+namespace media {
+namespace tv {
+namespace tuner {
-using MQDesc = MQDescriptorSync<uint8_t>;
using AidlMQDesc = MQDescriptor<int8_t, SynchronizedReadWrite>;
class TunerDvr : public BnTunerDvr {
public:
- TunerDvr(sp<IDvr> dvr, int type);
+ TunerDvr(shared_ptr<IDvr> dvr, DvrType type);
~TunerDvr();
- Status getQueueDesc(AidlMQDesc* _aidl_return) override;
+ ::ndk::ScopedAStatus getQueueDesc(AidlMQDesc* _aidl_return) override;
+ ::ndk::ScopedAStatus configure(const DvrSettings& in_settings) override;
+ ::ndk::ScopedAStatus attachFilter(const shared_ptr<ITunerFilter>& in_filter) override;
+ ::ndk::ScopedAStatus detachFilter(const shared_ptr<ITunerFilter>& in_filter) override;
+ ::ndk::ScopedAStatus start() override;
+ ::ndk::ScopedAStatus stop() override;
+ ::ndk::ScopedAStatus flush() override;
+ ::ndk::ScopedAStatus close() override;
- Status configure(const TunerDvrSettings& settings) override;
-
- Status attachFilter(const shared_ptr<ITunerFilter>& filter) override;
-
- Status detachFilter(const shared_ptr<ITunerFilter>& filter) override;
-
- Status start() override;
-
- Status stop() override;
-
- Status flush() override;
-
- Status close() override;
-
- struct DvrCallback : public IDvrCallback {
+ struct DvrCallback : public BnDvrCallback {
DvrCallback(const shared_ptr<ITunerDvrCallback> tunerDvrCallback)
- : mTunerDvrCallback(tunerDvrCallback) {};
+ : mTunerDvrCallback(tunerDvrCallback){};
- virtual Return<void> onRecordStatus(const RecordStatus status);
- virtual Return<void> onPlaybackStatus(const PlaybackStatus status);
+ ::ndk::ScopedAStatus onRecordStatus(const RecordStatus status) override;
+ ::ndk::ScopedAStatus onPlaybackStatus(const PlaybackStatus status) override;
- private:
- shared_ptr<ITunerDvrCallback> mTunerDvrCallback;
+ private:
+ shared_ptr<ITunerDvrCallback> mTunerDvrCallback;
};
private:
- DvrSettings getHidlDvrSettingsFromAidl(TunerDvrSettings settings);
-
- sp<IDvr> mDvr;
+ shared_ptr<IDvr> mDvr;
DvrType mType;
};
-} // namespace android
+} // namespace tuner
+} // namespace tv
+} // namespace media
+} // namespace android
+} // namespace aidl
#endif // ANDROID_MEDIA_TUNERDVR_H
diff --git a/services/tuner/TunerFilter.cpp b/services/tuner/TunerFilter.cpp
index 039fd31..005445a 100644
--- a/services/tuner/TunerFilter.cpp
+++ b/services/tuner/TunerFilter.cpp
@@ -18,893 +18,205 @@
#include "TunerFilter.h"
-using ::aidl::android::media::tv::tuner::TunerFilterSectionCondition;
+#include <aidl/android/hardware/tv/tuner/Result.h>
-using ::android::hardware::hidl_handle;
-using ::android::hardware::tv::tuner::V1_0::DemuxAlpLengthType;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterMainType;
-using ::android::hardware::tv::tuner::V1_0::DemuxIpAddress;
-using ::android::hardware::tv::tuner::V1_0::DemuxMmtpFilterType;
-using ::android::hardware::tv::tuner::V1_0::DemuxMmtpPid;
-using ::android::hardware::tv::tuner::V1_0::DemuxRecordScIndexType;
-using ::android::hardware::tv::tuner::V1_0::DemuxStreamId;
-using ::android::hardware::tv::tuner::V1_0::DemuxTsFilterType;
-using ::android::hardware::tv::tuner::V1_0::Result;
-using ::android::hardware::tv::tuner::V1_1::AudioStreamType;
-using ::android::hardware::tv::tuner::V1_1::Constant;
-using ::android::hardware::tv::tuner::V1_1::VideoStreamType;
+using ::aidl::android::hardware::tv::tuner::Result;
+namespace aidl {
namespace android {
+namespace media {
+namespace tv {
+namespace tuner {
using namespace std;
-TunerFilter::TunerFilter(
- sp<IFilter> filter, int mainType, int subType) {
- mFilter = filter;
- mFilter_1_1 = ::android::hardware::tv::tuner::V1_1::IFilter::castFrom(filter);
- mMainType = mainType;
- mSubType = subType;
-}
+TunerFilter::TunerFilter(shared_ptr<IFilter> filter, DemuxFilterType type)
+ : mFilter(filter), mType(type) {}
TunerFilter::~TunerFilter() {
mFilter = nullptr;
- mFilter_1_1 = nullptr;
}
-Status TunerFilter::getQueueDesc(AidlMQDesc* _aidl_return) {
- if (mFilter == NULL) {
- ALOGE("IFilter is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
- }
-
- MQDesc filterMQDesc;
- Result res;
- mFilter->getQueueDesc([&](Result r, const MQDesc& desc) {
- filterMQDesc = desc;
- res = r;
- });
- if (res != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
- }
-
- AidlMQDesc aidlMQDesc;
- unsafeHidlToAidlMQDescriptor<uint8_t, int8_t, SynchronizedReadWrite>(
- filterMQDesc, &aidlMQDesc);
- *_aidl_return = move(aidlMQDesc);
- return Status::ok();
-}
-
-Status TunerFilter::getId(int32_t* _aidl_return) {
+::ndk::ScopedAStatus TunerFilter::getQueueDesc(AidlMQDesc* _aidl_return) {
if (mFilter == nullptr) {
ALOGE("IFilter is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result res;
- mFilter->getId([&](Result r, uint32_t filterId) {
- res = r;
- mId = filterId;
- });
- if (res != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
- }
- *_aidl_return = mId;
- return Status::ok();
+ return mFilter->getQueueDesc(_aidl_return);
}
-Status TunerFilter::getId64Bit(int64_t* _aidl_return) {
- if (mFilter_1_1 == nullptr) {
- ALOGE("IFilter_1_1 is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
- }
-
- Result res;
- mFilter_1_1->getId64Bit([&](Result r, uint64_t filterId) {
- res = r;
- mId64Bit = filterId;
- });
- if (res != Result::SUCCESS) {
- return ::ndk::ScopedAStatus::fromServiceSpecificError(static_cast<int32_t>(res));
- }
- *_aidl_return = mId64Bit;
- return Status::ok();
-}
-
-Status TunerFilter::configure(const TunerFilterConfiguration& config) {
+::ndk::ScopedAStatus TunerFilter::getId(int32_t* _aidl_return) {
if (mFilter == nullptr) {
ALOGE("IFilter is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- DemuxFilterSettings settings;
- switch (config.getTag()) {
- case TunerFilterConfiguration::ts: {
- getHidlTsSettings(config, settings);
- break;
- }
- case TunerFilterConfiguration::mmtp: {
- getHidlMmtpSettings(config, settings);
- break;
- }
- case TunerFilterConfiguration::ip: {
- getHidlIpSettings(config, settings);
- break;
- }
- case TunerFilterConfiguration::tlv: {
- getHidlTlvSettings(config, settings);
- break;
- }
- case TunerFilterConfiguration::alp: {
- getHidlAlpSettings(config, settings);
- break;
- }
+ auto status = mFilter->getId(&mId);
+ if (status.isOk()) {
+ *_aidl_return = mId;
}
-
- Result res = mFilter->configure(settings);
- if (res != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
- }
- return Status::ok();
+ return status;
}
-Status TunerFilter::configureMonitorEvent(int monitorEventType) {
- if (mFilter_1_1 == nullptr) {
- ALOGE("IFilter_1_1 is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
- }
-
- Result res = mFilter_1_1->configureMonitorEvent(monitorEventType);
- if (res != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
- }
- return Status::ok();
-}
-
-Status TunerFilter::configureIpFilterContextId(int cid) {
- if (mFilter_1_1 == nullptr) {
- ALOGE("IFilter_1_1 is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
- }
-
- Result res = mFilter_1_1->configureIpCid(cid);
- if (res != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
- }
- return Status::ok();
-}
-
-Status TunerFilter::configureAvStreamType(int avStreamType) {
- if (mFilter_1_1 == nullptr) {
- ALOGE("IFilter_1_1 is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
- }
-
- AvStreamType type;
- if (!getHidlAvStreamType(avStreamType, type)) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::INVALID_STATE));
- }
-
- Result res = mFilter_1_1->configureAvStreamType(type);
- if (res != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
- }
- return Status::ok();
-}
-
-Status TunerFilter::setDataSource(const shared_ptr<ITunerFilter>& filter) {
+::ndk::ScopedAStatus TunerFilter::getId64Bit(int64_t* _aidl_return) {
if (mFilter == nullptr) {
ALOGE("IFilter is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- ITunerFilter* tunerFilter = filter.get();
- sp<IFilter> hidlFilter = static_cast<TunerFilter*>(tunerFilter)->getHalFilter();
- Result res = mFilter->setDataSource(hidlFilter);
- if (res != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
+ auto status = mFilter->getId64Bit(&mId64Bit);
+ if (status.isOk()) {
+ *_aidl_return = mId64Bit;
}
- return Status::ok();
+ return status;
}
-void TunerFilter::getHidlTsSettings(
- const TunerFilterConfiguration& config, DemuxFilterSettings& settings) {
- auto tsConf = config.get<TunerFilterConfiguration::ts>();
- DemuxTsFilterSettings ts{
- .tpid = static_cast<uint16_t>(tsConf.tpid),
- };
-
- TunerFilterSettings tunerSettings = tsConf.filterSettings;
- switch (tunerSettings.getTag()) {
- case TunerFilterSettings::av: {
- ts.filterSettings.av(getAvSettings(tunerSettings));
- break;
- }
- case TunerFilterSettings::section: {
- ts.filterSettings.section(getSectionSettings(tunerSettings));
- break;
- }
- case TunerFilterSettings::pesData: {
- ts.filterSettings.pesData(getPesDataSettings(tunerSettings));
- break;
- }
- case TunerFilterSettings::record: {
- ts.filterSettings.record(getRecordSettings(tunerSettings));
- break;
- }
- default: {
- ts.filterSettings.noinit();
- break;
- }
- }
- settings.ts(ts);
-}
-
-void TunerFilter::getHidlMmtpSettings(
- const TunerFilterConfiguration& config, DemuxFilterSettings& settings) {
- auto mmtpConf = config.get<TunerFilterConfiguration::mmtp>();
- DemuxMmtpFilterSettings mmtp{
- .mmtpPid = static_cast<DemuxMmtpPid>(mmtpConf.mmtpPid),
- };
-
- TunerFilterSettings tunerSettings = mmtpConf.filterSettings;
- switch (tunerSettings.getTag()) {
- case TunerFilterSettings::av: {
- mmtp.filterSettings.av(getAvSettings(tunerSettings));
- break;
- }
- case TunerFilterSettings::section: {
- mmtp.filterSettings.section(getSectionSettings(tunerSettings));
- break;
- }
- case TunerFilterSettings::pesData: {
- mmtp.filterSettings.pesData(getPesDataSettings(tunerSettings));
- break;
- }
- case TunerFilterSettings::record: {
- mmtp.filterSettings.record(getRecordSettings(tunerSettings));
- break;
- }
- case TunerFilterSettings::download: {
- mmtp.filterSettings.download(getDownloadSettings(tunerSettings));
- break;
- }
- default: {
- mmtp.filterSettings.noinit();
- break;
- }
- }
- settings.mmtp(mmtp);
-}
-
-void TunerFilter::getHidlIpSettings(
- const TunerFilterConfiguration& config, DemuxFilterSettings& settings) {
- auto ipConf = config.get<TunerFilterConfiguration::ip>();
- DemuxIpAddress ipAddr{
- .srcPort = static_cast<uint16_t>(ipConf.ipAddr.srcPort),
- .dstPort = static_cast<uint16_t>(ipConf.ipAddr.dstPort),
- };
-
- ipConf.ipAddr.srcIpAddress.isIpV6
- ? ipAddr.srcIpAddress.v6(getIpV6Address(ipConf.ipAddr.srcIpAddress))
- : ipAddr.srcIpAddress.v4(getIpV4Address(ipConf.ipAddr.srcIpAddress));
- ipConf.ipAddr.dstIpAddress.isIpV6
- ? ipAddr.dstIpAddress.v6(getIpV6Address(ipConf.ipAddr.dstIpAddress))
- : ipAddr.dstIpAddress.v4(getIpV4Address(ipConf.ipAddr.dstIpAddress));
- DemuxIpFilterSettings ip{
- .ipAddr = ipAddr,
- };
-
- TunerFilterSettings tunerSettings = ipConf.filterSettings;
- switch (tunerSettings.getTag()) {
- case TunerFilterSettings::section: {
- ip.filterSettings.section(getSectionSettings(tunerSettings));
- break;
- }
- case TunerFilterSettings::isPassthrough: {
- ip.filterSettings.bPassthrough(tunerSettings.isPassthrough);
- break;
- }
- default: {
- ip.filterSettings.noinit();
- break;
- }
- }
- settings.ip(ip);
-}
-
-hidl_array<uint8_t, IP_V6_LENGTH> TunerFilter::getIpV6Address(TunerDemuxIpAddress addr) {
- hidl_array<uint8_t, IP_V6_LENGTH> ip;
- if (addr.addr.size() != IP_V6_LENGTH) {
- return ip;
- }
- copy(addr.addr.begin(), addr.addr.end(), ip.data());
- return ip;
-}
-
-hidl_array<uint8_t, IP_V4_LENGTH> TunerFilter::getIpV4Address(TunerDemuxIpAddress addr) {
- hidl_array<uint8_t, IP_V4_LENGTH> ip;
- if (addr.addr.size() != IP_V4_LENGTH) {
- return ip;
- }
- copy(addr.addr.begin(), addr.addr.end(), ip.data());
- return ip;
-}
-
-void TunerFilter::getHidlTlvSettings(
- const TunerFilterConfiguration& config, DemuxFilterSettings& settings) {
- auto tlvConf = config.get<TunerFilterConfiguration::tlv>();
- DemuxTlvFilterSettings tlv{
- .packetType = static_cast<uint8_t>(tlvConf.packetType),
- .isCompressedIpPacket = tlvConf.isCompressedIpPacket,
- };
-
- TunerFilterSettings tunerSettings = tlvConf.filterSettings;
- switch (tunerSettings.getTag()) {
- case TunerFilterSettings::section: {
- tlv.filterSettings.section(getSectionSettings(tunerSettings));
- break;
- }
- case TunerFilterSettings::isPassthrough: {
- tlv.filterSettings.bPassthrough(tunerSettings.isPassthrough);
- break;
- }
- default: {
- tlv.filterSettings.noinit();
- break;
- }
- }
- settings.tlv(tlv);
-}
-
-void TunerFilter::getHidlAlpSettings(
- const TunerFilterConfiguration& config, DemuxFilterSettings& settings) {
- auto alpConf = config.get<TunerFilterConfiguration::alp>();
- DemuxAlpFilterSettings alp{
- .packetType = static_cast<uint8_t>(alpConf.packetType),
- .lengthType = static_cast<DemuxAlpLengthType>(alpConf.lengthType),
- };
-
- TunerFilterSettings tunerSettings = alpConf.filterSettings;
- switch (tunerSettings.getTag()) {
- case TunerFilterSettings::section: {
- alp.filterSettings.section(getSectionSettings(tunerSettings));
- break;
- }
- default: {
- alp.filterSettings.noinit();
- break;
- }
- }
- settings.alp(alp);
-}
-
-DemuxFilterAvSettings TunerFilter::getAvSettings(const TunerFilterSettings& settings) {
- DemuxFilterAvSettings av {
- .isPassthrough = settings.get<TunerFilterSettings::av>().isPassthrough,
- };
- return av;
-}
-
-DemuxFilterSectionSettings TunerFilter::getSectionSettings(const TunerFilterSettings& settings) {
- auto s = settings.get<TunerFilterSettings::section>();
- DemuxFilterSectionSettings section{
- .isCheckCrc = s.isCheckCrc,
- .isRepeat = s.isRepeat,
- .isRaw = s.isRaw,
- };
-
- switch (s.condition.getTag()) {
- case TunerFilterSectionCondition::sectionBits: {
- auto sectionBits = s.condition.get<TunerFilterSectionCondition::sectionBits>();
- vector<uint8_t> filter(sectionBits.filter.begin(), sectionBits.filter.end());
- vector<uint8_t> mask(sectionBits.mask.begin(), sectionBits.mask.end());
- vector<uint8_t> mode(sectionBits.mode.begin(), sectionBits.mode.end());
- section.condition.sectionBits({
- .filter = filter,
- .mask = mask,
- .mode = mode,
- });
- break;
- }
- case TunerFilterSectionCondition::tableInfo: {
- auto tableInfo = s.condition.get<TunerFilterSectionCondition::tableInfo>();
- section.condition.tableInfo({
- .tableId = static_cast<uint16_t>(tableInfo.tableId),
- .version = static_cast<uint16_t>(tableInfo.version),
- });
- break;
- }
- default: {
- break;
- }
- }
- return section;
-}
-
-DemuxFilterPesDataSettings TunerFilter::getPesDataSettings(const TunerFilterSettings& settings) {
- DemuxFilterPesDataSettings pes{
- .streamId = static_cast<DemuxStreamId>(
- settings.get<TunerFilterSettings::pesData>().streamId),
- .isRaw = settings.get<TunerFilterSettings::pesData>().isRaw,
- };
- return pes;
-}
-
-DemuxFilterRecordSettings TunerFilter::getRecordSettings(const TunerFilterSettings& settings) {
- auto r = settings.get<TunerFilterSettings::record>();
- DemuxFilterRecordSettings record{
- .tsIndexMask = static_cast<uint32_t>(r.tsIndexMask),
- .scIndexType = static_cast<DemuxRecordScIndexType>(r.scIndexType),
- };
-
- switch (r.scIndexMask.getTag()) {
- case TunerFilterScIndexMask::sc: {
- record.scIndexMask.sc(static_cast<uint32_t>(
- r.scIndexMask.get<TunerFilterScIndexMask::sc>()));
- break;
- }
- case TunerFilterScIndexMask::scHevc: {
- record.scIndexMask.scHevc(static_cast<uint32_t>(
- r.scIndexMask.get<TunerFilterScIndexMask::scHevc>()));
- break;
- }
- }
- return record;
-}
-
-DemuxFilterDownloadSettings TunerFilter::getDownloadSettings(const TunerFilterSettings& settings) {
- DemuxFilterDownloadSettings download {
- .downloadId = static_cast<uint32_t>(
- settings.get<TunerFilterSettings::download>().downloadId),
- };
- return download;
-}
-
-Status TunerFilter::getAvSharedHandleInfo(TunerFilterSharedHandleInfo* _aidl_return) {
- if (mFilter_1_1 == nullptr) {
- ALOGE("IFilter_1_1 is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
- }
-
- Result res;
- mFilter_1_1->getAvSharedHandle([&](Result r, hidl_handle avMemory, uint64_t avMemSize) {
- res = r;
- if (res == Result::SUCCESS) {
- TunerFilterSharedHandleInfo info{
- .handle = dupToAidl(avMemory),
- .size = static_cast<int64_t>(avMemSize),
- };
- *_aidl_return = move(info);
- } else {
- _aidl_return = NULL;
- }
- });
-
- if (res != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
- }
- return Status::ok();
-}
-
-Status TunerFilter::releaseAvHandle(
- const ::aidl::android::hardware::common::NativeHandle& handle, int64_t avDataId) {
+::ndk::ScopedAStatus TunerFilter::configure(const DemuxFilterSettings& in_settings) {
if (mFilter == nullptr) {
ALOGE("IFilter is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result res = mFilter->releaseAvHandle(hidl_handle(makeFromAidl(handle)), avDataId);
- if (res != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
- }
- return Status::ok();
+ return mFilter->configure(in_settings);
}
-Status TunerFilter::start() {
+::ndk::ScopedAStatus TunerFilter::configureMonitorEvent(int32_t monitorEventType) {
if (mFilter == nullptr) {
ALOGE("IFilter is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result res = mFilter->start();
- if (res != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
- }
- return Status::ok();
+
+ return mFilter->configureMonitorEvent(monitorEventType);
}
-Status TunerFilter::stop() {
+::ndk::ScopedAStatus TunerFilter::configureIpFilterContextId(int32_t cid) {
if (mFilter == nullptr) {
ALOGE("IFilter is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result res = mFilter->stop();
- if (res != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
- }
- return Status::ok();
+
+ return mFilter->configureIpCid(cid);
}
-Status TunerFilter::flush() {
+::ndk::ScopedAStatus TunerFilter::configureAvStreamType(const AvStreamType& in_avStreamType) {
if (mFilter == nullptr) {
ALOGE("IFilter is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result res = mFilter->flush();
- if (res != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
- }
- return Status::ok();
+
+ return mFilter->configureAvStreamType(in_avStreamType);
}
-Status TunerFilter::close() {
+::ndk::ScopedAStatus TunerFilter::setDataSource(const shared_ptr<ITunerFilter>& filter) {
if (mFilter == nullptr) {
ALOGE("IFilter is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result res = mFilter->close();
- mFilter = NULL;
- mFilter_1_1 = NULL;
- if (res != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
+ if (filter == nullptr) {
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::INVALID_ARGUMENT));
}
- return Status::ok();
+
+ shared_ptr<IFilter> halFilter = static_cast<TunerFilter*>(filter.get())->getHalFilter();
+ return mFilter->setDataSource(halFilter);
}
-sp<IFilter> TunerFilter::getHalFilter() {
+::ndk::ScopedAStatus TunerFilter::getAvSharedHandle(NativeHandle* out_avMemory,
+ int64_t* _aidl_return) {
+ if (mFilter == nullptr) {
+ ALOGE("IFilter is not initialized");
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
+ }
+
+ return mFilter->getAvSharedHandle(out_avMemory, _aidl_return);
+}
+
+::ndk::ScopedAStatus TunerFilter::releaseAvHandle(const NativeHandle& in_handle,
+ int64_t in_avDataId) {
+ if (mFilter == nullptr) {
+ ALOGE("IFilter is not initialized");
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
+ }
+
+ return mFilter->releaseAvHandle(in_handle, in_avDataId);
+}
+
+::ndk::ScopedAStatus TunerFilter::start() {
+ if (mFilter == nullptr) {
+ ALOGE("IFilter is not initialized");
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
+ }
+
+ return mFilter->start();
+}
+
+::ndk::ScopedAStatus TunerFilter::stop() {
+ if (mFilter == nullptr) {
+ ALOGE("IFilter is not initialized");
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
+ }
+
+ return mFilter->stop();
+}
+
+::ndk::ScopedAStatus TunerFilter::flush() {
+ if (mFilter == nullptr) {
+ ALOGE("IFilter is not initialized");
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
+ }
+
+ return mFilter->flush();
+}
+
+::ndk::ScopedAStatus TunerFilter::close() {
+ if (mFilter == nullptr) {
+ ALOGE("IFilter is not initialized");
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
+ }
+ auto res = mFilter->close();
+ mFilter = nullptr;
+
+ return res;
+}
+
+shared_ptr<IFilter> TunerFilter::getHalFilter() {
return mFilter;
}
-bool TunerFilter::isAudioFilter() {
- return (mMainType == (int)DemuxFilterMainType::TS
- && mSubType == (int)DemuxTsFilterType::AUDIO)
- || (mMainType == (int)DemuxFilterMainType::MMTP
- && mSubType == (int)DemuxMmtpFilterType::AUDIO);
-}
-
-bool TunerFilter::isVideoFilter() {
- return (mMainType == (int)DemuxFilterMainType::TS
- && mSubType == (int)DemuxTsFilterType::VIDEO)
- || (mMainType == (int)DemuxFilterMainType::MMTP
- && mSubType == (int)DemuxMmtpFilterType::VIDEO);
-}
-
-bool TunerFilter::getHidlAvStreamType(int avStreamType, AvStreamType& type) {
- if (isAudioFilter()) {
- type.audio(static_cast<AudioStreamType>(avStreamType));
- return true;
- }
-
- if (isVideoFilter()) {
- type.video(static_cast<VideoStreamType>(avStreamType));
- return true;
- }
-
- return false;
-}
-
/////////////// FilterCallback ///////////////////////
-
-Return<void> TunerFilter::FilterCallback::onFilterStatus(DemuxFilterStatus status) {
- if (mTunerFilterCallback != NULL) {
- mTunerFilterCallback->onFilterStatus((int)status);
+::ndk::ScopedAStatus TunerFilter::FilterCallback::onFilterStatus(DemuxFilterStatus status) {
+ if (mTunerFilterCallback != nullptr) {
+ mTunerFilterCallback->onFilterStatus(status);
}
- return Void();
+ return ::ndk::ScopedAStatus::ok();
}
-Return<void> TunerFilter::FilterCallback::onFilterEvent(const DemuxFilterEvent& filterEvent) {
- vector<DemuxFilterEventExt::Event> emptyEventsExt;
- DemuxFilterEventExt emptyFilterEventExt {
- .events = emptyEventsExt,
- };
- onFilterEvent_1_1(filterEvent, emptyFilterEventExt);
- return Void();
-}
-
-Return<void> TunerFilter::FilterCallback::onFilterEvent_1_1(const DemuxFilterEvent& filterEvent,
- const DemuxFilterEventExt& filterEventExt) {
- if (mTunerFilterCallback != NULL) {
- vector<DemuxFilterEvent::Event> events = filterEvent.events;
- vector<DemuxFilterEventExt::Event> eventsExt = filterEventExt.events;
- vector<TunerFilterEvent> tunerEvent;
-
- getAidlFilterEvent(events, eventsExt, tunerEvent);
- mTunerFilterCallback->onFilterEvent(tunerEvent);
+::ndk::ScopedAStatus TunerFilter::FilterCallback::onFilterEvent(
+ const vector<DemuxFilterEvent>& events) {
+ if (mTunerFilterCallback != nullptr) {
+ mTunerFilterCallback->onFilterEvent(events);
}
- return Void();
+ return ::ndk::ScopedAStatus::ok();
}
-/////////////// FilterCallback Helper Methods ///////////////////////
-
-void TunerFilter::FilterCallback::getAidlFilterEvent(vector<DemuxFilterEvent::Event>& events,
- vector<DemuxFilterEventExt::Event>& eventsExt,
- vector<TunerFilterEvent>& tunerEvent) {
- if (events.empty() && !eventsExt.empty()) {
- auto eventExt = eventsExt[0];
- switch (eventExt.getDiscriminator()) {
- case DemuxFilterEventExt::Event::hidl_discriminator::monitorEvent: {
- getMonitorEvent(eventsExt, tunerEvent);
- return;
- }
- case DemuxFilterEventExt::Event::hidl_discriminator::startId: {
- getRestartEvent(eventsExt, tunerEvent);
- return;
- }
- default: {
- break;
- }
- }
- return;
- }
-
- if (!events.empty()) {
- auto event = events[0];
- switch (event.getDiscriminator()) {
- case DemuxFilterEvent::Event::hidl_discriminator::media: {
- getMediaEvent(events, tunerEvent);
- break;
- }
- case DemuxFilterEvent::Event::hidl_discriminator::section: {
- getSectionEvent(events, tunerEvent);
- break;
- }
- case DemuxFilterEvent::Event::hidl_discriminator::pes: {
- getPesEvent(events, tunerEvent);
- break;
- }
- case DemuxFilterEvent::Event::hidl_discriminator::tsRecord: {
- getTsRecordEvent(events, eventsExt, tunerEvent);
- break;
- }
- case DemuxFilterEvent::Event::hidl_discriminator::mmtpRecord: {
- getMmtpRecordEvent(events, eventsExt, tunerEvent);
- break;
- }
- case DemuxFilterEvent::Event::hidl_discriminator::download: {
- getDownloadEvent(events, tunerEvent);
- break;
- }
- case DemuxFilterEvent::Event::hidl_discriminator::ipPayload: {
- getIpPayloadEvent(events, tunerEvent);
- break;
- }
- case DemuxFilterEvent::Event::hidl_discriminator::temi: {
- getTemiEvent(events, tunerEvent);
- break;
- }
- default: {
- break;
- }
- }
- }
-}
-
-void TunerFilter::FilterCallback::getMediaEvent(
- vector<DemuxFilterEvent::Event>& events, vector<TunerFilterEvent>& res) {
- for (DemuxFilterEvent::Event e : events) {
- DemuxFilterMediaEvent mediaEvent = e.media();
- TunerFilterMediaEvent tunerMedia;
-
- tunerMedia.streamId = static_cast<char16_t>(mediaEvent.streamId);
- tunerMedia.isPtsPresent = mediaEvent.isPtsPresent;
- tunerMedia.pts = static_cast<long>(mediaEvent.pts);
- tunerMedia.dataLength = static_cast<int>(mediaEvent.dataLength);
- tunerMedia.offset = static_cast<int>(mediaEvent.offset);
- tunerMedia.isSecureMemory = mediaEvent.isSecureMemory;
- tunerMedia.avDataId = static_cast<long>(mediaEvent.avDataId);
- tunerMedia.mpuSequenceNumber = static_cast<int>(mediaEvent.mpuSequenceNumber);
- tunerMedia.isPesPrivateData = mediaEvent.isPesPrivateData;
-
- if (mediaEvent.extraMetaData.getDiscriminator() ==
- DemuxFilterMediaEvent::ExtraMetaData::hidl_discriminator::audio) {
- tunerMedia.isAudioExtraMetaData = true;
- tunerMedia.audio = {
- .adFade = static_cast<int8_t>(
- mediaEvent.extraMetaData.audio().adFade),
- .adPan = static_cast<int8_t>(
- mediaEvent.extraMetaData.audio().adPan),
- .versionTextTag = static_cast<int8_t>(
- mediaEvent.extraMetaData.audio().versionTextTag),
- .adGainCenter = static_cast<int8_t>(
- mediaEvent.extraMetaData.audio().adGainCenter),
- .adGainFront = static_cast<int8_t>(
- mediaEvent.extraMetaData.audio().adGainFront),
- .adGainSurround = static_cast<int8_t>(
- mediaEvent.extraMetaData.audio().adGainSurround),
- };
- } else {
- tunerMedia.isAudioExtraMetaData = false;
- }
-
- if (mediaEvent.avMemory.getNativeHandle() != nullptr) {
- tunerMedia.avMemory = dupToAidl(mediaEvent.avMemory.getNativeHandle());
- }
-
- TunerFilterEvent tunerEvent;
- tunerEvent.set<TunerFilterEvent::media>(move(tunerMedia));
- res.push_back(move(tunerEvent));
- }
-}
-
-void TunerFilter::FilterCallback::getSectionEvent(
- vector<DemuxFilterEvent::Event>& events, vector<TunerFilterEvent>& res) {
- for (DemuxFilterEvent::Event e : events) {
- DemuxFilterSectionEvent sectionEvent = e.section();
- TunerFilterSectionEvent tunerSection;
-
- tunerSection.tableId = static_cast<char16_t>(sectionEvent.tableId);
- tunerSection.version = static_cast<char16_t>(sectionEvent.version);
- tunerSection.sectionNum = static_cast<char16_t>(sectionEvent.sectionNum);
- tunerSection.dataLength = static_cast<char16_t>(sectionEvent.dataLength);
-
- TunerFilterEvent tunerEvent;
- tunerEvent.set<TunerFilterEvent::section>(move(tunerSection));
- res.push_back(move(tunerEvent));
- }
-}
-
-void TunerFilter::FilterCallback::getPesEvent(
- vector<DemuxFilterEvent::Event>& events, vector<TunerFilterEvent>& res) {
- for (DemuxFilterEvent::Event e : events) {
- DemuxFilterPesEvent pesEvent = e.pes();
- TunerFilterPesEvent tunerPes;
-
- tunerPes.streamId = static_cast<char16_t>(pesEvent.streamId);
- tunerPes.dataLength = static_cast<char16_t>(pesEvent.dataLength);
- tunerPes.mpuSequenceNumber = static_cast<int>(pesEvent.mpuSequenceNumber);
-
- TunerFilterEvent tunerEvent;
- tunerEvent.set<TunerFilterEvent::pes>(move(tunerPes));
- res.push_back(move(tunerEvent));
- }
-}
-
-void TunerFilter::FilterCallback::getTsRecordEvent(vector<DemuxFilterEvent::Event>& events,
- vector<DemuxFilterEventExt::Event>& eventsExt, vector<TunerFilterEvent>& res) {
- for (int i = 0; i < events.size(); i++) {
- TunerFilterTsRecordEvent tunerTsRecord;
- DemuxFilterTsRecordEvent tsRecordEvent = events[i].tsRecord();
-
- TunerFilterScIndexMask scIndexMask;
- if (tsRecordEvent.scIndexMask.getDiscriminator()
- == DemuxFilterTsRecordEvent::ScIndexMask::hidl_discriminator::sc) {
- scIndexMask.set<TunerFilterScIndexMask::sc>(
- static_cast<int>(tsRecordEvent.scIndexMask.sc()));
- } else if (tsRecordEvent.scIndexMask.getDiscriminator()
- == DemuxFilterTsRecordEvent::ScIndexMask::hidl_discriminator::scHevc) {
- scIndexMask.set<TunerFilterScIndexMask::scHevc>(
- static_cast<int>(tsRecordEvent.scIndexMask.scHevc()));
- }
-
- if (tsRecordEvent.pid.getDiscriminator() == DemuxPid::hidl_discriminator::tPid) {
- tunerTsRecord.pid = static_cast<char16_t>(tsRecordEvent.pid.tPid());
- } else {
- tunerTsRecord.pid = static_cast<char16_t>(Constant::INVALID_TS_PID);
- }
-
- tunerTsRecord.scIndexMask = scIndexMask;
- tunerTsRecord.tsIndexMask = static_cast<int>(tsRecordEvent.tsIndexMask);
- tunerTsRecord.byteNumber = static_cast<long>(tsRecordEvent.byteNumber);
-
- if (eventsExt.size() > i && eventsExt[i].getDiscriminator() ==
- DemuxFilterEventExt::Event::hidl_discriminator::tsRecord) {
- tunerTsRecord.isExtended = true;
- tunerTsRecord.pts = static_cast<long>(eventsExt[i].tsRecord().pts);
- tunerTsRecord.firstMbInSlice = static_cast<int>(eventsExt[i].tsRecord().firstMbInSlice);
- } else {
- tunerTsRecord.isExtended = false;
- }
-
- TunerFilterEvent tunerEvent;
- tunerEvent.set<TunerFilterEvent::tsRecord>(move(tunerTsRecord));
- res.push_back(move(tunerEvent));
- }
-}
-
-void TunerFilter::FilterCallback::getMmtpRecordEvent(vector<DemuxFilterEvent::Event>& events,
- vector<DemuxFilterEventExt::Event>& eventsExt, vector<TunerFilterEvent>& res) {
- for (int i = 0; i < events.size(); i++) {
- TunerFilterMmtpRecordEvent tunerMmtpRecord;
- DemuxFilterMmtpRecordEvent mmtpRecordEvent = events[i].mmtpRecord();
-
- tunerMmtpRecord.scHevcIndexMask = static_cast<int>(mmtpRecordEvent.scHevcIndexMask);
- tunerMmtpRecord.byteNumber = static_cast<long>(mmtpRecordEvent.byteNumber);
-
- if (eventsExt.size() > i && eventsExt[i].getDiscriminator() ==
- DemuxFilterEventExt::Event::hidl_discriminator::mmtpRecord) {
- tunerMmtpRecord.isExtended = true;
- tunerMmtpRecord.pts = static_cast<long>(eventsExt[i].mmtpRecord().pts);
- tunerMmtpRecord.mpuSequenceNumber =
- static_cast<int>(eventsExt[i].mmtpRecord().mpuSequenceNumber);
- tunerMmtpRecord.firstMbInSlice =
- static_cast<int>(eventsExt[i].mmtpRecord().firstMbInSlice);
- tunerMmtpRecord.tsIndexMask = static_cast<int>(eventsExt[i].mmtpRecord().tsIndexMask);
- } else {
- tunerMmtpRecord.isExtended = false;
- }
-
- TunerFilterEvent tunerEvent;
- tunerEvent.set<TunerFilterEvent::mmtpRecord>(move(tunerMmtpRecord));
- res.push_back(move(tunerEvent));
- }
-}
-
-void TunerFilter::FilterCallback::getDownloadEvent(
- vector<DemuxFilterEvent::Event>& events, vector<TunerFilterEvent>& res) {
- for (DemuxFilterEvent::Event e : events) {
- DemuxFilterDownloadEvent downloadEvent = e.download();
- TunerFilterDownloadEvent tunerDownload;
-
- tunerDownload.itemId = static_cast<int>(downloadEvent.itemId);
- tunerDownload.itemFragmentIndex = static_cast<int>(downloadEvent.itemFragmentIndex);
- tunerDownload.mpuSequenceNumber = static_cast<int>(downloadEvent.mpuSequenceNumber);
- tunerDownload.lastItemFragmentIndex = static_cast<int>(downloadEvent.lastItemFragmentIndex);
- tunerDownload.dataLength = static_cast<char16_t>(downloadEvent.dataLength);
-
- TunerFilterEvent tunerEvent;
- tunerEvent.set<TunerFilterEvent::download>(move(tunerDownload));
- res.push_back(move(tunerEvent));
- }
-}
-
-void TunerFilter::FilterCallback::getIpPayloadEvent(
- vector<DemuxFilterEvent::Event>& events, vector<TunerFilterEvent>& res) {
- for (DemuxFilterEvent::Event e : events) {
- DemuxFilterIpPayloadEvent ipPayloadEvent = e.ipPayload();
- TunerFilterIpPayloadEvent tunerIpPayload;
-
- tunerIpPayload.dataLength = static_cast<char16_t>(ipPayloadEvent.dataLength);
-
- TunerFilterEvent tunerEvent;
- tunerEvent.set<TunerFilterEvent::ipPayload>(move(tunerIpPayload));
- res.push_back(move(tunerEvent));
- }
-}
-
-void TunerFilter::FilterCallback::getTemiEvent(
- vector<DemuxFilterEvent::Event>& events, vector<TunerFilterEvent>& res) {
- for (DemuxFilterEvent::Event e : events) {
- DemuxFilterTemiEvent temiEvent = e.temi();
- TunerFilterTemiEvent tunerTemi;
-
- tunerTemi.pts = static_cast<long>(temiEvent.pts);
- tunerTemi.descrTag = static_cast<int8_t>(temiEvent.descrTag);
- vector<uint8_t> descrData = temiEvent.descrData;
- tunerTemi.descrData.resize(descrData.size());
- copy(descrData.begin(), descrData.end(), tunerTemi.descrData.begin());
-
- TunerFilterEvent tunerEvent;
- tunerEvent.set<TunerFilterEvent::temi>(move(tunerTemi));
- res.push_back(move(tunerEvent));
- }
-}
-
-void TunerFilter::FilterCallback::getMonitorEvent(
- vector<DemuxFilterEventExt::Event>& eventsExt, vector<TunerFilterEvent>& res) {
- DemuxFilterMonitorEvent monitorEvent = eventsExt[0].monitorEvent();
- TunerFilterMonitorEvent tunerMonitor;
-
- switch (monitorEvent.getDiscriminator()) {
- case DemuxFilterMonitorEvent::hidl_discriminator::scramblingStatus: {
- tunerMonitor.set<TunerFilterMonitorEvent::scramblingStatus>(
- static_cast<int>(monitorEvent.scramblingStatus()));
- break;
- }
- case DemuxFilterMonitorEvent::hidl_discriminator::cid: {
- tunerMonitor.set<TunerFilterMonitorEvent::cid>(static_cast<int>(monitorEvent.cid()));
- break;
- }
- }
-
- TunerFilterEvent tunerEvent;
- tunerEvent.set<TunerFilterEvent::monitor>(move(tunerMonitor));
- res.push_back(move(tunerEvent));
-}
-
-void TunerFilter::FilterCallback::getRestartEvent(
- vector<DemuxFilterEventExt::Event>& eventsExt, vector<TunerFilterEvent>& res) {
- TunerFilterEvent tunerEvent;
- tunerEvent.set<TunerFilterEvent::startId>(static_cast<int>(eventsExt[0].startId()));
- res.push_back(move(tunerEvent));
-}
+} // namespace tuner
+} // namespace tv
+} // namespace media
} // namespace android
+} // namespace aidl
diff --git a/services/tuner/TunerFilter.h b/services/tuner/TunerFilter.h
index ff4728c..86d178c 100644
--- a/services/tuner/TunerFilter.h
+++ b/services/tuner/TunerFilter.h
@@ -17,176 +17,90 @@
#ifndef ANDROID_MEDIA_TUNERFILTER_H
#define ANDROID_MEDIA_TUNERFILTER_H
+#include <aidl/android/hardware/tv/tuner/AvStreamType.h>
+#include <aidl/android/hardware/tv/tuner/BnFilterCallback.h>
+#include <aidl/android/hardware/tv/tuner/DemuxFilterEvent.h>
+#include <aidl/android/hardware/tv/tuner/DemuxFilterSettings.h>
+#include <aidl/android/hardware/tv/tuner/DemuxFilterStatus.h>
+#include <aidl/android/hardware/tv/tuner/DemuxFilterType.h>
+#include <aidl/android/hardware/tv/tuner/IFilter.h>
#include <aidl/android/media/tv/tuner/BnTunerFilter.h>
#include <aidl/android/media/tv/tuner/ITunerFilterCallback.h>
-#include <aidlcommonsupport/NativeHandle.h>
-#include <android/hardware/tv/tuner/1.0/ITuner.h>
-#include <android/hardware/tv/tuner/1.1/IFilter.h>
-#include <android/hardware/tv/tuner/1.1/IFilterCallback.h>
-#include <android/hardware/tv/tuner/1.1/types.h>
#include <media/stagefright/foundation/ADebug.h>
-#include <fmq/ConvertMQDescriptors.h>
-#include <fmq/MessageQueue.h>
-using Status = ::ndk::ScopedAStatus;
+using ::aidl::android::hardware::common::NativeHandle;
using ::aidl::android::hardware::common::fmq::MQDescriptor;
using ::aidl::android::hardware::common::fmq::SynchronizedReadWrite;
+using ::aidl::android::hardware::tv::tuner::AvStreamType;
+using ::aidl::android::hardware::tv::tuner::BnFilterCallback;
+using ::aidl::android::hardware::tv::tuner::DemuxFilterEvent;
+using ::aidl::android::hardware::tv::tuner::DemuxFilterSettings;
+using ::aidl::android::hardware::tv::tuner::DemuxFilterStatus;
+using ::aidl::android::hardware::tv::tuner::DemuxFilterType;
+using ::aidl::android::hardware::tv::tuner::IFilter;
using ::aidl::android::media::tv::tuner::BnTunerFilter;
-using ::aidl::android::media::tv::tuner::ITunerFilterCallback;
-using ::aidl::android::media::tv::tuner::TunerDemuxIpAddress;
-using ::aidl::android::media::tv::tuner::TunerFilterConfiguration;
-using ::aidl::android::media::tv::tuner::TunerFilterDownloadEvent;
-using ::aidl::android::media::tv::tuner::TunerFilterIpPayloadEvent;
-using ::aidl::android::media::tv::tuner::TunerFilterEvent;
-using ::aidl::android::media::tv::tuner::TunerFilterMediaEvent;
-using ::aidl::android::media::tv::tuner::TunerFilterMmtpRecordEvent;
-using ::aidl::android::media::tv::tuner::TunerFilterMonitorEvent;
-using ::aidl::android::media::tv::tuner::TunerFilterPesEvent;
-using ::aidl::android::media::tv::tuner::TunerFilterScIndexMask;
-using ::aidl::android::media::tv::tuner::TunerFilterSectionEvent;
-using ::aidl::android::media::tv::tuner::TunerFilterSharedHandleInfo;
-using ::aidl::android::media::tv::tuner::TunerFilterSettings;
-using ::aidl::android::media::tv::tuner::TunerFilterTemiEvent;
-using ::aidl::android::media::tv::tuner::TunerFilterTsRecordEvent;
-using ::android::hardware::MQDescriptorSync;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::hardware::hidl_array;
-using ::android::hardware::tv::tuner::V1_0::DemuxAlpFilterSettings;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterAvSettings;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterDownloadEvent;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterDownloadSettings;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterIpPayloadEvent;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterEvent;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterMediaEvent;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterMmtpRecordEvent;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterPesDataSettings;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterPesEvent;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterRecordSettings;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterSectionEvent;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterSectionSettings;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterSettings;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterStatus;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterTemiEvent;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterTsRecordEvent;
-using ::android::hardware::tv::tuner::V1_0::DemuxIpFilterSettings;
-using ::android::hardware::tv::tuner::V1_0::DemuxMmtpFilterSettings;
-using ::android::hardware::tv::tuner::V1_0::DemuxTlvFilterSettings;
-using ::android::hardware::tv::tuner::V1_0::DemuxTsFilterSettings;
-using ::android::hardware::tv::tuner::V1_0::DemuxPid;
-using ::android::hardware::tv::tuner::V1_0::IFilter;
-using ::android::hardware::tv::tuner::V1_1::AvStreamType;
-using ::android::hardware::tv::tuner::V1_1::DemuxFilterEventExt;
-using ::android::hardware::tv::tuner::V1_1::DemuxFilterMonitorEvent;
-using ::android::hardware::tv::tuner::V1_1::DemuxFilterTsRecordEventExt;
-using ::android::hardware::tv::tuner::V1_1::IFilterCallback;
+using namespace std;
+
+namespace aidl {
namespace android {
+namespace media {
+namespace tv {
+namespace tuner {
-using MQDesc = MQDescriptorSync<uint8_t>;
using AidlMQDesc = MQDescriptor<int8_t, SynchronizedReadWrite>;
-const static int IP_V4_LENGTH = 4;
-const static int IP_V6_LENGTH = 16;
-
class TunerFilter : public BnTunerFilter {
public:
- TunerFilter(sp<IFilter> filter, int mainType, int subTyp);
+ TunerFilter(shared_ptr<IFilter> filter, DemuxFilterType type);
virtual ~TunerFilter();
- Status getId(int32_t* _aidl_return) override;
- Status getId64Bit(int64_t* _aidl_return) override;
- Status getQueueDesc(AidlMQDesc* _aidl_return) override;
- Status configure(const TunerFilterConfiguration& config) override;
- Status configureMonitorEvent(int monitorEventType) override;
- Status configureIpFilterContextId(int cid) override;
- Status configureAvStreamType(int avStreamType) override;
- Status getAvSharedHandleInfo(TunerFilterSharedHandleInfo* _aidl_return) override;
- Status releaseAvHandle(const ::aidl::android::hardware::common::NativeHandle& handle,
- int64_t avDataId) override;
- Status setDataSource(const std::shared_ptr<ITunerFilter>& filter) override;
- Status start() override;
- Status stop() override;
- Status flush() override;
- Status close() override;
- sp<IFilter> getHalFilter();
- struct FilterCallback : public IFilterCallback {
- FilterCallback(const std::shared_ptr<ITunerFilterCallback> tunerFilterCallback)
- : mTunerFilterCallback(tunerFilterCallback) {};
+ ::ndk::ScopedAStatus getId(int32_t* _aidl_return) override;
+ ::ndk::ScopedAStatus getId64Bit(int64_t* _aidl_return) override;
+ ::ndk::ScopedAStatus getQueueDesc(AidlMQDesc* _aidl_return) override;
+ ::ndk::ScopedAStatus configure(const DemuxFilterSettings& in_settings) override;
+ ::ndk::ScopedAStatus configureMonitorEvent(int32_t in_monitorEventTypes) override;
+ ::ndk::ScopedAStatus configureIpFilterContextId(int32_t in_cid) override;
+ ::ndk::ScopedAStatus configureAvStreamType(const AvStreamType& in_avStreamType) override;
+ ::ndk::ScopedAStatus getAvSharedHandle(NativeHandle* out_avMemory,
+ int64_t* _aidl_return) override;
+ ::ndk::ScopedAStatus releaseAvHandle(const NativeHandle& in_handle,
+ int64_t in_avDataId) override;
+ ::ndk::ScopedAStatus setDataSource(const shared_ptr<ITunerFilter>& in_filter) override;
+ ::ndk::ScopedAStatus start() override;
+ ::ndk::ScopedAStatus stop() override;
+ ::ndk::ScopedAStatus flush() override;
+ ::ndk::ScopedAStatus close() override;
- virtual Return<void> onFilterEvent(const DemuxFilterEvent& filterEvent);
- virtual Return<void> onFilterEvent_1_1(const DemuxFilterEvent& filterEvent,
- const DemuxFilterEventExt& filterEventExt);
- virtual Return<void> onFilterStatus(DemuxFilterStatus status);
+ shared_ptr<IFilter> getHalFilter();
- void getAidlFilterEvent(std::vector<DemuxFilterEvent::Event>& events,
- std::vector<DemuxFilterEventExt::Event>& eventsExt,
- std::vector<TunerFilterEvent>& tunerEvent);
+ class FilterCallback : public BnFilterCallback {
+ public:
+ FilterCallback(const shared_ptr<ITunerFilterCallback> tunerFilterCallback)
+ : mTunerFilterCallback(tunerFilterCallback){};
- void getMediaEvent(
- std::vector<DemuxFilterEvent::Event>& events, std::vector<TunerFilterEvent>& res);
- void getSectionEvent(
- std::vector<DemuxFilterEvent::Event>& events, std::vector<TunerFilterEvent>& res);
- void getPesEvent(
- std::vector<DemuxFilterEvent::Event>& events, std::vector<TunerFilterEvent>& res);
- void getTsRecordEvent(
- std::vector<DemuxFilterEvent::Event>& events,
- std::vector<DemuxFilterEventExt::Event>& eventsExt,
- std::vector<TunerFilterEvent>& res);
- void getMmtpRecordEvent(
- std::vector<DemuxFilterEvent::Event>& events,
- std::vector<DemuxFilterEventExt::Event>& eventsExt,
- std::vector<TunerFilterEvent>& res);
- void getDownloadEvent(
- std::vector<DemuxFilterEvent::Event>& events, std::vector<TunerFilterEvent>& res);
- void getIpPayloadEvent(
- std::vector<DemuxFilterEvent::Event>& events, std::vector<TunerFilterEvent>& res);
- void getTemiEvent(
- std::vector<DemuxFilterEvent::Event>& events, std::vector<TunerFilterEvent>& res);
- void getMonitorEvent(
- std::vector<DemuxFilterEventExt::Event>& eventsExt,
- std::vector<TunerFilterEvent>& res);
- void getRestartEvent(
- std::vector<DemuxFilterEventExt::Event>& eventsExt,
- std::vector<TunerFilterEvent>& res);
+ ::ndk::ScopedAStatus onFilterEvent(const vector<DemuxFilterEvent>& events) override;
+ ::ndk::ScopedAStatus onFilterStatus(DemuxFilterStatus status) override;
- std::shared_ptr<ITunerFilterCallback> mTunerFilterCallback;
+ private:
+ shared_ptr<ITunerFilterCallback> mTunerFilterCallback;
};
private:
- DemuxFilterAvSettings getAvSettings(const TunerFilterSettings& settings);
- DemuxFilterSectionSettings getSectionSettings(const TunerFilterSettings& settings);
- DemuxFilterPesDataSettings getPesDataSettings(const TunerFilterSettings& settings);
- DemuxFilterRecordSettings getRecordSettings(const TunerFilterSettings& settings);
- DemuxFilterDownloadSettings getDownloadSettings(const TunerFilterSettings& settings);
-
bool isAudioFilter();
bool isVideoFilter();
- bool getHidlAvStreamType(int avStreamType, AvStreamType& type);
- void getHidlTsSettings(
- const TunerFilterConfiguration& config, DemuxFilterSettings& settings);
- void getHidlMmtpSettings(
- const TunerFilterConfiguration& config, DemuxFilterSettings& settings);
- void getHidlIpSettings(
- const TunerFilterConfiguration& config, DemuxFilterSettings& settings);
- void getHidlTlvSettings(
- const TunerFilterConfiguration& config, DemuxFilterSettings& settings);
- void getHidlAlpSettings(
- const TunerFilterConfiguration& config, DemuxFilterSettings& settings);
-
- hidl_array<uint8_t, IP_V4_LENGTH> getIpV4Address(TunerDemuxIpAddress addr);
- hidl_array<uint8_t, IP_V6_LENGTH> getIpV6Address(TunerDemuxIpAddress addr);
-
- sp<IFilter> mFilter;
- sp<::android::hardware::tv::tuner::V1_1::IFilter> mFilter_1_1;
+ shared_ptr<IFilter> mFilter;
int32_t mId;
int64_t mId64Bit;
- int mMainType;
- int mSubType;
+ DemuxFilterType mType;
};
-} // namespace android
+} // namespace tuner
+} // namespace tv
+} // namespace media
+} // namespace android
+} // namespace aidl
#endif // ANDROID_MEDIA_TUNERFILTER_H
diff --git a/services/tuner/TunerFrontend.cpp b/services/tuner/TunerFrontend.cpp
index 74b5519..e86e8e1 100644
--- a/services/tuner/TunerFrontend.cpp
+++ b/services/tuner/TunerFrontend.cpp
@@ -1,5 +1,5 @@
/**
- * Copyright 2020, The Android Open Source Project
+ * Copyright 2021, 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.
@@ -14,1081 +14,186 @@
* limitations under the License.
*/
+//#define LOG_NDEBUG 0
#define LOG_TAG "TunerFrontend"
#include "TunerFrontend.h"
+
+#include <aidl/android/hardware/tv/tuner/Result.h>
+
#include "TunerLnb.h"
-using ::aidl::android::media::tv::tuner::TunerFrontendAtsc3PlpSettings;
-using ::aidl::android::media::tv::tuner::TunerFrontendScanAtsc3PlpInfo;
-using ::aidl::android::media::tv::tuner::TunerFrontendStatusAtsc3PlpInfo;
-using ::aidl::android::media::tv::tuner::TunerFrontendUnionSettings;
-using ::android::hardware::tv::tuner::V1_0::FrontendAnalogSifStandard;
-using ::android::hardware::tv::tuner::V1_0::FrontendAnalogType;
-using ::android::hardware::tv::tuner::V1_0::FrontendAtscModulation;
-using ::android::hardware::tv::tuner::V1_0::FrontendAtsc3Bandwidth;
-using ::android::hardware::tv::tuner::V1_0::FrontendAtsc3CodeRate;
-using ::android::hardware::tv::tuner::V1_0::FrontendAtsc3DemodOutputFormat;
-using ::android::hardware::tv::tuner::V1_0::FrontendAtsc3Fec;
-using ::android::hardware::tv::tuner::V1_0::FrontendAtsc3Modulation;
-using ::android::hardware::tv::tuner::V1_0::FrontendAtsc3TimeInterleaveMode;
-using ::android::hardware::tv::tuner::V1_0::FrontendDvbcAnnex;
-using ::android::hardware::tv::tuner::V1_0::FrontendDvbcModulation;
-using ::android::hardware::tv::tuner::V1_0::FrontendDvbcOuterFec;
-using ::android::hardware::tv::tuner::V1_0::FrontendDvbcSpectralInversion;
-using ::android::hardware::tv::tuner::V1_0::FrontendDvbsModulation;
-using ::android::hardware::tv::tuner::V1_0::FrontendDvbsPilot;
-using ::android::hardware::tv::tuner::V1_0::FrontendDvbsRolloff;
-using ::android::hardware::tv::tuner::V1_0::FrontendDvbsSettings;
-using ::android::hardware::tv::tuner::V1_0::FrontendDvbsStandard;
-using ::android::hardware::tv::tuner::V1_0::FrontendDvbsVcmMode;
-using ::android::hardware::tv::tuner::V1_0::FrontendDvbtBandwidth;
-using ::android::hardware::tv::tuner::V1_0::FrontendDvbtCoderate;
-using ::android::hardware::tv::tuner::V1_0::FrontendDvbtConstellation;
-using ::android::hardware::tv::tuner::V1_0::FrontendDvbtGuardInterval;
-using ::android::hardware::tv::tuner::V1_0::FrontendDvbtHierarchy;
-using ::android::hardware::tv::tuner::V1_0::FrontendDvbtPlpMode;
-using ::android::hardware::tv::tuner::V1_0::FrontendDvbtSettings;
-using ::android::hardware::tv::tuner::V1_0::FrontendDvbtStandard;
-using ::android::hardware::tv::tuner::V1_0::FrontendDvbtTransmissionMode;
-using ::android::hardware::tv::tuner::V1_0::FrontendInnerFec;
-using ::android::hardware::tv::tuner::V1_0::FrontendIsdbs3Coderate;
-using ::android::hardware::tv::tuner::V1_0::FrontendIsdbs3Modulation;
-using ::android::hardware::tv::tuner::V1_0::FrontendIsdbs3Rolloff;
-using ::android::hardware::tv::tuner::V1_0::FrontendIsdbs3Settings;
-using ::android::hardware::tv::tuner::V1_0::FrontendIsdbsCoderate;
-using ::android::hardware::tv::tuner::V1_0::FrontendIsdbsModulation;
-using ::android::hardware::tv::tuner::V1_0::FrontendIsdbsRolloff;
-using ::android::hardware::tv::tuner::V1_0::FrontendIsdbsSettings;
-using ::android::hardware::tv::tuner::V1_0::FrontendIsdbsStreamIdType;
-using ::android::hardware::tv::tuner::V1_0::FrontendIsdbtBandwidth;
-using ::android::hardware::tv::tuner::V1_0::FrontendIsdbtCoderate;
-using ::android::hardware::tv::tuner::V1_0::FrontendIsdbtGuardInterval;
-using ::android::hardware::tv::tuner::V1_0::FrontendIsdbtMode;
-using ::android::hardware::tv::tuner::V1_0::FrontendIsdbtModulation;
-using ::android::hardware::tv::tuner::V1_0::FrontendIsdbtSettings;
-using ::android::hardware::tv::tuner::V1_0::FrontendModulationStatus;
-using ::android::hardware::tv::tuner::V1_0::FrontendScanAtsc3PlpInfo;
-using ::android::hardware::tv::tuner::V1_0::FrontendScanType;
-using ::android::hardware::tv::tuner::V1_0::FrontendStatusType;
-using ::android::hardware::tv::tuner::V1_0::Result;
-using ::android::hardware::tv::tuner::V1_1::FrontendAnalogAftFlag;
-using ::android::hardware::tv::tuner::V1_1::FrontendBandwidth;
-using ::android::hardware::tv::tuner::V1_1::FrontendCableTimeInterleaveMode;
-using ::android::hardware::tv::tuner::V1_1::FrontendDvbcBandwidth;
-using ::android::hardware::tv::tuner::V1_1::FrontendDtmbBandwidth;
-using ::android::hardware::tv::tuner::V1_1::FrontendDtmbCodeRate;
-using ::android::hardware::tv::tuner::V1_1::FrontendDtmbGuardInterval;
-using ::android::hardware::tv::tuner::V1_1::FrontendDtmbModulation;
-using ::android::hardware::tv::tuner::V1_1::FrontendDtmbTimeInterleaveMode;
-using ::android::hardware::tv::tuner::V1_1::FrontendDtmbTransmissionMode;
-using ::android::hardware::tv::tuner::V1_1::FrontendDvbsScanType;
-using ::android::hardware::tv::tuner::V1_1::FrontendGuardInterval;
-using ::android::hardware::tv::tuner::V1_1::FrontendInterleaveMode;
-using ::android::hardware::tv::tuner::V1_1::FrontendModulation;
-using ::android::hardware::tv::tuner::V1_1::FrontendRollOff;
-using ::android::hardware::tv::tuner::V1_1::FrontendTransmissionMode;
-using ::android::hardware::tv::tuner::V1_1::FrontendSpectralInversion;
-using ::android::hardware::tv::tuner::V1_1::FrontendStatusTypeExt1_1;
+using ::aidl::android::hardware::tv::tuner::Result;
+namespace aidl {
namespace android {
+namespace media {
+namespace tv {
+namespace tuner {
-TunerFrontend::TunerFrontend(sp<IFrontend> frontend, int id) {
+TunerFrontend::TunerFrontend(shared_ptr<IFrontend> frontend, int id) {
mFrontend = frontend;
- mFrontend_1_1 = ::android::hardware::tv::tuner::V1_1::IFrontend::castFrom(mFrontend);
mId = id;
}
TunerFrontend::~TunerFrontend() {
- mFrontend = NULL;
- mFrontend_1_1 = NULL;
+ mFrontend = nullptr;
mId = -1;
}
-Status TunerFrontend::setCallback(
+::ndk::ScopedAStatus TunerFrontend::setCallback(
const shared_ptr<ITunerFrontendCallback>& tunerFrontendCallback) {
- if (mFrontend == NULL) {
+ if (mFrontend == nullptr) {
ALOGE("IFrontend is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- if (tunerFrontendCallback == NULL) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::INVALID_ARGUMENT));
+ if (tunerFrontendCallback == nullptr) {
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::INVALID_ARGUMENT));
}
- sp<IFrontendCallback> frontendCallback = new FrontendCallback(tunerFrontendCallback);
- Result status = mFrontend->setCallback(frontendCallback);
- if (status == Result::SUCCESS) {
- return Status::ok();
- }
-
- return Status::fromServiceSpecificError(static_cast<int32_t>(status));
+ shared_ptr<IFrontendCallback> frontendCallback =
+ ::ndk::SharedRefBase::make<FrontendCallback>(tunerFrontendCallback);
+ return mFrontend->setCallback(frontendCallback);
}
-Status TunerFrontend::tune(const TunerFrontendSettings& settings) {
- if (mFrontend == NULL) {
+::ndk::ScopedAStatus TunerFrontend::tune(const FrontendSettings& settings) {
+ if (mFrontend == nullptr) {
ALOGE("IFrontend is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result status;
- FrontendSettings frontendSettings = getHidlFrontendSettings(settings);
- if (settings.isExtended) {
- if (mFrontend_1_1 == NULL) {
- ALOGE("IFrontend_1_1 is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
- }
- FrontendSettingsExt1_1 frontendSettingsExt = getHidlFrontendSettingsExt(settings);
- status = mFrontend_1_1->tune_1_1(frontendSettings, frontendSettingsExt);
- } else {
- status = mFrontend->tune(frontendSettings);
- }
-
- if (status == Result::SUCCESS) {
- return Status::ok();
- }
-
- return Status::fromServiceSpecificError(static_cast<int32_t>(status));
+ return mFrontend->tune(settings);
}
-Status TunerFrontend::stopTune() {
- if (mFrontend == NULL) {
+::ndk::ScopedAStatus TunerFrontend::stopTune() {
+ if (mFrontend == nullptr) {
ALOGD("IFrontend is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result status = mFrontend->stopTune();
- if (status == Result::SUCCESS) {
- return Status::ok();
- }
-
- return Status::fromServiceSpecificError(static_cast<int32_t>(status));
+ return mFrontend->stopTune();
}
-Status TunerFrontend::scan(const TunerFrontendSettings& settings, int frontendScanType) {
- if (mFrontend == NULL) {
+::ndk::ScopedAStatus TunerFrontend::scan(const FrontendSettings& settings,
+ FrontendScanType frontendScanType) {
+ if (mFrontend == nullptr) {
ALOGD("IFrontend is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result status;
- FrontendSettings frontendSettings = getHidlFrontendSettings(settings);
- if (settings.isExtended) {
- if (mFrontend_1_1 == NULL) {
- ALOGE("IFrontend_1_1 is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
- }
- FrontendSettingsExt1_1 frontendSettingsExt = getHidlFrontendSettingsExt(settings);
- status = mFrontend_1_1->scan_1_1(frontendSettings,
- static_cast<FrontendScanType>(frontendScanType), frontendSettingsExt);
- } else {
- status = mFrontend->scan(
- frontendSettings, static_cast<FrontendScanType>(frontendScanType));
- }
-
- if (status == Result::SUCCESS) {
- return Status::ok();
- }
-
- return Status::fromServiceSpecificError(static_cast<int32_t>(status));
+ return mFrontend->scan(settings, frontendScanType);
}
-Status TunerFrontend::stopScan() {
- if (mFrontend == NULL) {
+::ndk::ScopedAStatus TunerFrontend::stopScan() {
+ if (mFrontend == nullptr) {
ALOGD("IFrontend is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result status = mFrontend->stopScan();
- if (status == Result::SUCCESS) {
- return Status::ok();
- }
-
- return Status::fromServiceSpecificError(static_cast<int32_t>(status));
+ return mFrontend->stopScan();
}
-Status TunerFrontend::setLnb(const shared_ptr<ITunerLnb>& lnb) {
- if (mFrontend == NULL) {
+::ndk::ScopedAStatus TunerFrontend::setLnb(const shared_ptr<ITunerLnb>& lnb) {
+ if (mFrontend == nullptr) {
ALOGD("IFrontend is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result status = mFrontend->setLnb(static_cast<TunerLnb*>(lnb.get())->getId());
- if (status == Result::SUCCESS) {
- return Status::ok();
+ if (lnb == nullptr) {
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::INVALID_ARGUMENT));
}
- return Status::fromServiceSpecificError(static_cast<int32_t>(status));
+ return mFrontend->setLnb(static_cast<TunerLnb*>(lnb.get())->getId());
}
-Status TunerFrontend::setLna(bool bEnable) {
- if (mFrontend == NULL) {
+::ndk::ScopedAStatus TunerFrontend::setLna(bool bEnable) {
+ if (mFrontend == nullptr) {
ALOGD("IFrontend is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result status = mFrontend->setLna(bEnable);
- if (status == Result::SUCCESS) {
- return Status::ok();
- }
-
- return Status::fromServiceSpecificError(static_cast<int32_t>(status));
+ return mFrontend->setLna(bEnable);
}
-Status TunerFrontend::linkCiCamToFrontend(int ciCamId, int32_t* _aidl_return) {
- if (mFrontend_1_1 == NULL) {
- ALOGD("IFrontend_1_1 is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
- }
-
- int ltsId;
- Result status;
- mFrontend_1_1->linkCiCam(static_cast<uint32_t>(ciCamId),
- [&](Result r, uint32_t id) {
- status = r;
- ltsId = id;
- });
-
- if (status == Result::SUCCESS) {
- *_aidl_return = ltsId;
- return Status::ok();
- }
-
- return Status::fromServiceSpecificError(static_cast<int32_t>(status));
-}
-
-Status TunerFrontend::unlinkCiCamToFrontend(int ciCamId) {
- if (mFrontend_1_1 == NULL) {
- ALOGD("IFrontend_1_1 is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
- }
-
- Result status = mFrontend_1_1->unlinkCiCam(ciCamId);
- if (status == Result::SUCCESS) {
- return Status::ok();
- }
-
- return Status::fromServiceSpecificError(static_cast<int32_t>(status));
-}
-
-Status TunerFrontend::close() {
- if (mFrontend == NULL) {
+::ndk::ScopedAStatus TunerFrontend::linkCiCamToFrontend(int32_t ciCamId, int32_t* _aidl_return) {
+ if (mFrontend == nullptr) {
ALOGD("IFrontend is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result status = mFrontend->close();
- mFrontend = NULL;
- mFrontend_1_1 = NULL;
-
- if (status != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(status));
- }
- return Status::ok();
+ return mFrontend->linkCiCam(ciCamId, _aidl_return);
}
-Status TunerFrontend::getStatus(const vector<int32_t>& statusTypes,
- vector<TunerFrontendStatus>* _aidl_return) {
- if (mFrontend == NULL) {
+::ndk::ScopedAStatus TunerFrontend::unlinkCiCamToFrontend(int32_t ciCamId) {
+ if (mFrontend == nullptr) {
ALOGD("IFrontend is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result res;
- vector<FrontendStatus> status;
- vector<FrontendStatusType> types;
- for (auto s : statusTypes) {
- types.push_back(static_cast<FrontendStatusType>(s));
- }
-
- mFrontend->getStatus(types, [&](Result r, const hidl_vec<FrontendStatus>& s) {
- res = r;
- status = s;
- });
- if (res != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
- }
-
- getAidlFrontendStatus(status, *_aidl_return);
- return Status::ok();
+ return mFrontend->unlinkCiCam(ciCamId);
}
-Status TunerFrontend::getStatusExtended_1_1(const vector<int32_t>& statusTypes,
- vector<TunerFrontendStatus>* _aidl_return) {
- if (mFrontend_1_1 == NULL) {
- ALOGD("IFrontend_1_1 is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+::ndk::ScopedAStatus TunerFrontend::close() {
+ if (mFrontend == nullptr) {
+ ALOGD("IFrontend is not initialized");
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result res;
- vector<FrontendStatusExt1_1> status;
- vector<FrontendStatusTypeExt1_1> types;
- for (auto s : statusTypes) {
- types.push_back(static_cast<FrontendStatusTypeExt1_1>(s));
- }
+ auto res = mFrontend->close();
+ mFrontend = nullptr;
- mFrontend_1_1->getStatusExt1_1(types, [&](Result r, const hidl_vec<FrontendStatusExt1_1>& s) {
- res = r;
- status = s;
- });
- if (res != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
- }
-
- getAidlFrontendStatusExt(status, *_aidl_return);
- return Status::ok();
+ return res;
}
-Status TunerFrontend::getFrontendId(int* _aidl_return) {
+::ndk::ScopedAStatus TunerFrontend::getStatus(const vector<FrontendStatusType>& in_statusTypes,
+ vector<FrontendStatus>* _aidl_return) {
+ if (mFrontend == nullptr) {
+ ALOGD("IFrontend is not initialized");
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
+ }
+
+ return mFrontend->getStatus(in_statusTypes, _aidl_return);
+}
+
+::ndk::ScopedAStatus TunerFrontend::getFrontendId(int32_t* _aidl_return) {
*_aidl_return = mId;
- return Status::ok();
+ return ::ndk::ScopedAStatus::ok();
}
/////////////// FrontendCallback ///////////////////////
-
-Return<void> TunerFrontend::FrontendCallback::onEvent(FrontendEventType frontendEventType) {
- ALOGD("FrontendCallback::onEvent, type=%d", frontendEventType);
- mTunerFrontendCallback->onEvent((int)frontendEventType);
- return Void();
+::ndk::ScopedAStatus TunerFrontend::FrontendCallback::onEvent(FrontendEventType frontendEventType) {
+ ALOGV("FrontendCallback::onEvent, type=%d", frontendEventType);
+ if (mTunerFrontendCallback != nullptr) {
+ mTunerFrontendCallback->onEvent(frontendEventType);
+ }
+ return ndk::ScopedAStatus::ok();
}
-Return<void> TunerFrontend::FrontendCallback::onScanMessage(
+::ndk::ScopedAStatus TunerFrontend::FrontendCallback::onScanMessage(
FrontendScanMessageType type, const FrontendScanMessage& message) {
- ALOGD("FrontendCallback::onScanMessage, type=%d", type);
- TunerFrontendScanMessage scanMessage;
- switch(type) {
- case FrontendScanMessageType::LOCKED: {
- scanMessage.set<TunerFrontendScanMessage::isLocked>(message.isLocked());
- break;
- }
- case FrontendScanMessageType::END: {
- scanMessage.set<TunerFrontendScanMessage::isEnd>(message.isEnd());
- break;
- }
- case FrontendScanMessageType::PROGRESS_PERCENT: {
- scanMessage.set<TunerFrontendScanMessage::progressPercent>(message.progressPercent());
- break;
- }
- case FrontendScanMessageType::FREQUENCY: {
- auto f = message.frequencies();
- vector<int> frequencies(begin(f), end(f));
- scanMessage.set<TunerFrontendScanMessage::frequencies>(frequencies);
- break;
- }
- case FrontendScanMessageType::SYMBOL_RATE: {
- auto s = message.symbolRates();
- vector<int> symbolRates(begin(s), end(s));
- scanMessage.set<TunerFrontendScanMessage::symbolRates>(symbolRates);
- break;
- }
- case FrontendScanMessageType::HIERARCHY: {
- scanMessage.set<TunerFrontendScanMessage::hierarchy>((int)message.hierarchy());
- break;
- }
- case FrontendScanMessageType::ANALOG_TYPE: {
- scanMessage.set<TunerFrontendScanMessage::analogType>((int)message.analogType());
- break;
- }
- case FrontendScanMessageType::PLP_IDS: {
- auto p = message.plpIds();
- vector<uint8_t> plpIds(begin(p), end(p));
- scanMessage.set<TunerFrontendScanMessage::plpIds>(plpIds);
- break;
- }
- case FrontendScanMessageType::GROUP_IDS: {
- auto g = message.groupIds();
- vector<uint8_t> groupIds(begin(g), end(g));
- scanMessage.set<TunerFrontendScanMessage::groupIds>(groupIds);
- break;
- }
- case FrontendScanMessageType::INPUT_STREAM_IDS: {
- auto i = message.inputStreamIds();
- vector<char16_t> streamIds(begin(i), end(i));
- scanMessage.set<TunerFrontendScanMessage::inputStreamIds>(streamIds);
- break;
- }
- case FrontendScanMessageType::STANDARD: {
- FrontendScanMessage::Standard std = message.std();
- int standard;
- if (std.getDiscriminator() == FrontendScanMessage::Standard::hidl_discriminator::sStd) {
- standard = (int) std.sStd();
- } else if (std.getDiscriminator() ==
- FrontendScanMessage::Standard::hidl_discriminator::tStd) {
- standard = (int) std.tStd();
- } else if (std.getDiscriminator() ==
- FrontendScanMessage::Standard::hidl_discriminator::sifStd) {
- standard = (int) std.sifStd();
- }
- scanMessage.set<TunerFrontendScanMessage::std>(standard);
- break;
- }
- case FrontendScanMessageType::ATSC3_PLP_INFO: {
- vector<FrontendScanAtsc3PlpInfo> plpInfos = message.atsc3PlpInfos();
- vector<TunerFrontendScanAtsc3PlpInfo> tunerPlpInfos;
- for (int i = 0; i < plpInfos.size(); i++) {
- auto info = plpInfos[i];
- int8_t plpId = (int8_t) info.plpId;
- bool lls = (bool) info.bLlsFlag;
- TunerFrontendScanAtsc3PlpInfo plpInfo{
- .plpId = plpId,
- .llsFlag = lls,
- };
- tunerPlpInfos.push_back(plpInfo);
- }
- scanMessage.set<TunerFrontendScanMessage::atsc3PlpInfos>(tunerPlpInfos);
- break;
- }
- default:
- break;
+ ALOGV("FrontendCallback::onScanMessage, type=%d", type);
+ if (mTunerFrontendCallback != nullptr) {
+ mTunerFrontendCallback->onScanMessage(type, message);
}
- mTunerFrontendCallback->onScanMessage((int)type, scanMessage);
- return Void();
+ return ndk::ScopedAStatus::ok();
}
-Return<void> TunerFrontend::FrontendCallback::onScanMessageExt1_1(
- FrontendScanMessageTypeExt1_1 type, const FrontendScanMessageExt1_1& message) {
- ALOGD("onScanMessageExt1_1::onScanMessage, type=%d", type);
- TunerFrontendScanMessage scanMessage;
- switch(type) {
- case FrontendScanMessageTypeExt1_1::MODULATION: {
- FrontendModulation m = message.modulation();
- int modulation;
- switch (m.getDiscriminator()) {
- case FrontendModulation::hidl_discriminator::dvbc:
- modulation = (int) m.dvbc();
- break;
- case FrontendModulation::hidl_discriminator::dvbt:
- modulation = (int) m.dvbt();
- break;
- case FrontendModulation::hidl_discriminator::dvbs:
- modulation = (int) m.dvbs();
- break;
- case FrontendModulation::hidl_discriminator::isdbs:
- modulation = (int) m.isdbs();
- break;
- case FrontendModulation::hidl_discriminator::isdbs3:
- modulation = (int) m.isdbs3();
- break;
- case FrontendModulation::hidl_discriminator::isdbt:
- modulation = (int) m.isdbt();
- break;
- case FrontendModulation::hidl_discriminator::atsc:
- modulation = (int) m.atsc();
- break;
- case FrontendModulation::hidl_discriminator::atsc3:
- modulation = (int) m.atsc3();
- break;
- case FrontendModulation::hidl_discriminator::dtmb:
- modulation = (int) m.dtmb();
- break;
- }
- scanMessage.set<TunerFrontendScanMessage::modulation>(modulation);
- break;
- }
- case FrontendScanMessageTypeExt1_1::DVBC_ANNEX: {
- scanMessage.set<TunerFrontendScanMessage::annex>((int)message.annex());
- break;
- }
- case FrontendScanMessageTypeExt1_1::HIGH_PRIORITY: {
- scanMessage.set<TunerFrontendScanMessage::isHighPriority>(message.isHighPriority());
- break;
- }
- default:
- break;
- }
- mTunerFrontendCallback->onScanMessage((int)type, scanMessage);
- return Void();
-}
-
-/////////////// TunerFrontend Helper Methods ///////////////////////
-
-void TunerFrontend::getAidlFrontendStatus(
- vector<FrontendStatus>& hidlStatus, vector<TunerFrontendStatus>& aidlStatus) {
- for (FrontendStatus s : hidlStatus) {
- TunerFrontendStatus status;
- switch (s.getDiscriminator()) {
- case FrontendStatus::hidl_discriminator::isDemodLocked: {
- status.set<TunerFrontendStatus::isDemodLocked>(s.isDemodLocked());
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatus::hidl_discriminator::snr: {
- status.set<TunerFrontendStatus::snr>((int)s.snr());
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatus::hidl_discriminator::ber: {
- status.set<TunerFrontendStatus::ber>((int)s.ber());
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatus::hidl_discriminator::per: {
- status.set<TunerFrontendStatus::per>((int)s.per());
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatus::hidl_discriminator::preBer: {
- status.set<TunerFrontendStatus::preBer>((int)s.preBer());
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatus::hidl_discriminator::signalQuality: {
- status.set<TunerFrontendStatus::signalQuality>((int)s.signalQuality());
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatus::hidl_discriminator::signalStrength: {
- status.set<TunerFrontendStatus::signalStrength>((int)s.signalStrength());
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatus::hidl_discriminator::symbolRate: {
- status.set<TunerFrontendStatus::symbolRate>((int)s.symbolRate());
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatus::hidl_discriminator::innerFec: {
- status.set<TunerFrontendStatus::innerFec>((long)s.innerFec());
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatus::hidl_discriminator::modulation: {
- switch (s.modulation().getDiscriminator()) {
- case FrontendModulationStatus::hidl_discriminator::dvbc:
- status.set<TunerFrontendStatus::modulation>((int)s.modulation().dvbc());
- aidlStatus.push_back(status);
- break;
- case FrontendModulationStatus::hidl_discriminator::dvbs:
- status.set<TunerFrontendStatus::modulation>((int)s.modulation().dvbs());
- aidlStatus.push_back(status);
- break;
- case FrontendModulationStatus::hidl_discriminator::isdbs:
- status.set<TunerFrontendStatus::modulation>((int)s.modulation().isdbs());
- aidlStatus.push_back(status);
- break;
- case FrontendModulationStatus::hidl_discriminator::isdbs3:
- status.set<TunerFrontendStatus::modulation>((int)s.modulation().isdbs3());
- aidlStatus.push_back(status);
- break;
- case FrontendModulationStatus::hidl_discriminator::isdbt:
- status.set<TunerFrontendStatus::modulation>((int)s.modulation().isdbt());
- aidlStatus.push_back(status);
- break;
- }
- break;
- }
- case FrontendStatus::hidl_discriminator::inversion: {
- status.set<TunerFrontendStatus::inversion>((int)s.inversion());
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatus::hidl_discriminator::lnbVoltage: {
- status.set<TunerFrontendStatus::lnbVoltage>((int)s.lnbVoltage());
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatus::hidl_discriminator::plpId: {
- status.set<TunerFrontendStatus::plpId>((int8_t)s.plpId());
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatus::hidl_discriminator::isEWBS: {
- status.set<TunerFrontendStatus::isEWBS>(s.isEWBS());
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatus::hidl_discriminator::agc: {
- status.set<TunerFrontendStatus::agc>((int8_t)s.agc());
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatus::hidl_discriminator::isLnaOn: {
- status.set<TunerFrontendStatus::isLnaOn>(s.isLnaOn());
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatus::hidl_discriminator::isLayerError: {
- vector<bool> e(s.isLayerError().begin(), s.isLayerError().end());
- status.set<TunerFrontendStatus::isLayerError>(e);
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatus::hidl_discriminator::mer: {
- status.set<TunerFrontendStatus::mer>((int)s.mer());
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatus::hidl_discriminator::freqOffset: {
- status.set<TunerFrontendStatus::freqOffset>((int)s.freqOffset());
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatus::hidl_discriminator::hierarchy: {
- status.set<TunerFrontendStatus::hierarchy>((int)s.hierarchy());
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatus::hidl_discriminator::isRfLocked: {
- status.set<TunerFrontendStatus::isRfLocked>(s.isRfLocked());
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatus::hidl_discriminator::plpInfo: {
- vector<TunerFrontendStatusAtsc3PlpInfo> info;
- for (auto i : s.plpInfo()) {
- info.push_back({
- .plpId = (int8_t)i.plpId,
- .isLocked = i.isLocked,
- .uec = (int)i.uec,
- });
- }
- status.set<TunerFrontendStatus::plpInfo>(info);
- aidlStatus.push_back(status);
- break;
- }
- }
- }
-}
-
-void TunerFrontend::getAidlFrontendStatusExt(
- vector<FrontendStatusExt1_1>& hidlStatus, vector<TunerFrontendStatus>& aidlStatus) {
- for (FrontendStatusExt1_1 s : hidlStatus) {
- TunerFrontendStatus status;
- switch (s.getDiscriminator()) {
- case FrontendStatusExt1_1::hidl_discriminator::modulations: {
- vector<int> aidlMod;
- for (auto m : s.modulations()) {
- switch (m.getDiscriminator()) {
- case FrontendModulation::hidl_discriminator::dvbc:
- aidlMod.push_back((int)m.dvbc());
- break;
- case FrontendModulation::hidl_discriminator::dvbs:
- aidlMod.push_back((int)m.dvbs());
- break;
- case FrontendModulation::hidl_discriminator::dvbt:
- aidlMod.push_back((int)m.dvbt());
- break;
- case FrontendModulation::hidl_discriminator::isdbs:
- aidlMod.push_back((int)m.isdbs());
- break;
- case FrontendModulation::hidl_discriminator::isdbs3:
- aidlMod.push_back((int)m.isdbs3());
- break;
- case FrontendModulation::hidl_discriminator::isdbt:
- aidlMod.push_back((int)m.isdbt());
- break;
- case FrontendModulation::hidl_discriminator::atsc:
- aidlMod.push_back((int)m.atsc());
- break;
- case FrontendModulation::hidl_discriminator::atsc3:
- aidlMod.push_back((int)m.atsc3());
- break;
- case FrontendModulation::hidl_discriminator::dtmb:
- aidlMod.push_back((int)m.dtmb());
- break;
- }
- }
- status.set<TunerFrontendStatus::modulations>(aidlMod);
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatusExt1_1::hidl_discriminator::bers: {
- vector<int> b(s.bers().begin(), s.bers().end());
- status.set<TunerFrontendStatus::bers>(b);
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatusExt1_1::hidl_discriminator::codeRates: {
- vector<int64_t> codeRates;
- for (auto c : s.codeRates()) {
- codeRates.push_back((long)c);
- }
- status.set<TunerFrontendStatus::codeRates>(codeRates);
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatusExt1_1::hidl_discriminator::bandwidth: {
- switch (s.bandwidth().getDiscriminator()) {
- case FrontendBandwidth::hidl_discriminator::atsc3:
- status.set<TunerFrontendStatus::bandwidth>((int)s.bandwidth().atsc3());
- break;
- case FrontendBandwidth::hidl_discriminator::dvbc:
- status.set<TunerFrontendStatus::bandwidth>((int)s.bandwidth().dvbc());
- break;
- case FrontendBandwidth::hidl_discriminator::dvbt:
- status.set<TunerFrontendStatus::bandwidth>((int)s.bandwidth().dvbt());
- break;
- case FrontendBandwidth::hidl_discriminator::isdbt:
- status.set<TunerFrontendStatus::bandwidth>((int)s.bandwidth().isdbt());
- break;
- case FrontendBandwidth::hidl_discriminator::dtmb:
- status.set<TunerFrontendStatus::bandwidth>((int)s.bandwidth().dtmb());
- break;
- }
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatusExt1_1::hidl_discriminator::interval: {
- switch (s.interval().getDiscriminator()) {
- case FrontendGuardInterval::hidl_discriminator::dvbt:
- status.set<TunerFrontendStatus::interval>((int)s.interval().dvbt());
- break;
- case FrontendGuardInterval::hidl_discriminator::isdbt:
- status.set<TunerFrontendStatus::interval>((int)s.interval().isdbt());
- break;
- case FrontendGuardInterval::hidl_discriminator::dtmb:
- status.set<TunerFrontendStatus::interval>((int)s.interval().dtmb());
- break;
- }
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatusExt1_1::hidl_discriminator::transmissionMode: {
- switch (s.transmissionMode().getDiscriminator()) {
- case FrontendTransmissionMode::hidl_discriminator::dvbt:
- status.set<TunerFrontendStatus::transmissionMode>(
- (int)s.transmissionMode().dvbt());
- break;
- case FrontendTransmissionMode::hidl_discriminator::isdbt:
- status.set<TunerFrontendStatus::transmissionMode>(
- (int)s.transmissionMode().isdbt());
- break;
- case FrontendTransmissionMode::hidl_discriminator::dtmb:
- status.set<TunerFrontendStatus::transmissionMode>(
- (int)s.transmissionMode().dtmb());
- break;
- }
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatusExt1_1::hidl_discriminator::uec: {
- status.set<TunerFrontendStatus::uec>((int)s.uec());
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatusExt1_1::hidl_discriminator::systemId: {
- status.set<TunerFrontendStatus::systemId>((char16_t)s.systemId());
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatusExt1_1::hidl_discriminator::interleaving: {
- vector<int> aidlInter;
- for (auto i : s.interleaving()) {
- switch (i.getDiscriminator()) {
- case FrontendInterleaveMode::hidl_discriminator::atsc3:
- aidlInter.push_back((int)i.atsc3());
- break;
- case FrontendInterleaveMode::hidl_discriminator::dvbc:
- aidlInter.push_back((int)i.dvbc());
- break;
- case FrontendInterleaveMode::hidl_discriminator::dtmb:
- aidlInter.push_back((int)i.dtmb());
- break;
- }
- }
- status.set<TunerFrontendStatus::interleaving>(aidlInter);
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatusExt1_1::hidl_discriminator::isdbtSegment: {
- auto seg = s.isdbtSegment();
- vector<uint8_t> i(seg.begin(), seg.end());
- status.set<TunerFrontendStatus::isdbtSegment>(i);
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatusExt1_1::hidl_discriminator::tsDataRate: {
- vector<int> ts(s.tsDataRate().begin(), s.tsDataRate().end());
- status.set<TunerFrontendStatus::tsDataRate>(ts);
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatusExt1_1::hidl_discriminator::rollOff: {
- switch (s.rollOff().getDiscriminator()) {
- case FrontendRollOff::hidl_discriminator::dvbs:
- status.set<TunerFrontendStatus::rollOff>((int)s.rollOff().dvbs());
- break;
- case FrontendRollOff::hidl_discriminator::isdbs:
- status.set<TunerFrontendStatus::rollOff>((int)s.rollOff().isdbs());
- break;
- case FrontendRollOff::hidl_discriminator::isdbs3:
- status.set<TunerFrontendStatus::rollOff>((int)s.rollOff().isdbs3());
- break;
- }
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatusExt1_1::hidl_discriminator::isMiso: {
- status.set<TunerFrontendStatus::isMiso>(s.isMiso());
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatusExt1_1::hidl_discriminator::isLinear: {
- status.set<TunerFrontendStatus::isLinear>(s.isLinear());
- aidlStatus.push_back(status);
- break;
- }
- case FrontendStatusExt1_1::hidl_discriminator::isShortFrames: {
- status.set<TunerFrontendStatus::isShortFrames>(s.isShortFrames());
- aidlStatus.push_back(status);
- break;
- }
- }
- }
-}
-
-hidl_vec<FrontendAtsc3PlpSettings> TunerFrontend::getAtsc3PlpSettings(
- const TunerFrontendAtsc3Settings& settings) {
- int len = settings.plpSettings.size();
- hidl_vec<FrontendAtsc3PlpSettings> plps = hidl_vec<FrontendAtsc3PlpSettings>(len);
- // parse PLP settings
- for (int i = 0; i < len; i++) {
- uint8_t plpId = static_cast<uint8_t>(settings.plpSettings[i].plpId);
- FrontendAtsc3Modulation modulation =
- static_cast<FrontendAtsc3Modulation>(settings.plpSettings[i].modulation);
- FrontendAtsc3TimeInterleaveMode interleaveMode =
- static_cast<FrontendAtsc3TimeInterleaveMode>(
- settings.plpSettings[i].interleaveMode);
- FrontendAtsc3CodeRate codeRate =
- static_cast<FrontendAtsc3CodeRate>(settings.plpSettings[i].codeRate);
- FrontendAtsc3Fec fec =
- static_cast<FrontendAtsc3Fec>(settings.plpSettings[i].fec);
- FrontendAtsc3PlpSettings frontendAtsc3PlpSettings {
- .plpId = plpId,
- .modulation = modulation,
- .interleaveMode = interleaveMode,
- .codeRate = codeRate,
- .fec = fec,
- };
- plps[i] = frontendAtsc3PlpSettings;
- }
- return plps;
-}
-
-FrontendDvbsCodeRate TunerFrontend::getDvbsCodeRate(const TunerFrontendDvbsCodeRate& codeRate) {
- FrontendInnerFec innerFec = static_cast<FrontendInnerFec>(codeRate.fec);
- bool isLinear = codeRate.isLinear;
- bool isShortFrames = codeRate.isShortFrames;
- uint32_t bitsPer1000Symbol = static_cast<uint32_t>(codeRate.bitsPer1000Symbol);
- FrontendDvbsCodeRate coderate {
- .fec = innerFec,
- .isLinear = isLinear,
- .isShortFrames = isShortFrames,
- .bitsPer1000Symbol = bitsPer1000Symbol,
- };
- return coderate;
-}
-
-FrontendSettings TunerFrontend::getHidlFrontendSettings(const TunerFrontendSettings& aidlSettings) {
- auto settings = aidlSettings.settings;
- FrontendSettings frontendSettings;
-
- switch (settings.getTag()) {
- case TunerFrontendUnionSettings::analog: {
- auto analog = settings.get<TunerFrontendUnionSettings::analog>();
- frontendSettings.analog({
- .frequency = static_cast<uint32_t>(analog.frequency),
- .type = static_cast<FrontendAnalogType>(analog.signalType),
- .sifStandard = static_cast<FrontendAnalogSifStandard>(analog.sifStandard),
- });
- break;
- }
- case TunerFrontendUnionSettings::atsc: {
- auto atsc = settings.get<TunerFrontendUnionSettings::atsc>();
- frontendSettings.atsc({
- .frequency = static_cast<uint32_t>(atsc.frequency),
- .modulation = static_cast<FrontendAtscModulation>(atsc.modulation),
- });
- break;
- }
- case TunerFrontendUnionSettings::atsc3: {
- auto atsc3 = settings.get<TunerFrontendUnionSettings::atsc3>();
- frontendSettings.atsc3({
- .frequency = static_cast<uint32_t>(atsc3.frequency),
- .bandwidth = static_cast<FrontendAtsc3Bandwidth>(atsc3.bandwidth),
- .demodOutputFormat = static_cast<FrontendAtsc3DemodOutputFormat>(
- atsc3.demodOutputFormat),
- .plpSettings = getAtsc3PlpSettings(atsc3),
- });
- break;
- }
- case TunerFrontendUnionSettings::cable: {
- auto dvbc = settings.get<TunerFrontendUnionSettings::cable>();
- frontendSettings.dvbc({
- .frequency = static_cast<uint32_t>(dvbc.frequency),
- .modulation = static_cast<FrontendDvbcModulation>(dvbc.modulation),
- .fec = static_cast<FrontendInnerFec>(dvbc.innerFec),
- .symbolRate = static_cast<uint32_t>(dvbc.symbolRate),
- .outerFec = static_cast<FrontendDvbcOuterFec>(dvbc.outerFec),
- .annex = static_cast<FrontendDvbcAnnex>(dvbc.annex),
- .spectralInversion = static_cast<FrontendDvbcSpectralInversion>(
- dvbc.spectralInversion),
- });
- break;
- }
- case TunerFrontendUnionSettings::dvbs: {
- auto dvbs = settings.get<TunerFrontendUnionSettings::dvbs>();
- frontendSettings.dvbs({
- .frequency = static_cast<uint32_t>(dvbs.frequency),
- .modulation = static_cast<FrontendDvbsModulation>(dvbs.modulation),
- .coderate = getDvbsCodeRate(dvbs.codeRate),
- .symbolRate = static_cast<uint32_t>(dvbs.symbolRate),
- .rolloff = static_cast<FrontendDvbsRolloff>(dvbs.rolloff),
- .pilot = static_cast<FrontendDvbsPilot>(dvbs.pilot),
- .inputStreamId = static_cast<uint32_t>(dvbs.inputStreamId),
- .standard = static_cast<FrontendDvbsStandard>(dvbs.standard),
- .vcmMode = static_cast<FrontendDvbsVcmMode>(dvbs.vcm),
- });
- break;
- }
- case TunerFrontendUnionSettings::dvbt: {
- auto dvbt = settings.get<TunerFrontendUnionSettings::dvbt>();
- frontendSettings.dvbt({
- .frequency = static_cast<uint32_t>(dvbt.frequency),
- .transmissionMode = static_cast<FrontendDvbtTransmissionMode>(
- dvbt.transmissionMode),
- .bandwidth = static_cast<FrontendDvbtBandwidth>(dvbt.bandwidth),
- .constellation = static_cast<FrontendDvbtConstellation>(dvbt.constellation),
- .hierarchy = static_cast<FrontendDvbtHierarchy>(dvbt.hierarchy),
- .hpCoderate = static_cast<FrontendDvbtCoderate>(dvbt.hpCodeRate),
- .lpCoderate = static_cast<FrontendDvbtCoderate>(dvbt.lpCodeRate),
- .guardInterval = static_cast<FrontendDvbtGuardInterval>(dvbt.guardInterval),
- .isHighPriority = dvbt.isHighPriority,
- .standard = static_cast<FrontendDvbtStandard>(dvbt.standard),
- .isMiso = dvbt.isMiso,
- .plpMode = static_cast<FrontendDvbtPlpMode>(dvbt.plpMode),
- .plpId = static_cast<uint8_t>(dvbt.plpId),
- .plpGroupId = static_cast<uint8_t>(dvbt.plpGroupId),
- });
- break;
- }
- case TunerFrontendUnionSettings::isdbs: {
- auto isdbs = settings.get<TunerFrontendUnionSettings::isdbs>();
- frontendSettings.isdbs({
- .frequency = static_cast<uint32_t>(isdbs.frequency),
- .streamId = static_cast<uint16_t>(isdbs.streamId),
- .streamIdType = static_cast<FrontendIsdbsStreamIdType>(isdbs.streamIdType),
- .modulation = static_cast<FrontendIsdbsModulation>(isdbs.modulation),
- .coderate = static_cast<FrontendIsdbsCoderate>(isdbs.codeRate),
- .symbolRate = static_cast<uint32_t>(isdbs.symbolRate),
- .rolloff = static_cast<FrontendIsdbsRolloff>(isdbs.rolloff),
- });
- break;
- }
- case TunerFrontendUnionSettings::isdbs3: {
- auto isdbs3 = settings.get<TunerFrontendUnionSettings::isdbs3>();
- frontendSettings.isdbs3({
- .frequency = static_cast<uint32_t>(isdbs3.frequency),
- .streamId = static_cast<uint16_t>(isdbs3.streamId),
- .streamIdType = static_cast<FrontendIsdbsStreamIdType>(isdbs3.streamIdType),
- .modulation = static_cast<FrontendIsdbs3Modulation>(isdbs3.modulation),
- .coderate = static_cast<FrontendIsdbs3Coderate>(isdbs3.codeRate),
- .symbolRate = static_cast<uint32_t>(isdbs3.symbolRate),
- .rolloff = static_cast<FrontendIsdbs3Rolloff>(isdbs3.rolloff),
- });
- break;
- }
- case TunerFrontendUnionSettings::isdbt: {
- auto isdbt = settings.get<TunerFrontendUnionSettings::isdbt>();
- frontendSettings.isdbt({
- .frequency = static_cast<uint32_t>(isdbt.frequency),
- .modulation = static_cast<FrontendIsdbtModulation>(isdbt.modulation),
- .bandwidth = static_cast<FrontendIsdbtBandwidth>(isdbt.bandwidth),
- .mode = static_cast<FrontendIsdbtMode>(isdbt.mode),
- .coderate = static_cast<FrontendIsdbtCoderate>(isdbt.codeRate),
- .guardInterval = static_cast<FrontendIsdbtGuardInterval>(isdbt.guardInterval),
- .serviceAreaId = static_cast<uint32_t>(isdbt.serviceAreaId),
- });
- break;
- }
- default:
- break;
- }
-
- return frontendSettings;
-}
-
-FrontendSettingsExt1_1 TunerFrontend::getHidlFrontendSettingsExt(
- const TunerFrontendSettings& aidlSettings) {
- FrontendSettingsExt1_1 frontendSettingsExt{
- .endFrequency = static_cast<uint32_t>(aidlSettings.endFrequency),
- .inversion = static_cast<FrontendSpectralInversion>(aidlSettings.inversion),
- };
-
- auto settings = aidlSettings.settings;
- switch (settings.getTag()) {
- case TunerFrontendUnionSettings::analog: {
- auto analog = settings.get<TunerFrontendUnionSettings::analog>();
- if (analog.isExtended) {
- frontendSettingsExt.settingExt.analog({
- .aftFlag = static_cast<FrontendAnalogAftFlag>(analog.aftFlag),
- });
- } else {
- frontendSettingsExt.settingExt.noinit();
- }
- break;
- }
- case TunerFrontendUnionSettings::cable: {
- auto dvbc = settings.get<TunerFrontendUnionSettings::cable>();
- if (dvbc.isExtended) {
- frontendSettingsExt.settingExt.dvbc({
- .interleaveMode = static_cast<FrontendCableTimeInterleaveMode>(
- dvbc.interleaveMode),
- .bandwidth = static_cast<FrontendDvbcBandwidth>(
- dvbc.bandwidth),
- });
- } else {
- frontendSettingsExt.settingExt.noinit();
- }
- break;
- }
- case TunerFrontendUnionSettings::dvbs: {
- auto dvbs = settings.get<TunerFrontendUnionSettings::dvbs>();
- if (dvbs.isExtended) {
- frontendSettingsExt.settingExt.dvbs({
- .scanType = static_cast<FrontendDvbsScanType>(dvbs.scanType),
- .isDiseqcRxMessage = dvbs.isDiseqcRxMessage,
- });
- } else {
- frontendSettingsExt.settingExt.noinit();
- }
- break;
- }
- case TunerFrontendUnionSettings::dvbt: {
- auto dvbt = settings.get<TunerFrontendUnionSettings::dvbt>();
- if (dvbt.isExtended) {
- frontendSettingsExt.settingExt.dvbt({
- .constellation =
- static_cast<hardware::tv::tuner::V1_1::FrontendDvbtConstellation>(
- dvbt.constellation),
- .transmissionMode =
- static_cast<hardware::tv::tuner::V1_1::FrontendDvbtTransmissionMode>(
- dvbt.transmissionMode),
- });
- } else {
- frontendSettingsExt.settingExt.noinit();
- }
- break;
- }
- case TunerFrontendUnionSettings::dtmb: {
- auto dtmb = settings.get<TunerFrontendUnionSettings::dtmb>();
- frontendSettingsExt.settingExt.dtmb({
- .frequency = static_cast<uint32_t>(dtmb.frequency),
- .transmissionMode = static_cast<FrontendDtmbTransmissionMode>(
- dtmb.transmissionMode),
- .bandwidth = static_cast<FrontendDtmbBandwidth>(dtmb.bandwidth),
- .modulation = static_cast<FrontendDtmbModulation>(dtmb.modulation),
- .codeRate = static_cast<FrontendDtmbCodeRate>(dtmb.codeRate),
- .guardInterval = static_cast<FrontendDtmbGuardInterval>(dtmb.guardInterval),
- .interleaveMode = static_cast<FrontendDtmbTimeInterleaveMode>(dtmb.interleaveMode),
- });
- break;
- }
- default:
- frontendSettingsExt.settingExt.noinit();
- break;
- }
-
- return frontendSettingsExt;
-}
+} // namespace tuner
+} // namespace tv
+} // namespace media
} // namespace android
+} // namespace aidl
diff --git a/services/tuner/TunerFrontend.h b/services/tuner/TunerFrontend.h
index 22fd509..4106941 100644
--- a/services/tuner/TunerFrontend.h
+++ b/services/tuner/TunerFrontend.h
@@ -1,5 +1,5 @@
/**
- * Copyright 2020, The Android Open Source Project
+ * Copyright 2021, 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.
@@ -17,95 +17,74 @@
#ifndef ANDROID_MEDIA_TUNERFRONTEND_H
#define ANDROID_MEDIA_TUNERFRONTEND_H
+#include <aidl/android/hardware/tv/tuner/BnFrontendCallback.h>
+#include <aidl/android/hardware/tv/tuner/IFrontend.h>
+#include <aidl/android/hardware/tv/tuner/IFrontendCallback.h>
#include <aidl/android/media/tv/tuner/BnTunerFrontend.h>
-#include <android/hardware/tv/tuner/1.0/ITuner.h>
-#include <android/hardware/tv/tuner/1.1/IFrontend.h>
-#include <android/hardware/tv/tuner/1.1/IFrontendCallback.h>
#include <media/stagefright/foundation/ADebug.h>
#include <utils/Log.h>
-using Status = ::ndk::ScopedAStatus;
-using ::aidl::android::media::tv::tuner::BnTunerFrontend;
-using ::aidl::android::media::tv::tuner::ITunerFrontendCallback;
-using ::aidl::android::media::tv::tuner::ITunerLnb;
-using ::aidl::android::media::tv::tuner::TunerFrontendAtsc3Settings;
-using ::aidl::android::media::tv::tuner::TunerFrontendDvbsCodeRate;
-using ::aidl::android::media::tv::tuner::TunerFrontendScanMessage;
-using ::aidl::android::media::tv::tuner::TunerFrontendSettings;
-using ::aidl::android::media::tv::tuner::TunerFrontendStatus;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::tv::tuner::V1_0::FrontendAtsc3PlpSettings;
-using ::android::hardware::tv::tuner::V1_0::FrontendDvbsCodeRate;
-using ::android::hardware::tv::tuner::V1_0::FrontendEventType;
-using ::android::hardware::tv::tuner::V1_0::FrontendId;
-using ::android::hardware::tv::tuner::V1_0::FrontendScanMessage;
-using ::android::hardware::tv::tuner::V1_0::FrontendScanMessageType;
-using ::android::hardware::tv::tuner::V1_0::FrontendSettings;
-using ::android::hardware::tv::tuner::V1_0::FrontendStatus;
-using ::android::hardware::tv::tuner::V1_0::IFrontend;
-using ::android::hardware::tv::tuner::V1_1::IFrontendCallback;
-using ::android::hardware::tv::tuner::V1_1::FrontendScanMessageExt1_1;
-using ::android::hardware::tv::tuner::V1_1::FrontendScanMessageTypeExt1_1;
-using ::android::hardware::tv::tuner::V1_1::FrontendSettingsExt1_1;
-using ::android::hardware::tv::tuner::V1_1::FrontendStatusExt1_1;
+using ::aidl::android::hardware::tv::tuner::BnFrontendCallback;
+using ::aidl::android::hardware::tv::tuner::FrontendEventType;
+using ::aidl::android::hardware::tv::tuner::FrontendScanMessage;
+using ::aidl::android::hardware::tv::tuner::FrontendScanMessageType;
+using ::aidl::android::hardware::tv::tuner::FrontendScanType;
+using ::aidl::android::hardware::tv::tuner::FrontendSettings;
+using ::aidl::android::hardware::tv::tuner::FrontendStatus;
+using ::aidl::android::hardware::tv::tuner::FrontendStatusType;
+using ::aidl::android::hardware::tv::tuner::IFrontend;
+using ::aidl::android::hardware::tv::tuner::IFrontendCallback;
using namespace std;
+namespace aidl {
namespace android {
+namespace media {
+namespace tv {
+namespace tuner {
class TunerFrontend : public BnTunerFrontend {
public:
- TunerFrontend(sp<IFrontend> frontend, int id);
+ TunerFrontend(shared_ptr<IFrontend> frontend, int id);
virtual ~TunerFrontend();
- Status setCallback(
- const shared_ptr<ITunerFrontendCallback>& tunerFrontendCallback) override;
- Status tune(const TunerFrontendSettings& settings) override;
- Status stopTune() override;
- Status scan(const TunerFrontendSettings& settings, int frontendScanType) override;
- Status stopScan() override;
- Status setLnb(const shared_ptr<ITunerLnb>& lnb) override;
- Status setLna(bool bEnable) override;
- Status linkCiCamToFrontend(int ciCamId, int32_t* _aidl_return) override;
- Status unlinkCiCamToFrontend(int ciCamId) override;
- Status close() override;
- Status getStatus(const vector<int32_t>& statusTypes,
- vector<TunerFrontendStatus>* _aidl_return) override;
- Status getStatusExtended_1_1(const vector<int32_t>& statusTypes,
- vector<TunerFrontendStatus>* _aidl_return) override;
- Status getFrontendId(int* _aidl_return) override;
- struct FrontendCallback : public IFrontendCallback {
+ ::ndk::ScopedAStatus setCallback(
+ const shared_ptr<ITunerFrontendCallback>& in_tunerFrontendCallback) override;
+ ::ndk::ScopedAStatus tune(const FrontendSettings& in_settings) override;
+ ::ndk::ScopedAStatus stopTune() override;
+ ::ndk::ScopedAStatus scan(const FrontendSettings& in_settings,
+ FrontendScanType in_frontendScanType) override;
+ ::ndk::ScopedAStatus stopScan() override;
+ ::ndk::ScopedAStatus setLnb(const shared_ptr<ITunerLnb>& in_lnb) override;
+ ::ndk::ScopedAStatus setLna(bool in_bEnable) override;
+ ::ndk::ScopedAStatus linkCiCamToFrontend(int32_t in_ciCamId, int32_t* _aidl_return) override;
+ ::ndk::ScopedAStatus unlinkCiCamToFrontend(int32_t in_ciCamId) override;
+ ::ndk::ScopedAStatus close() override;
+ ::ndk::ScopedAStatus getStatus(const vector<FrontendStatusType>& in_statusTypes,
+ vector<FrontendStatus>* _aidl_return) override;
+ ::ndk::ScopedAStatus getFrontendId(int32_t* _aidl_return) override;
+
+ struct FrontendCallback : public BnFrontendCallback {
FrontendCallback(const shared_ptr<ITunerFrontendCallback> tunerFrontendCallback)
- : mTunerFrontendCallback(tunerFrontendCallback) {};
+ : mTunerFrontendCallback(tunerFrontendCallback){};
- virtual Return<void> onEvent(FrontendEventType frontendEventType);
- virtual Return<void> onScanMessage(
- FrontendScanMessageType type, const FrontendScanMessage& message);
- virtual Return<void> onScanMessageExt1_1(
- FrontendScanMessageTypeExt1_1 type, const FrontendScanMessageExt1_1& message);
+ ::ndk::ScopedAStatus onEvent(FrontendEventType frontendEventType) override;
+ ::ndk::ScopedAStatus onScanMessage(FrontendScanMessageType type,
+ const FrontendScanMessage& message) override;
shared_ptr<ITunerFrontendCallback> mTunerFrontendCallback;
};
private:
- hidl_vec<FrontendAtsc3PlpSettings> getAtsc3PlpSettings(
- const TunerFrontendAtsc3Settings& settings);
- FrontendDvbsCodeRate getDvbsCodeRate(const TunerFrontendDvbsCodeRate& codeRate);
- FrontendSettings getHidlFrontendSettings(const TunerFrontendSettings& aidlSettings);
- FrontendSettingsExt1_1 getHidlFrontendSettingsExt(const TunerFrontendSettings& aidlSettings);
- void getAidlFrontendStatus(
- vector<FrontendStatus>& hidlStatus, vector<TunerFrontendStatus>& aidlStatus);
- void getAidlFrontendStatusExt(
- vector<FrontendStatusExt1_1>& hidlStatus, vector<TunerFrontendStatus>& aidlStatus);
-
int mId;
- sp<IFrontend> mFrontend;
- sp<::android::hardware::tv::tuner::V1_1::IFrontend> mFrontend_1_1;
+ shared_ptr<IFrontend> mFrontend;
};
-} // namespace android
+} // namespace tuner
+} // namespace tv
+} // namespace media
+} // namespace android
+} // namespace aidl
#endif // ANDROID_MEDIA_TUNERFRONTEND_H
diff --git a/services/tuner/TunerLnb.cpp b/services/tuner/TunerLnb.cpp
index 77248d4..1e143c3 100644
--- a/services/tuner/TunerLnb.cpp
+++ b/services/tuner/TunerLnb.cpp
@@ -18,123 +18,116 @@
#include "TunerLnb.h"
-using ::android::hardware::tv::tuner::V1_0::LnbPosition;
-using ::android::hardware::tv::tuner::V1_0::LnbTone;
-using ::android::hardware::tv::tuner::V1_0::LnbVoltage;
-using ::android::hardware::tv::tuner::V1_0::Result;
+#include <aidl/android/hardware/tv/tuner/ILnbCallback.h>
+#include <aidl/android/hardware/tv/tuner/Result.h>
+using ::aidl::android::hardware::tv::tuner::ILnbCallback;
+using ::aidl::android::hardware::tv::tuner::Result;
+
+namespace aidl {
namespace android {
+namespace media {
+namespace tv {
+namespace tuner {
-TunerLnb::TunerLnb(sp<ILnb> lnb, int id) {
+TunerLnb::TunerLnb(shared_ptr<ILnb> lnb, int id) {
mLnb = lnb;
mId = id;
}
TunerLnb::~TunerLnb() {
- mLnb = NULL;
+ mLnb = nullptr;
mId = -1;
}
-Status TunerLnb::setCallback(
- const shared_ptr<ITunerLnbCallback>& tunerLnbCallback) {
- if (mLnb == NULL) {
+::ndk::ScopedAStatus TunerLnb::setCallback(
+ const shared_ptr<ITunerLnbCallback>& in_tunerLnbCallback) {
+ if (mLnb == nullptr) {
ALOGE("ILnb is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- if (tunerLnbCallback == NULL) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::INVALID_ARGUMENT));
+ if (in_tunerLnbCallback == nullptr) {
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::INVALID_ARGUMENT));
}
- sp<ILnbCallback> lnbCallback = new LnbCallback(tunerLnbCallback);
- Result status = mLnb->setCallback(lnbCallback);
- if (status != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(status));
- }
- return Status::ok();
+ shared_ptr<ILnbCallback> lnbCallback =
+ ::ndk::SharedRefBase::make<LnbCallback>(in_tunerLnbCallback);
+ return mLnb->setCallback(lnbCallback);
}
-Status TunerLnb::setVoltage(int voltage) {
- if (mLnb == NULL) {
+::ndk::ScopedAStatus TunerLnb::setVoltage(LnbVoltage in_voltage) {
+ if (mLnb == nullptr) {
ALOGE("ILnb is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result status = mLnb->setVoltage(static_cast<LnbVoltage>(voltage));
- if (status != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(status));
- }
- return Status::ok();
+ return mLnb->setVoltage(in_voltage);
}
-Status TunerLnb::setTone(int tone) {
- if (mLnb == NULL) {
+::ndk::ScopedAStatus TunerLnb::setTone(LnbTone in_tone) {
+ if (mLnb == nullptr) {
ALOGE("ILnb is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result status = mLnb->setTone(static_cast<LnbTone>(tone));
- if (status != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(status));
- }
- return Status::ok();
+ return mLnb->setTone(in_tone);
}
-Status TunerLnb::setSatellitePosition(int position) {
- if (mLnb == NULL) {
+::ndk::ScopedAStatus TunerLnb::setSatellitePosition(LnbPosition in_position) {
+ if (mLnb == nullptr) {
ALOGE("ILnb is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result status = mLnb->setSatellitePosition(static_cast<LnbPosition>(position));
- if (status != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(status));
- }
- return Status::ok();
+ return mLnb->setSatellitePosition(in_position);
}
-Status TunerLnb::sendDiseqcMessage(const vector<uint8_t>& diseqcMessage) {
- if (mLnb == NULL) {
+::ndk::ScopedAStatus TunerLnb::sendDiseqcMessage(const vector<uint8_t>& in_diseqcMessage) {
+ if (mLnb == nullptr) {
ALOGE("ILnb is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result status = mLnb->sendDiseqcMessage(diseqcMessage);
- if (status != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(status));
- }
- return Status::ok();
+ return mLnb->sendDiseqcMessage(in_diseqcMessage);
}
-Status TunerLnb::close() {
- if (mLnb == NULL) {
+::ndk::ScopedAStatus TunerLnb::close() {
+ if (mLnb == nullptr) {
ALOGE("ILnb is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result res = mLnb->close();
- mLnb = NULL;
+ auto res = mLnb->close();
+ mLnb = nullptr;
- if (res != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
- }
- return Status::ok();
+ return res;
}
/////////////// ILnbCallback ///////////////////////
-
-Return<void> TunerLnb::LnbCallback::onEvent(const LnbEventType lnbEventType) {
- if (mTunerLnbCallback != NULL) {
- mTunerLnbCallback->onEvent((int)lnbEventType);
+::ndk::ScopedAStatus TunerLnb::LnbCallback::onEvent(const LnbEventType lnbEventType) {
+ if (mTunerLnbCallback != nullptr) {
+ mTunerLnbCallback->onEvent(lnbEventType);
}
- return Void();
+ return ndk::ScopedAStatus::ok();
}
-Return<void> TunerLnb::LnbCallback::onDiseqcMessage(const hidl_vec<uint8_t>& diseqcMessage) {
- if (mTunerLnbCallback != NULL && diseqcMessage != NULL) {
- vector<uint8_t> msg(begin(diseqcMessage), end(diseqcMessage));
- mTunerLnbCallback->onDiseqcMessage(msg);
+::ndk::ScopedAStatus TunerLnb::LnbCallback::onDiseqcMessage(const vector<uint8_t>& diseqcMessage) {
+ if (mTunerLnbCallback != nullptr) {
+ mTunerLnbCallback->onDiseqcMessage(diseqcMessage);
}
- return Void();
+ return ndk::ScopedAStatus::ok();
}
+
+} // namespace tuner
+} // namespace tv
+} // namespace media
} // namespace android
+} // namespace aidl
diff --git a/services/tuner/TunerLnb.h b/services/tuner/TunerLnb.h
index 500d072..37efdf8 100644
--- a/services/tuner/TunerLnb.h
+++ b/services/tuner/TunerLnb.h
@@ -17,55 +17,62 @@
#ifndef ANDROID_MEDIA_TUNERFLNB_H
#define ANDROID_MEDIA_TUNERFLNB_H
+#include <aidl/android/hardware/tv/tuner/BnLnbCallback.h>
+#include <aidl/android/hardware/tv/tuner/ILnb.h>
#include <aidl/android/media/tv/tuner/BnTunerLnb.h>
-#include <android/hardware/tv/tuner/1.0/ILnb.h>
-#include <android/hardware/tv/tuner/1.0/ILnbCallback.h>
#include <media/stagefright/foundation/ADebug.h>
#include <utils/Log.h>
-using Status = ::ndk::ScopedAStatus;
-using ::aidl::android::media::tv::tuner::BnTunerLnb;
-using ::aidl::android::media::tv::tuner::ITunerLnbCallback;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::tv::tuner::V1_0::ILnb;
-using ::android::hardware::tv::tuner::V1_0::ILnbCallback;
-using ::android::hardware::tv::tuner::V1_0::LnbEventType;
+using ::aidl::android::hardware::tv::tuner::BnLnbCallback;
+using ::aidl::android::hardware::tv::tuner::ILnb;
+using ::aidl::android::hardware::tv::tuner::LnbEventType;
+using ::aidl::android::hardware::tv::tuner::LnbPosition;
+using ::aidl::android::hardware::tv::tuner::LnbTone;
+using ::aidl::android::hardware::tv::tuner::LnbVoltage;
using namespace std;
+namespace aidl {
namespace android {
+namespace media {
+namespace tv {
+namespace tuner {
class TunerLnb : public BnTunerLnb {
public:
- TunerLnb(sp<ILnb> lnb, int id);
+ TunerLnb(shared_ptr<ILnb> lnb, int id);
virtual ~TunerLnb();
- Status setCallback(const shared_ptr<ITunerLnbCallback>& tunerLnbCallback) override;
- Status setVoltage(int voltage) override;
- Status setTone(int tone) override;
- Status setSatellitePosition(int position) override;
- Status sendDiseqcMessage(const vector<uint8_t>& diseqcMessage) override;
- Status close() override;
+
+ ::ndk::ScopedAStatus setCallback(
+ const shared_ptr<ITunerLnbCallback>& in_tunerLnbCallback) override;
+ ::ndk::ScopedAStatus setVoltage(LnbVoltage in_voltage) override;
+ ::ndk::ScopedAStatus setTone(LnbTone in_tone) override;
+ ::ndk::ScopedAStatus setSatellitePosition(LnbPosition in_position) override;
+ ::ndk::ScopedAStatus sendDiseqcMessage(const vector<uint8_t>& in_diseqcMessage) override;
+ ::ndk::ScopedAStatus close() override;
int getId() { return mId; }
- struct LnbCallback : public ILnbCallback {
+ struct LnbCallback : public BnLnbCallback {
LnbCallback(const shared_ptr<ITunerLnbCallback> tunerLnbCallback)
- : mTunerLnbCallback(tunerLnbCallback) {};
+ : mTunerLnbCallback(tunerLnbCallback){};
- virtual Return<void> onEvent(const LnbEventType lnbEventType);
- virtual Return<void> onDiseqcMessage(const hidl_vec<uint8_t>& diseqcMessage);
+ ::ndk::ScopedAStatus onEvent(const LnbEventType lnbEventType) override;
+ ::ndk::ScopedAStatus onDiseqcMessage(const vector<uint8_t>& diseqcMessage) override;
shared_ptr<ITunerLnbCallback> mTunerLnbCallback;
};
private:
int mId;
- sp<ILnb> mLnb;
+ shared_ptr<ILnb> mLnb;
};
-} // namespace android
+} // namespace tuner
+} // namespace tv
+} // namespace media
+} // namespace android
+} // namespace aidl
#endif // ANDROID_MEDIA_TUNERFLNB_H
diff --git a/services/tuner/TunerService.cpp b/services/tuner/TunerService.cpp
index 5b4129a..0703700 100644
--- a/services/tuner/TunerService.cpp
+++ b/services/tuner/TunerService.cpp
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2020, The Android Open Source Project
+ * Copyright (c) 2021, 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.
@@ -14,60 +14,63 @@
* limitations under the License.
*/
+//#define LOG_NDEBUG 0
#define LOG_TAG "TunerService"
+#include "TunerService.h"
+
+#include <aidl/android/hardware/tv/tuner/IDemux.h>
+#include <aidl/android/hardware/tv/tuner/IDescrambler.h>
+#include <aidl/android/hardware/tv/tuner/IFrontend.h>
+#include <aidl/android/hardware/tv/tuner/ILnb.h>
+#include <aidl/android/hardware/tv/tuner/Result.h>
+#include <aidl/android/media/tv/tunerresourcemanager/TunerFrontendInfo.h>
#include <android/binder_manager.h>
#include <android/content/pm/IPackageManagerNative.h>
#include <binder/IServiceManager.h>
#include <utils/Log.h>
-#include "TunerService.h"
-#include "TunerFrontend.h"
-#include "TunerLnb.h"
+
#include "TunerDemux.h"
#include "TunerDescrambler.h"
+#include "TunerFrontend.h"
+#include "TunerLnb.h"
-using ::aidl::android::media::tv::tuner::TunerFrontendAnalogCapabilities;
-using ::aidl::android::media::tv::tuner::TunerFrontendAtsc3Capabilities;
-using ::aidl::android::media::tv::tuner::TunerFrontendAtscCapabilities;
-using ::aidl::android::media::tv::tuner::TunerFrontendCableCapabilities;
-using ::aidl::android::media::tv::tuner::TunerFrontendCapabilities;
-using ::aidl::android::media::tv::tuner::TunerFrontendDvbsCapabilities;
-using ::aidl::android::media::tv::tuner::TunerFrontendDvbtCapabilities;
-using ::aidl::android::media::tv::tuner::TunerFrontendIsdbs3Capabilities;
-using ::aidl::android::media::tv::tuner::TunerFrontendIsdbsCapabilities;
-using ::aidl::android::media::tv::tuner::TunerFrontendIsdbtCapabilities;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterAvSettings;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterMainType;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterSettings;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterType;
-using ::android::hardware::tv::tuner::V1_0::DemuxTsFilterType;
-using ::android::hardware::tv::tuner::V1_0::FrontendId;
-using ::android::hardware::tv::tuner::V1_0::FrontendType;
-using ::android::hardware::tv::tuner::V1_0::IFrontend;
-using ::android::hardware::tv::tuner::V1_0::ILnb;
-using ::android::hardware::tv::tuner::V1_0::LnbId;
-using ::android::hardware::tv::tuner::V1_0::Result;
-using ::android::hardware::tv::tuner::V1_1::FrontendDtmbCapabilities;
+using ::aidl::android::hardware::tv::tuner::IDemux;
+using ::aidl::android::hardware::tv::tuner::IDescrambler;
+using ::aidl::android::hardware::tv::tuner::IFrontend;
+using ::aidl::android::hardware::tv::tuner::Result;
+using ::aidl::android::media::tv::tunerresourcemanager::TunerFrontendInfo;
+using ::android::defaultServiceManager;
+using ::android::IBinder;
+using ::android::interface_cast;
+using ::android::IServiceManager;
+using ::android::sp;
+using ::android::String16;
+using ::android::binder::Status;
+using ::android::content::pm::IPackageManagerNative;
+namespace aidl {
namespace android {
+namespace media {
+namespace tv {
+namespace tuner {
TunerService::TunerService() {
sp<IServiceManager> serviceMgr = defaultServiceManager();
- sp<content::pm::IPackageManagerNative> packageMgr;
+ sp<IPackageManagerNative> packageMgr;
if (serviceMgr.get() == nullptr) {
ALOGE("%s: Cannot find service manager", __func__);
return;
} else {
sp<IBinder> binder = serviceMgr->waitForService(String16("package_native"));
- packageMgr = interface_cast<content::pm::IPackageManagerNative>(binder);
+ packageMgr = interface_cast<IPackageManagerNative>(binder);
}
- bool hasFeature = false;
if (packageMgr != nullptr) {
- binder::Status status = packageMgr->hasSystemFeature(FEATURE_TUNER, 0, &hasFeature);
+ bool hasFeature = false;
+ Status status = packageMgr->hasSystemFeature(FEATURE_TUNER, 0, &hasFeature);
if (!status.isOk()) {
- ALOGE("%s: hasSystemFeature failed: %s",
- __func__, status.exceptionMessage().c_str());
+ ALOGE("%s: hasSystemFeature failed: %s", __func__, status.exceptionMessage().c_str());
return;
}
if (!hasFeature) {
@@ -93,231 +96,149 @@
}
bool TunerService::hasITuner() {
- ALOGD("hasITuner");
+ ALOGV("hasITuner");
if (mTuner != nullptr) {
return true;
}
- mTuner = ITuner::getService();
- if (mTuner == nullptr) {
- ALOGE("Failed to get ITuner service");
+ const string statsServiceName = string() + ITuner::descriptor + "/default";
+ if (AServiceManager_isDeclared(statsServiceName.c_str())) {
+ ::ndk::SpAIBinder binder(AServiceManager_waitForService(statsServiceName.c_str()));
+ mTuner = ITuner::fromBinder(binder);
+ } else {
+ mTuner = nullptr;
+ ALOGE("Failed to get Tuner HAL Service");
return false;
}
- mTunerVersion = TUNER_HAL_VERSION_1_0;
- mTuner_1_1 = ::android::hardware::tv::tuner::V1_1::ITuner::castFrom(mTuner);
- if (mTuner_1_1 != nullptr) {
- mTunerVersion = TUNER_HAL_VERSION_1_1;
- } else {
- ALOGE("Failed to get ITuner_1_1 service");
- }
+
+ mTunerVersion = TUNER_HAL_VERSION_2_0;
+ // TODO: Enable this after Tuner HAL is frozen.
+ // if (mTuner->getInterfaceVersion(&mTunerVersion).isOk()) {
+ // // Tuner AIDL HAL version 1 will be Tuner HAL 2.0
+ // mTunerVersion = (mTunerVersion + 1) << 16;
+ //}
+
return true;
}
-bool TunerService::hasITuner_1_1() {
- ALOGD("hasITuner_1_1");
- hasITuner();
- return (mTunerVersion == TUNER_HAL_VERSION_1_1);
-}
-
-Status TunerService::openDemux(
- int /* demuxHandle */, std::shared_ptr<ITunerDemux>* _aidl_return) {
- ALOGD("openDemux");
+::ndk::ScopedAStatus TunerService::openDemux(int32_t /* in_demuxHandle */,
+ shared_ptr<ITunerDemux>* _aidl_return) {
+ ALOGV("openDemux");
if (!hasITuner()) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::NOT_INITIALIZED));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result res;
- uint32_t id;
- sp<IDemux> demuxSp = nullptr;
- shared_ptr<ITunerDemux> tunerDemux = nullptr;
- mTuner->openDemux([&](Result r, uint32_t demuxId, const sp<IDemux>& demux) {
- demuxSp = demux;
- id = demuxId;
- res = r;
- ALOGD("open demux, id = %d", demuxId);
- });
- if (res == Result::SUCCESS) {
- tunerDemux = ::ndk::SharedRefBase::make<TunerDemux>(demuxSp, id);
- *_aidl_return = tunerDemux->ref<ITunerDemux>();
- return Status::ok();
+ vector<int32_t> id;
+ shared_ptr<IDemux> demux;
+ auto status = mTuner->openDemux(&id, &demux);
+ if (status.isOk()) {
+ *_aidl_return = ::ndk::SharedRefBase::make<TunerDemux>(demux, id[0]);
}
- ALOGW("open demux failed, res = %d", res);
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
+ return status;
}
-Status TunerService::getDemuxCaps(TunerDemuxCapabilities* _aidl_return) {
- ALOGD("getDemuxCaps");
+::ndk::ScopedAStatus TunerService::getDemuxCaps(DemuxCapabilities* _aidl_return) {
+ ALOGV("getDemuxCaps");
if (!hasITuner()) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::NOT_INITIALIZED));
- }
- Result res;
- DemuxCapabilities caps;
- mTuner->getDemuxCaps([&](Result r, const DemuxCapabilities& demuxCaps) {
- caps = demuxCaps;
- res = r;
- });
- if (res == Result::SUCCESS) {
- *_aidl_return = getAidlDemuxCaps(caps);
- return Status::ok();
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- ALOGW("Get demux caps failed, res = %d", res);
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
+ return mTuner->getDemuxCaps(_aidl_return);
}
-Status TunerService::getFrontendIds(vector<int32_t>* ids) {
+::ndk::ScopedAStatus TunerService::getFrontendIds(vector<int32_t>* ids) {
if (!hasITuner()) {
- return Status::fromServiceSpecificError(
- static_cast<int32_t>(Result::NOT_INITIALIZED));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- hidl_vec<FrontendId> feIds;
- Result res = getHidlFrontendIds(feIds);
- if (res != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
- }
- ids->resize(feIds.size());
- copy(feIds.begin(), feIds.end(), ids->begin());
- return Status::ok();
+ return mTuner->getFrontendIds(ids);
}
-Status TunerService::getFrontendInfo(int32_t id, TunerFrontendInfo* _aidl_return) {
+::ndk::ScopedAStatus TunerService::getFrontendInfo(int32_t id, FrontendInfo* _aidl_return) {
if (!hasITuner()) {
ALOGE("ITuner service is not init.");
return ::ndk::ScopedAStatus::fromServiceSpecificError(
static_cast<int32_t>(Result::UNAVAILABLE));
}
- FrontendInfo info;
- Result res = getHidlFrontendInfo(id, info);
- if (res != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
- }
-
- TunerFrontendInfo tunerInfo = convertToAidlFrontendInfo(info);
- *_aidl_return = tunerInfo;
- return Status::ok();
+ return mTuner->getFrontendInfo(id, _aidl_return);
}
-Status TunerService::getFrontendDtmbCapabilities(
- int32_t id, TunerFrontendDtmbCapabilities* _aidl_return) {
- if (!hasITuner_1_1()) {
- ALOGE("ITuner_1_1 service is not init.");
+::ndk::ScopedAStatus TunerService::openFrontend(int32_t frontendHandle,
+ shared_ptr<ITunerFrontend>* _aidl_return) {
+ if (!hasITuner()) {
+ ALOGE("ITuner service is not init.");
return ::ndk::ScopedAStatus::fromServiceSpecificError(
static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result res;
- FrontendDtmbCapabilities dtmbCaps;
- mTuner_1_1->getFrontendDtmbCapabilities(id,
- [&](Result r, const FrontendDtmbCapabilities& caps) {
- dtmbCaps = caps;
- res = r;
- });
- if (res != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
- }
-
- TunerFrontendDtmbCapabilities aidlDtmbCaps{
- .transmissionModeCap = (int)dtmbCaps.transmissionModeCap,
- .bandwidthCap = (int)dtmbCaps.bandwidthCap,
- .modulationCap = (int)dtmbCaps.modulationCap,
- .codeRateCap = (int)dtmbCaps.codeRateCap,
- .guardIntervalCap = (int)dtmbCaps.guardIntervalCap,
- .interleaveModeCap = (int)dtmbCaps.interleaveModeCap,
- };
-
- *_aidl_return = aidlDtmbCaps;
- return Status::ok();
-}
-
-Status TunerService::openFrontend(
- int32_t frontendHandle, shared_ptr<ITunerFrontend>* _aidl_return) {
- if (!hasITuner()) {
- ALOGE("ITuner service is not init.");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
- }
-
- Result status;
- sp<IFrontend> frontend;
int id = getResourceIdFromHandle(frontendHandle, FRONTEND);
- mTuner->openFrontendById(id, [&](Result result, const sp<IFrontend>& fe) {
- frontend = fe;
- status = result;
- });
- if (status != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(status));
+ shared_ptr<IFrontend> frontend;
+ auto status = mTuner->openFrontendById(id, &frontend);
+ if (status.isOk()) {
+ *_aidl_return = ::ndk::SharedRefBase::make<TunerFrontend>(frontend, id);
}
- *_aidl_return = ::ndk::SharedRefBase::make<TunerFrontend>(frontend, id);
- return Status::ok();
+
+ return status;
}
-Status TunerService::openLnb(int lnbHandle, shared_ptr<ITunerLnb>* _aidl_return) {
+::ndk::ScopedAStatus TunerService::openLnb(int lnbHandle, shared_ptr<ITunerLnb>* _aidl_return) {
if (!hasITuner()) {
ALOGD("get ITuner failed");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result status;
- sp<ILnb> lnb;
+ shared_ptr<ILnb> lnb;
int id = getResourceIdFromHandle(lnbHandle, LNB);
- mTuner->openLnbById(id, [&](Result result, const sp<ILnb>& lnbSp){
- lnb = lnbSp;
- status = result;
- });
- if (status != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(status));
+ auto status = mTuner->openLnbById(id, &lnb);
+ if (status.isOk()) {
+ *_aidl_return = ::ndk::SharedRefBase::make<TunerLnb>(lnb, id);
}
- *_aidl_return = ::ndk::SharedRefBase::make<TunerLnb>(lnb, id);
- return Status::ok();
+ return status;
}
-Status TunerService::openLnbByName(const string& lnbName, shared_ptr<ITunerLnb>* _aidl_return) {
+::ndk::ScopedAStatus TunerService::openLnbByName(const string& lnbName,
+ shared_ptr<ITunerLnb>* _aidl_return) {
if (!hasITuner()) {
ALOGE("get ITuner failed");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- int lnbId;
- Result status;
- sp<ILnb> lnb;
- mTuner->openLnbByName(lnbName, [&](Result r, LnbId id, const sp<ILnb>& lnbSp) {
- status = r;
- lnb = lnbSp;
- lnbId = (int)id;
- });
- if (status != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(status));
+ vector<int32_t> id;
+ shared_ptr<ILnb> lnb;
+ auto status = mTuner->openLnbByName(lnbName, &id, &lnb);
+ if (status.isOk()) {
+ *_aidl_return = ::ndk::SharedRefBase::make<TunerLnb>(lnb, id[0]);
}
- *_aidl_return = ::ndk::SharedRefBase::make<TunerLnb>(lnb, lnbId);
- return Status::ok();
+ return ::ndk::ScopedAStatus::ok();
}
-Status TunerService::openDescrambler(int32_t /*descramblerHandle*/,
- std::shared_ptr<ITunerDescrambler>* _aidl_return) {
+::ndk::ScopedAStatus TunerService::openDescrambler(int32_t /*descramblerHandle*/,
+ shared_ptr<ITunerDescrambler>* _aidl_return) {
if (!hasITuner()) {
ALOGD("get ITuner failed");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result status;
- sp<IDescrambler> descrambler;
- //int id = getResourceIdFromHandle(descramblerHandle, DESCRAMBLER);
- mTuner->openDescrambler([&](Result r, const sp<IDescrambler>& descramblerSp) {
- status = r;
- descrambler = descramblerSp;
- });
- if (status != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(status));
+ shared_ptr<IDescrambler> descrambler;
+ // int id = getResourceIdFromHandle(descramblerHandle, DESCRAMBLER);
+ auto status = mTuner->openDescrambler(&descrambler);
+ if (status.isOk()) {
+ *_aidl_return = ::ndk::SharedRefBase::make<TunerDescrambler>(descrambler);
}
- *_aidl_return = ::ndk::SharedRefBase::make<TunerDescrambler>(descrambler);
- return Status::ok();
+ return status;
}
void TunerService::updateTunerResources() {
- if (!hasITuner() || mTunerResourceManager == NULL) {
+ if (!hasITuner() || mTunerResourceManager == nullptr) {
ALOGE("Failed to updateTunerResources");
return;
}
@@ -327,29 +248,30 @@
// TODO: update Demux, Descrambler.
}
-Status TunerService::getTunerHalVersion(int* _aidl_return) {
+::ndk::ScopedAStatus TunerService::getTunerHalVersion(int* _aidl_return) {
hasITuner();
*_aidl_return = mTunerVersion;
- return Status::ok();
+ return ::ndk::ScopedAStatus::ok();
}
void TunerService::updateFrontendResources() {
- hidl_vec<FrontendId> ids;
- Result res = getHidlFrontendIds(ids);
- if (res != Result::SUCCESS) {
+ vector<int32_t> ids;
+ auto status = mTuner->getFrontendIds(&ids);
+ if (!status.isOk()) {
return;
}
+
vector<TunerFrontendInfo> infos;
for (int i = 0; i < ids.size(); i++) {
FrontendInfo frontendInfo;
- Result res = getHidlFrontendInfo((int)ids[i], frontendInfo);
- if (res != Result::SUCCESS) {
+ auto res = mTuner->getFrontendInfo(ids[i], &frontendInfo);
+ if (!res.isOk()) {
continue;
}
TunerFrontendInfo tunerFrontendInfo{
- .handle = getResourceHandleFromId((int)ids[i], FRONTEND),
- .type = static_cast<int>(frontendInfo.type),
- .exclusiveGroupId = static_cast<int>(frontendInfo.exclusiveGroupId),
+ .handle = getResourceHandleFromId((int)ids[i], FRONTEND),
+ .type = static_cast<int>(frontendInfo.type),
+ .exclusiveGroupId = frontendInfo.exclusiveGroupId,
};
infos.push_back(tunerFrontendInfo);
}
@@ -357,26 +279,21 @@
}
void TunerService::updateLnbResources() {
- vector<int> handles = getLnbHandles();
+ vector<int32_t> handles = getLnbHandles();
if (handles.size() == 0) {
return;
}
mTunerResourceManager->setLnbInfoList(handles);
}
-vector<int> TunerService::getLnbHandles() {
- vector<int> lnbHandles;
- if (mTuner != NULL) {
- Result res;
- vector<LnbId> lnbIds;
- mTuner->getLnbIds([&](Result r, const hardware::hidl_vec<LnbId>& ids) {
- lnbIds = ids;
- res = r;
- });
- if (res != Result::SUCCESS || lnbIds.size() == 0) {
- } else {
+vector<int32_t> TunerService::getLnbHandles() {
+ vector<int32_t> lnbHandles;
+ if (mTuner != nullptr) {
+ vector<int32_t> lnbIds;
+ auto res = mTuner->getLnbIds(&lnbIds);
+ if (res.isOk()) {
for (int i = 0; i < lnbIds.size(); i++) {
- lnbHandles.push_back(getResourceHandleFromId((int)lnbIds[i], LNB));
+ lnbHandles.push_back(getResourceHandleFromId(lnbIds[i], LNB));
}
}
}
@@ -384,186 +301,8 @@
return lnbHandles;
}
-Result TunerService::getHidlFrontendIds(hidl_vec<FrontendId>& ids) {
- if (mTuner == NULL) {
- return Result::NOT_INITIALIZED;
- }
- Result res;
- mTuner->getFrontendIds([&](Result r, const hidl_vec<FrontendId>& frontendIds) {
- ids = frontendIds;
- res = r;
- });
- return res;
-}
-
-Result TunerService::getHidlFrontendInfo(int id, FrontendInfo& info) {
- if (mTuner == NULL) {
- return Result::NOT_INITIALIZED;
- }
- Result res;
- mTuner->getFrontendInfo(id, [&](Result r, const FrontendInfo& feInfo) {
- info = feInfo;
- res = r;
- });
- return res;
-}
-
-TunerDemuxCapabilities TunerService::getAidlDemuxCaps(DemuxCapabilities caps) {
- TunerDemuxCapabilities aidlCaps{
- .numDemux = (int)caps.numDemux,
- .numRecord = (int)caps.numRecord,
- .numPlayback = (int)caps.numPlayback,
- .numTsFilter = (int)caps.numTsFilter,
- .numSectionFilter = (int)caps.numSectionFilter,
- .numAudioFilter = (int)caps.numAudioFilter,
- .numVideoFilter = (int)caps.numVideoFilter,
- .numPesFilter = (int)caps.numPesFilter,
- .numPcrFilter = (int)caps.numPcrFilter,
- .numBytesInSectionFilter = (int)caps.numBytesInSectionFilter,
- .filterCaps = (int)caps.filterCaps,
- .bTimeFilter = caps.bTimeFilter,
- };
- aidlCaps.linkCaps.resize(caps.linkCaps.size());
- copy(caps.linkCaps.begin(), caps.linkCaps.end(), aidlCaps.linkCaps.begin());
- return aidlCaps;
-}
-
-TunerFrontendInfo TunerService::convertToAidlFrontendInfo(FrontendInfo halInfo) {
- TunerFrontendInfo info{
- .type = (int)halInfo.type,
- .minFrequency = (int)halInfo.minFrequency,
- .maxFrequency = (int)halInfo.maxFrequency,
- .minSymbolRate = (int)halInfo.minSymbolRate,
- .maxSymbolRate = (int)halInfo.maxSymbolRate,
- .acquireRange = (int)halInfo.acquireRange,
- .exclusiveGroupId = (int)halInfo.exclusiveGroupId,
- };
- for (int i = 0; i < halInfo.statusCaps.size(); i++) {
- info.statusCaps.push_back((int)halInfo.statusCaps[i]);
- }
-
- TunerFrontendCapabilities caps;
- switch (halInfo.type) {
- case FrontendType::ANALOG: {
- if (FrontendInfo::FrontendCapabilities::hidl_discriminator::analogCaps
- == halInfo.frontendCaps.getDiscriminator()) {
- TunerFrontendAnalogCapabilities analogCaps{
- .typeCap = (int)halInfo.frontendCaps.analogCaps().typeCap,
- .sifStandardCap = (int)halInfo.frontendCaps.analogCaps().sifStandardCap,
- };
- caps.set<TunerFrontendCapabilities::analogCaps>(analogCaps);
- }
- break;
- }
- case FrontendType::ATSC: {
- if (FrontendInfo::FrontendCapabilities::hidl_discriminator::atscCaps
- == halInfo.frontendCaps.getDiscriminator()) {
- TunerFrontendAtscCapabilities atscCaps{
- .modulationCap = (int)halInfo.frontendCaps.atscCaps().modulationCap,
- };
- caps.set<TunerFrontendCapabilities::atscCaps>(atscCaps);
- }
- break;
- }
- case FrontendType::ATSC3: {
- if (FrontendInfo::FrontendCapabilities::hidl_discriminator::atsc3Caps
- == halInfo.frontendCaps.getDiscriminator()) {
- TunerFrontendAtsc3Capabilities atsc3Caps{
- .bandwidthCap = (int)halInfo.frontendCaps.atsc3Caps().bandwidthCap,
- .modulationCap = (int)halInfo.frontendCaps.atsc3Caps().modulationCap,
- .timeInterleaveModeCap =
- (int)halInfo.frontendCaps.atsc3Caps().timeInterleaveModeCap,
- .codeRateCap = (int)halInfo.frontendCaps.atsc3Caps().codeRateCap,
- .demodOutputFormatCap
- = (int)halInfo.frontendCaps.atsc3Caps().demodOutputFormatCap,
- .fecCap = (int)halInfo.frontendCaps.atsc3Caps().fecCap,
- };
- caps.set<TunerFrontendCapabilities::atsc3Caps>(atsc3Caps);
- }
- break;
- }
- case FrontendType::DVBC: {
- if (FrontendInfo::FrontendCapabilities::hidl_discriminator::dvbcCaps
- == halInfo.frontendCaps.getDiscriminator()) {
- TunerFrontendCableCapabilities cableCaps{
- .modulationCap = (int)halInfo.frontendCaps.dvbcCaps().modulationCap,
- .codeRateCap = (int64_t)halInfo.frontendCaps.dvbcCaps().fecCap,
- .annexCap = (int)halInfo.frontendCaps.dvbcCaps().annexCap,
- };
- caps.set<TunerFrontendCapabilities::cableCaps>(cableCaps);
- }
- break;
- }
- case FrontendType::DVBS: {
- if (FrontendInfo::FrontendCapabilities::hidl_discriminator::dvbsCaps
- == halInfo.frontendCaps.getDiscriminator()) {
- TunerFrontendDvbsCapabilities dvbsCaps{
- .modulationCap = (int)halInfo.frontendCaps.dvbsCaps().modulationCap,
- .codeRateCap = (long)halInfo.frontendCaps.dvbsCaps().innerfecCap,
- .standard = (int)halInfo.frontendCaps.dvbsCaps().standard,
- };
- caps.set<TunerFrontendCapabilities::dvbsCaps>(dvbsCaps);
- }
- break;
- }
- case FrontendType::DVBT: {
- if (FrontendInfo::FrontendCapabilities::hidl_discriminator::dvbtCaps
- == halInfo.frontendCaps.getDiscriminator()) {
- TunerFrontendDvbtCapabilities dvbtCaps{
- .transmissionModeCap = (int)halInfo.frontendCaps.dvbtCaps().transmissionModeCap,
- .bandwidthCap = (int)halInfo.frontendCaps.dvbtCaps().bandwidthCap,
- .constellationCap = (int)halInfo.frontendCaps.dvbtCaps().constellationCap,
- .codeRateCap = (int)halInfo.frontendCaps.dvbtCaps().coderateCap,
- .hierarchyCap = (int)halInfo.frontendCaps.dvbtCaps().hierarchyCap,
- .guardIntervalCap = (int)halInfo.frontendCaps.dvbtCaps().guardIntervalCap,
- .isT2Supported = (bool)halInfo.frontendCaps.dvbtCaps().isT2Supported,
- .isMisoSupported = (bool)halInfo.frontendCaps.dvbtCaps().isMisoSupported,
- };
- caps.set<TunerFrontendCapabilities::dvbtCaps>(dvbtCaps);
- }
- break;
- }
- case FrontendType::ISDBS: {
- if (FrontendInfo::FrontendCapabilities::hidl_discriminator::isdbsCaps
- == halInfo.frontendCaps.getDiscriminator()) {
- TunerFrontendIsdbsCapabilities isdbsCaps{
- .modulationCap = (int)halInfo.frontendCaps.isdbsCaps().modulationCap,
- .codeRateCap = (int)halInfo.frontendCaps.isdbsCaps().coderateCap,
- };
- caps.set<TunerFrontendCapabilities::isdbsCaps>(isdbsCaps);
- }
- break;
- }
- case FrontendType::ISDBS3: {
- if (FrontendInfo::FrontendCapabilities::hidl_discriminator::isdbs3Caps
- == halInfo.frontendCaps.getDiscriminator()) {
- TunerFrontendIsdbs3Capabilities isdbs3Caps{
- .modulationCap = (int)halInfo.frontendCaps.isdbs3Caps().modulationCap,
- .codeRateCap = (int)halInfo.frontendCaps.isdbs3Caps().coderateCap,
- };
- caps.set<TunerFrontendCapabilities::isdbs3Caps>(isdbs3Caps);
- }
- break;
- }
- case FrontendType::ISDBT: {
- if (FrontendInfo::FrontendCapabilities::hidl_discriminator::isdbtCaps
- == halInfo.frontendCaps.getDiscriminator()) {
- TunerFrontendIsdbtCapabilities isdbtCaps{
- .modeCap = (int)halInfo.frontendCaps.isdbtCaps().modeCap,
- .bandwidthCap = (int)halInfo.frontendCaps.isdbtCaps().bandwidthCap,
- .modulationCap = (int)halInfo.frontendCaps.isdbtCaps().modulationCap,
- .codeRateCap = (int)halInfo.frontendCaps.isdbtCaps().coderateCap,
- .guardIntervalCap = (int)halInfo.frontendCaps.isdbtCaps().guardIntervalCap,
- };
- caps.set<TunerFrontendCapabilities::isdbtCaps>(isdbtCaps);
- }
- break;
- }
- default:
- break;
- }
-
- info.caps = caps;
- return info;
-}
-} // namespace android
+} // namespace tuner
+} // namespace tv
+} // namespace media
+} // namespace android
+} // namespace aidl
diff --git a/services/tuner/TunerService.h b/services/tuner/TunerService.h
index f8e2ee6..164bef8 100644
--- a/services/tuner/TunerService.h
+++ b/services/tuner/TunerService.h
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2020, The Android Open Source Project
+ * Copyright (c) 2021, 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.
@@ -17,61 +17,33 @@
#ifndef ANDROID_MEDIA_TUNERSERVICE_H
#define ANDROID_MEDIA_TUNERSERVICE_H
-#include <aidl/android/media/tv/tunerresourcemanager/ITunerResourceManager.h>
+#include <aidl/android/hardware/tv/tuner/BnFilterCallback.h>
+#include <aidl/android/hardware/tv/tuner/DemuxFilterEvent.h>
+#include <aidl/android/hardware/tv/tuner/DemuxFilterStatus.h>
+#include <aidl/android/hardware/tv/tuner/ITuner.h>
#include <aidl/android/media/tv/tuner/BnTunerService.h>
-#include <android/hardware/tv/tuner/1.1/ITuner.h>
-#include <fmq/AidlMessageQueue.h>
-#include <fmq/EventFlag.h>
-#include <fmq/MessageQueue.h>
+#include <aidl/android/media/tv/tunerresourcemanager/ITunerResourceManager.h>
-using ::aidl::android::hardware::common::fmq::GrantorDescriptor;
-using ::aidl::android::hardware::common::fmq::MQDescriptor;
-using ::aidl::android::hardware::common::fmq::SynchronizedReadWrite;
-using ::aidl::android::media::tv::tuner::BnTunerService;
-using ::aidl::android::media::tv::tuner::ITunerDemux;
-using ::aidl::android::media::tv::tuner::ITunerDescrambler;
-using ::aidl::android::media::tv::tuner::ITunerFrontend;
-using ::aidl::android::media::tv::tuner::ITunerLnb;
-using ::aidl::android::media::tv::tuner::TunerDemuxCapabilities;
-using ::aidl::android::media::tv::tuner::TunerFrontendDtmbCapabilities;
-using ::aidl::android::media::tv::tuner::TunerFrontendInfo;
+using ::aidl::android::hardware::tv::tuner::BnFilterCallback;
+using ::aidl::android::hardware::tv::tuner::DemuxCapabilities;
+using ::aidl::android::hardware::tv::tuner::DemuxFilterEvent;
+using ::aidl::android::hardware::tv::tuner::DemuxFilterStatus;
+using ::aidl::android::hardware::tv::tuner::FrontendInfo;
+using ::aidl::android::hardware::tv::tuner::ITuner;
using ::aidl::android::media::tv::tunerresourcemanager::ITunerResourceManager;
-using ::android::hardware::details::logError;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::kSynchronizedReadWrite;
-using ::android::hardware::EventFlag;
-using ::android::hardware::MessageQueue;
-using ::android::hardware::MQDescriptorSync;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::hardware::tv::tuner::V1_0::DemuxCapabilities;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterAvSettings;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterEvent;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterMainType;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterSettings;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterStatus;
-using ::android::hardware::tv::tuner::V1_0::DemuxFilterType;
-using ::android::hardware::tv::tuner::V1_0::DemuxTsFilterSettings;
-using ::android::hardware::tv::tuner::V1_0::DemuxTsFilterType;
-using ::android::hardware::tv::tuner::V1_0::FrontendId;
-using ::android::hardware::tv::tuner::V1_0::FrontendInfo;
-using ::android::hardware::tv::tuner::V1_0::IDemux;
-using ::android::hardware::tv::tuner::V1_0::IDescrambler;
-using ::android::hardware::tv::tuner::V1_0::IFilter;
-using ::android::hardware::tv::tuner::V1_0::IFilterCallback;
-using ::android::hardware::tv::tuner::V1_0::ITuner;
-using ::android::hardware::tv::tuner::V1_0::Result;
-
-using Status = ::ndk::ScopedAStatus;
-
using namespace std;
+namespace aidl {
namespace android {
+namespace media {
+namespace tv {
+namespace tuner {
const static int TUNER_HAL_VERSION_UNKNOWN = 0;
const static int TUNER_HAL_VERSION_1_0 = 1 << 16;
const static int TUNER_HAL_VERSION_1_1 = (1 << 16) | 1;
+const static int TUNER_HAL_VERSION_2_0 = 2 << 16;
// System Feature defined in PackageManager
static const ::android::String16 FEATURE_TUNER(::android::String16("android.hardware.tv.tuner"));
@@ -82,40 +54,40 @@
DESCRAMBLER,
} TunerResourceType;
-struct FilterCallback : public IFilterCallback {
+struct FilterCallback : public BnFilterCallback {
~FilterCallback() {}
- Return<void> onFilterEvent(const DemuxFilterEvent&) {
- return Void();
+ virtual ::ndk::ScopedAStatus onFilterEvent(
+ const vector<DemuxFilterEvent>& /* events */) override {
+ return ::ndk::ScopedAStatus::ok();
}
- Return<void> onFilterStatus(const DemuxFilterStatus) {
- return Void();
+
+ virtual ::ndk::ScopedAStatus onFilterStatus(const DemuxFilterStatus /*status*/) override {
+ return ::ndk::ScopedAStatus::ok();
}
};
class TunerService : public BnTunerService {
- typedef AidlMessageQueue<int8_t, SynchronizedReadWrite> AidlMessageQueue;
- typedef MessageQueue<uint8_t, kSynchronizedReadWrite> HidlMessageQueue;
- typedef MQDescriptor<int8_t, SynchronizedReadWrite> AidlMQDesc;
-
public:
static char const *getServiceName() { return "media.tuner"; }
static binder_status_t instantiate();
TunerService();
virtual ~TunerService();
- Status getFrontendIds(vector<int32_t>* ids) override;
- Status getFrontendInfo(int32_t id, TunerFrontendInfo* _aidl_return) override;
- Status getFrontendDtmbCapabilities(
- int32_t id, TunerFrontendDtmbCapabilities* _aidl_return) override;
- Status openFrontend(
- int32_t frontendHandle, shared_ptr<ITunerFrontend>* _aidl_return) override;
- Status openLnb(int lnbHandle, shared_ptr<ITunerLnb>* _aidl_return) override;
- Status openLnbByName(const string& lnbName, shared_ptr<ITunerLnb>* _aidl_return) override;
- Status openDemux(int32_t demuxHandle, std::shared_ptr<ITunerDemux>* _aidl_return) override;
- Status getDemuxCaps(TunerDemuxCapabilities* _aidl_return) override;
- Status openDescrambler(int32_t descramblerHandle,
- std::shared_ptr<ITunerDescrambler>* _aidl_return) override;
- Status getTunerHalVersion(int* _aidl_return) override;
+ ::ndk::ScopedAStatus getFrontendIds(vector<int32_t>* out_ids) override;
+ ::ndk::ScopedAStatus getFrontendInfo(int32_t in_frontendHandle,
+ FrontendInfo* _aidl_return) override;
+ ::ndk::ScopedAStatus openFrontend(int32_t in_frontendHandle,
+ shared_ptr<ITunerFrontend>* _aidl_return) override;
+ ::ndk::ScopedAStatus openLnb(int32_t in_lnbHandle,
+ shared_ptr<ITunerLnb>* _aidl_return) override;
+ ::ndk::ScopedAStatus openLnbByName(const string& in_lnbName,
+ shared_ptr<ITunerLnb>* _aidl_return) override;
+ ::ndk::ScopedAStatus openDemux(int32_t in_demuxHandle,
+ shared_ptr<ITunerDemux>* _aidl_return) override;
+ ::ndk::ScopedAStatus getDemuxCaps(DemuxCapabilities* _aidl_return) override;
+ ::ndk::ScopedAStatus openDescrambler(int32_t in_descramblerHandle,
+ shared_ptr<ITunerDescrambler>* _aidl_return) override;
+ ::ndk::ScopedAStatus getTunerHalVersion(int32_t* _aidl_return) override;
// TODO: create a map between resource id and handles.
static int getResourceIdFromHandle(int resourceHandle, int /*type*/) {
@@ -131,27 +103,21 @@
private:
bool hasITuner();
- bool hasITuner_1_1();
void updateTunerResources();
-
void updateFrontendResources();
void updateLnbResources();
- Result getHidlFrontendIds(hidl_vec<FrontendId>& ids);
- Result getHidlFrontendInfo(int id, FrontendInfo& info);
- vector<int> getLnbHandles();
+ vector<int32_t> getLnbHandles();
- TunerDemuxCapabilities getAidlDemuxCaps(DemuxCapabilities caps);
- TunerFrontendInfo convertToAidlFrontendInfo(FrontendInfo halInfo);
-
- sp<ITuner> mTuner;
- sp<::android::hardware::tv::tuner::V1_1::ITuner> mTuner_1_1;
-
+ shared_ptr<ITuner> mTuner;
shared_ptr<ITunerResourceManager> mTunerResourceManager;
int mResourceRequestCount = 0;
-
int mTunerVersion = TUNER_HAL_VERSION_UNKNOWN;
};
-} // namespace android
+} // namespace tuner
+} // namespace tv
+} // namespace media
+} // namespace android
+} // namespace aidl
#endif // ANDROID_MEDIA_TUNERSERVICE_H
diff --git a/services/tuner/TunerTimeFilter.cpp b/services/tuner/TunerTimeFilter.cpp
index ea9da30..73cd6b4 100644
--- a/services/tuner/TunerTimeFilter.cpp
+++ b/services/tuner/TunerTimeFilter.cpp
@@ -18,97 +18,91 @@
#include "TunerTimeFilter.h"
-using ::android::hardware::tv::tuner::V1_0::Result;
-using ::android::hardware::tv::tuner::V1_1::Constant64Bit;
+#include <aidl/android/hardware/tv/tuner/Constant64Bit.h>
+#include <aidl/android/hardware/tv/tuner/Result.h>
+using ::aidl::android::hardware::tv::tuner::Constant64Bit;
+using ::aidl::android::hardware::tv::tuner::Result;
+
+namespace aidl {
namespace android {
+namespace media {
+namespace tv {
+namespace tuner {
-TunerTimeFilter::TunerTimeFilter(sp<ITimeFilter> timeFilter) {
+TunerTimeFilter::TunerTimeFilter(shared_ptr<ITimeFilter> timeFilter) {
mTimeFilter = timeFilter;
}
TunerTimeFilter::~TunerTimeFilter() {
- mTimeFilter = NULL;
+ mTimeFilter = nullptr;
}
-Status TunerTimeFilter::setTimeStamp(int64_t timeStamp) {
- if (mTimeFilter == NULL) {
+::ndk::ScopedAStatus TunerTimeFilter::setTimeStamp(int64_t timeStamp) {
+ if (mTimeFilter == nullptr) {
ALOGE("ITimeFilter is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result status = mTimeFilter->setTimeStamp(timeStamp);
- if (status != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(status));
- }
- return Status::ok();
+ return mTimeFilter->setTimeStamp(timeStamp);
}
-Status TunerTimeFilter::clearTimeStamp() {
- if (mTimeFilter == NULL) {
+::ndk::ScopedAStatus TunerTimeFilter::clearTimeStamp() {
+ if (mTimeFilter == nullptr) {
ALOGE("ITimeFilter is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result status = mTimeFilter->clearTimeStamp();
- if (status != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(status));
- }
- return Status::ok();
+ return mTimeFilter->clearTimeStamp();
}
-Status TunerTimeFilter::getSourceTime(int64_t* _aidl_return) {
- if (mTimeFilter == NULL) {
+::ndk::ScopedAStatus TunerTimeFilter::getSourceTime(int64_t* _aidl_return) {
+ if (mTimeFilter == nullptr) {
*_aidl_return = (int64_t)Constant64Bit::INVALID_PRESENTATION_TIME_STAMP;
ALOGE("ITimeFilter is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result status;
- mTimeFilter->getSourceTime(
- [&](Result r, uint64_t t) {
- status = r;
- *_aidl_return = t;
- });
- if (status != Result::SUCCESS) {
+ auto status = mTimeFilter->getSourceTime(_aidl_return);
+ if (!status.isOk()) {
*_aidl_return = (int64_t)Constant64Bit::INVALID_PRESENTATION_TIME_STAMP;
- return Status::fromServiceSpecificError(static_cast<int32_t>(status));
}
- return Status::ok();
+ return status;
}
-Status TunerTimeFilter::getTimeStamp(int64_t* _aidl_return) {
- if (mTimeFilter == NULL) {
+::ndk::ScopedAStatus TunerTimeFilter::getTimeStamp(int64_t* _aidl_return) {
+ if (mTimeFilter == nullptr) {
*_aidl_return = (int64_t)Constant64Bit::INVALID_PRESENTATION_TIME_STAMP;
ALOGE("ITimeFilter is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result status;
- mTimeFilter->getTimeStamp(
- [&](Result r, uint64_t t) {
- status = r;
- *_aidl_return = t;
- });
- if (status != Result::SUCCESS) {
+ auto status = mTimeFilter->getTimeStamp(_aidl_return);
+ if (!status.isOk()) {
*_aidl_return = (int64_t)Constant64Bit::INVALID_PRESENTATION_TIME_STAMP;
- return Status::fromServiceSpecificError(static_cast<int32_t>(status));
}
- return Status::ok();
+ return status;
}
-Status TunerTimeFilter::close() {
- if (mTimeFilter == NULL) {
+::ndk::ScopedAStatus TunerTimeFilter::close() {
+ if (mTimeFilter == nullptr) {
ALOGE("ITimeFilter is not initialized");
- return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE));
+ return ::ndk::ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Result::UNAVAILABLE));
}
- Result res = mTimeFilter->close();
- mTimeFilter = NULL;
+ auto status = mTimeFilter->close();
+ mTimeFilter = nullptr;
- if (res != Result::SUCCESS) {
- return Status::fromServiceSpecificError(static_cast<int32_t>(res));
- }
- return Status::ok();
+ return status;
}
+
+} // namespace tuner
+} // namespace tv
+} // namespace media
} // namespace android
+} // namespace aidl
diff --git a/services/tuner/TunerTimeFilter.h b/services/tuner/TunerTimeFilter.h
index d675319..c111694 100644
--- a/services/tuner/TunerTimeFilter.h
+++ b/services/tuner/TunerTimeFilter.h
@@ -17,38 +17,41 @@
#ifndef ANDROID_MEDIA_TUNERFTIMEFILTER_H
#define ANDROID_MEDIA_TUNERFTIMEFILTER_H
+#include <aidl/android/hardware/tv/tuner/ITimeFilter.h>
#include <aidl/android/media/tv/tuner/BnTunerTimeFilter.h>
-#include <android/hardware/tv/tuner/1.0/ITimeFilter.h>
-#include <android/hardware/tv/tuner/1.1/types.h>
#include <media/stagefright/foundation/ADebug.h>
#include <utils/Log.h>
-using Status = ::ndk::ScopedAStatus;
-using ::aidl::android::media::tv::tuner::BnTunerTimeFilter;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::tv::tuner::V1_0::ITimeFilter;
+using ::aidl::android::hardware::tv::tuner::ITimeFilter;
using namespace std;
+namespace aidl {
namespace android {
+namespace media {
+namespace tv {
+namespace tuner {
class TunerTimeFilter : public BnTunerTimeFilter {
public:
- TunerTimeFilter(sp<ITimeFilter> timeFilter);
+ TunerTimeFilter(shared_ptr<ITimeFilter> timeFilter);
virtual ~TunerTimeFilter();
- Status setTimeStamp(int64_t timeStamp) override;
- Status clearTimeStamp() override;
- Status getSourceTime(int64_t* _aidl_return) override;
- Status getTimeStamp(int64_t* _aidl_return) override;
- Status close() override;
+
+ ::ndk::ScopedAStatus setTimeStamp(int64_t in_timeStamp) override;
+ ::ndk::ScopedAStatus clearTimeStamp() override;
+ ::ndk::ScopedAStatus getSourceTime(int64_t* _aidl_return) override;
+ ::ndk::ScopedAStatus getTimeStamp(int64_t* _aidl_return) override;
+ ::ndk::ScopedAStatus close() override;
private:
- sp<ITimeFilter> mTimeFilter;
+ shared_ptr<ITimeFilter> mTimeFilter;
};
-} // namespace android
+} // namespace tuner
+} // namespace tv
+} // namespace media
+} // namespace android
+} // namespace aidl
#endif // ANDROID_MEDIA_TUNERFTIMEFILTER_H
diff --git a/services/tuner/aidl/android/media/tv/OWNERS b/services/tuner/aidl/android/media/tv/OWNERS
index 0ceb8e8..bf9fe34 100644
--- a/services/tuner/aidl/android/media/tv/OWNERS
+++ b/services/tuner/aidl/android/media/tv/OWNERS
@@ -1,2 +1,2 @@
-nchalko@google.com
+hgchen@google.com
quxiangfang@google.com
diff --git a/services/tuner/aidl/android/media/tv/tuner/ITunerDemux.aidl b/services/tuner/aidl/android/media/tv/tuner/ITunerDemux.aidl
index 73b00ae..fa326b2 100644
--- a/services/tuner/aidl/android/media/tv/tuner/ITunerDemux.aidl
+++ b/services/tuner/aidl/android/media/tv/tuner/ITunerDemux.aidl
@@ -16,6 +16,8 @@
package android.media.tv.tuner;
+import android.hardware.tv.tuner.DemuxFilterType;
+import android.hardware.tv.tuner.DvrType;
import android.media.tv.tuner.ITunerDvr;
import android.media.tv.tuner.ITunerDvrCallback;
import android.media.tv.tuner.ITunerFilter;
@@ -36,10 +38,15 @@
void setFrontendDataSource(in ITunerFrontend frontend);
/**
+ * Set a frontend resource by ID as data input of the demux
+ */
+ void setFrontendDataSourceById(in int frontendId);
+
+ /**
* Open a new filter in the demux
*/
- ITunerFilter openFilter(
- in int mainType, in int subtype, in int bufferSize, in ITunerFilterCallback cb);
+ ITunerFilter openFilter(in DemuxFilterType type, in int bufferSize,
+ in ITunerFilterCallback cb);
/**
* Open time filter of the demux.
@@ -59,7 +66,7 @@
/**
* Open a DVR (Digital Video Record) instance in the demux.
*/
- ITunerDvr openDvr(in int dvbType, in int bufferSize, in ITunerDvrCallback cb);
+ ITunerDvr openDvr(in DvrType dvbType, in int bufferSize, in ITunerDvrCallback cb);
/**
* Connect Conditional Access Modules (CAM) through Common Interface (CI).
diff --git a/services/tuner/aidl/android/media/tv/tuner/ITunerDescrambler.aidl b/services/tuner/aidl/android/media/tv/tuner/ITunerDescrambler.aidl
index 7370eee..39d193c 100644
--- a/services/tuner/aidl/android/media/tv/tuner/ITunerDescrambler.aidl
+++ b/services/tuner/aidl/android/media/tv/tuner/ITunerDescrambler.aidl
@@ -16,9 +16,9 @@
package android.media.tv.tuner;
+import android.hardware.tv.tuner.DemuxPid;
import android.media.tv.tuner.ITunerDemux;
import android.media.tv.tuner.ITunerFilter;
-import android.media.tv.tuner.TunerDemuxPid;
/**
* Tuner Demux interface handles tuner related operations.
@@ -39,12 +39,12 @@
/**
* Add packets' PID to the descrambler for descrambling.
*/
- void addPid(in TunerDemuxPid pid, in ITunerFilter optionalSourceFilter);
+ void addPid(in DemuxPid pid, in ITunerFilter optionalSourceFilter);
/**
* Remove packets' PID from the descrambler.
*/
- void removePid(in TunerDemuxPid pid, in ITunerFilter optionalSourceFilter);
+ void removePid(in DemuxPid pid, in ITunerFilter optionalSourceFilter);
/**
* Close a new interface of ITunerDescrambler.
diff --git a/services/tuner/aidl/android/media/tv/tuner/ITunerDvr.aidl b/services/tuner/aidl/android/media/tv/tuner/ITunerDvr.aidl
index 8f1601b..2c01c4e 100644
--- a/services/tuner/aidl/android/media/tv/tuner/ITunerDvr.aidl
+++ b/services/tuner/aidl/android/media/tv/tuner/ITunerDvr.aidl
@@ -18,8 +18,8 @@
import android.hardware.common.fmq.MQDescriptor;
import android.hardware.common.fmq.SynchronizedReadWrite;
+import android.hardware.tv.tuner.DvrSettings;
import android.media.tv.tuner.ITunerFilter;
-import android.media.tv.tuner.TunerDvrSettings;
/**
* Tuner Dvr interface handles tuner related operations.
@@ -35,7 +35,7 @@
/**
* Configure the DVR.
*/
- void configure(in TunerDvrSettings settings);
+ void configure(in DvrSettings settings);
/**
* Attach one filter to DVR interface for recording.
diff --git a/services/tuner/aidl/android/media/tv/tuner/ITunerDvrCallback.aidl b/services/tuner/aidl/android/media/tv/tuner/ITunerDvrCallback.aidl
index e234fe5..3043d24 100644
--- a/services/tuner/aidl/android/media/tv/tuner/ITunerDvrCallback.aidl
+++ b/services/tuner/aidl/android/media/tv/tuner/ITunerDvrCallback.aidl
@@ -16,6 +16,9 @@
package android.media.tv.tuner;
+import android.hardware.tv.tuner.PlaybackStatus;
+import android.hardware.tv.tuner.RecordStatus;
+
/**
* TunerDvrCallback interface handles tuner dvr related callbacks.
*
@@ -25,10 +28,10 @@
/**
* Notify the client a new status of the demux's record.
*/
- void onRecordStatus(in int status);
+ void onRecordStatus(in RecordStatus status);
/**
* Notify the client a new status of the demux's playback.
*/
- void onPlaybackStatus(in int status);
+ void onPlaybackStatus(in PlaybackStatus status);
}
diff --git a/services/tuner/aidl/android/media/tv/tuner/ITunerFilter.aidl b/services/tuner/aidl/android/media/tv/tuner/ITunerFilter.aidl
index 10d4c3b..b043fb4 100644
--- a/services/tuner/aidl/android/media/tv/tuner/ITunerFilter.aidl
+++ b/services/tuner/aidl/android/media/tv/tuner/ITunerFilter.aidl
@@ -19,8 +19,9 @@
import android.hardware.common.fmq.MQDescriptor;
import android.hardware.common.fmq.SynchronizedReadWrite;
import android.hardware.common.NativeHandle;
-import android.media.tv.tuner.TunerFilterConfiguration;
-import android.media.tv.tuner.TunerFilterSharedHandleInfo;
+import android.hardware.tv.tuner.DemuxFilterSettings;
+import android.hardware.tv.tuner.AvStreamType;
+import android.hardware.tv.tuner.DemuxFilterMonitorEventType;
/**
* Tuner Filter interface handles tuner related operations.
@@ -46,12 +47,12 @@
/**
* Configure the filter.
*/
- void configure(in TunerFilterConfiguration config);
+ void configure(in DemuxFilterSettings settings);
/**
* Configure the monitor event of the Filter.
*/
- void configureMonitorEvent(in int monitorEventType);
+ void configureMonitorEvent(in int monitorEventTypes);
/**
* Configure the context id of the IP Filter.
@@ -61,12 +62,12 @@
/**
* Configure the stream type of the media Filter.
*/
- void configureAvStreamType(in int avStreamType);
+ void configureAvStreamType(in AvStreamType avStreamType);
/**
* Get the a/v shared memory handle
*/
- TunerFilterSharedHandleInfo getAvSharedHandleInfo();
+ long getAvSharedHandle(out NativeHandle avMemory);
/**
* Release the handle reported by the HAL for AV memory.
diff --git a/services/tuner/aidl/android/media/tv/tuner/ITunerFilterCallback.aidl b/services/tuner/aidl/android/media/tv/tuner/ITunerFilterCallback.aidl
index e7a52a7..6c53042 100644
--- a/services/tuner/aidl/android/media/tv/tuner/ITunerFilterCallback.aidl
+++ b/services/tuner/aidl/android/media/tv/tuner/ITunerFilterCallback.aidl
@@ -16,7 +16,8 @@
package android.media.tv.tuner;
-import android.media.tv.tuner.TunerFilterEvent;
+import android.hardware.tv.tuner.DemuxFilterEvent;
+import android.hardware.tv.tuner.DemuxFilterStatus;
/**
* TunerFilterCallback interface handles tuner filter related callbacks.
@@ -27,10 +28,10 @@
/**
* Notify the client a new status of a filter.
*/
- void onFilterStatus(int status);
+ void onFilterStatus(in DemuxFilterStatus status);
/**
* Notify the client that a new filter event happened.
*/
- void onFilterEvent(in TunerFilterEvent[] filterEvent);
+ void onFilterEvent(in DemuxFilterEvent[] events);
}
diff --git a/services/tuner/aidl/android/media/tv/tuner/ITunerFrontend.aidl b/services/tuner/aidl/android/media/tv/tuner/ITunerFrontend.aidl
index ef0255a..771a647 100644
--- a/services/tuner/aidl/android/media/tv/tuner/ITunerFrontend.aidl
+++ b/services/tuner/aidl/android/media/tv/tuner/ITunerFrontend.aidl
@@ -1,5 +1,5 @@
/**
- * Copyright 2020, The Android Open Source Project
+ * Copyright 2021, 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.
@@ -16,10 +16,12 @@
package android.media.tv.tuner;
+import android.hardware.tv.tuner.FrontendScanType;
+import android.hardware.tv.tuner.FrontendSettings;
+import android.hardware.tv.tuner.FrontendStatus;
+import android.hardware.tv.tuner.FrontendStatusType;
import android.media.tv.tuner.ITunerFrontendCallback;
import android.media.tv.tuner.ITunerLnb;
-import android.media.tv.tuner.TunerFrontendSettings;
-import android.media.tv.tuner.TunerFrontendStatus;
/**
* Tuner Frontend interface handles frontend related operations.
@@ -39,7 +41,7 @@
*
* @param settings the settings to tune with.
*/
- void tune(in TunerFrontendSettings settings);
+ void tune(in FrontendSettings settings);
/**
* Stop the previous tuning.
@@ -52,7 +54,7 @@
* @param settings the settings to scan with.
* @param frontendScanType scan with given type.
*/
- void scan(in TunerFrontendSettings settings, in int frontendScanType);
+ void scan(in FrontendSettings settings, in FrontendScanType frontendScanType);
/**
* Stop the previous scanning.
@@ -93,12 +95,7 @@
/**
* Gets the statuses of the frontend.
*/
- TunerFrontendStatus[] getStatus(in int[] statusTypes);
-
- /**
- * Gets the 1.1 extended statuses of the frontend.
- */
- TunerFrontendStatus[] getStatusExtended_1_1(in int[] statusTypes);
+ FrontendStatus[] getStatus(in FrontendStatusType[] statusTypes);
/**
* Gets the id of the frontend.
diff --git a/services/tuner/aidl/android/media/tv/tuner/ITunerFrontendCallback.aidl b/services/tuner/aidl/android/media/tv/tuner/ITunerFrontendCallback.aidl
index c92f5ee..d0ab11d 100644
--- a/services/tuner/aidl/android/media/tv/tuner/ITunerFrontendCallback.aidl
+++ b/services/tuner/aidl/android/media/tv/tuner/ITunerFrontendCallback.aidl
@@ -1,5 +1,5 @@
/**
- * Copyright 2020, The Android Open Source Project
+ * Copyright 2021, 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.
@@ -16,7 +16,9 @@
package android.media.tv.tuner;
-import android.media.tv.tuner.TunerFrontendScanMessage;
+import android.hardware.tv.tuner.FrontendEventType;
+import android.hardware.tv.tuner.FrontendScanMessage;
+import android.hardware.tv.tuner.FrontendScanMessageType;
/**
* TunerFrontendCallback interface handles tuner frontend related callbacks.
@@ -24,13 +26,14 @@
* {@hide}
*/
interface ITunerFrontendCallback {
- /**
+ /**
* Notify the client that a new event happened on the frontend.
*/
- void onEvent(in int frontendEventType);
+ void onEvent(in FrontendEventType frontendEventType);
/**
* notify the client of scan messages.
*/
- void onScanMessage(in int messageType, in TunerFrontendScanMessage message);
+ void onScanMessage(in FrontendScanMessageType messageType,
+ in FrontendScanMessage message);
}
diff --git a/services/tuner/aidl/android/media/tv/tuner/ITunerLnb.aidl b/services/tuner/aidl/android/media/tv/tuner/ITunerLnb.aidl
index d62145e..79f0761 100644
--- a/services/tuner/aidl/android/media/tv/tuner/ITunerLnb.aidl
+++ b/services/tuner/aidl/android/media/tv/tuner/ITunerLnb.aidl
@@ -16,6 +16,9 @@
package android.media.tv.tuner;
+import android.hardware.tv.tuner.LnbPosition;
+import android.hardware.tv.tuner.LnbTone;
+import android.hardware.tv.tuner.LnbVoltage;
import android.media.tv.tuner.ITunerLnbCallback;
/**
@@ -32,17 +35,17 @@
/**
* Set the lnb's power voltage.
*/
- void setVoltage(in int voltage);
+ void setVoltage(in LnbVoltage voltage);
/**
* Set the lnb's tone mode.
*/
- void setTone(in int tone);
+ void setTone(in LnbTone tone);
/**
* Select the lnb's position.
*/
- void setSatellitePosition(in int position);
+ void setSatellitePosition(in LnbPosition position);
/**
* Sends DiSEqC (Digital Satellite Equipment Control) message.
diff --git a/services/tuner/aidl/android/media/tv/tuner/ITunerLnbCallback.aidl b/services/tuner/aidl/android/media/tv/tuner/ITunerLnbCallback.aidl
index 117352f..2b6eb5f 100644
--- a/services/tuner/aidl/android/media/tv/tuner/ITunerLnbCallback.aidl
+++ b/services/tuner/aidl/android/media/tv/tuner/ITunerLnbCallback.aidl
@@ -16,6 +16,8 @@
package android.media.tv.tuner;
+import android.hardware.tv.tuner.LnbEventType;
+
/**
* TuneLnbCallback interface handles tuner lnb related callbacks.
*
@@ -25,7 +27,7 @@
/**
* Notify the client that a new event happened on the Lnb.
*/
- void onEvent(in int lnbEventType);
+ void onEvent(in LnbEventType lnbEventType);
/**
* notify the client of new DiSEqC message.
diff --git a/services/tuner/aidl/android/media/tv/tuner/ITunerService.aidl b/services/tuner/aidl/android/media/tv/tuner/ITunerService.aidl
index 755b152..c5733a5 100644
--- a/services/tuner/aidl/android/media/tv/tuner/ITunerService.aidl
+++ b/services/tuner/aidl/android/media/tv/tuner/ITunerService.aidl
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2020, The Android Open Source Project
+ * Copyright (c) 2021, 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.
@@ -16,16 +16,12 @@
package android.media.tv.tuner;
-import android.hardware.common.fmq.MQDescriptor;
-import android.hardware.common.fmq.SynchronizedReadWrite;
-import android.hardware.common.fmq.UnsynchronizedWrite;
+import android.hardware.tv.tuner.DemuxCapabilities;
+import android.hardware.tv.tuner.FrontendInfo;
import android.media.tv.tuner.ITunerDemux;
import android.media.tv.tuner.ITunerDescrambler;
import android.media.tv.tuner.ITunerFrontend;
import android.media.tv.tuner.ITunerLnb;
-import android.media.tv.tuner.TunerDemuxCapabilities;
-import android.media.tv.tuner.TunerFrontendDtmbCapabilities;
-import android.media.tv.tuner.TunerFrontendInfo;
/**
* TunerService interface handles tuner related operations.
@@ -33,8 +29,8 @@
* {@hide}
*/
//@VintfStability
+@SuppressWarnings(value={"out-array"})
interface ITunerService {
-
/**
* Gets frontend IDs.
*/
@@ -43,15 +39,10 @@
/**
* Retrieve the frontend's information.
*
- * @param frontendHandle the handle of the frontend granted by TRM.
+ * @param frontendId the ID of the frontend.
* @return the information of the frontend.
*/
- TunerFrontendInfo getFrontendInfo(in int frontendHandle);
-
- /**
- * Get Dtmb Frontend Capabilities.
- */
- TunerFrontendDtmbCapabilities getFrontendDtmbCapabilities(in int id);
+ FrontendInfo getFrontendInfo(in int frontendId);
/**
* Open a Tuner Frontend interface.
@@ -87,7 +78,7 @@
*
* @return the demux’s capabilities.
*/
- TunerDemuxCapabilities getDemuxCaps();
+ DemuxCapabilities getDemuxCaps();
/* Open a new interface of ITunerDescrambler given a descramblerHandle.
*
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerAudioExtraMetaData.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerAudioExtraMetaData.aidl
deleted file mode 100644
index df3374a..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerAudioExtraMetaData.aidl
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * Copyright 2021, 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.media.tv.tuner;
-
-/**
- * Extra Meta Data from AD (Audio Descriptor) according to ETSI TS 101 154 V2.1.1.
- *
- * {@hide}
- */
-parcelable TunerAudioExtraMetaData {
- byte adFade;
-
- byte adPan;
-
- byte versionTextTag;
-
- byte adGainCenter;
-
- byte adGainFront;
-
- byte adGainSurround;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerDemuxCapabilities.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerDemuxCapabilities.aidl
deleted file mode 100644
index 71ab151..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerDemuxCapabilities.aidl
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * Copyright 2021, 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.media.tv.tuner;
-
-/**
- * Tuner Demux capabilities interface.
- *
- * {@hide}
- */
-parcelable TunerDemuxCapabilities {
- int numDemux;
-
- int numRecord;
-
- int numPlayback;
-
- int numTsFilter;
-
- int numSectionFilter;
-
- int numAudioFilter;
-
- int numVideoFilter;
-
- int numPesFilter;
-
- int numPcrFilter;
-
- int numBytesInSectionFilter;
-
- int filterCaps;
-
- int[] linkCaps;
-
- boolean bTimeFilter;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerDemuxIpAddress.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerDemuxIpAddress.aidl
deleted file mode 100644
index b65f404..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerDemuxIpAddress.aidl
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
- * Copyright 2021, 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.media.tv.tuner;
-
-/**
- * Demux ip address configure.
- *
- * {@hide}
- */
-parcelable TunerDemuxIpAddress {
- boolean isIpV6;
-
- byte[] addr;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerDemuxIpAddressSettings.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerDemuxIpAddressSettings.aidl
deleted file mode 100644
index b244388..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerDemuxIpAddressSettings.aidl
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * Copyright 2021, 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.media.tv.tuner;
-
-import android.media.tv.tuner.TunerDemuxIpAddress;
-
-/**
- * Filter Settings for an Ip filter.
- *
- * {@hide}
- */
-parcelable TunerDemuxIpAddressSettings {
- TunerDemuxIpAddress srcIpAddress;
-
- TunerDemuxIpAddress dstIpAddress;
-
- char srcPort;
-
- char dstPort;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerDemuxPid.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerDemuxPid.aidl
deleted file mode 100644
index 8b238b6..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerDemuxPid.aidl
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
- * Copyright 2021, 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.media.tv.tuner;
-
-/**
- * Demux PID interface.
- *
- * {@hide}
- */
-union TunerDemuxPid {
- char tPid;
-
- char mmtpPid;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerDvrSettings.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerDvrSettings.aidl
deleted file mode 100644
index 4ec4d75..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerDvrSettings.aidl
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * Copyright 2021, 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.media.tv.tuner;
-
-/**
- * Dvr Settings interface.
- *
- * {@hide}
- */
-parcelable TunerDvrSettings {
- int statusMask;
-
- int lowThreshold;
-
- int highThreshold;
-
- int dataFormat;
-
- int packetSize;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFilterAlpConfiguration.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFilterAlpConfiguration.aidl
deleted file mode 100644
index 4c9e3af..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFilterAlpConfiguration.aidl
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
- * Copyright 2021, 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.media.tv.tuner;
-
-import android.media.tv.tuner.TunerFilterSettings;
-
-/**
- * Filter Settings for an ALP filter.
- *
- * {@hide}
- */
-parcelable TunerFilterAlpConfiguration {
- byte packetType;
-
- byte lengthType;
-
- TunerFilterSettings filterSettings;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFilterAvSettings.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFilterAvSettings.aidl
deleted file mode 100644
index 6bf88f0..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFilterAvSettings.aidl
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * Copyright 2021, 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.media.tv.tuner;
-
-/**
- * Filter Settings for a Video and Audio.
- *
- * {@hide}
- */
-parcelable TunerFilterAvSettings {
- /**
- * true if the filter output goes to decoder directly in pass through mode.
- */
- boolean isPassthrough;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFilterConfiguration.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFilterConfiguration.aidl
deleted file mode 100644
index 808cfd1..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFilterConfiguration.aidl
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * Copyright 2021, 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.media.tv.tuner;
-
-import android.media.tv.tuner.TunerFilterAlpConfiguration;
-import android.media.tv.tuner.TunerFilterIpConfiguration;
-import android.media.tv.tuner.TunerFilterMmtpConfiguration;
-import android.media.tv.tuner.TunerFilterTlvConfiguration;
-import android.media.tv.tuner.TunerFilterTsConfiguration;
-
-/**
- * Filter configuration.
- *
- * {@hide}
- */
-union TunerFilterConfiguration {
- TunerFilterTsConfiguration ts;
-
- TunerFilterMmtpConfiguration mmtp;
-
- TunerFilterIpConfiguration ip;
-
- TunerFilterTlvConfiguration tlv;
-
- TunerFilterAlpConfiguration alp;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFilterDownloadEvent.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFilterDownloadEvent.aidl
deleted file mode 100644
index b971dd3..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFilterDownloadEvent.aidl
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * Copyright 2021, 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.media.tv.tuner;
-
-/**
- * Filter Event for Download data.
- *
- * {@hide}
- */
-parcelable TunerFilterDownloadEvent {
- int itemId;
-
- /**
- * MPU sequence number of filtered data (only for MMTP)
- */
- int mpuSequenceNumber;
-
- int itemFragmentIndex;
-
- int lastItemFragmentIndex;
-
- /**
- * Data size in bytes of filtered data
- */
- char dataLength;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFilterDownloadSettings.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFilterDownloadSettings.aidl
deleted file mode 100644
index 417a5fe..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFilterDownloadSettings.aidl
+++ /dev/null
@@ -1,26 +0,0 @@
-/**
- * Copyright 2021, 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.media.tv.tuner;
-
-/**
- * Filter Settings for downloading.
- *
- * {@hide}
- */
-parcelable TunerFilterDownloadSettings {
- int downloadId;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFilterEvent.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFilterEvent.aidl
deleted file mode 100644
index 1305510..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFilterEvent.aidl
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- * Copyright 2021, 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.media.tv.tuner;
-
-import android.media.tv.tuner.TunerFilterDownloadEvent;
-import android.media.tv.tuner.TunerFilterIpPayloadEvent;
-import android.media.tv.tuner.TunerFilterMediaEvent;
-import android.media.tv.tuner.TunerFilterMmtpRecordEvent;
-import android.media.tv.tuner.TunerFilterMonitorEvent;
-import android.media.tv.tuner.TunerFilterPesEvent;
-import android.media.tv.tuner.TunerFilterSectionEvent;
-import android.media.tv.tuner.TunerFilterTemiEvent;
-import android.media.tv.tuner.TunerFilterTsRecordEvent;
-
-/**
- * Filter events.
- *
- * {@hide}
- */
-union TunerFilterEvent {
- TunerFilterMediaEvent media;
-
- TunerFilterSectionEvent section;
-
- TunerFilterPesEvent pes;
-
- TunerFilterTsRecordEvent tsRecord;
-
- TunerFilterMmtpRecordEvent mmtpRecord;
-
- TunerFilterDownloadEvent download;
-
- TunerFilterIpPayloadEvent ipPayload;
-
- TunerFilterTemiEvent temi;
-
- TunerFilterMonitorEvent monitor;
-
- int startId;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFilterIpConfiguration.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFilterIpConfiguration.aidl
deleted file mode 100644
index 8b4d889..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFilterIpConfiguration.aidl
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * Copyright 2021, 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.media.tv.tuner;
-
-import android.media.tv.tuner.TunerDemuxIpAddressSettings;
-import android.media.tv.tuner.TunerFilterSettings;
-
-/**
- * Filter Settings for a ip filter.
- *
- * {@hide}
- */
-parcelable TunerFilterIpConfiguration {
- TunerDemuxIpAddressSettings ipAddr;
-
- TunerFilterSettings filterSettings;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFilterIpPayloadEvent.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFilterIpPayloadEvent.aidl
deleted file mode 100644
index d5bda93..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFilterIpPayloadEvent.aidl
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * Copyright 2021, 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.media.tv.tuner;
-
-/**
- * Filter Event for IP payload data.
- *
- * {@hide}
- */
-parcelable TunerFilterIpPayloadEvent {
- /**
- * Data size in bytes of ip data
- */
- char dataLength;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFilterMediaEvent.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFilterMediaEvent.aidl
deleted file mode 100644
index c3dbce9..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFilterMediaEvent.aidl
+++ /dev/null
@@ -1,84 +0,0 @@
-/**
- * Copyright 2021, 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.media.tv.tuner;
-
-import android.hardware.common.NativeHandle;
-import android.media.tv.tuner.TunerAudioExtraMetaData;
-
-/**
- * Filter Event for Audio or Video Filter.
- *
- * {@hide}
- */
-parcelable TunerFilterMediaEvent {
- char streamId;
-
- /**
- * true if PTS is present in PES header.
- */
- boolean isPtsPresent;
-
- /**
- * Presentation Time Stamp for audio or video frame. It based on 90KHz has
- * the same format as PTS (Presentation Time Stamp).
- */
- long pts;
-
- /**
- * Data size in bytes of audio or video frame
- */
- int dataLength;
-
- /**
- * The offset in the memory block which is shared among multiple
- * MediaEvents.
- */
- int offset;
-
- /**
- * A handle associated to the memory where audio or video data stays.
- */
- NativeHandle avMemory;
-
- /**
- * True if the avMemory is in secure area, and isn't mappable.
- */
- boolean isSecureMemory;
-
- /**
- * An Id is used by HAL to provide additional information for AV data.
- * For secure audio, it's the audio handle used by Audio Track.
- */
- long avDataId;
-
- /**
- * MPU sequence number of filtered data (only for MMTP)
- */
- int mpuSequenceNumber;
-
- boolean isPesPrivateData;
-
- /**
- * If TunerAudioExtraMetaData field is valid or not
- */
- boolean isAudioExtraMetaData;
-
- /**
- * Only valid when isAudioExtraMetaData is true
- */
- TunerAudioExtraMetaData audio;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFilterMmtpConfiguration.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFilterMmtpConfiguration.aidl
deleted file mode 100644
index 162ca8e..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFilterMmtpConfiguration.aidl
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * Copyright 2021, 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.media.tv.tuner;
-
-import android.media.tv.tuner.TunerFilterSettings;
-
-/**
- * Filter Settings for an mmtp filter.
- *
- * {@hide}
- */
-parcelable TunerFilterMmtpConfiguration {
- char mmtpPid;
-
- TunerFilterSettings filterSettings;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFilterMmtpRecordEvent.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFilterMmtpRecordEvent.aidl
deleted file mode 100644
index b8871cf..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFilterMmtpRecordEvent.aidl
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * Copyright 2021, 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.media.tv.tuner;
-
-/**
- * Filter Event for an MMTP Record Filter.
- *
- * {@hide}
- */
-parcelable TunerFilterMmtpRecordEvent {
- int scHevcIndexMask;
-
- /**
- * Byte number from beginning of the filter's output
- */
- long byteNumber;
-
- /**
- * If the current event contains extended information or not
- */
- boolean isExtended;
-
- /**
- * The Presentation Time Stamp(PTS) for the audio or video frame. It is based on 90KHz
- * and has the same format as the PTS in ISO/IEC 13818-1.
- */
- long pts;
-
- /**
- * MPU sequence number of the filtered data. This is only used for MMTP.
- */
- int mpuSequenceNumber;
-
- /**
- * Specifies the address of the first macroblock in the slice defined in ITU-T Rec. H.264.
- */
- int firstMbInSlice;
-
- /**
- * TS index mask.
- */
- int tsIndexMask;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFilterMonitorEvent.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFilterMonitorEvent.aidl
deleted file mode 100644
index 31ab5e6..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFilterMonitorEvent.aidl
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * Copyright 2021, 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.media.tv.tuner;
-
-/**
- * Filter monitor events.
- *
- * {@hide}
- */
-union TunerFilterMonitorEvent {
- /**
- * New scrambling status.
- */
- int scramblingStatus;
-
- /**
- * New cid for the IP filter.
- */
- int cid;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFilterPesDataSettings.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFilterPesDataSettings.aidl
deleted file mode 100644
index 312f314..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFilterPesDataSettings.aidl
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
- * Copyright 2021, 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.media.tv.tuner;
-
-/**
- * Filter Settings for Pes Data.
- *
- * {@hide}
- */
-parcelable TunerFilterPesDataSettings {
- char streamId;
-
- boolean isRaw;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFilterPesEvent.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFilterPesEvent.aidl
deleted file mode 100644
index dc1ecc6..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFilterPesEvent.aidl
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * Copyright 2021, 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.media.tv.tuner;
-
-/**
- * Filter Event for PES Filter.
- *
- * {@hide}
- */
-parcelable TunerFilterPesEvent {
- char streamId;
-
- /**
- * Data size in bytes of PES data
- */
- char dataLength;
-
- /**
- * MPU sequence number of filtered data
- */
- int mpuSequenceNumber;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFilterRecordSettings.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFilterRecordSettings.aidl
deleted file mode 100644
index 29be624..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFilterRecordSettings.aidl
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
- * Copyright 2021, 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.media.tv.tuner;
-
-import android.media.tv.tuner.TunerFilterScIndexMask;
-
-/**
- * Filter Settings for recording.
- *
- * {@hide}
- */
-parcelable TunerFilterRecordSettings {
- int tsIndexMask;
-
- int scIndexType;
-
- TunerFilterScIndexMask scIndexMask;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFilterScIndexMask.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFilterScIndexMask.aidl
deleted file mode 100644
index ed37fce..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFilterScIndexMask.aidl
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
- * Copyright 2021, 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.media.tv.tuner;
-
-/**
- * Filter SC Index Mask
- *
- * {@hide}
- */
-union TunerFilterScIndexMask {
- int sc;
-
- int scHevc;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFilterSectionBits.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFilterSectionBits.aidl
deleted file mode 100644
index dd4f842..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFilterSectionBits.aidl
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * Copyright 2021, 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.media.tv.tuner;
-
-/**
- * Bits settings of a section Filter.
- *
- * {@hide}
- */
-parcelable TunerFilterSectionBits {
- byte[] filter;
-
- byte[] mask;
-
- byte[] mode;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFilterSectionCondition.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFilterSectionCondition.aidl
deleted file mode 100644
index 00aabe4..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFilterSectionCondition.aidl
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * Copyright 2021, 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.media.tv.tuner;
-
-import android.media.tv.tuner.TunerFilterSectionBits;
-import android.media.tv.tuner.TunerFilterSectionTableInfo;
-
-/**
- * Section filter condition settings.
- *
- * {@hide}
- */
-union TunerFilterSectionCondition {
- TunerFilterSectionBits sectionBits;
-
- TunerFilterSectionTableInfo tableInfo;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFilterSectionEvent.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFilterSectionEvent.aidl
deleted file mode 100644
index 5f20926..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFilterSectionEvent.aidl
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * Copyright 2021, 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.media.tv.tuner;
-
-/**
- * Filter Event for Section Filter.
- *
- * {@hide}
- */
-parcelable TunerFilterSectionEvent {
- /**
- * Table ID of filtered data
- */
- char tableId;
-
- /**
- * Version number of filtered data
- */
- char version;
-
- /**
- * Section number of filtered data
- */
- char sectionNum;
-
- /**
- * Data size in bytes of filtered data
- */
- char dataLength;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFilterSectionSettings.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFilterSectionSettings.aidl
deleted file mode 100644
index 22129b6..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFilterSectionSettings.aidl
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * Copyright 2021, 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.media.tv.tuner;
-
-import android.media.tv.tuner.TunerFilterSectionCondition;
-
-/**
- * Filter Settings for a section filter.
- *
- * {@hide}
- */
-parcelable TunerFilterSectionSettings {
- TunerFilterSectionCondition condition;
-
- boolean isCheckCrc;
-
- boolean isRepeat;
-
- boolean isRaw;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFilterSectionTableInfo.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFilterSectionTableInfo.aidl
deleted file mode 100644
index cc78c9d..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFilterSectionTableInfo.aidl
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
- * Copyright 2021, 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.media.tv.tuner;
-
-/**
- * Table info settings of a section Filter.
- *
- * {@hide}
- */
-parcelable TunerFilterSectionTableInfo {
- char tableId;
-
- char version;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFilterSettings.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFilterSettings.aidl
deleted file mode 100644
index eb7eaa5..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFilterSettings.aidl
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * Copyright 2021, 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.media.tv.tuner;
-
-import android.media.tv.tuner.TunerFilterAvSettings;
-import android.media.tv.tuner.TunerFilterDownloadSettings;
-import android.media.tv.tuner.TunerFilterPesDataSettings;
-import android.media.tv.tuner.TunerFilterRecordSettings;
-import android.media.tv.tuner.TunerFilterSectionSettings;
-
-/**
- * Filter Settings.
- *
- * {@hide}
- */
-union TunerFilterSettings {
- boolean nothing;
-
- TunerFilterAvSettings av;
-
- TunerFilterSectionSettings section;
-
- TunerFilterPesDataSettings pesData;
-
- TunerFilterRecordSettings record;
-
- TunerFilterDownloadSettings download;
-
- boolean isPassthrough;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFilterSharedHandleInfo.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFilterSharedHandleInfo.aidl
deleted file mode 100644
index 122dfc3..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFilterSharedHandleInfo.aidl
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * Copyright 2021, 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.media.tv.tuner;
-
-import android.hardware.common.NativeHandle;
-
-/**
- * Filter Shared Handle Information.
- *
- * {@hide}
- */
-parcelable TunerFilterSharedHandleInfo {
- NativeHandle handle;
- long size;
-}
\ No newline at end of file
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFilterTemiEvent.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFilterTemiEvent.aidl
deleted file mode 100644
index 4c4e993..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFilterTemiEvent.aidl
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * Copyright 2021, 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.media.tv.tuner;
-
-/**
- * Filter Event for Timed External Media Information (TEMI) data.
- *
- * {@hide}
- */
-parcelable TunerFilterTemiEvent {
- /**
- * Presentation Time Stamp for audio or video frame. It based on 90KHz has
- * the same format as PTS (Presentation Time Stamp) in ISO/IEC 13818-1.
- */
- long pts;
-
- /**
- * TEMI Descriptor Tag
- */
- byte descrTag;
-
- /**
- * TEMI Descriptor
- */
- byte[] descrData;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFilterTlvConfiguration.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFilterTlvConfiguration.aidl
deleted file mode 100644
index 0b237b4..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFilterTlvConfiguration.aidl
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
- * Copyright 2021, 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.media.tv.tuner;
-
-import android.media.tv.tuner.TunerFilterSettings;
-
-/**
- * Filter Settings for a tlv filter.
- *
- * {@hide}
- */
-parcelable TunerFilterTlvConfiguration {
- byte packetType;
-
- boolean isCompressedIpPacket;
-
- TunerFilterSettings filterSettings;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFilterTsConfiguration.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFilterTsConfiguration.aidl
deleted file mode 100644
index 2e386e6..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFilterTsConfiguration.aidl
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * Copyright 2021, 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.media.tv.tuner;
-
-import android.media.tv.tuner.TunerFilterSettings;
-
-/**
- * Filter Settings for a TS filter.
- *
- * {@hide}
- */
-parcelable TunerFilterTsConfiguration {
- char tpid;
-
- TunerFilterSettings filterSettings;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFilterTsRecordEvent.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFilterTsRecordEvent.aidl
deleted file mode 100644
index c52a749..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFilterTsRecordEvent.aidl
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- * Copyright 2021, 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.media.tv.tuner;
-
-import android.media.tv.tuner.TunerFilterScIndexMask;
-
-/**
- * Filter Event for TS Record Filter.
- *
- * {@hide}
- */
-parcelable TunerFilterTsRecordEvent {
- char pid;
-
- int tsIndexMask;
-
- /**
- * Indexes of record output
- */
- TunerFilterScIndexMask scIndexMask;
-
- /**
- * Byte number from beginning of the filter's output
- */
- long byteNumber;
-
- /**
- * If the current event contains extended information or not
- */
- boolean isExtended;
-
- /**
- * The Presentation Time Stamp(PTS) for the audio or video frame. It is based on 90KHz
- * and has the same format as the PTS in ISO/IEC 13818-1.
- */
- long pts;
-
- /**
- * Specifies the address of the first macroblock in the slice defined in ITU-T Rec. H.264.
- */
- int firstMbInSlice;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendAnalogCapabilities.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFrontendAnalogCapabilities.aidl
deleted file mode 100644
index 74bf04e..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendAnalogCapabilities.aidl
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * 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.media.tv.tuner;
-
-/**
- * Analog Frontend Capabilities interface.
- *
- * {@hide}
- */
-parcelable TunerFrontendAnalogCapabilities {
- /**
- * Signal Type capability
- */
- int typeCap;
-
- /**
- * Standard Interchange Format (SIF) capability
- */
- int sifStandardCap;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendAnalogSettings.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFrontendAnalogSettings.aidl
deleted file mode 100644
index 40cd8c9..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendAnalogSettings.aidl
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * 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.media.tv.tuner;
-
-/**
- * Analog Frontend Settings interface.
- *
- * {@hide}
- */
-parcelable TunerFrontendAnalogSettings {
- /**
- * Signal frequency in Hertz
- */
- int frequency;
-
- int signalType;
-
- /**
- * Standard Interchange Format (SIF) setting
- */
- int sifStandard;
-
- /**
- * Fields after isExtended are only valid when isExtended is true
- */
- boolean isExtended;
-
- int aftFlag;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendAtsc3Capabilities.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFrontendAtsc3Capabilities.aidl
deleted file mode 100644
index 6c9be77..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendAtsc3Capabilities.aidl
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- * 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.media.tv.tuner;
-
-/**
- * ATSC3 Frontend Capabilities interface.
- *
- * {@hide}
- */
-parcelable TunerFrontendAtsc3Capabilities {
- /**
- * Bandwidth capability
- */
- int bandwidthCap;
-
- /**
- * Modulation capability
- */
- int modulationCap;
-
- /**
- * TimeInterleaveMode capability
- */
- int timeInterleaveModeCap;
-
- /**
- * CodeRate capability
- */
- int codeRateCap;
-
- /**
- * FEC capability
- */
- int fecCap;
-
- /**
- * Demodulator Output Format capability
- */
- int demodOutputFormatCap;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendAtsc3PlpSettings.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFrontendAtsc3PlpSettings.aidl
deleted file mode 100644
index b29e1f7..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendAtsc3PlpSettings.aidl
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * 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.media.tv.tuner;
-
-/**
- * Atsc3 Frontend Physical Layer Pipe Settings interface.
- *
- * {@hide}
- */
-parcelable TunerFrontendAtsc3PlpSettings {
- int plpId;
-
- int modulation;
-
- int interleaveMode;
-
- int codeRate;
-
- /**
- * Forward Error Correction Type.
- */
- int fec;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendAtsc3Settings.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFrontendAtsc3Settings.aidl
deleted file mode 100644
index 32fb8c7..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendAtsc3Settings.aidl
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * 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.media.tv.tuner;
-
-import android.media.tv.tuner.TunerFrontendAtsc3PlpSettings;
-
-/**
- * Atsc3 Frontend Settings interface.
- *
- * {@hide}
- */
-parcelable TunerFrontendAtsc3Settings {
- /**
- * Signal frequency in Hertz
- */
- int frequency;
-
- /**
- * Bandwidth of tuning band.
- */
- int bandwidth;
-
- int demodOutputFormat;
-
- TunerFrontendAtsc3PlpSettings[] plpSettings;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendAtscCapabilities.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFrontendAtscCapabilities.aidl
deleted file mode 100644
index 2b6c2fc..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendAtscCapabilities.aidl
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * 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.media.tv.tuner;
-
-/**
- * ATSC Frontend Capabilities interface.
- *
- * {@hide}
- */
-parcelable TunerFrontendAtscCapabilities {
- /**
- * Modulation capability
- */
- int modulationCap;
-}
\ No newline at end of file
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendAtscSettings.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFrontendAtscSettings.aidl
deleted file mode 100644
index c7a8c07..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendAtscSettings.aidl
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * 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.media.tv.tuner;
-
-/**
- * Atsc Frontend Settings interface.
- *
- * {@hide}
- */
-parcelable TunerFrontendAtscSettings {
- /**
- * Signal frequency in Hertz
- */
- int frequency;
-
- int modulation;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendCableCapabilities.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFrontendCableCapabilities.aidl
deleted file mode 100644
index b880c60..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendCableCapabilities.aidl
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * 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.media.tv.tuner;
-
-/**
- * Cable(DVBC) Frontend Capabilities interface.
- *
- * {@hide}
- */
-parcelable TunerFrontendCableCapabilities {
- /**
- * Modulation capability
- */
- int modulationCap;
-
- /**
- * Code Rate capability
- */
- long codeRateCap; // inner FEC will converge to codeRate
-
- /**
- * Annex capability
- */
- int annexCap;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendCableSettings.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFrontendCableSettings.aidl
deleted file mode 100644
index b9bcf29..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendCableSettings.aidl
+++ /dev/null
@@ -1,63 +0,0 @@
-/**
- * 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.media.tv.tuner;
-
-/**
- * Cable Frontend Settings interface.
- *
- * {@hide}
- */
-parcelable TunerFrontendCableSettings {
- /**
- * Signal frequency in Hertz
- */
- int frequency;
-
- int modulation;
-
- /**
- * Inner Forward Error Correction type as specified in ETSI EN 300 468 V1.15.1
- * and ETSI EN 302 307-2 V1.1.1.
- */
- long innerFec;
-
- /**
- * Symbols per second
- */
- int symbolRate;
-
- /**
- * Outer Forward Error Correction (FEC) Type.
- */
- int outerFec;
-
- int annex;
-
- /**
- * Spectral Inversion Type.
- */
- int spectralInversion;
-
- /**
- * Fields after isExtended are only valid when isExtended is true
- */
- boolean isExtended;
-
- int interleaveMode;
-
- int bandwidth;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendCapabilities.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFrontendCapabilities.aidl
deleted file mode 100644
index 19f31f1..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendCapabilities.aidl
+++ /dev/null
@@ -1,85 +0,0 @@
-/**
- * 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.media.tv.tuner;
-
-import android.media.tv.tuner.TunerFrontendAnalogCapabilities;
-import android.media.tv.tuner.TunerFrontendAtscCapabilities;
-import android.media.tv.tuner.TunerFrontendAtsc3Capabilities;
-import android.media.tv.tuner.TunerFrontendCableCapabilities;
-import android.media.tv.tuner.TunerFrontendDvbsCapabilities;
-import android.media.tv.tuner.TunerFrontendDvbtCapabilities;
-import android.media.tv.tuner.TunerFrontendIsdbsCapabilities;
-import android.media.tv.tuner.TunerFrontendIsdbs3Capabilities;
-import android.media.tv.tuner.TunerFrontendIsdbtCapabilities;
-
-/**
- * Frontend Capabilities interface.
- *
- * Use a group of vectors as the workaround for Union structure that is not fully supported
- * in AIDL currently.
- *
- * Client may use FrontendInfo.type as the discriminar to check the corresponding vector. If
- * the vector is not null, it contains valid value.
- *
- * {@hide}
- */
-union TunerFrontendCapabilities {
- /**
- * Analog Frontend Capabilities
- */
- TunerFrontendAnalogCapabilities analogCaps;
-
- /**
- * ATSC Frontend Capabilities
- */
- TunerFrontendAtscCapabilities atscCaps;
-
- /**
- * ATSC3 Frontend Capabilities
- */
- TunerFrontendAtsc3Capabilities atsc3Caps;
-
- /**
- * Cable Frontend Capabilities
- */
- TunerFrontendCableCapabilities cableCaps;
-
- /**
- * DVBS Frontend Capabilities
- */
- TunerFrontendDvbsCapabilities dvbsCaps;
-
- /**
- * DVBT Frontend Capabilities
- */
- TunerFrontendDvbtCapabilities dvbtCaps;
-
- /**
- * ISDB-S Frontend Capabilities
- */
- TunerFrontendIsdbsCapabilities isdbsCaps;
-
- /**
- * ISDB-S3 Frontend Capabilities
- */
- TunerFrontendIsdbs3Capabilities isdbs3Caps;
-
- /**
- * ISDB-T Frontend Capabilities
- */
- TunerFrontendIsdbtCapabilities isdbtCaps;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendDtmbCapabilities.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFrontendDtmbCapabilities.aidl
deleted file mode 100644
index e8e4933..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendDtmbCapabilities.aidl
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * Copyright 2021, 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.media.tv.tuner;
-
-/**
- * DTMB Frontend Capabilities interface.
- *
- * {@hide}
- */
-parcelable TunerFrontendDtmbCapabilities {
- int transmissionModeCap;
-
- int bandwidthCap;
-
- int modulationCap;
-
- int codeRateCap;
-
- int guardIntervalCap;
-
- int interleaveModeCap;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendDtmbSettings.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFrontendDtmbSettings.aidl
deleted file mode 100644
index 45e7ff9..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendDtmbSettings.aidl
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * Copyright 2021, 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.media.tv.tuner;
-
-/**
- * DTMB Frontend Settings interface.
- *
- * {@hide}
- */
-parcelable TunerFrontendDtmbSettings {
- int frequency;
-
- int transmissionMode;
-
- int bandwidth;
-
- int modulation;
-
- int codeRate;
-
- int guardInterval;
-
- int interleaveMode;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendDvbsCapabilities.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFrontendDvbsCapabilities.aidl
deleted file mode 100644
index 5e4322c..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendDvbsCapabilities.aidl
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * 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.media.tv.tuner;
-
-/**
- * DVBS Frontend Capabilities interface.
- *
- * {@hide}
- */
-parcelable TunerFrontendDvbsCapabilities {
- /**
- * Modulation capability
- */
- int modulationCap;
-
- /**
- * Code Rate capability
- */
- long codeRateCap; // inner FEC will converge to codeRate
-
- /**
- * Sub standards capability
- */
- int standard;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendDvbsCodeRate.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFrontendDvbsCodeRate.aidl
deleted file mode 100644
index 59b7de3..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendDvbsCodeRate.aidl
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * 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.media.tv.tuner;
-
-/**
- * Dvbs Frontend CodeRate interface.
- *
- * {@hide}
- */
-parcelable TunerFrontendDvbsCodeRate {
- /**
- * Inner Forward Error Correction type as specified in ETSI EN 300 468 V1.15.1
- * and ETSI EN 302 307-2 V1.1.1.
- */
- long fec;
-
- boolean isLinear;
-
- /**
- * true if enable short frame
- */
- boolean isShortFrames;
-
- /**
- * bits number in 1000 symbol. 0 if use the default.
- */
- int bitsPer1000Symbol;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendDvbsSettings.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFrontendDvbsSettings.aidl
deleted file mode 100644
index ec3e4b9..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendDvbsSettings.aidl
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- * 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.media.tv.tuner;
-
-import android.media.tv.tuner.TunerFrontendDvbsCodeRate;
-
-/**
- * Dvbs Frontend Settings interface.
- *
- * {@hide}
- */
-parcelable TunerFrontendDvbsSettings {
- /**
- * Signal frequency in Hertz
- */
- int frequency;
-
- int modulation;
-
- TunerFrontendDvbsCodeRate codeRate;
-
- int symbolRate;
-
- /**
- * Roll off type.
- */
- int rolloff;
-
- /**
- * Pilot mode.
- */
- int pilot;
-
- int inputStreamId;
-
- int standard;
-
- /**
- * Vcm mode.
- */
- int vcm;
-
- /**
- * Fields after isExtended are only valid when isExtended is true
- */
- boolean isExtended;
-
- int scanType;
-
- boolean isDiseqcRxMessage;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendDvbtCapabilities.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFrontendDvbtCapabilities.aidl
deleted file mode 100644
index 73f16dd..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendDvbtCapabilities.aidl
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
- * 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.media.tv.tuner;
-
-/**
- * DVBT Frontend Capabilities interface.
- *
- * {@hide}
- */
-parcelable TunerFrontendDvbtCapabilities {
- /**
- * Transmission Mode capability
- */
- int transmissionModeCap;
-
- /**
- * Bandwidth capability
- */
- int bandwidthCap;
-
- /**
- * Constellation capability
- */
- int constellationCap;
-
- /**
- * Code Rate capability
- */
- int codeRateCap;
-
- /**
- * Hierarchy Type capability
- */
- int hierarchyCap;
-
- /**
- * Guard Interval capability
- */
- int guardIntervalCap;
-
- /**
- * T2 Support capability
- */
- boolean isT2Supported;
-
- /**
- * Miso Support capability
- */
- boolean isMisoSupported;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendDvbtSettings.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFrontendDvbtSettings.aidl
deleted file mode 100644
index 14c942a..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendDvbtSettings.aidl
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * 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.media.tv.tuner;
-
-/**
- * Dvbt Frontend Settings interface.
- *
- * {@hide}
- */
-parcelable TunerFrontendDvbtSettings {
- /**
- * Signal frequency in Hertz
- */
- int frequency;
-
- int transmissionMode;
-
- int bandwidth;
-
- int constellation;
-
- int hierarchy;
-
- /**
- * Code Rate for High Priority level
- */
- int hpCodeRate;
-
- /**
- * Code Rate for Low Priority level
- */
- int lpCodeRate;
-
- int guardInterval;
-
- boolean isHighPriority;
-
- int standard;
-
- boolean isMiso;
-
- /**
- * Physical Layer Pipe (PLP) mode
- */
- int plpMode;
-
- /**
- * Physical Layer Pipe (PLP) Id
- */
- int plpId;
-
- /**
- * Physical Layer Pipe (PLP) Group Id
- */
- int plpGroupId;
-
- /**
- * Fields after isExtended are only valid when isExtended is true
- */
- boolean isExtended;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendInfo.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFrontendInfo.aidl
deleted file mode 100644
index 4bccd56..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendInfo.aidl
+++ /dev/null
@@ -1,80 +0,0 @@
-/**
- * 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.media.tv.tuner;
-
-import android.media.tv.tuner.TunerFrontendCapabilities;
-
-/**
- * FrontendInfo interface that carries tuner frontend information.
- *
- * <p>This is used to update the TunerResourceManager and pass Frontend
- * information from HAL to the client side.
- *
- * {@hide}
- */
-parcelable TunerFrontendInfo {
- /**
- * Frontend Handle
- */
- int handle;
-
- /**
- * Frontend Type
- */
- int type;
-
- /**
- * Minimum Frequency in Hertz
- */
- int minFrequency;
-
- /**
- * Maximum Frequency in Hertz
- */
- int maxFrequency;
-
- /**
- * Minimum symbols per second
- */
- int minSymbolRate;
-
- /**
- * Maximum symbols per second
- */
- int maxSymbolRate;
-
- /**
- * Range in Hertz
- */
- int acquireRange;
-
- /**
- * Frontends are assigned with the same exclusiveGroupId if they can't
- * function at same time. For instance, they share same hardware module.
- */
- int exclusiveGroupId;
-
- /**
- * A list of supported status types which client can inquiry
- */
- int[] statusCaps;
-
- /**
- * Frontend Capabilities
- */
- TunerFrontendCapabilities caps;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendIsdbs3Capabilities.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFrontendIsdbs3Capabilities.aidl
deleted file mode 100644
index 84dd67a..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendIsdbs3Capabilities.aidl
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * 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.media.tv.tuner;
-
-/**
- * ISDB-S3 Frontend Capabilities interface.
- *
- * {@hide}
- */
-parcelable TunerFrontendIsdbs3Capabilities {
- /**
- * Modulation capability
- */
- int modulationCap;
-
- /**
- * Code Rate capability
- */
- int codeRateCap;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendIsdbs3Settings.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFrontendIsdbs3Settings.aidl
deleted file mode 100644
index 9a11fd5..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendIsdbs3Settings.aidl
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * 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.media.tv.tuner;
-
-/**
- * Isdbs3 Frontend Settings interface.
- *
- * {@hide}
- */
-parcelable TunerFrontendIsdbs3Settings {
- /**
- * Signal frequency in Hertz
- */
- int frequency;
-
- char streamId;
-
- int streamIdType;
-
- int modulation;
-
- int codeRate;
-
- /**
- * Symbols per second
- */
- int symbolRate;
-
- int rolloff;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendIsdbsCapabilities.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFrontendIsdbsCapabilities.aidl
deleted file mode 100644
index 15dfdf7..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendIsdbsCapabilities.aidl
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * 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.media.tv.tuner;
-
-/**
- * ISDB-S Frontend Capabilities interface.
- *
- * {@hide}
- */
-parcelable TunerFrontendIsdbsCapabilities {
- /**
- * Modulation capability
- */
- int modulationCap;
-
- /**
- * Code Rate capability
- */
- int codeRateCap;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendIsdbsSettings.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFrontendIsdbsSettings.aidl
deleted file mode 100644
index dff9f4a..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendIsdbsSettings.aidl
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * 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.media.tv.tuner;
-
-/**
- * Isdbs Frontend Settings interface.
- *
- * {@hide}
- */
-parcelable TunerFrontendIsdbsSettings {
- /**
- * Signal frequency in Hertz
- */
- int frequency;
-
- char streamId;
-
- int streamIdType;
-
- int modulation;
-
- int codeRate;
-
- /**
- * Symbols per second
- */
- int symbolRate;
-
- int rolloff;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendIsdbtCapabilities.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFrontendIsdbtCapabilities.aidl
deleted file mode 100644
index c9295d8..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendIsdbtCapabilities.aidl
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * 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.media.tv.tuner;
-
-/**
- * ISDB-T Frontend Capabilities interface.
- *
- * {@hide}
- */
-parcelable TunerFrontendIsdbtCapabilities {
- /**
- * ISDB-T Mode capability
- */
- int modeCap;
-
- /**
- * Bandwidth capability
- */
- int bandwidthCap;
-
- /**
- * Modulation capability
- */
- int modulationCap;
-
- /**
- * Code Rate capability
- */
- int codeRateCap;
-
- /**
- * Guard Interval capability
- */
- int guardIntervalCap;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendIsdbtSettings.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFrontendIsdbtSettings.aidl
deleted file mode 100644
index 191f3a6..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendIsdbtSettings.aidl
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * 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.media.tv.tuner;
-
-/**
- * Isdbt Frontend Settings interface.
- *
- * {@hide}
- */
-parcelable TunerFrontendIsdbtSettings {
- /**
- * Signal frequency in Hertz
- */
- int frequency;
-
- int modulation;
-
- int bandwidth;
-
- int mode;
-
- int codeRate;
-
- int guardInterval;
-
- int serviceAreaId;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendScanAtsc3PlpInfo.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFrontendScanAtsc3PlpInfo.aidl
deleted file mode 100644
index 1b8fcbb..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendScanAtsc3PlpInfo.aidl
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
- * 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.media.tv.tuner;
-
-/**
- * Atsc3 Frontend Physical Layer Pipe Info.
- *
- * {@hide}
- */
-parcelable TunerFrontendScanAtsc3PlpInfo {
- byte plpId;
-
- boolean llsFlag;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendScanMessage.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFrontendScanMessage.aidl
deleted file mode 100644
index 9921ca1..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendScanMessage.aidl
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- * Copyright 2021, 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.media.tv.tuner;
-
-import android.media.tv.tuner.TunerFrontendScanAtsc3PlpInfo;
-
-/**
- * Tuner Frontend Scan Message interface.
- *
- * {@hide}
- */
-union TunerFrontendScanMessage {
- boolean isLocked;
-
- boolean isEnd;
-
- byte progressPercent;
-
- int[] frequencies;
-
- int[] symbolRates;
-
- int hierarchy;
-
- int analogType;
-
- byte[] plpIds;
-
- byte[] groupIds;
-
- char[] inputStreamIds;
-
- int std;
-
- TunerFrontendScanAtsc3PlpInfo[] atsc3PlpInfos;
-
- int modulation;
-
- int annex;
-
- boolean isHighPriority;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendSettings.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFrontendSettings.aidl
deleted file mode 100644
index 70a5f3e..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendSettings.aidl
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * Copyright 2021, 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.media.tv.tuner;
-
-import android.media.tv.tuner.TunerFrontendUnionSettings;
-
-/**
- * Frontend Settings interface.
- *
- * {@hide}
- */
-parcelable TunerFrontendSettings {
- TunerFrontendUnionSettings settings;
-
- boolean isExtended;
-
- int endFrequency;
-
- int inversion;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendStatus.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFrontendStatus.aidl
deleted file mode 100644
index 2b3c01b..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendStatus.aidl
+++ /dev/null
@@ -1,187 +0,0 @@
-/**
- * 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.media.tv.tuner;
-
-import android.media.tv.tuner.TunerFrontendStatusAtsc3PlpInfo;
-
-/**
- * Tuner Frontend Status interface.
- *
- * {@hide}
- */
-union TunerFrontendStatus {
- /**
- * Lock status for Demod in True/False.
- */
- boolean isDemodLocked;
-
- /**
- * SNR value measured by 0.001 dB.
- */
- int snr;
-
- /**
- * The number of error bits per 1 billion bits.
- */
- int ber;
-
- /**
- * The number of error packages per 1 billion packages.
- */
- int per;
-
- /**
- * The number of error bits per 1 billion bits before FEC.
- */
- int preBer;
-
- /**
- * Signal Quality in percent.
- */
- int signalQuality;
-
- /**
- * Signal Strength measured by 0.001 dBm.
- */
- int signalStrength;
-
- /**
- * Symbols per second
- */
- int symbolRate;
-
- long innerFec;
-
- /**
- * Check frontend type to decide the hidl type value
- */
- int modulation;
-
- int inversion;
-
- int lnbVoltage;
-
- byte plpId;
-
- boolean isEWBS;
-
- /**
- * AGC value is normalized from 0 to 255.
- */
- byte agc;
-
- boolean isLnaOn;
-
- boolean[] isLayerError;
-
- /**
- * MER value measured by 0.001 dB
- */
- int mer;
-
- /**
- * Frequency difference in Hertz.
- */
- int freqOffset;
-
- int hierarchy;
-
- boolean isRfLocked;
-
- /**
- * A list of PLP status for tuned PLPs for ATSC3 frontend.
- */
- TunerFrontendStatusAtsc3PlpInfo[] plpInfo;
-
- // 1.1 Extension Starting
-
- /**
- * Extended modulation status. Check frontend type to decide the hidl type value.
- */
- int[] modulations;
-
- /**
- * Extended bit error ratio status.
- */
- int[] bers;
-
- /**
- * Extended code rate status.
- */
- long[] codeRates;
-
- /**
- * Extended bandwidth status. Check frontend type to decide the hidl type value.
- */
- int bandwidth;
-
- /**
- * Extended guard interval status. Check frontend type to decide the hidl type value.
- */
- int interval;
-
- /**
- * Extended transmission mode status. Check frontend type to decide the hidl type value.
- */
- int transmissionMode;
-
- /**
- * Uncorrectable Error Counts of the frontend's Physical Layer Pipe (PLP)
- * since the last tune operation.
- */
- int uec;
-
- /**
- * The current DVB-T2 system id status.
- */
- char systemId;
-
- /**
- * Frontend Interleaving Modes. Check frontend type to decide the hidl type value.
- */
- int[] interleaving;
-
- /**
- * Segments in ISDB-T Specification of all the channels.
- */
- byte[] isdbtSegment;
-
- /**
- * Transport Stream Data Rate in BPS of the current channel.
- */
- int[] tsDataRate;
-
- /**
- * Roll Off Type status of the frontend. Check frontend type to decide the hidl type value.
- */
- int rollOff;
-
- /**
- * If the frontend currently supports MISO or not.
- */
- boolean isMiso;
-
- /**
- * If the frontend code rate is linear or not.
- */
- boolean isLinear;
-
- /**
- * If short frames are enabled or not.
- */
- boolean isShortFrames;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendStatusAtsc3PlpInfo.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFrontendStatusAtsc3PlpInfo.aidl
deleted file mode 100644
index 4116c34..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendStatusAtsc3PlpInfo.aidl
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Copyright 2021, 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.media.tv.tuner;
-
-/**
- * Atsc3 Frontend Physical Layer Pipe Info in Frontend status.
- *
- * {@hide}
- */
-parcelable TunerFrontendStatusAtsc3PlpInfo {
- /**
- * PLP Id value.
- */
- byte plpId;
-
- /**
- * Demod Lock/Unlock status of this particular PLP.
- */
- boolean isLocked;
-
- /**
- * Uncorrectable Error Counts (UEC) of this particular PLP since last tune operation.
- */
- int uec;
-}
diff --git a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendUnionSettings.aidl b/services/tuner/aidl/android/media/tv/tuner/TunerFrontendUnionSettings.aidl
deleted file mode 100644
index c362c2a..0000000
--- a/services/tuner/aidl/android/media/tv/tuner/TunerFrontendUnionSettings.aidl
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * 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.media.tv.tuner;
-
-import android.media.tv.tuner.TunerFrontendAnalogSettings;
-import android.media.tv.tuner.TunerFrontendAtscSettings;
-import android.media.tv.tuner.TunerFrontendAtsc3Settings;
-import android.media.tv.tuner.TunerFrontendCableSettings;
-import android.media.tv.tuner.TunerFrontendDtmbSettings;
-import android.media.tv.tuner.TunerFrontendDvbsSettings;
-import android.media.tv.tuner.TunerFrontendDvbtSettings;
-import android.media.tv.tuner.TunerFrontendIsdbsSettings;
-import android.media.tv.tuner.TunerFrontendIsdbs3Settings;
-import android.media.tv.tuner.TunerFrontendIsdbtSettings;
-
-/**
- * Frontend Settings Union interface.
- *
- * {@hide}
- */
-union TunerFrontendUnionSettings {
- TunerFrontendAnalogSettings analog;
-
- TunerFrontendAtscSettings atsc;
-
- TunerFrontendAtsc3Settings atsc3;
-
- TunerFrontendCableSettings cable;
-
- TunerFrontendDvbsSettings dvbs;
-
- TunerFrontendDvbtSettings dvbt;
-
- TunerFrontendIsdbsSettings isdbs;
-
- TunerFrontendIsdbs3Settings isdbs3;
-
- TunerFrontendIsdbtSettings isdbt;
-
- TunerFrontendDtmbSettings dtmb;
-}
diff --git a/services/tuner/main_tunerservice.cpp b/services/tuner/main_tunerservice.cpp
index 586a0e2..bda2f71 100644
--- a/services/tuner/main_tunerservice.cpp
+++ b/services/tuner/main_tunerservice.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020 The Android Open Source Project
+ * Copyright (C) 2021 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.
@@ -14,30 +14,27 @@
* limitations under the License.
*/
-#include <utils/Log.h>
+#include <android-base/logging.h>
#include <binder/IPCThreadState.h>
#include <binder/IServiceManager.h>
-#include <binder/ProcessState.h>
-#include <hidl/HidlTransportSupport.h>
+#include <utils/Log.h>
#include "TunerService.h"
+using ::aidl::android::media::tv::tuner::TunerService;
+
using namespace android;
-int main(int argc __unused, char** argv) {
+int main() {
ALOGD("Tuner service starting");
- strcpy(argv[0], "media.tuner");
sp<ProcessState> proc(ProcessState::self());
sp<IServiceManager> sm = defaultServiceManager();
- ALOGD("ServiceManager: %p", sm.get());
binder_status_t status = TunerService::instantiate();
- if (status != STATUS_OK) {
- ALOGD("Failed to add tuner service as AIDL interface");
- return -1;
- }
+ CHECK(status == STATUS_OK);
ProcessState::self()->startThreadPool();
IPCThreadState::self()->joinThreadPool();
+ return EXIT_FAILURE; // should not reached
}