AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
AndroidSLESBufferQueue.h
Go to the documentation of this file.
1 /*
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  * http://aws.amazon.com/apache2.0/
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 #ifndef ALEXA_CLIENT_SDK_APPLICATIONUTILITIES_ANDROIDUTILITIES_INCLUDE_ANDROIDUTILITIES_ANDROIDSLESBUFFERQUEUE_H_
16 #define ALEXA_CLIENT_SDK_APPLICATIONUTILITIES_ANDROIDUTILITIES_INCLUDE_ANDROIDUTILITIES_ANDROIDSLESBUFFERQUEUE_H_
17 
18 #include <array>
19 #include <vector>
20 
21 #include <SLES/OpenSLES_Android.h>
22 
25 
26 namespace alexaClientSDK {
27 namespace applicationUtilities {
28 namespace androidUtilities {
29 
42 public:
50  static std::unique_ptr<AndroidSLESBufferQueue> create(
51  std::shared_ptr<AndroidSLESObject> queueObject,
52  std::shared_ptr<avsCommon::avs::AudioInputStream::Writer> writer);
53 
58  void onBufferCompleted();
59 
65  bool enqueueBuffers();
66 
72  bool clearBuffers();
73 
78 
80  static constexpr uint32_t NUMBER_OF_BUFFERS{2u};
81 
82 private:
91  std::shared_ptr<AndroidSLESObject> slObject,
92  SLAndroidSimpleBufferQueueItf bufferQueue,
93  std::shared_ptr<avsCommon::avs::AudioInputStream::Writer> writer);
94 
96  bool enqueueBufferLocked();
97 
99  static constexpr size_t BUFFER_SIZE{8192u};
100 
102  std::mutex m_mutex;
103 
106  std::shared_ptr<AndroidSLESObject> m_slObject;
107 
109  SLAndroidSimpleBufferQueueItf m_queueInterface;
110 
113  std::array<std::array<int16_t, BUFFER_SIZE>, NUMBER_OF_BUFFERS> m_buffers;
114 
116  std::shared_ptr<avsCommon::avs::AudioInputStream::Writer> m_writer;
117 
119  std::size_t m_index;
120 };
121 
122 } // namespace androidUtilities
123 } // namespace applicationUtilities
124 } // namespace alexaClientSDK
125 
126 #endif // ALEXA_CLIENT_SDK_APPLICATIONUTILITIES_ANDROIDUTILITIES_INCLUDE_ANDROIDUTILITIES_ANDROIDSLESBUFFERQUEUE_H_
static constexpr uint32_t NUMBER_OF_BUFFERS
The number of buffers to use.
Definition: AndroidSLESBufferQueue.h:80
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
static std::unique_ptr< AndroidSLESBufferQueue > create(std::shared_ptr< AndroidSLESObject > queueObject, std::shared_ptr< avsCommon::avs::AudioInputStream::Writer > writer)

AlexaClientSDK 3.0.0 - Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0