Merge "Add updateTrackMetadata support with audioSerssion_2_2 control"
This commit is contained in:
commit
5ad2fe4589
5 changed files with 64 additions and 1 deletions
|
@ -761,6 +761,13 @@ void HidlToAidlMiddleware_2_2::StopStream(const SessionType_2_1& session_type) {
|
||||||
from_session_type_2_1(session_type));
|
from_session_type_2_1(session_type));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HidlToAidlMiddleware_2_2::UpdateTracksMetadata(
|
||||||
|
const SessionType_2_1& session_type,
|
||||||
|
const struct source_metadata* source_metadata) {
|
||||||
|
return BluetoothAudioSessionControl::UpdateSourceMetadata(
|
||||||
|
from_session_type_2_1(session_type), *source_metadata);
|
||||||
|
}
|
||||||
|
|
||||||
void HidlToAidlMiddleware_2_2::UpdateSinkMetadata(
|
void HidlToAidlMiddleware_2_2::UpdateSinkMetadata(
|
||||||
const SessionType_2_1& session_type,
|
const SessionType_2_1& session_type,
|
||||||
const struct sink_metadata* sink_metadata) {
|
const struct sink_metadata* sink_metadata) {
|
||||||
|
|
|
@ -54,6 +54,10 @@ class HidlToAidlMiddleware_2_2 {
|
||||||
|
|
||||||
static void StopStream(const SessionType_2_1& session_type);
|
static void StopStream(const SessionType_2_1& session_type);
|
||||||
|
|
||||||
|
static void UpdateTracksMetadata(
|
||||||
|
const SessionType_2_1& session_type,
|
||||||
|
const struct source_metadata* source_metadata);
|
||||||
|
|
||||||
static void UpdateSinkMetadata(const SessionType_2_1& session_type,
|
static void UpdateSinkMetadata(const SessionType_2_1& session_type,
|
||||||
const struct sink_metadata* sink_metadata);
|
const struct sink_metadata* sink_metadata);
|
||||||
};
|
};
|
||||||
|
|
|
@ -152,7 +152,7 @@ class BluetoothAudioSessionControl_2_2 {
|
||||||
std::shared_ptr<BluetoothAudioSession_2_2> session_ptr =
|
std::shared_ptr<BluetoothAudioSession_2_2> session_ptr =
|
||||||
BluetoothAudioSessionInstance_2_2::GetSessionInstance(session_type);
|
BluetoothAudioSessionInstance_2_2::GetSessionInstance(session_type);
|
||||||
if (session_ptr != nullptr) {
|
if (session_ptr != nullptr) {
|
||||||
session_ptr->GetAudioSession()->UpdateTracksMetadata(source_metadata);
|
session_ptr->UpdateTracksMetadata(source_metadata);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,9 +31,13 @@ namespace audio {
|
||||||
|
|
||||||
using ::aidl::android::hardware::bluetooth::audio::HidlToAidlMiddleware_2_0;
|
using ::aidl::android::hardware::bluetooth::audio::HidlToAidlMiddleware_2_0;
|
||||||
using ::aidl::android::hardware::bluetooth::audio::HidlToAidlMiddleware_2_2;
|
using ::aidl::android::hardware::bluetooth::audio::HidlToAidlMiddleware_2_2;
|
||||||
|
using ::android::hardware::audio::common::V5_0::AudioContentType;
|
||||||
using ::android::hardware::audio::common::V5_0::AudioSource;
|
using ::android::hardware::audio::common::V5_0::AudioSource;
|
||||||
|
using ::android::hardware::audio::common::V5_0::AudioUsage;
|
||||||
|
using ::android::hardware::audio::common::V5_0::PlaybackTrackMetadata;
|
||||||
using ::android::hardware::audio::common::V5_0::RecordTrackMetadata;
|
using ::android::hardware::audio::common::V5_0::RecordTrackMetadata;
|
||||||
using ::android::hardware::audio::common::V5_0::SinkMetadata;
|
using ::android::hardware::audio::common::V5_0::SinkMetadata;
|
||||||
|
using ::android::hardware::audio::common::V5_0::SourceMetadata;
|
||||||
using ::android::hardware::bluetooth::audio::V2_0::BitsPerSample;
|
using ::android::hardware::bluetooth::audio::V2_0::BitsPerSample;
|
||||||
using ::android::hardware::bluetooth::audio::V2_0::ChannelMode;
|
using ::android::hardware::bluetooth::audio::V2_0::ChannelMode;
|
||||||
using ::android::hardware::bluetooth::audio::V2_2::LeAudioConfiguration;
|
using ::android::hardware::bluetooth::audio::V2_2::LeAudioConfiguration;
|
||||||
|
@ -128,6 +132,53 @@ BluetoothAudioSession_2_2::GetAudioSession_2_1() {
|
||||||
return audio_session_2_1;
|
return audio_session_2_1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BluetoothAudioSession_2_2::UpdateTracksMetadata(
|
||||||
|
const struct source_metadata* source_metadata) {
|
||||||
|
if (HidlToAidlMiddleware_2_0::IsAidlAvailable())
|
||||||
|
return HidlToAidlMiddleware_2_2::UpdateTracksMetadata(raw_session_type_,
|
||||||
|
source_metadata);
|
||||||
|
std::lock_guard<std::recursive_mutex> guard(audio_session->mutex_);
|
||||||
|
if (!IsSessionReady()) {
|
||||||
|
LOG(DEBUG) << __func__ << " - SessionType=" << toString(session_type_2_1_)
|
||||||
|
<< " has NO session";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ssize_t track_count = source_metadata->track_count;
|
||||||
|
LOG(INFO) << __func__ << " - SessionType=" << toString(session_type_2_1_)
|
||||||
|
<< ", " << track_count << " track(s)";
|
||||||
|
|
||||||
|
if (session_type_2_1_ == SessionType_2_1::UNKNOWN) {
|
||||||
|
audio_session->UpdateTracksMetadata(source_metadata);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct playback_track_metadata* track = source_metadata->tracks;
|
||||||
|
SourceMetadata sourceMetadata;
|
||||||
|
PlaybackTrackMetadata* halMetadata;
|
||||||
|
|
||||||
|
sourceMetadata.tracks.resize(track_count);
|
||||||
|
halMetadata = sourceMetadata.tracks.data();
|
||||||
|
while (track_count && track) {
|
||||||
|
halMetadata->usage = static_cast<AudioUsage>(track->usage);
|
||||||
|
halMetadata->contentType =
|
||||||
|
static_cast<AudioContentType>(track->content_type);
|
||||||
|
halMetadata->gain = track->gain;
|
||||||
|
LOG(VERBOSE) << __func__ << " - SessionType=" << toString(session_type_2_1_)
|
||||||
|
<< ", usage=" << toString(halMetadata->usage)
|
||||||
|
<< ", content=" << toString(halMetadata->contentType)
|
||||||
|
<< ", gain=" << halMetadata->gain;
|
||||||
|
--track_count;
|
||||||
|
++track;
|
||||||
|
++halMetadata;
|
||||||
|
}
|
||||||
|
auto hal_retval = audio_session->stack_iface_->updateMetadata(sourceMetadata);
|
||||||
|
if (!hal_retval.isOk()) {
|
||||||
|
LOG(WARNING) << __func__ << " - IBluetoothAudioPort SessionType="
|
||||||
|
<< toString(session_type_2_1_) << " failed";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void BluetoothAudioSession_2_2::UpdateSinkMetadata(
|
void BluetoothAudioSession_2_2::UpdateSinkMetadata(
|
||||||
const struct sink_metadata* sink_metadata) {
|
const struct sink_metadata* sink_metadata) {
|
||||||
if (HidlToAidlMiddleware_2_0::IsAidlAvailable())
|
if (HidlToAidlMiddleware_2_0::IsAidlAvailable())
|
||||||
|
|
|
@ -152,6 +152,7 @@ class BluetoothAudioSession_2_2 {
|
||||||
const ::android::hardware::bluetooth::audio::V2_2::AudioConfiguration
|
const ::android::hardware::bluetooth::audio::V2_2::AudioConfiguration
|
||||||
GetAudioConfig();
|
GetAudioConfig();
|
||||||
|
|
||||||
|
void UpdateTracksMetadata(const struct source_metadata* source_metadata);
|
||||||
void UpdateSinkMetadata(const struct sink_metadata* sink_metadata);
|
void UpdateSinkMetadata(const struct sink_metadata* sink_metadata);
|
||||||
|
|
||||||
static constexpr ::android::hardware::bluetooth::audio::V2_2::
|
static constexpr ::android::hardware::bluetooth::audio::V2_2::
|
||||||
|
|
Loading…
Reference in a new issue