Change-Id: Ib02900bde69ee24685d9d374c0e5f73d33fa59e7 Signed-off-by: François Gaffie <francois.gaffie@renault.com> Test: make Bug: 124767636gugelfrei
parent
63c0f36d2b
commit
4b2018b0c0
@ -0,0 +1 @@
|
||||
../../media/libaudioclient/include/media/AudioVolumeGroup.h
|
@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "AudioVolumeGroup"
|
||||
|
||||
//#define LOG_NDEBUG 0
|
||||
|
||||
#include <utils/Log.h>
|
||||
#include <binder/Parcel.h>
|
||||
|
||||
#include <media/AudioVolumeGroup.h>
|
||||
#include <media/AudioAttributes.h>
|
||||
|
||||
namespace android {
|
||||
|
||||
status_t AudioVolumeGroup::readFromParcel(const Parcel *parcel)
|
||||
{
|
||||
status_t ret = parcel->readUtf8FromUtf16(&mName);
|
||||
if (ret != NO_ERROR) {
|
||||
return ret;
|
||||
}
|
||||
mGroupId = static_cast<volume_group_t>(parcel->readInt32());
|
||||
size_t size = static_cast<size_t>(parcel->readInt32());
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
AudioAttributes attribute;
|
||||
attribute.readFromParcel(parcel);
|
||||
if (ret != NO_ERROR) {
|
||||
mAudioAttributes.clear();
|
||||
return ret;
|
||||
}
|
||||
mAudioAttributes.push_back(attribute.getAttributes());
|
||||
}
|
||||
size = static_cast<size_t>(parcel->readInt32());
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
audio_stream_type_t stream = static_cast<audio_stream_type_t>(parcel->readInt32());
|
||||
mStreams.push_back(stream);
|
||||
}
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
status_t AudioVolumeGroup::writeToParcel(Parcel *parcel) const
|
||||
{
|
||||
parcel->writeUtf8AsUtf16(mName);
|
||||
parcel->writeInt32(static_cast<int32_t>(mGroupId));
|
||||
size_t size = mAudioAttributes.size();
|
||||
size_t sizePosition = parcel->dataPosition();
|
||||
parcel->writeInt32(size);
|
||||
size_t finalSize = size;
|
||||
for (const auto &attributes : mAudioAttributes) {
|
||||
size_t position = parcel->dataPosition();
|
||||
AudioAttributes attribute(attributes);
|
||||
status_t ret = attribute.writeToParcel(parcel);
|
||||
if (ret != NO_ERROR) {
|
||||
parcel->setDataPosition(position);
|
||||
finalSize--;
|
||||
}
|
||||
}
|
||||
if (size != finalSize) {
|
||||
size_t position = parcel->dataPosition();
|
||||
parcel->setDataPosition(sizePosition);
|
||||
parcel->writeInt32(finalSize);
|
||||
parcel->setDataPosition(position);
|
||||
}
|
||||
parcel->writeInt32(mStreams.size());
|
||||
for (const auto &stream : mStreams) {
|
||||
parcel->writeInt32(static_cast<int32_t>(stream));
|
||||
}
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
} // namespace android
|
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.
|
||||
*/
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <media/AudioProductStrategy.h>
|
||||
#include <system/audio.h>
|
||||
#include <system/audio_policy.h>
|
||||
#include <binder/Parcelable.h>
|
||||
|
||||
namespace android {
|
||||
|
||||
class AudioVolumeGroup : public Parcelable
|
||||
{
|
||||
public:
|
||||
AudioVolumeGroup() {}
|
||||
AudioVolumeGroup(const std::string &name,
|
||||
volume_group_t group,
|
||||
const AttributesVector &attributes,
|
||||
const StreamTypeVector &streams) :
|
||||
mName(name), mGroupId(group), mAudioAttributes(attributes), mStreams(streams) {}
|
||||
|
||||
const std::string &getName() const { return mName; }
|
||||
volume_group_t getId() const { return mGroupId; }
|
||||
AttributesVector getAudioAttributes() const { return mAudioAttributes; }
|
||||
StreamTypeVector getStreamTypes() const { return mStreams; }
|
||||
|
||||
status_t readFromParcel(const Parcel *parcel) override;
|
||||
status_t writeToParcel(Parcel *parcel) const override;
|
||||
|
||||
private:
|
||||
std::string mName;
|
||||
volume_group_t mGroupId = VOLUME_GROUP_NONE;
|
||||
AttributesVector mAudioAttributes;
|
||||
StreamTypeVector mStreams;
|
||||
};
|
||||
|
||||
using AudioVolumeGroupVector = std::vector<AudioVolumeGroup>;
|
||||
|
||||
} // namespace android
|
Loading…
Reference in new issue