2013-09-10 18:24:07 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef MODULES_AUDIO_DEVICE_ANDROID_OPENSLES_COMMON_H_
|
|
|
|
|
#define MODULES_AUDIO_DEVICE_ANDROID_OPENSLES_COMMON_H_
|
2013-09-10 18:24:07 +00:00
|
|
|
|
|
|
|
|
#include <SLES/OpenSLES.h>
|
2016-09-19 15:44:09 +02:00
|
|
|
#include <stddef.h>
|
2013-09-10 18:24:07 +00:00
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "rtc_base/checks.h"
|
2017-07-06 19:44:34 +02:00
|
|
|
|
Adding support for OpenSL ES output in native WebRTC
BUG=4573,2982,2175,3590
TEST=modules_unittests --gtest_filter=AudioDevice*, AppRTCDemo and WebRTCDemo
Summary:
- Removes dependency of the 'enable_android_opensl' compiler flag.
Instead, OpenSL ES is always supported, and will enabled for devices that
supports low-latency output.
- WebRTC no longer supports OpenSL ES for the input/recording side.
- Removes old code and demos using OpenSL ES for audio input.
- Improves accuracy of total delay estimates (better AEC performance).
- Reduces roundtrip audio latency; especially when OpenSL can be used.
Performance verified on: Nexus 5, 6, 7 and 9. Samsung Galaxy S4 and S6.
Android One device.
R=magjed@webrtc.org, phoglund@webrtc.org, tommi@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/51759004
Cr-Commit-Position: refs/heads/master@{#9208}
2015-05-18 16:49:16 +02:00
|
|
|
namespace webrtc {
|
2013-09-10 18:24:07 +00:00
|
|
|
|
2016-05-31 07:03:17 -07:00
|
|
|
// Returns a string representation given an integer SL_RESULT_XXX code.
|
|
|
|
|
// The mapping can be found in <SLES/OpenSLES.h>.
|
|
|
|
|
const char* GetSLErrorString(size_t code);
|
|
|
|
|
|
2016-09-19 15:44:09 +02:00
|
|
|
// Configures an SL_DATAFORMAT_PCM structure based on native audio parameters.
|
|
|
|
|
SLDataFormat_PCM CreatePCMConfiguration(size_t channels,
|
|
|
|
|
int sample_rate,
|
|
|
|
|
size_t bits_per_sample);
|
2013-09-10 18:24:07 +00:00
|
|
|
|
Adding support for OpenSL ES output in native WebRTC
BUG=4573,2982,2175,3590
TEST=modules_unittests --gtest_filter=AudioDevice*, AppRTCDemo and WebRTCDemo
Summary:
- Removes dependency of the 'enable_android_opensl' compiler flag.
Instead, OpenSL ES is always supported, and will enabled for devices that
supports low-latency output.
- WebRTC no longer supports OpenSL ES for the input/recording side.
- Removes old code and demos using OpenSL ES for audio input.
- Improves accuracy of total delay estimates (better AEC performance).
- Reduces roundtrip audio latency; especially when OpenSL can be used.
Performance verified on: Nexus 5, 6, 7 and 9. Samsung Galaxy S4 and S6.
Android One device.
R=magjed@webrtc.org, phoglund@webrtc.org, tommi@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/51759004
Cr-Commit-Position: refs/heads/master@{#9208}
2015-05-18 16:49:16 +02:00
|
|
|
// Helper class for using SLObjectItf interfaces.
|
|
|
|
|
template <typename SLType, typename SLDerefType>
|
|
|
|
|
class ScopedSLObject {
|
|
|
|
|
public:
|
|
|
|
|
ScopedSLObject() : obj_(nullptr) {}
|
|
|
|
|
|
|
|
|
|
~ScopedSLObject() { Reset(); }
|
|
|
|
|
|
|
|
|
|
SLType* Receive() {
|
2015-09-17 00:24:34 -07:00
|
|
|
RTC_DCHECK(!obj_);
|
Adding support for OpenSL ES output in native WebRTC
BUG=4573,2982,2175,3590
TEST=modules_unittests --gtest_filter=AudioDevice*, AppRTCDemo and WebRTCDemo
Summary:
- Removes dependency of the 'enable_android_opensl' compiler flag.
Instead, OpenSL ES is always supported, and will enabled for devices that
supports low-latency output.
- WebRTC no longer supports OpenSL ES for the input/recording side.
- Removes old code and demos using OpenSL ES for audio input.
- Improves accuracy of total delay estimates (better AEC performance).
- Reduces roundtrip audio latency; especially when OpenSL can be used.
Performance verified on: Nexus 5, 6, 7 and 9. Samsung Galaxy S4 and S6.
Android One device.
R=magjed@webrtc.org, phoglund@webrtc.org, tommi@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/51759004
Cr-Commit-Position: refs/heads/master@{#9208}
2015-05-18 16:49:16 +02:00
|
|
|
return &obj_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SLDerefType operator->() { return *obj_; }
|
|
|
|
|
|
|
|
|
|
SLType Get() const { return obj_; }
|
|
|
|
|
|
|
|
|
|
void Reset() {
|
|
|
|
|
if (obj_) {
|
|
|
|
|
(*obj_)->Destroy(obj_);
|
|
|
|
|
obj_ = nullptr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
SLType obj_;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
typedef ScopedSLObject<SLObjectItf, const SLObjectItf_*> ScopedSLObjectItf;
|
|
|
|
|
|
2016-09-19 15:44:09 +02:00
|
|
|
} // namespace webrtc
|
2013-09-10 18:24:07 +00:00
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // MODULES_AUDIO_DEVICE_ANDROID_OPENSLES_COMMON_H_
|