Loading audio/6.0/IStream.hal +3 −1 Original line number Diff line number Diff line Loading @@ -123,9 +123,11 @@ interface IStream { * equivalent to getting AUDIO_PARAMETER_STREAM_SUP_FORMATS on the legacy * HAL. * * @return retval operation completion status. * @return formats supported audio formats. * Must be non empty if retval is OK. */ getSupportedFormats() generates (vec<AudioFormat> formats); getSupportedFormats() generates (Result retval, vec<AudioFormat> formats); /** * Sets the audio format of the stream. Calling this method is equivalent to Loading audio/core/all-versions/default/Stream.cpp +9 −0 Original line number Diff line number Diff line Loading @@ -175,8 +175,17 @@ Return<void> Stream::getSupportedFormats(getSupportedFormats_cb _hidl_cb) { for (size_t i = 0; i < halFormats.size(); ++i) { formats[i] = AudioFormat(halFormats[i]); } // Legacy get_parameter does not return a status_t, thus can not advertise of failure. // Note that the method must not return an empty list if this capability is supported. if (formats.size() == 0) { result = Result::NOT_SUPPORTED; } } #if MAJOR_VERSION <= 5 _hidl_cb(formats); #elif MAJOR_VERSION >= 6 _hidl_cb(result, formats); #endif return Void(); } Loading audio/core/all-versions/vts/functional/4.0/AudioPrimaryHidlHalTest.cpp +3 −2 Original line number Diff line number Diff line Loading @@ -172,9 +172,10 @@ static void testSetDevices(IStream* stream, const DeviceAddress& address) { DeviceAddress otherAddress = address; otherAddress.device = (address.device & AudioDevice::BIT_IN) == 0 ? AudioDevice::OUT_SPEAKER : AudioDevice::IN_BUILTIN_MIC; EXPECT_OK(stream->setDevices({otherAddress})); EXPECT_RESULT(okOrNotSupported, stream->setDevices({otherAddress})); ASSERT_OK(stream->setDevices({address})); // Go back to the original value ASSERT_RESULT(okOrNotSupported, stream->setDevices({address})); // Go back to the original value } TEST_IO_STREAM(SetDevices, "Check that the stream can be rerouted to SPEAKER or BUILTIN_MIC", Loading audio/core/all-versions/vts/functional/4.0/AudioPrimaryHidlHalUtils.h +8 −1 Original line number Diff line number Diff line Loading @@ -75,11 +75,18 @@ struct GetSupported { return res; } #if MAJOR_VERSION <= 5 static Result formats(IStream* stream, hidl_vec<AudioFormat>& capabilities) { EXPECT_OK(stream->getSupportedFormats(returnIn(capabilities))); // TODO: this should be an optional function return Result::OK; } #elif MAJOR_VERSION >= 6 static Result formats(IStream* stream, hidl_vec<AudioFormat>& capabilities) { Result res; EXPECT_OK(stream->getSupportedFormats(returnIn(res, capabilities))); return res; } #endif }; template <class T> Loading audio/core/all-versions/vts/functional/6.0/AudioPrimaryHidlHalTest.cpp +74 −0 Original line number Diff line number Diff line Loading @@ -64,3 +64,77 @@ const std::vector<DeviceParameter>& getDeviceParameters() { }(); return parameters; } const std::vector<DeviceConfigParameter>& getOutputDeviceConfigParameters() { static std::vector<DeviceConfigParameter> parameters = [] { std::vector<DeviceConfigParameter> result; for (const auto& device : getDeviceParameters()) { auto module = getCachedPolicyConfig().getModuleFromName(std::get<PARAM_DEVICE_NAME>(device)); for (const auto& ioProfile : module->getOutputProfiles()) { for (const auto& profile : ioProfile->getAudioProfiles()) { auto configs = ConfigHelper::combineAudioConfig(profile->getChannels(), profile->getSampleRates(), profile->getFormat()); auto flags = ioProfile->getFlags(); for (auto& config : configs) { // Some combinations of flags declared in the config file require special // treatment. bool special = false; if (flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) { config.offloadInfo.sampleRateHz = config.sampleRateHz; config.offloadInfo.channelMask = config.channelMask; config.offloadInfo.format = config.format; config.offloadInfo.streamType = AudioStreamType::MUSIC; config.offloadInfo.bitRatePerSecond = 320; config.offloadInfo.durationMicroseconds = -1; config.offloadInfo.bitWidth = 16; config.offloadInfo.bufferSize = 256; // arbitrary value config.offloadInfo.usage = AudioUsage::MEDIA; result.emplace_back( device, config, AudioOutputFlag(AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD)); special = true; } if ((flags & AUDIO_OUTPUT_FLAG_DIRECT) && !(flags & AUDIO_OUTPUT_FLAG_HW_AV_SYNC)) { result.emplace_back(device, config, AudioOutputFlag(AUDIO_OUTPUT_FLAG_DIRECT)); special = true; } if (flags & AUDIO_OUTPUT_FLAG_PRIMARY) { // ignore the flag flags &= ~AUDIO_OUTPUT_FLAG_PRIMARY; } if (!special) { result.emplace_back(device, config, AudioOutputFlag(flags)); } } } } } return result; }(); return parameters; } const std::vector<DeviceConfigParameter>& getInputDeviceConfigParameters() { static std::vector<DeviceConfigParameter> parameters = [] { std::vector<DeviceConfigParameter> result; for (const auto& device : getDeviceParameters()) { auto module = getCachedPolicyConfig().getModuleFromName(std::get<PARAM_DEVICE_NAME>(device)); for (const auto& ioProfile : module->getInputProfiles()) { for (const auto& profile : ioProfile->getAudioProfiles()) { auto configs = ConfigHelper::combineAudioConfig(profile->getChannels(), profile->getSampleRates(), profile->getFormat()); for (const auto& config : configs) { result.emplace_back(device, config, AudioInputFlag(ioProfile->getFlags())); } } } } return result; }(); return parameters; } Loading
audio/6.0/IStream.hal +3 −1 Original line number Diff line number Diff line Loading @@ -123,9 +123,11 @@ interface IStream { * equivalent to getting AUDIO_PARAMETER_STREAM_SUP_FORMATS on the legacy * HAL. * * @return retval operation completion status. * @return formats supported audio formats. * Must be non empty if retval is OK. */ getSupportedFormats() generates (vec<AudioFormat> formats); getSupportedFormats() generates (Result retval, vec<AudioFormat> formats); /** * Sets the audio format of the stream. Calling this method is equivalent to Loading
audio/core/all-versions/default/Stream.cpp +9 −0 Original line number Diff line number Diff line Loading @@ -175,8 +175,17 @@ Return<void> Stream::getSupportedFormats(getSupportedFormats_cb _hidl_cb) { for (size_t i = 0; i < halFormats.size(); ++i) { formats[i] = AudioFormat(halFormats[i]); } // Legacy get_parameter does not return a status_t, thus can not advertise of failure. // Note that the method must not return an empty list if this capability is supported. if (formats.size() == 0) { result = Result::NOT_SUPPORTED; } } #if MAJOR_VERSION <= 5 _hidl_cb(formats); #elif MAJOR_VERSION >= 6 _hidl_cb(result, formats); #endif return Void(); } Loading
audio/core/all-versions/vts/functional/4.0/AudioPrimaryHidlHalTest.cpp +3 −2 Original line number Diff line number Diff line Loading @@ -172,9 +172,10 @@ static void testSetDevices(IStream* stream, const DeviceAddress& address) { DeviceAddress otherAddress = address; otherAddress.device = (address.device & AudioDevice::BIT_IN) == 0 ? AudioDevice::OUT_SPEAKER : AudioDevice::IN_BUILTIN_MIC; EXPECT_OK(stream->setDevices({otherAddress})); EXPECT_RESULT(okOrNotSupported, stream->setDevices({otherAddress})); ASSERT_OK(stream->setDevices({address})); // Go back to the original value ASSERT_RESULT(okOrNotSupported, stream->setDevices({address})); // Go back to the original value } TEST_IO_STREAM(SetDevices, "Check that the stream can be rerouted to SPEAKER or BUILTIN_MIC", Loading
audio/core/all-versions/vts/functional/4.0/AudioPrimaryHidlHalUtils.h +8 −1 Original line number Diff line number Diff line Loading @@ -75,11 +75,18 @@ struct GetSupported { return res; } #if MAJOR_VERSION <= 5 static Result formats(IStream* stream, hidl_vec<AudioFormat>& capabilities) { EXPECT_OK(stream->getSupportedFormats(returnIn(capabilities))); // TODO: this should be an optional function return Result::OK; } #elif MAJOR_VERSION >= 6 static Result formats(IStream* stream, hidl_vec<AudioFormat>& capabilities) { Result res; EXPECT_OK(stream->getSupportedFormats(returnIn(res, capabilities))); return res; } #endif }; template <class T> Loading
audio/core/all-versions/vts/functional/6.0/AudioPrimaryHidlHalTest.cpp +74 −0 Original line number Diff line number Diff line Loading @@ -64,3 +64,77 @@ const std::vector<DeviceParameter>& getDeviceParameters() { }(); return parameters; } const std::vector<DeviceConfigParameter>& getOutputDeviceConfigParameters() { static std::vector<DeviceConfigParameter> parameters = [] { std::vector<DeviceConfigParameter> result; for (const auto& device : getDeviceParameters()) { auto module = getCachedPolicyConfig().getModuleFromName(std::get<PARAM_DEVICE_NAME>(device)); for (const auto& ioProfile : module->getOutputProfiles()) { for (const auto& profile : ioProfile->getAudioProfiles()) { auto configs = ConfigHelper::combineAudioConfig(profile->getChannels(), profile->getSampleRates(), profile->getFormat()); auto flags = ioProfile->getFlags(); for (auto& config : configs) { // Some combinations of flags declared in the config file require special // treatment. bool special = false; if (flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) { config.offloadInfo.sampleRateHz = config.sampleRateHz; config.offloadInfo.channelMask = config.channelMask; config.offloadInfo.format = config.format; config.offloadInfo.streamType = AudioStreamType::MUSIC; config.offloadInfo.bitRatePerSecond = 320; config.offloadInfo.durationMicroseconds = -1; config.offloadInfo.bitWidth = 16; config.offloadInfo.bufferSize = 256; // arbitrary value config.offloadInfo.usage = AudioUsage::MEDIA; result.emplace_back( device, config, AudioOutputFlag(AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD)); special = true; } if ((flags & AUDIO_OUTPUT_FLAG_DIRECT) && !(flags & AUDIO_OUTPUT_FLAG_HW_AV_SYNC)) { result.emplace_back(device, config, AudioOutputFlag(AUDIO_OUTPUT_FLAG_DIRECT)); special = true; } if (flags & AUDIO_OUTPUT_FLAG_PRIMARY) { // ignore the flag flags &= ~AUDIO_OUTPUT_FLAG_PRIMARY; } if (!special) { result.emplace_back(device, config, AudioOutputFlag(flags)); } } } } } return result; }(); return parameters; } const std::vector<DeviceConfigParameter>& getInputDeviceConfigParameters() { static std::vector<DeviceConfigParameter> parameters = [] { std::vector<DeviceConfigParameter> result; for (const auto& device : getDeviceParameters()) { auto module = getCachedPolicyConfig().getModuleFromName(std::get<PARAM_DEVICE_NAME>(device)); for (const auto& ioProfile : module->getInputProfiles()) { for (const auto& profile : ioProfile->getAudioProfiles()) { auto configs = ConfigHelper::combineAudioConfig(profile->getChannels(), profile->getSampleRates(), profile->getFormat()); for (const auto& config : configs) { result.emplace_back(device, config, AudioInputFlag(ioProfile->getFlags())); } } } } return result; }(); return parameters; }