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

Unified Diff: media/audio/win/waveout_output_win.cc

Issue 155894: Surround Sound handling by folding 5 channels down to stereo. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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/win/waveout_output_win.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/win/waveout_output_win.cc
===================================================================
--- media/audio/win/waveout_output_win.cc (revision 21354)
+++ media/audio/win/waveout_output_win.cc (working copy)
@@ -29,6 +29,9 @@
// to make sure we are not executing inside the audio source's OnMoreData()
// or that we take locks inside WaveCallback() or QueueNextPacket().
+// Enable or disable software folding
+#define FOLDING 1
+
namespace {
// We settled for a double buffering scheme. It seems to strike a good balance
@@ -56,9 +59,14 @@
callback_(NULL),
buffer_(NULL),
buffer_size_(0),
- volume_(1) {
+ volume_(1),
+ channels_(channels) {
format_.wFormatTag = WAVE_FORMAT_PCM;
+#ifdef FOLDING
+ format_.nChannels = channels > 2 ? 2 : channels;
+#else
format_.nChannels = channels;
+#endif
format_.nSamplesPerSec = sampling_rate;
format_.wBitsPerSample = bits_per_sample;
format_.cbSize = 0;
@@ -226,10 +234,17 @@
// TODO(fbarchard): Handle used 0 by queueing more.
size_t used = callback_->OnMoreData(this, buffer->lpData, buffer_size_);
if (used <= buffer_size_) {
- buffer->dwBufferLength = used;
- media::AdjustVolume(buffer->lpData, buffer->dwBufferLength,
- format_.nChannels, format_.wBitsPerSample >> 3,
- volume_);
+ buffer->dwBufferLength = used * format_.nChannels / channels_;
+ if (channels_ > 2 && format_.nChannels == 2) {
+ media::FoldChannels(buffer->lpData, used,
+ channels_, format_.wBitsPerSample >> 3,
+ volume_);
+ } else {
+ media::AdjustVolume(buffer->lpData, used,
+ format_.nChannels, format_.wBitsPerSample >> 3,
+ volume_);
+ }
+
} else {
HandleError(0);
return;
« no previous file with comments | « media/audio/win/waveout_output_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698