Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Unified Diff: media/audio/android/opensles_output.h

Issue 2793123003: Enable float audio output on L+ Android devices. (Closed)
Patch Set: Use __ANDROID_API__. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | media/audio/android/opensles_output.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/android/opensles_output.h
diff --git a/media/audio/android/opensles_output.h b/media/audio/android/opensles_output.h
index 671dbdec4a337c0a28856a08955b2f3b7daefae5..80d8929769a68f7cd46ed1afeef117ff5838346d 100644
--- a/media/audio/android/opensles_output.h
+++ b/media/audio/android/opensles_output.h
@@ -21,6 +21,25 @@
#include "media/base/audio_parameters.h"
#include "media/base/audio_timestamp_helper.h"
+// On L+, we want to use floating point output for better fidelity.
+#if __ANDROID_API__ < 21
+#define SL_ANDROID_PCM_REPRESENTATION_SIGNED_INT ((SLuint32)0x00000001)
+#define SL_ANDROID_PCM_REPRESENTATION_UNSIGNED_INT ((SLuint32)0x00000002)
+#define SL_ANDROID_PCM_REPRESENTATION_FLOAT ((SLuint32)0x00000003)
+#define SL_ANDROID_DATAFORMAT_PCM_EX ((SLuint32)0x00000004)
+
+typedef struct SLAndroidDataFormat_PCM_EX_ {
+ SLuint32 formatType;
+ SLuint32 numChannels;
+ SLuint32 sampleRate;
+ SLuint32 bitsPerSample;
+ SLuint32 containerSize;
+ SLuint32 channelMask;
+ SLuint32 endianness;
+ SLuint32 representation;
+} SLAndroidDataFormat_PCM_EX;
+#endif
+
namespace media {
class AudioManagerAndroid;
@@ -101,14 +120,13 @@ class OpenSLESOutputStream : public AudioOutputStream {
SLAndroidSimpleBufferQueueItf simple_buffer_queue_;
SLDataFormat_PCM format_;
+ SLAndroidDataFormat_PCM_EX float_format_;
// Audio buffers that are allocated during Open() based on parameters given
// during construction.
uint8_t* audio_data_[kMaxNumOfBuffersInQueue];
int active_buffer_index_;
- int bytes_per_frame_;
- size_t buffer_size_bytes_;
bool started_;
@@ -123,6 +141,12 @@ class OpenSLESOutputStream : public AudioOutputStream {
int samples_per_second_;
+ // On Android 5.0+ we can output directly to float instead of in integer.
+ bool have_float_output_;
+
+ int bytes_per_frame_;
+ size_t buffer_size_bytes_;
+
// Used to calculate the delay value for each OnMoreData() call.
AudioTimestampHelper delay_calculator_;
« no previous file with comments | « no previous file | media/audio/android/opensles_output.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698