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

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

Issue 10823100: Adds support for multi-channel output audio for the low-latency path in Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
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 2c217ccf976b1e3023ad71fd68f53e3abfd57ce1..73251003e7a7239e31d1dd1da256852c47f06702 100644
--- a/media/audio/win/audio_low_latency_output_win.h
+++ b/media/audio/win/audio_low_latency_output_win.h
@@ -182,9 +182,19 @@ class MEDIA_EXPORT WASAPIAudioOutputStream
virtual void SetVolume(double volume) OVERRIDE;
virtual void GetVolume(double* volume) OVERRIDE;
- // 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.
+ // Retrieves the number of channels the audio engine uses for its internal
+ // processing/mixing of shared-mode streams for the default endpoint device.
+ static int HardwareChannelCount();
+
+ // Retrieves the channel layout the audio engine uses for its internal
+ // processing/mixing of shared-mode streams for the default endpoint device.
+ // Note that we convert an internal channel layout mask (see ChannelMask())
+ // into a Chrome-specific channel layout enumerator in this method, hence
+ // the match might not be perfect.
+ static ChannelLayout HardwareChannelLayout();
+
+ // Retrieves the sample rate the audio engine uses for its internal
+ // processing/mixing of shared-mode streams for the default endpoint device.
static int HardwareSampleRate(ERole device_role);
// Returns AUDCLNT_SHAREMODE_EXCLUSIVE if --enable-exclusive-mode is used
@@ -237,6 +247,10 @@ class MEDIA_EXPORT WASAPIAudioOutputStream
bool DesiredFormatIsSupported();
HRESULT InitializeAudioEngine();
+ // Retrieves the stream format that the audio engine uses for its internal
+ // processing/mixing of shared-mode streams.
+ static HRESULT GetMixFormat(ERole device_role, WAVEFORMATEX** device_format);
scherkus (not reviewing) 2012/08/01 00:14:05 any reason static private methods need to be here?
henrika (OOO until Aug 14) 2012/08/01 16:11:09 Great input, thanks. I actually did use private me
scherkus (not reviewing) 2012/08/02 00:41:57 Above the function.
+
// Called when the device will be opened in shared mode and use the
// internal audio engine's mix format.
HRESULT SharedModeInitialization();
@@ -255,7 +269,32 @@ class MEDIA_EXPORT WASAPIAudioOutputStream
// new default audio device.
bool RestartRenderingUsingNewDefaultDevice();
+ // Retrieves an integer mask which corresponds to the channel layout the
+ // audio engine uses for its internal processing/mixing of shared-mode
+ // streams. This mask indicates which channels are present in the multi-
+ // channel stream. The least significant bit corresponds with the Front Left
+ // speaker, the next least significant bit corresponds to the Front Right
+ // speaker, and so on, continuing in the order defined in KsMedia.h.
+ // See http://msdn.microsoft.com/en-us/library/windows/hardware/ff537083(v=vs.85).aspx
+ // for more details.
+ static uint32 ChannelConfig();
tommi (sloooow) - chröme 2012/07/31 21:39:30 Maybe we could define our own type for channel con
henrika (OOO until Aug 14) 2012/08/01 16:11:09 Added typedef ChannelConfigMask in media. Got conf
+
+ // Converts Microsoft's channel configuration to Chrome's ChannelLayout.
+ // This mapping is not perfect but the best we can do given the current
+ // ChannelLayout enumerator and the Windows-specific speaker configurations
+ // defined in ksmedia.h. Don't assume that the channel ordering in
+ // ChannelLayout is exactly the same as the Windows specific configuration.
+ // As an example: KSAUDIO_SPEAKER_7POINT1_SURROUND is mapped to
+ // CHANNEL_LAYOUT_7_1 but the positions of Back L, Back R and Side L, Side R
+ // speakers are different in these two definitions.
+ static ChannelLayout ChannelConfigToChromeChannelLayout(uint32 layout);
+
AUDCLNT_SHAREMODE share_mode() const { return share_mode_; }
+ int endpoint_channel_count() const { return endpoint_channel_count_; }
scherkus (not reviewing) 2012/08/01 00:14:05 huh? these are all private methods -- why the acce
henrika (OOO until Aug 14) 2012/08/01 16:11:09 Got it. Will clean up.
+ uint32 endpoint_channel_config() const { return endpoint_channel_config_; }
+ int client_channel_count() const {
+ return client_audio_parameters_.channels();
+ }
// Initializes the COM library for use by the calling thread and sets the
// thread's concurrency model to multi-threaded.
@@ -267,17 +306,21 @@ class MEDIA_EXPORT WASAPIAudioOutputStream
// Our creator, the audio manager needs to be notified when we close.
AudioManagerWin* manager_;
+ AudioParameters client_audio_parameters_;
tommi (sloooow) - chröme 2012/07/31 21:39:30 are there any other audio parameters that this cla
henrika (OOO until Aug 14) 2012/08/01 16:11:09 I store this one to keep track of the parameters s
+
// Rendering is driven by this thread (which has no message loop).
// All OnMoreData() callbacks will be called from this thread.
base::DelegateSimpleThread* render_thread_;
// Contains the desired audio format which is set up at construction.
- WAVEFORMATEX format_;
+ // Extended PCM waveform format structure based on WAVEFORMATEXTENSIBLE.
+ // Use this for multiple channel and hi-resolution PCM data.
+ WAVEFORMATPCMEX format_;
// Copy of the audio format which we know the audio engine supports.
// It is recommended to ensure that the sample rate in |format_| is identical
// to the sample rate in |audio_engine_mix_format_|.
- base::win::ScopedCoMem<WAVEFORMATEX> audio_engine_mix_format_;
+ base::win::ScopedCoMem<WAVEFORMATPCMEX> audio_engine_mix_format_;
bool opened_;
bool started_;
@@ -316,6 +359,18 @@ class MEDIA_EXPORT WASAPIAudioOutputStream
// where AUDCLNT_SHAREMODE_SHARED is the default.
AUDCLNT_SHAREMODE share_mode_;
+ // Contains the number of channels the audio engine uses for its internal
+ // processing/mixing of shared-mode streams for the default endpoint device.
+ const int endpoint_channel_count_;
+
+ // Contains the channel configuration the audio engine uses for its internal
+ // processing/mixing of shared-mode streams for the default endpoint
+ // device.
+ const uint32 endpoint_channel_config_;
+
+ // TODO(henrika): add comments....
+ int channel_factor_;
+
// Counts the number of audio frames written to the endpoint buffer.
UINT64 num_written_frames_;

Powered by Google App Engine
This is Rietveld 408576698