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

Unified Diff: media/audio/audio_input_controller.h

Issue 287873004: Adds volume level measurements to the AudioInputController for low-latency clients (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: improved thread handling Created 6 years, 7 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 | « content/browser/speech/speech_recognizer_impl.h ('k') | media/audio/audio_input_controller.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/audio_input_controller.h
diff --git a/media/audio/audio_input_controller.h b/media/audio/audio_input_controller.h
index 3facfb511d18670a4a6d2ce0e0f19071099fe0e8..35ec1b77fc72f8f527093e7345da2af5d4f40499 100644
--- a/media/audio/audio_input_controller.h
+++ b/media/audio/audio_input_controller.h
@@ -16,6 +16,9 @@
#include "base/timer/timer.h"
#include "media/audio/audio_io.h"
#include "media/audio/audio_manager_base.h"
+#include "media/audio/audio_parameters.h"
+#include "media/audio/audio_power_monitor.h"
+#include "media/base/audio_bus.h"
// An AudioInputController controls an AudioInputStream and records data
// from this input stream. The two main methods are Record() and Close() and
@@ -72,6 +75,11 @@
//
namespace media {
+// Only do power monitoring for non-mobile platforms to save resources.
+#if !defined(OS_ANDROID) && !defined(OS_IOS)
+#define AUDIO_POWER_MONITORING
+#endif
+
class UserInputMonitor;
class MEDIA_EXPORT AudioInputController
@@ -111,6 +119,8 @@ class MEDIA_EXPORT AudioInputController
ErrorCode error_code) = 0;
virtual void OnData(AudioInputController* controller, const uint8* data,
uint32 size) = 0;
+ virtual void OnLog(AudioInputController* controller,
+ const std::string& message) = 0;
protected:
virtual ~EventHandler() {}
@@ -252,6 +262,7 @@ class MEDIA_EXPORT AudioInputController
void DoSetVolume(double volume);
void DoSetAutomaticGainControl(bool enabled);
void DoOnData(scoped_ptr<uint8[]> data, uint32 size);
+ void DoLogAudioLevel(float level_dbfs);
// Method to check if we get recorded data after a stream was started,
// and log the result to UMA.
@@ -309,6 +320,16 @@ class MEDIA_EXPORT AudioInputController
UserInputMonitor* user_input_monitor_;
+#if defined(AUDIO_POWER_MONITORING)
+ // Scans audio samples from OnData() as input to compute audio levels.
+ scoped_ptr<AudioPowerMonitor> audio_level_;
+
+ // We need these to be able to feed data to the AudioPowerMonitor.
+ scoped_ptr<AudioBus> audio_bus_;
+ media::AudioParameters audio_params_;
+ base::TimeTicks last_audio_level_log_time_;
+#endif
+
size_t prev_key_down_count_;
DISALLOW_COPY_AND_ASSIGN(AudioInputController);
« no previous file with comments | « content/browser/speech/speech_recognizer_impl.h ('k') | media/audio/audio_input_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698