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

Unified Diff: media/audio/win/audio_low_latency_output_win.h

Issue 10575017: Adding experimental exclusive-mode streaming to WASAPIAudioOutputStream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Minor changes proposed by Andrew Created 8 years, 5 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 | « media/audio/audio_util.cc ('k') | media/audio/win/audio_low_latency_output_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/win/audio_low_latency_output_win.h
diff --git a/media/audio/win/audio_low_latency_output_win.h b/media/audio/win/audio_low_latency_output_win.h
index 67a5d6c5f0a2c496c6e8828815110ac06f3ad202..2c217ccf976b1e3023ad71fd68f53e3abfd57ce1 100644
--- a/media/audio/win/audio_low_latency_output_win.h
+++ b/media/audio/win/audio_low_latency_output_win.h
@@ -112,6 +112,27 @@
// - All callback methods from the IMMNotificationClient interface will be
// called on a Windows-internal MMDevice thread.
//
+// Experimental exclusive mode:
+//
+// - It is possible to open up a stream in exclusive mode by using the
+// --enable-exclusive-mode command line flag.
+// - The internal buffering scheme is less flexible for exclusive streams.
+// Hence, some manual tuning will be required before deciding what frame
+// size to use. See the WinAudioOutputTest unit test for more details.
+// - If an application opens a stream in exclusive mode, the application has
+// exclusive use of the audio endpoint device that plays the stream.
+// - Exclusive-mode should only be utilized when the lowest possible latency
+// is important.
+// - In exclusive mode, the client can choose to open the stream in any audio
+// format that the endpoint device supports, i.e. not limited to the device's
+// current (default) configuration.
+// - Initial measurements on Windows 7 (HP Z600 workstation) have shown that
+// the lowest possible latencies we can achieve on this machine are:
+// o ~3.3333ms @ 48kHz <=> 160 audio frames per buffer.
+// o ~3.6281ms @ 44.1kHz <=> 160 audio frames per buffer.
+// - See http://msdn.microsoft.com/en-us/library/windows/desktop/dd370844(v=vs.85).aspx
+// for more details.
+
#ifndef MEDIA_AUDIO_WIN_AUDIO_LOW_LATENCY_OUTPUT_WIN_H_
#define MEDIA_AUDIO_WIN_AUDIO_LOW_LATENCY_OUTPUT_WIN_H_
@@ -163,8 +184,13 @@ class MEDIA_EXPORT WASAPIAudioOutputStream
// Retrieves the stream format that the audio engine uses for its internal
// processing/mixing of shared-mode streams.
+ // This method should not be used in combination with exclusive-mode streams.
static int HardwareSampleRate(ERole device_role);
+ // Returns AUDCLNT_SHAREMODE_EXCLUSIVE if --enable-exclusive-mode is used
+ // as command-line flag and AUDCLNT_SHAREMODE_SHARED otherwise (default).
+ static AUDCLNT_SHAREMODE GetShareMode();
+
bool started() const { return started_; }
private:
@@ -206,12 +232,19 @@ class MEDIA_EXPORT WASAPIAudioOutputStream
void HandleError(HRESULT err);
// The Open() method is divided into these sub methods.
- HRESULT SetRenderDevice(ERole device_role);
+ HRESULT SetRenderDevice();
HRESULT ActivateRenderDevice();
- HRESULT GetAudioEngineStreamFormat();
bool DesiredFormatIsSupported();
HRESULT InitializeAudioEngine();
+ // Called when the device will be opened in shared mode and use the
+ // internal audio engine's mix format.
+ HRESULT SharedModeInitialization();
+
+ // Called when the device will be opened in exclusive mode and use the
+ // application specified format.
+ HRESULT ExclusiveModeInitialization();
+
// Converts unique endpoint ID to user-friendly device name.
std::string GetDeviceName(LPCWSTR device_id) const;
@@ -222,6 +255,8 @@ class MEDIA_EXPORT WASAPIAudioOutputStream
// new default audio device.
bool RestartRenderingUsingNewDefaultDevice();
+ AUDCLNT_SHAREMODE share_mode() const { return share_mode_; }
+
// Initializes the COM library for use by the calling thread and sets the
// thread's concurrency model to multi-threaded.
base::win::ScopedCOMInitializer com_init_;
@@ -276,6 +311,11 @@ class MEDIA_EXPORT WASAPIAudioOutputStream
// Defines the role that the system has assigned to an audio endpoint device.
ERole device_role_;
+ // The sharing mode for the connection.
+ // Valid values are AUDCLNT_SHAREMODE_SHARED and AUDCLNT_SHAREMODE_EXCLUSIVE
+ // where AUDCLNT_SHAREMODE_SHARED is the default.
+ AUDCLNT_SHAREMODE share_mode_;
+
// Counts the number of audio frames written to the endpoint buffer.
UINT64 num_written_frames_;
« no previous file with comments | « media/audio/audio_util.cc ('k') | media/audio/win/audio_low_latency_output_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698