AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
PortAudioMicrophoneWrapper.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 
16 #ifndef ALEXA_CLIENT_SDK_LIBIPCSERVERSAMPLEAPP_INCLUDE_IPCSERVERSAMPLEAPP_PORTAUDIOMICROPHONEWRAPPER_H_
17 #define ALEXA_CLIENT_SDK_LIBIPCSERVERSAMPLEAPP_INCLUDE_IPCSERVERSAMPLEAPP_PORTAUDIOMICROPHONEWRAPPER_H_
18 
19 #include <mutex>
20 #include <thread>
21 
23 
24 #include <portaudio.h>
26 
27 namespace alexaClientSDK {
28 namespace sampleApplications {
29 namespace ipcServerSampleApp {
30 
33 public:
40  static std::unique_ptr<PortAudioMicrophoneWrapper> create(std::shared_ptr<avsCommon::avs::AudioInputStream> stream);
41 
47  bool stopStreamingMicrophoneData() override;
48 
54  bool startStreamingMicrophoneData() override;
55 
61  bool isStreaming() override;
62 
67 
68 private:
74  PortAudioMicrophoneWrapper(std::shared_ptr<avsCommon::avs::AudioInputStream> stream);
75 
87  static int PortAudioCallback(
88  const void* inputBuffer,
89  void* outputBuffer,
90  unsigned long numSamples,
91  const PaStreamCallbackTimeInfo* timeInfo,
92  PaStreamCallbackFlags statusFlags,
93  void* userData);
94 
96  bool initialize();
97 
105  bool getConfigSuggestedLatency(PaTime& suggestedLatency);
106 
108  const std::shared_ptr<avsCommon::avs::AudioInputStream> m_audioInputStream;
109 
111  std::shared_ptr<avsCommon::avs::AudioInputStream::Writer> m_writer;
112 
114  PaStream* m_paStream;
115 
120  std::mutex m_mutex;
121 
125  bool m_isStreaming;
126 };
127 
128 } // namespace ipcServerSampleApp
129 } // namespace sampleApplications
130 } // namespace alexaClientSDK
131 
132 #endif // ALEXA_CLIENT_SDK_LIBIPCSERVERSAMPLEAPP_INCLUDE_IPCSERVERSAMPLEAPP_PORTAUDIOMICROPHONEWRAPPER_H_
static std::unique_ptr< PortAudioMicrophoneWrapper > create(std::shared_ptr< avsCommon::avs::AudioInputStream > stream)
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
This acts as a wrapper around PortAudio, a cross-platform open-source audio I/O library.
Definition: PortAudioMicrophoneWrapper.h:32
This acts as an interface to record audio input from a microphone.
Definition: MicrophoneInterface.h:28

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