2017-06-23 23:26:34 +00:00
|
|
|
/*
|
2020-04-13 22:56:35 +00:00
|
|
|
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
2017-05-18 05:02:48 +00:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License").
|
|
|
|
* You may not use this file except in compliance with the License.
|
|
|
|
* A copy of the License is located at
|
|
|
|
*
|
|
|
|
* http://aws.amazon.com/apache2.0/
|
|
|
|
*
|
|
|
|
* or in the "license" file accompanying this file. This file 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 <random>
|
|
|
|
#include <chrono>
|
|
|
|
#include <sstream>
|
Version 1.16 alexa-client-sdk
Changes in this update:
**Enhancements**
- Added support for SpeechSynthesizer v.1.2 which includes the new `playBehaviour` directive. For more information, see [SpeechSynthesizer v1.2](https://github.com/alexa/avs-device-sdk/wiki/SpeechSynthesizer-Interface-v1.2).
- Added support for pre-buffering in [AudioPlayer](https://alexa.github.io/avs-device-sdk/classalexa_client_s_d_k_1_1capability_agents_1_1audio_player_1_1_audio_player.html). You can optionally choose the number of instances MediaPlayer uses in the [AlexaClientSDKconfig.json](https://github.com/alexa/avs-device-sdk/blob/master/Integration/AlexaClientSDKConfig.json). Important: the contract for [MediaPlayerInterface](https://alexa.github.io/avs-device-sdk/classalexa_client_s_d_k_1_1avs_common_1_1utils_1_1media_player_1_1_media_player_interface.html) has changed. You must now make sure that the `SourceId` value returned by `setSource()` is unique across all instances.
- AudioPlayer is now licensed under the Amazon Software License instead of the Apache Software License.
**Bug Fixes**
- Fixed Android issue that caused the build script to ignore PKG_CONFIG_PATH. This sometimes caused the build to use a preinstalled dependency instead of the specific version downloaded by the Android script (e.g - openssl).
- Fixed Android issue that prevented the Sample app from running at the same time as other applications using the microphone. Android doesn't inherently allow two applications to use the microphone. Pressing the mute button now temporarily stops Alexa from accessing the microphone.
- Added 'quit' (– q) to the settings sub menu.
- Fixed outdated dependencies issue in the Windows install script.
- Fixed reminders issue that caused Notification LEDs to stay on, even after dismissing the alert.
**Known Issues**
* Music playback history isn't displayed in the Alexa app for certain account and device types.
* When using Gnu Compiler Collection 8+ (GCC 8+), `-Wclass-memaccess` triggers warnings. You can ignore these, they don't cause the build to fail.
* Android error `libDefaultClient.so not found` might occur. Resolve this by upgrading to ADB version 1.0.40.
* If a device loses a network connection, the lost connection status isn't returned via local TTS.
* ACL encounters issues if it receives audio attachments but doesn't consume them.
* `SpeechSynthesizerState` uses `GAINING_FOCUS` and `LOSING_FOCUS` as a workaround for handling intermediate states.
* Media steamed through Bluetooth might abruptly stop. To restart playback, resume the media in the source application or toggle next/previous.
* If a connected Bluetooth device is inactive, the Alexa app might indicates that audio is playing.
* The Bluetooth agent assumes that the Bluetooth adapter is always connected to a power source. Disconnecting from a power source during operation isn't yet supported.
* When using some products, interrupted Bluetooth playback might not resume if other content is locally streamed.
* `make integration` isn't available for Android. To run Android integration tests, manually upload the test binary and input file and run ADB.
* Alexa might truncate the beginning of speech when responding to text-to-speech (TTS) user events. This only impacts Raspberry Pi devices running Android Things with HDMI output audio.
* A reminder TTS message doesn't play if the sample app restarts and loses a network connection. Instead, the default alarm tone plays twice.
* `ServerDisconnectIntegratonTest` tests are disabled until they are updated to reflect new service behavior.
* Bluetooth initialization must complete before connecting devices, otherwise devices are ignored.
* The `DirectiveSequencerTest.test_handleBlockingThenImmediatelyThenNonBockingOnSameDialogId` test fails intermittently.
* On some devices, Alexa gets stuck in a permanent listening state. Pressing `t` and `h` in the Sample App doesn't exit the listening state.
* Exiting the `settings` menu doesn't provide a message to indicate that you are back in the main menu.
2019-10-25 20:19:44 +00:00
|
|
|
#include <string>
|
2017-05-18 05:02:48 +00:00
|
|
|
#include <iomanip>
|
Version 1.16 alexa-client-sdk
Changes in this update:
**Enhancements**
- Added support for SpeechSynthesizer v.1.2 which includes the new `playBehaviour` directive. For more information, see [SpeechSynthesizer v1.2](https://github.com/alexa/avs-device-sdk/wiki/SpeechSynthesizer-Interface-v1.2).
- Added support for pre-buffering in [AudioPlayer](https://alexa.github.io/avs-device-sdk/classalexa_client_s_d_k_1_1capability_agents_1_1audio_player_1_1_audio_player.html). You can optionally choose the number of instances MediaPlayer uses in the [AlexaClientSDKconfig.json](https://github.com/alexa/avs-device-sdk/blob/master/Integration/AlexaClientSDKConfig.json). Important: the contract for [MediaPlayerInterface](https://alexa.github.io/avs-device-sdk/classalexa_client_s_d_k_1_1avs_common_1_1utils_1_1media_player_1_1_media_player_interface.html) has changed. You must now make sure that the `SourceId` value returned by `setSource()` is unique across all instances.
- AudioPlayer is now licensed under the Amazon Software License instead of the Apache Software License.
**Bug Fixes**
- Fixed Android issue that caused the build script to ignore PKG_CONFIG_PATH. This sometimes caused the build to use a preinstalled dependency instead of the specific version downloaded by the Android script (e.g - openssl).
- Fixed Android issue that prevented the Sample app from running at the same time as other applications using the microphone. Android doesn't inherently allow two applications to use the microphone. Pressing the mute button now temporarily stops Alexa from accessing the microphone.
- Added 'quit' (– q) to the settings sub menu.
- Fixed outdated dependencies issue in the Windows install script.
- Fixed reminders issue that caused Notification LEDs to stay on, even after dismissing the alert.
**Known Issues**
* Music playback history isn't displayed in the Alexa app for certain account and device types.
* When using Gnu Compiler Collection 8+ (GCC 8+), `-Wclass-memaccess` triggers warnings. You can ignore these, they don't cause the build to fail.
* Android error `libDefaultClient.so not found` might occur. Resolve this by upgrading to ADB version 1.0.40.
* If a device loses a network connection, the lost connection status isn't returned via local TTS.
* ACL encounters issues if it receives audio attachments but doesn't consume them.
* `SpeechSynthesizerState` uses `GAINING_FOCUS` and `LOSING_FOCUS` as a workaround for handling intermediate states.
* Media steamed through Bluetooth might abruptly stop. To restart playback, resume the media in the source application or toggle next/previous.
* If a connected Bluetooth device is inactive, the Alexa app might indicates that audio is playing.
* The Bluetooth agent assumes that the Bluetooth adapter is always connected to a power source. Disconnecting from a power source during operation isn't yet supported.
* When using some products, interrupted Bluetooth playback might not resume if other content is locally streamed.
* `make integration` isn't available for Android. To run Android integration tests, manually upload the test binary and input file and run ADB.
* Alexa might truncate the beginning of speech when responding to text-to-speech (TTS) user events. This only impacts Raspberry Pi devices running Android Things with HDMI output audio.
* A reminder TTS message doesn't play if the sample app restarts and loses a network connection. Instead, the default alarm tone plays twice.
* `ServerDisconnectIntegratonTest` tests are disabled until they are updated to reflect new service behavior.
* Bluetooth initialization must complete before connecting devices, otherwise devices are ignored.
* The `DirectiveSequencerTest.test_handleBlockingThenImmediatelyThenNonBockingOnSameDialogId` test fails intermittently.
* On some devices, Alexa gets stuck in a permanent listening state. Pressing `t` and `h` in the Sample App doesn't exit the listening state.
* Exiting the `settings` menu doesn't provide a message to indicate that you are back in the main menu.
2019-10-25 20:19:44 +00:00
|
|
|
#include <cmath>
|
2017-05-18 05:02:48 +00:00
|
|
|
#include <mutex>
|
|
|
|
#include <climits>
|
|
|
|
#include <algorithm>
|
2017-06-23 23:26:34 +00:00
|
|
|
#include <functional>
|
2020-10-27 00:14:11 +00:00
|
|
|
#include <list>
|
2017-05-18 05:02:48 +00:00
|
|
|
|
2017-07-18 22:25:37 +00:00
|
|
|
#include "AVSCommon/Utils/Logger/Logger.h"
|
2017-05-18 05:02:48 +00:00
|
|
|
#include "AVSCommon/Utils/UUIDGeneration/UUIDGeneration.h"
|
|
|
|
|
|
|
|
namespace alexaClientSDK {
|
|
|
|
namespace avsCommon {
|
|
|
|
namespace utils {
|
|
|
|
namespace uuidGeneration {
|
|
|
|
|
2017-07-18 22:25:37 +00:00
|
|
|
/// String to identify log entries originating from this file.
|
|
|
|
static const std::string TAG("UUIDGeneration");
|
2017-05-18 05:02:48 +00:00
|
|
|
|
2017-07-18 22:25:37 +00:00
|
|
|
/**
|
|
|
|
* Create a LogEntry using this file's TAG and the specified event string.
|
|
|
|
*
|
|
|
|
* @param The event string for this @c LogEntry.
|
|
|
|
*/
|
|
|
|
#define LX(event) alexaClientSDK::avsCommon::utils::logger::LogEntry(TAG, event)
|
2017-05-18 05:02:48 +00:00
|
|
|
|
2017-07-18 22:25:37 +00:00
|
|
|
/// The UUID version (Version 4), shifted into the correct position in the byte.
|
2017-05-18 05:02:48 +00:00
|
|
|
static const uint8_t UUID_VERSION_VALUE = 4 << 4;
|
|
|
|
|
2017-07-18 22:25:37 +00:00
|
|
|
/// The UUID variant (Variant 1), shifted into the correct position in the byte.
|
2017-05-18 05:02:48 +00:00
|
|
|
static const size_t UUID_VARIANT_VALUE = 2 << 6;
|
|
|
|
|
|
|
|
/// Separator used between UUID fields.
|
|
|
|
static const std::string SEPARATOR("-");
|
|
|
|
|
2017-07-18 22:25:37 +00:00
|
|
|
/// Number of bits in the replacement value.
|
|
|
|
static const size_t MAX_NUM_REPLACEMENT_BITS = CHAR_BIT;
|
|
|
|
|
|
|
|
/// Number of bits in a hex digit.
|
|
|
|
static const size_t BITS_IN_HEX_DIGIT = 4;
|
|
|
|
|
Version 1.16 alexa-client-sdk
Changes in this update:
**Enhancements**
- Added support for SpeechSynthesizer v.1.2 which includes the new `playBehaviour` directive. For more information, see [SpeechSynthesizer v1.2](https://github.com/alexa/avs-device-sdk/wiki/SpeechSynthesizer-Interface-v1.2).
- Added support for pre-buffering in [AudioPlayer](https://alexa.github.io/avs-device-sdk/classalexa_client_s_d_k_1_1capability_agents_1_1audio_player_1_1_audio_player.html). You can optionally choose the number of instances MediaPlayer uses in the [AlexaClientSDKconfig.json](https://github.com/alexa/avs-device-sdk/blob/master/Integration/AlexaClientSDKConfig.json). Important: the contract for [MediaPlayerInterface](https://alexa.github.io/avs-device-sdk/classalexa_client_s_d_k_1_1avs_common_1_1utils_1_1media_player_1_1_media_player_interface.html) has changed. You must now make sure that the `SourceId` value returned by `setSource()` is unique across all instances.
- AudioPlayer is now licensed under the Amazon Software License instead of the Apache Software License.
**Bug Fixes**
- Fixed Android issue that caused the build script to ignore PKG_CONFIG_PATH. This sometimes caused the build to use a preinstalled dependency instead of the specific version downloaded by the Android script (e.g - openssl).
- Fixed Android issue that prevented the Sample app from running at the same time as other applications using the microphone. Android doesn't inherently allow two applications to use the microphone. Pressing the mute button now temporarily stops Alexa from accessing the microphone.
- Added 'quit' (– q) to the settings sub menu.
- Fixed outdated dependencies issue in the Windows install script.
- Fixed reminders issue that caused Notification LEDs to stay on, even after dismissing the alert.
**Known Issues**
* Music playback history isn't displayed in the Alexa app for certain account and device types.
* When using Gnu Compiler Collection 8+ (GCC 8+), `-Wclass-memaccess` triggers warnings. You can ignore these, they don't cause the build to fail.
* Android error `libDefaultClient.so not found` might occur. Resolve this by upgrading to ADB version 1.0.40.
* If a device loses a network connection, the lost connection status isn't returned via local TTS.
* ACL encounters issues if it receives audio attachments but doesn't consume them.
* `SpeechSynthesizerState` uses `GAINING_FOCUS` and `LOSING_FOCUS` as a workaround for handling intermediate states.
* Media steamed through Bluetooth might abruptly stop. To restart playback, resume the media in the source application or toggle next/previous.
* If a connected Bluetooth device is inactive, the Alexa app might indicates that audio is playing.
* The Bluetooth agent assumes that the Bluetooth adapter is always connected to a power source. Disconnecting from a power source during operation isn't yet supported.
* When using some products, interrupted Bluetooth playback might not resume if other content is locally streamed.
* `make integration` isn't available for Android. To run Android integration tests, manually upload the test binary and input file and run ADB.
* Alexa might truncate the beginning of speech when responding to text-to-speech (TTS) user events. This only impacts Raspberry Pi devices running Android Things with HDMI output audio.
* A reminder TTS message doesn't play if the sample app restarts and loses a network connection. Instead, the default alarm tone plays twice.
* `ServerDisconnectIntegratonTest` tests are disabled until they are updated to reflect new service behavior.
* Bluetooth initialization must complete before connecting devices, otherwise devices are ignored.
* The `DirectiveSequencerTest.test_handleBlockingThenImmediatelyThenNonBockingOnSameDialogId` test fails intermittently.
* On some devices, Alexa gets stuck in a permanent listening state. Pressing `t` and `h` in the Sample App doesn't exit the listening state.
* Exiting the `settings` menu doesn't provide a message to indicate that you are back in the main menu.
2019-10-25 20:19:44 +00:00
|
|
|
/// Indicates if next UUID should be seeded. Must not be accessed unless g_mutex is locked.
|
|
|
|
static bool g_seedNeeded = true;
|
|
|
|
|
|
|
|
/// Lock to avoid collisions in generationing uuid and setting seed.
|
|
|
|
static std::mutex g_mutex;
|
|
|
|
|
|
|
|
/// Entropy Threshold for sufficient uniqueness. Value chosen by experiment.
|
|
|
|
static const double ENTROPY_THRESHOLD = 600;
|
|
|
|
|
2020-10-27 00:14:11 +00:00
|
|
|
/// extra seeds
|
|
|
|
static const size_t MAX_SEEDS_POOL_SIZE = 1024;
|
|
|
|
|
|
|
|
/// pool of seeds
|
|
|
|
static std::list<uint32_t> seedsPool;
|
|
|
|
|
|
|
|
/// last time generateUUID was invoked
|
|
|
|
static uint64_t lastInvokeTime;
|
|
|
|
|
Version 1.16 alexa-client-sdk
Changes in this update:
**Enhancements**
- Added support for SpeechSynthesizer v.1.2 which includes the new `playBehaviour` directive. For more information, see [SpeechSynthesizer v1.2](https://github.com/alexa/avs-device-sdk/wiki/SpeechSynthesizer-Interface-v1.2).
- Added support for pre-buffering in [AudioPlayer](https://alexa.github.io/avs-device-sdk/classalexa_client_s_d_k_1_1capability_agents_1_1audio_player_1_1_audio_player.html). You can optionally choose the number of instances MediaPlayer uses in the [AlexaClientSDKconfig.json](https://github.com/alexa/avs-device-sdk/blob/master/Integration/AlexaClientSDKConfig.json). Important: the contract for [MediaPlayerInterface](https://alexa.github.io/avs-device-sdk/classalexa_client_s_d_k_1_1avs_common_1_1utils_1_1media_player_1_1_media_player_interface.html) has changed. You must now make sure that the `SourceId` value returned by `setSource()` is unique across all instances.
- AudioPlayer is now licensed under the Amazon Software License instead of the Apache Software License.
**Bug Fixes**
- Fixed Android issue that caused the build script to ignore PKG_CONFIG_PATH. This sometimes caused the build to use a preinstalled dependency instead of the specific version downloaded by the Android script (e.g - openssl).
- Fixed Android issue that prevented the Sample app from running at the same time as other applications using the microphone. Android doesn't inherently allow two applications to use the microphone. Pressing the mute button now temporarily stops Alexa from accessing the microphone.
- Added 'quit' (– q) to the settings sub menu.
- Fixed outdated dependencies issue in the Windows install script.
- Fixed reminders issue that caused Notification LEDs to stay on, even after dismissing the alert.
**Known Issues**
* Music playback history isn't displayed in the Alexa app for certain account and device types.
* When using Gnu Compiler Collection 8+ (GCC 8+), `-Wclass-memaccess` triggers warnings. You can ignore these, they don't cause the build to fail.
* Android error `libDefaultClient.so not found` might occur. Resolve this by upgrading to ADB version 1.0.40.
* If a device loses a network connection, the lost connection status isn't returned via local TTS.
* ACL encounters issues if it receives audio attachments but doesn't consume them.
* `SpeechSynthesizerState` uses `GAINING_FOCUS` and `LOSING_FOCUS` as a workaround for handling intermediate states.
* Media steamed through Bluetooth might abruptly stop. To restart playback, resume the media in the source application or toggle next/previous.
* If a connected Bluetooth device is inactive, the Alexa app might indicates that audio is playing.
* The Bluetooth agent assumes that the Bluetooth adapter is always connected to a power source. Disconnecting from a power source during operation isn't yet supported.
* When using some products, interrupted Bluetooth playback might not resume if other content is locally streamed.
* `make integration` isn't available for Android. To run Android integration tests, manually upload the test binary and input file and run ADB.
* Alexa might truncate the beginning of speech when responding to text-to-speech (TTS) user events. This only impacts Raspberry Pi devices running Android Things with HDMI output audio.
* A reminder TTS message doesn't play if the sample app restarts and loses a network connection. Instead, the default alarm tone plays twice.
* `ServerDisconnectIntegratonTest` tests are disabled until they are updated to reflect new service behavior.
* Bluetooth initialization must complete before connecting devices, otherwise devices are ignored.
* The `DirectiveSequencerTest.test_handleBlockingThenImmediatelyThenNonBockingOnSameDialogId` test fails intermittently.
* On some devices, Alexa gets stuck in a permanent listening state. Pressing `t` and `h` in the Sample App doesn't exit the listening state.
* Exiting the `settings` menu doesn't provide a message to indicate that you are back in the main menu.
2019-10-25 20:19:44 +00:00
|
|
|
/// Catch for platforms where entropy is a hard coded value. Value chosen by experiment.
|
|
|
|
static const int ENTROPY_REPEAT_THRESHOLD = 16;
|
|
|
|
|
2020-10-27 00:14:11 +00:00
|
|
|
/// The default read entropy function. This can be customized using UUIDGeneration::setEntropyReader().
|
|
|
|
static std::function<double(void)> readEntropyFunc = []() {
|
|
|
|
std::random_device rd;
|
|
|
|
return rd.entropy();
|
|
|
|
};
|
|
|
|
|
|
|
|
void setEntropyReader(std::function<double(void)> func) {
|
|
|
|
readEntropyFunc = func;
|
|
|
|
}
|
|
|
|
|
Version 1.16 alexa-client-sdk
Changes in this update:
**Enhancements**
- Added support for SpeechSynthesizer v.1.2 which includes the new `playBehaviour` directive. For more information, see [SpeechSynthesizer v1.2](https://github.com/alexa/avs-device-sdk/wiki/SpeechSynthesizer-Interface-v1.2).
- Added support for pre-buffering in [AudioPlayer](https://alexa.github.io/avs-device-sdk/classalexa_client_s_d_k_1_1capability_agents_1_1audio_player_1_1_audio_player.html). You can optionally choose the number of instances MediaPlayer uses in the [AlexaClientSDKconfig.json](https://github.com/alexa/avs-device-sdk/blob/master/Integration/AlexaClientSDKConfig.json). Important: the contract for [MediaPlayerInterface](https://alexa.github.io/avs-device-sdk/classalexa_client_s_d_k_1_1avs_common_1_1utils_1_1media_player_1_1_media_player_interface.html) has changed. You must now make sure that the `SourceId` value returned by `setSource()` is unique across all instances.
- AudioPlayer is now licensed under the Amazon Software License instead of the Apache Software License.
**Bug Fixes**
- Fixed Android issue that caused the build script to ignore PKG_CONFIG_PATH. This sometimes caused the build to use a preinstalled dependency instead of the specific version downloaded by the Android script (e.g - openssl).
- Fixed Android issue that prevented the Sample app from running at the same time as other applications using the microphone. Android doesn't inherently allow two applications to use the microphone. Pressing the mute button now temporarily stops Alexa from accessing the microphone.
- Added 'quit' (– q) to the settings sub menu.
- Fixed outdated dependencies issue in the Windows install script.
- Fixed reminders issue that caused Notification LEDs to stay on, even after dismissing the alert.
**Known Issues**
* Music playback history isn't displayed in the Alexa app for certain account and device types.
* When using Gnu Compiler Collection 8+ (GCC 8+), `-Wclass-memaccess` triggers warnings. You can ignore these, they don't cause the build to fail.
* Android error `libDefaultClient.so not found` might occur. Resolve this by upgrading to ADB version 1.0.40.
* If a device loses a network connection, the lost connection status isn't returned via local TTS.
* ACL encounters issues if it receives audio attachments but doesn't consume them.
* `SpeechSynthesizerState` uses `GAINING_FOCUS` and `LOSING_FOCUS` as a workaround for handling intermediate states.
* Media steamed through Bluetooth might abruptly stop. To restart playback, resume the media in the source application or toggle next/previous.
* If a connected Bluetooth device is inactive, the Alexa app might indicates that audio is playing.
* The Bluetooth agent assumes that the Bluetooth adapter is always connected to a power source. Disconnecting from a power source during operation isn't yet supported.
* When using some products, interrupted Bluetooth playback might not resume if other content is locally streamed.
* `make integration` isn't available for Android. To run Android integration tests, manually upload the test binary and input file and run ADB.
* Alexa might truncate the beginning of speech when responding to text-to-speech (TTS) user events. This only impacts Raspberry Pi devices running Android Things with HDMI output audio.
* A reminder TTS message doesn't play if the sample app restarts and loses a network connection. Instead, the default alarm tone plays twice.
* `ServerDisconnectIntegratonTest` tests are disabled until they are updated to reflect new service behavior.
* Bluetooth initialization must complete before connecting devices, otherwise devices are ignored.
* The `DirectiveSequencerTest.test_handleBlockingThenImmediatelyThenNonBockingOnSameDialogId` test fails intermittently.
* On some devices, Alexa gets stuck in a permanent listening state. Pressing `t` and `h` in the Sample App doesn't exit the listening state.
* Exiting the `settings` menu doesn't provide a message to indicate that you are back in the main menu.
2019-10-25 20:19:44 +00:00
|
|
|
void setSalt(const std::string& newSalt) {
|
|
|
|
std::unique_lock<std::mutex> lock(g_mutex);
|
2020-10-27 00:14:11 +00:00
|
|
|
std::copy_n(newSalt.begin(), std::min(newSalt.size(), MAX_SEEDS_POOL_SIZE), std::front_inserter(seedsPool));
|
|
|
|
g_seedNeeded = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void addSeeds(const std::vector<uint32_t>& seeds) {
|
|
|
|
std::unique_lock<std::mutex> lock(g_mutex);
|
|
|
|
std::copy_n(seeds.begin(), std::min(seeds.size(), MAX_SEEDS_POOL_SIZE), std::front_inserter(seedsPool));
|
Version 1.16 alexa-client-sdk
Changes in this update:
**Enhancements**
- Added support for SpeechSynthesizer v.1.2 which includes the new `playBehaviour` directive. For more information, see [SpeechSynthesizer v1.2](https://github.com/alexa/avs-device-sdk/wiki/SpeechSynthesizer-Interface-v1.2).
- Added support for pre-buffering in [AudioPlayer](https://alexa.github.io/avs-device-sdk/classalexa_client_s_d_k_1_1capability_agents_1_1audio_player_1_1_audio_player.html). You can optionally choose the number of instances MediaPlayer uses in the [AlexaClientSDKconfig.json](https://github.com/alexa/avs-device-sdk/blob/master/Integration/AlexaClientSDKConfig.json). Important: the contract for [MediaPlayerInterface](https://alexa.github.io/avs-device-sdk/classalexa_client_s_d_k_1_1avs_common_1_1utils_1_1media_player_1_1_media_player_interface.html) has changed. You must now make sure that the `SourceId` value returned by `setSource()` is unique across all instances.
- AudioPlayer is now licensed under the Amazon Software License instead of the Apache Software License.
**Bug Fixes**
- Fixed Android issue that caused the build script to ignore PKG_CONFIG_PATH. This sometimes caused the build to use a preinstalled dependency instead of the specific version downloaded by the Android script (e.g - openssl).
- Fixed Android issue that prevented the Sample app from running at the same time as other applications using the microphone. Android doesn't inherently allow two applications to use the microphone. Pressing the mute button now temporarily stops Alexa from accessing the microphone.
- Added 'quit' (– q) to the settings sub menu.
- Fixed outdated dependencies issue in the Windows install script.
- Fixed reminders issue that caused Notification LEDs to stay on, even after dismissing the alert.
**Known Issues**
* Music playback history isn't displayed in the Alexa app for certain account and device types.
* When using Gnu Compiler Collection 8+ (GCC 8+), `-Wclass-memaccess` triggers warnings. You can ignore these, they don't cause the build to fail.
* Android error `libDefaultClient.so not found` might occur. Resolve this by upgrading to ADB version 1.0.40.
* If a device loses a network connection, the lost connection status isn't returned via local TTS.
* ACL encounters issues if it receives audio attachments but doesn't consume them.
* `SpeechSynthesizerState` uses `GAINING_FOCUS` and `LOSING_FOCUS` as a workaround for handling intermediate states.
* Media steamed through Bluetooth might abruptly stop. To restart playback, resume the media in the source application or toggle next/previous.
* If a connected Bluetooth device is inactive, the Alexa app might indicates that audio is playing.
* The Bluetooth agent assumes that the Bluetooth adapter is always connected to a power source. Disconnecting from a power source during operation isn't yet supported.
* When using some products, interrupted Bluetooth playback might not resume if other content is locally streamed.
* `make integration` isn't available for Android. To run Android integration tests, manually upload the test binary and input file and run ADB.
* Alexa might truncate the beginning of speech when responding to text-to-speech (TTS) user events. This only impacts Raspberry Pi devices running Android Things with HDMI output audio.
* A reminder TTS message doesn't play if the sample app restarts and loses a network connection. Instead, the default alarm tone plays twice.
* `ServerDisconnectIntegratonTest` tests are disabled until they are updated to reflect new service behavior.
* Bluetooth initialization must complete before connecting devices, otherwise devices are ignored.
* The `DirectiveSequencerTest.test_handleBlockingThenImmediatelyThenNonBockingOnSameDialogId` test fails intermittently.
* On some devices, Alexa gets stuck in a permanent listening state. Pressing `t` and `h` in the Sample App doesn't exit the listening state.
* Exiting the `settings` menu doesn't provide a message to indicate that you are back in the main menu.
2019-10-25 20:19:44 +00:00
|
|
|
g_seedNeeded = true;
|
|
|
|
}
|
|
|
|
|
2017-07-18 22:25:37 +00:00
|
|
|
/**
|
|
|
|
* Randomly generate a string of hex digits. Before the conversion of hex to string,
|
|
|
|
* the function allows replacement of the bits of the first two generated hex digits.
|
|
|
|
* Replacement happens starting at the most significant, to the least significant bit.
|
|
|
|
*
|
|
|
|
* @param ibe A random number generator.
|
|
|
|
* @param numDigits The number of hex digits [0-9],[a-f] to generate.
|
|
|
|
* @param replacementBits The replacement value for up to the first two digits generated.
|
|
|
|
* @param numReplacementBits The number of bits of @c replacementBits to use.
|
|
|
|
*
|
|
|
|
* @return A hex string of length @c numDigits.
|
|
|
|
*/
|
|
|
|
static const std::string generateHexWithReplacement(
|
2020-12-08 23:09:40 +00:00
|
|
|
std::independent_bits_engine<std::mt19937, CHAR_BIT, uint32_t>& ibe,
|
2017-10-02 22:59:05 +00:00
|
|
|
unsigned int numDigits,
|
|
|
|
uint8_t replacementBits,
|
2020-10-27 00:14:11 +00:00
|
|
|
uint8_t numReplacementBits) {
|
2017-07-18 22:25:37 +00:00
|
|
|
if (numReplacementBits > MAX_NUM_REPLACEMENT_BITS) {
|
|
|
|
ACSDK_ERROR(LX("generateHexWithReplacementFailed")
|
2017-10-02 22:59:05 +00:00
|
|
|
.d("reason", "replacingMoreBitsThanProvided")
|
|
|
|
.d("numReplacementBitsLimit", MAX_NUM_REPLACEMENT_BITS)
|
|
|
|
.d("numReplacementBits", numReplacementBits));
|
2017-07-18 22:25:37 +00:00
|
|
|
return "";
|
|
|
|
}
|
2017-05-18 05:02:48 +00:00
|
|
|
|
2017-07-18 22:25:37 +00:00
|
|
|
if (numReplacementBits > (numDigits * BITS_IN_HEX_DIGIT)) {
|
|
|
|
ACSDK_ERROR(LX("generateHexWithReplacementFailed")
|
2017-10-02 22:59:05 +00:00
|
|
|
.d("reason", "replacingMoreBitsThanGenerated")
|
|
|
|
.d("numDigitsInBits", numDigits * BITS_IN_HEX_DIGIT)
|
|
|
|
.d("numReplacementBits", numReplacementBits));
|
2017-07-18 22:25:37 +00:00
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2020-02-19 18:35:26 +00:00
|
|
|
const size_t arrayLen = (numDigits + 1) / 2;
|
|
|
|
|
|
|
|
std::vector<uint8_t> bytes(arrayLen);
|
2020-10-27 00:14:11 +00:00
|
|
|
std::generate(bytes.begin(), bytes.end(), std::ref(ibe));
|
2017-05-18 05:02:48 +00:00
|
|
|
|
2017-07-18 22:25:37 +00:00
|
|
|
// Replace the specified number of bits from the first byte.
|
|
|
|
bytes.at(0) &= (0xff >> numReplacementBits);
|
|
|
|
replacementBits &= (0xff << (MAX_NUM_REPLACEMENT_BITS - numReplacementBits));
|
|
|
|
bytes.at(0) |= replacementBits;
|
2017-05-18 05:02:48 +00:00
|
|
|
|
2017-07-18 22:25:37 +00:00
|
|
|
std::ostringstream oss;
|
2017-10-02 22:59:05 +00:00
|
|
|
for (const auto& byte : bytes) {
|
2017-07-18 22:25:37 +00:00
|
|
|
oss << std::hex << std::setfill('0') << std::setw(2) << static_cast<int>(byte);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string bytesText = oss.str();
|
|
|
|
// Remove the last digit for odd numDigits case.
|
|
|
|
bytesText.resize(numDigits);
|
|
|
|
|
|
|
|
return bytesText;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Randomly generate a string of hex digits.
|
|
|
|
*
|
|
|
|
* @param ibe A random number generator.
|
|
|
|
* @param numDigits The number of hex digits [0-9],[a-f] to generate.
|
|
|
|
*
|
|
|
|
* @return A hex string of length @c numDigits.
|
|
|
|
*/
|
|
|
|
static const std::string generateHex(
|
2020-12-08 23:09:40 +00:00
|
|
|
std::independent_bits_engine<std::mt19937, CHAR_BIT, uint32_t>& ibe,
|
2017-10-02 22:59:05 +00:00
|
|
|
unsigned int numDigits) {
|
2017-07-18 22:25:37 +00:00
|
|
|
return generateHexWithReplacement(ibe, numDigits, 0, 0);
|
|
|
|
}
|
2017-05-18 05:02:48 +00:00
|
|
|
|
2020-10-27 00:14:11 +00:00
|
|
|
/**
|
|
|
|
* Add default seed to the pool, should only be used in generateUUID and locked by g_mutex.
|
|
|
|
*/
|
|
|
|
static void addDefaultSeedLocked() {
|
|
|
|
std::random_device rd;
|
|
|
|
uint64_t timeSeed = std::chrono::high_resolution_clock::now().time_since_epoch().count();
|
|
|
|
if (lastInvokeTime > 0) {
|
|
|
|
seedsPool.push_front((uint32_t)(timeSeed - lastInvokeTime)); // interval between two invocations
|
|
|
|
}
|
|
|
|
lastInvokeTime = timeSeed;
|
|
|
|
seedsPool.push_front((uint32_t)timeSeed); // lower 32bits of current time
|
|
|
|
seedsPool.push_front(rd()); // random device
|
|
|
|
seedsPool.push_front(
|
2022-05-25 14:10:32 +00:00
|
|
|
reinterpret_cast<std::uintmax_t>(&timeSeed)); // lower 32bits of memory address of temporary variable
|
2020-10-27 00:14:11 +00:00
|
|
|
|
|
|
|
if (seedsPool.size() > MAX_SEEDS_POOL_SIZE) {
|
|
|
|
seedsPool.resize(MAX_SEEDS_POOL_SIZE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-18 05:02:48 +00:00
|
|
|
const std::string generateUUID() {
|
2020-12-08 23:09:40 +00:00
|
|
|
static std::independent_bits_engine<std::mt19937, CHAR_BIT, uint32_t> ibe;
|
Version 1.16 alexa-client-sdk
Changes in this update:
**Enhancements**
- Added support for SpeechSynthesizer v.1.2 which includes the new `playBehaviour` directive. For more information, see [SpeechSynthesizer v1.2](https://github.com/alexa/avs-device-sdk/wiki/SpeechSynthesizer-Interface-v1.2).
- Added support for pre-buffering in [AudioPlayer](https://alexa.github.io/avs-device-sdk/classalexa_client_s_d_k_1_1capability_agents_1_1audio_player_1_1_audio_player.html). You can optionally choose the number of instances MediaPlayer uses in the [AlexaClientSDKconfig.json](https://github.com/alexa/avs-device-sdk/blob/master/Integration/AlexaClientSDKConfig.json). Important: the contract for [MediaPlayerInterface](https://alexa.github.io/avs-device-sdk/classalexa_client_s_d_k_1_1avs_common_1_1utils_1_1media_player_1_1_media_player_interface.html) has changed. You must now make sure that the `SourceId` value returned by `setSource()` is unique across all instances.
- AudioPlayer is now licensed under the Amazon Software License instead of the Apache Software License.
**Bug Fixes**
- Fixed Android issue that caused the build script to ignore PKG_CONFIG_PATH. This sometimes caused the build to use a preinstalled dependency instead of the specific version downloaded by the Android script (e.g - openssl).
- Fixed Android issue that prevented the Sample app from running at the same time as other applications using the microphone. Android doesn't inherently allow two applications to use the microphone. Pressing the mute button now temporarily stops Alexa from accessing the microphone.
- Added 'quit' (– q) to the settings sub menu.
- Fixed outdated dependencies issue in the Windows install script.
- Fixed reminders issue that caused Notification LEDs to stay on, even after dismissing the alert.
**Known Issues**
* Music playback history isn't displayed in the Alexa app for certain account and device types.
* When using Gnu Compiler Collection 8+ (GCC 8+), `-Wclass-memaccess` triggers warnings. You can ignore these, they don't cause the build to fail.
* Android error `libDefaultClient.so not found` might occur. Resolve this by upgrading to ADB version 1.0.40.
* If a device loses a network connection, the lost connection status isn't returned via local TTS.
* ACL encounters issues if it receives audio attachments but doesn't consume them.
* `SpeechSynthesizerState` uses `GAINING_FOCUS` and `LOSING_FOCUS` as a workaround for handling intermediate states.
* Media steamed through Bluetooth might abruptly stop. To restart playback, resume the media in the source application or toggle next/previous.
* If a connected Bluetooth device is inactive, the Alexa app might indicates that audio is playing.
* The Bluetooth agent assumes that the Bluetooth adapter is always connected to a power source. Disconnecting from a power source during operation isn't yet supported.
* When using some products, interrupted Bluetooth playback might not resume if other content is locally streamed.
* `make integration` isn't available for Android. To run Android integration tests, manually upload the test binary and input file and run ADB.
* Alexa might truncate the beginning of speech when responding to text-to-speech (TTS) user events. This only impacts Raspberry Pi devices running Android Things with HDMI output audio.
* A reminder TTS message doesn't play if the sample app restarts and loses a network connection. Instead, the default alarm tone plays twice.
* `ServerDisconnectIntegratonTest` tests are disabled until they are updated to reflect new service behavior.
* Bluetooth initialization must complete before connecting devices, otherwise devices are ignored.
* The `DirectiveSequencerTest.test_handleBlockingThenImmediatelyThenNonBockingOnSameDialogId` test fails intermittently.
* On some devices, Alexa gets stuck in a permanent listening state. Pressing `t` and `h` in the Sample App doesn't exit the listening state.
* Exiting the `settings` menu doesn't provide a message to indicate that you are back in the main menu.
2019-10-25 20:19:44 +00:00
|
|
|
std::unique_lock<std::mutex> lock(g_mutex);
|
|
|
|
|
|
|
|
if (g_seedNeeded) {
|
2020-12-08 23:09:40 +00:00
|
|
|
static int consistentEntropyReports = 0;
|
|
|
|
static double priorEntropyResult = 0;
|
2020-10-27 00:14:11 +00:00
|
|
|
addDefaultSeedLocked();
|
|
|
|
std::seed_seq seed(seedsPool.begin(), seedsPool.end());
|
|
|
|
ibe.seed(seed);
|
|
|
|
|
|
|
|
double currentEntropy = readEntropyFunc();
|
Version 1.16 alexa-client-sdk
Changes in this update:
**Enhancements**
- Added support for SpeechSynthesizer v.1.2 which includes the new `playBehaviour` directive. For more information, see [SpeechSynthesizer v1.2](https://github.com/alexa/avs-device-sdk/wiki/SpeechSynthesizer-Interface-v1.2).
- Added support for pre-buffering in [AudioPlayer](https://alexa.github.io/avs-device-sdk/classalexa_client_s_d_k_1_1capability_agents_1_1audio_player_1_1_audio_player.html). You can optionally choose the number of instances MediaPlayer uses in the [AlexaClientSDKconfig.json](https://github.com/alexa/avs-device-sdk/blob/master/Integration/AlexaClientSDKConfig.json). Important: the contract for [MediaPlayerInterface](https://alexa.github.io/avs-device-sdk/classalexa_client_s_d_k_1_1avs_common_1_1utils_1_1media_player_1_1_media_player_interface.html) has changed. You must now make sure that the `SourceId` value returned by `setSource()` is unique across all instances.
- AudioPlayer is now licensed under the Amazon Software License instead of the Apache Software License.
**Bug Fixes**
- Fixed Android issue that caused the build script to ignore PKG_CONFIG_PATH. This sometimes caused the build to use a preinstalled dependency instead of the specific version downloaded by the Android script (e.g - openssl).
- Fixed Android issue that prevented the Sample app from running at the same time as other applications using the microphone. Android doesn't inherently allow two applications to use the microphone. Pressing the mute button now temporarily stops Alexa from accessing the microphone.
- Added 'quit' (– q) to the settings sub menu.
- Fixed outdated dependencies issue in the Windows install script.
- Fixed reminders issue that caused Notification LEDs to stay on, even after dismissing the alert.
**Known Issues**
* Music playback history isn't displayed in the Alexa app for certain account and device types.
* When using Gnu Compiler Collection 8+ (GCC 8+), `-Wclass-memaccess` triggers warnings. You can ignore these, they don't cause the build to fail.
* Android error `libDefaultClient.so not found` might occur. Resolve this by upgrading to ADB version 1.0.40.
* If a device loses a network connection, the lost connection status isn't returned via local TTS.
* ACL encounters issues if it receives audio attachments but doesn't consume them.
* `SpeechSynthesizerState` uses `GAINING_FOCUS` and `LOSING_FOCUS` as a workaround for handling intermediate states.
* Media steamed through Bluetooth might abruptly stop. To restart playback, resume the media in the source application or toggle next/previous.
* If a connected Bluetooth device is inactive, the Alexa app might indicates that audio is playing.
* The Bluetooth agent assumes that the Bluetooth adapter is always connected to a power source. Disconnecting from a power source during operation isn't yet supported.
* When using some products, interrupted Bluetooth playback might not resume if other content is locally streamed.
* `make integration` isn't available for Android. To run Android integration tests, manually upload the test binary and input file and run ADB.
* Alexa might truncate the beginning of speech when responding to text-to-speech (TTS) user events. This only impacts Raspberry Pi devices running Android Things with HDMI output audio.
* A reminder TTS message doesn't play if the sample app restarts and loses a network connection. Instead, the default alarm tone plays twice.
* `ServerDisconnectIntegratonTest` tests are disabled until they are updated to reflect new service behavior.
* Bluetooth initialization must complete before connecting devices, otherwise devices are ignored.
* The `DirectiveSequencerTest.test_handleBlockingThenImmediatelyThenNonBockingOnSameDialogId` test fails intermittently.
* On some devices, Alexa gets stuck in a permanent listening state. Pressing `t` and `h` in the Sample App doesn't exit the listening state.
* Exiting the `settings` menu doesn't provide a message to indicate that you are back in the main menu.
2019-10-25 20:19:44 +00:00
|
|
|
|
|
|
|
if (std::fabs(currentEntropy - priorEntropyResult) < std::numeric_limits<double>::epsilon()) {
|
|
|
|
++consistentEntropyReports;
|
|
|
|
} else {
|
|
|
|
consistentEntropyReports = 0;
|
|
|
|
}
|
|
|
|
priorEntropyResult = currentEntropy;
|
|
|
|
|
|
|
|
if (currentEntropy > ENTROPY_THRESHOLD) {
|
|
|
|
g_seedNeeded = false;
|
|
|
|
} else {
|
2021-08-24 20:46:00 +00:00
|
|
|
ACSDK_INFO(LX("low entropy on call to generate UUID").d("current entropy", currentEntropy));
|
2020-10-27 00:14:11 +00:00
|
|
|
if (consistentEntropyReports > ENTROPY_REPEAT_THRESHOLD) {
|
|
|
|
g_seedNeeded = false;
|
2021-08-24 20:46:00 +00:00
|
|
|
ACSDK_INFO(LX("multiple repeat values for entropy")
|
2020-10-27 00:14:11 +00:00
|
|
|
.d("current entropy", currentEntropy)
|
|
|
|
.d("consistent entropy reports", consistentEntropyReports));
|
|
|
|
}
|
Version 1.16 alexa-client-sdk
Changes in this update:
**Enhancements**
- Added support for SpeechSynthesizer v.1.2 which includes the new `playBehaviour` directive. For more information, see [SpeechSynthesizer v1.2](https://github.com/alexa/avs-device-sdk/wiki/SpeechSynthesizer-Interface-v1.2).
- Added support for pre-buffering in [AudioPlayer](https://alexa.github.io/avs-device-sdk/classalexa_client_s_d_k_1_1capability_agents_1_1audio_player_1_1_audio_player.html). You can optionally choose the number of instances MediaPlayer uses in the [AlexaClientSDKconfig.json](https://github.com/alexa/avs-device-sdk/blob/master/Integration/AlexaClientSDKConfig.json). Important: the contract for [MediaPlayerInterface](https://alexa.github.io/avs-device-sdk/classalexa_client_s_d_k_1_1avs_common_1_1utils_1_1media_player_1_1_media_player_interface.html) has changed. You must now make sure that the `SourceId` value returned by `setSource()` is unique across all instances.
- AudioPlayer is now licensed under the Amazon Software License instead of the Apache Software License.
**Bug Fixes**
- Fixed Android issue that caused the build script to ignore PKG_CONFIG_PATH. This sometimes caused the build to use a preinstalled dependency instead of the specific version downloaded by the Android script (e.g - openssl).
- Fixed Android issue that prevented the Sample app from running at the same time as other applications using the microphone. Android doesn't inherently allow two applications to use the microphone. Pressing the mute button now temporarily stops Alexa from accessing the microphone.
- Added 'quit' (– q) to the settings sub menu.
- Fixed outdated dependencies issue in the Windows install script.
- Fixed reminders issue that caused Notification LEDs to stay on, even after dismissing the alert.
**Known Issues**
* Music playback history isn't displayed in the Alexa app for certain account and device types.
* When using Gnu Compiler Collection 8+ (GCC 8+), `-Wclass-memaccess` triggers warnings. You can ignore these, they don't cause the build to fail.
* Android error `libDefaultClient.so not found` might occur. Resolve this by upgrading to ADB version 1.0.40.
* If a device loses a network connection, the lost connection status isn't returned via local TTS.
* ACL encounters issues if it receives audio attachments but doesn't consume them.
* `SpeechSynthesizerState` uses `GAINING_FOCUS` and `LOSING_FOCUS` as a workaround for handling intermediate states.
* Media steamed through Bluetooth might abruptly stop. To restart playback, resume the media in the source application or toggle next/previous.
* If a connected Bluetooth device is inactive, the Alexa app might indicates that audio is playing.
* The Bluetooth agent assumes that the Bluetooth adapter is always connected to a power source. Disconnecting from a power source during operation isn't yet supported.
* When using some products, interrupted Bluetooth playback might not resume if other content is locally streamed.
* `make integration` isn't available for Android. To run Android integration tests, manually upload the test binary and input file and run ADB.
* Alexa might truncate the beginning of speech when responding to text-to-speech (TTS) user events. This only impacts Raspberry Pi devices running Android Things with HDMI output audio.
* A reminder TTS message doesn't play if the sample app restarts and loses a network connection. Instead, the default alarm tone plays twice.
* `ServerDisconnectIntegratonTest` tests are disabled until they are updated to reflect new service behavior.
* Bluetooth initialization must complete before connecting devices, otherwise devices are ignored.
* The `DirectiveSequencerTest.test_handleBlockingThenImmediatelyThenNonBockingOnSameDialogId` test fails intermittently.
* On some devices, Alexa gets stuck in a permanent listening state. Pressing `t` and `h` in the Sample App doesn't exit the listening state.
* Exiting the `settings` menu doesn't provide a message to indicate that you are back in the main menu.
2019-10-25 20:19:44 +00:00
|
|
|
}
|
2017-05-18 05:02:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
std::ostringstream uuidText;
|
2017-10-02 22:59:05 +00:00
|
|
|
uuidText << generateHex(ibe, 8) << SEPARATOR << generateHex(ibe, 4) << SEPARATOR
|
|
|
|
<< generateHexWithReplacement(ibe, 4, UUID_VERSION_VALUE, 4) << SEPARATOR
|
|
|
|
<< generateHexWithReplacement(ibe, 4, UUID_VARIANT_VALUE, 2) << SEPARATOR << generateHex(ibe, 12);
|
2017-07-18 22:25:37 +00:00
|
|
|
|
|
|
|
lock.unlock();
|
|
|
|
|
2017-05-18 05:02:48 +00:00
|
|
|
return uuidText.str();
|
|
|
|
}
|
|
|
|
|
2017-10-02 22:59:05 +00:00
|
|
|
} // namespace uuidGeneration
|
|
|
|
} // namespace utils
|
|
|
|
} // namespace avsCommon
|
|
|
|
} // namespace alexaClientSDK
|