Replace basic_string<uint8_t> with std::vector
In newer versions of libc++, std::char_traits<T> is no longer defined
for non-character types, and a result, std::basic_string<uint8_t> is
also no longer defined. See
https://discourse.llvm.org/t/deprecating-std-string-t-for-non-character-t/66779.
Bug: 175635923
Test: make checkbuild
Change-Id: I1893d1b1419f528115739275ca0f1d80ddb22470
diff --git a/media/libaudiohal/impl/DeviceHalAidl.cpp b/media/libaudiohal/impl/DeviceHalAidl.cpp
index fe44ecd..1d8fec0 100644
--- a/media/libaudiohal/impl/DeviceHalAidl.cpp
+++ b/media/libaudiohal/impl/DeviceHalAidl.cpp
@@ -398,8 +398,7 @@
*static_cast<StreamCallbackBase*>(this)),
StreamCallbackBaseHelper<StreamOutHalInterfaceLatencyModeCallback>(
*static_cast<StreamCallbackBase*>(this)) {}
- ndk::ScopedAStatus onCodecFormatChanged(const std::vector<uint8_t>& in_audioMetadata) override {
- std::basic_string<uint8_t> halMetadata(in_audioMetadata.begin(), in_audioMetadata.end());
+ ndk::ScopedAStatus onCodecFormatChanged(const std::vector<uint8_t>& halMetadata) override {
return StreamCallbackBaseHelper<StreamOutHalInterfaceEventCallback>::runCb(
[&halMetadata](auto cb) { cb->onCodecFormatChanged(halMetadata); });
}
diff --git a/media/libaudiohal/impl/StreamHalHidl.cpp b/media/libaudiohal/impl/StreamHalHidl.cpp
index 72eadc6..77c75db 100644
--- a/media/libaudiohal/impl/StreamHalHidl.cpp
+++ b/media/libaudiohal/impl/StreamHalHidl.cpp
@@ -840,7 +840,7 @@
const android::hardware::hidl_vec<uint8_t>& audioMetadata) override {
sp<StreamOutHalHidl> stream = mStream.promote();
if (stream != nullptr) {
- std::basic_string<uint8_t> metadataBs(audioMetadata.begin(), audioMetadata.end());
+ std::vector<uint8_t> metadataBs(audioMetadata.begin(), audioMetadata.end());
stream->onCodecFormatChanged(metadataBs);
}
return Void();
@@ -967,7 +967,7 @@
callback->onError();
}
-void StreamOutHalHidl::onCodecFormatChanged(const std::basic_string<uint8_t>& metadataBs) {
+void StreamOutHalHidl::onCodecFormatChanged(const std::vector<uint8_t>& metadataBs) {
sp<StreamOutHalInterfaceEventCallback> callback = mEventCallback.load().promote();
if (callback == nullptr) return;
ALOGV("asyncCodecFormatCallback %s", __func__);
diff --git a/media/libaudiohal/impl/StreamHalHidl.h b/media/libaudiohal/impl/StreamHalHidl.h
index 5361047..48da633 100644
--- a/media/libaudiohal/impl/StreamHalHidl.h
+++ b/media/libaudiohal/impl/StreamHalHidl.h
@@ -194,7 +194,7 @@
status_t setEventCallback(const sp<StreamOutHalInterfaceEventCallback>& callback) override;
// Methods used by StreamCodecFormatCallback (HIDL).
- void onCodecFormatChanged(const std::basic_string<uint8_t>& metadataBs);
+ void onCodecFormatChanged(const std::vector<uint8_t>& metadataBs);
status_t setLatencyMode(audio_latency_mode_t mode) override;
status_t getRecommendedLatencyModes(std::vector<audio_latency_mode_t> *modes) override;
diff --git a/media/libaudiohal/include/media/audiohal/StreamHalInterface.h b/media/libaudiohal/include/media/audiohal/StreamHalInterface.h
index a780a17..37615af 100644
--- a/media/libaudiohal/include/media/audiohal/StreamHalInterface.h
+++ b/media/libaudiohal/include/media/audiohal/StreamHalInterface.h
@@ -116,7 +116,7 @@
class StreamOutHalInterfaceEventCallback : public virtual RefBase {
public:
- virtual void onCodecFormatChanged(const std::basic_string<uint8_t>& metadataBs) = 0;
+ virtual void onCodecFormatChanged(const std::vector<uint8_t>& metadataBs) = 0;
protected:
StreamOutHalInterfaceEventCallback() = default;
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index 01e7b0d..c5931f6 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -3046,7 +3046,7 @@
}
void PlaybackThread::onCodecFormatChanged(
- const std::basic_string<uint8_t>& metadataBs)
+ const std::vector<uint8_t>& metadataBs)
{
const auto weakPointerThis = wp<PlaybackThread>::fromExisting(this);
std::thread([this, metadataBs, weakPointerThis]() {
diff --git a/services/audioflinger/Threads.h b/services/audioflinger/Threads.h
index b84079a..8a62ebe 100644
--- a/services/audioflinger/Threads.h
+++ b/services/audioflinger/Threads.h
@@ -925,7 +925,7 @@
protected:
// StreamHalInterfaceCodecFormatCallback implementation
void onCodecFormatChanged(
- const std::basic_string<uint8_t>& metadataBs) final;
+ const std::vector<uint8_t>& metadataBs) final;
// ThreadBase virtuals
void preExit() final EXCLUDES_ThreadBase_Mutex;