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

Side by Side Diff: media/audio/win/waveout_output_win.cc

Issue 11316284: Boost WaveOut thread priority for background audio. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Typo. Created 8 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/audio/win/waveout_output_win.h" 5 #include "media/audio/win/waveout_output_win.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <mmsystem.h> 8 #include <mmsystem.h>
9 #pragma comment(lib, "winmm.lib") 9 #pragma comment(lib, "winmm.lib")
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/debug/trace_event.h" 12 #include "base/debug/trace_event.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/message_loop_proxy.h"
15 #include "base/threading/platform_thread.h"
14 #include "media/audio/audio_io.h" 16 #include "media/audio/audio_io.h"
15 #include "media/audio/audio_util.h" 17 #include "media/audio/audio_util.h"
16 #include "media/audio/win/audio_manager_win.h" 18 #include "media/audio/win/audio_manager_win.h"
17 19
18 namespace media { 20 namespace media {
19 21
20 // Some general thoughts about the waveOut API which is badly documented : 22 // Some general thoughts about the waveOut API which is badly documented :
21 // - We use CALLBACK_EVENT mode in which XP signals events such as buffer 23 // - We use CALLBACK_EVENT mode in which XP signals events such as buffer
22 // releases. 24 // releases.
23 // - We use RegisterWaitForSingleObject() so one of threads in thread pool 25 // - We use RegisterWaitForSingleObject() so one of threads in thread pool
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 format_.Format.wBitsPerSample) / 8; 103 format_.Format.wBitsPerSample) / 8;
102 format_.Format.nAvgBytesPerSec = format_.Format.nBlockAlign * 104 format_.Format.nAvgBytesPerSec = format_.Format.nBlockAlign *
103 format_.Format.nSamplesPerSec; 105 format_.Format.nSamplesPerSec;
104 if (params.channels() > kMaxChannelsToMask) { 106 if (params.channels() > kMaxChannelsToMask) {
105 format_.dwChannelMask = kChannelsToMask[kMaxChannelsToMask]; 107 format_.dwChannelMask = kChannelsToMask[kMaxChannelsToMask];
106 } else { 108 } else {
107 format_.dwChannelMask = kChannelsToMask[params.channels()]; 109 format_.dwChannelMask = kChannelsToMask[params.channels()];
108 } 110 }
109 format_.SubFormat = KSDATAFORMAT_SUBTYPE_PCM; 111 format_.SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
110 format_.Samples.wValidBitsPerSample = params.bits_per_sample(); 112 format_.Samples.wValidBitsPerSample = params.bits_per_sample();
113
114 // Boost thread priority. Required for glitch free background audio.
scherkus (not reviewing) 2012/11/30 22:13:34 which thread is this? the OS callback thread or a
henrika (OOO until Aug 14) 2012/12/03 08:35:43 Same question as Andrew.
DaleCurtis 2012/12/03 18:11:06 Henrik, please see the old messages for full discu
115 DCHECK(manager_->GetMessageLoop()->BelongsToCurrentThread());
116 base::PlatformThread::SetThreadPriority(
117 GetCurrentThread(), base::kThreadPriority_RealtimeAudio);
111 } 118 }
112 119
113 PCMWaveOutAudioOutputStream::~PCMWaveOutAudioOutputStream() { 120 PCMWaveOutAudioOutputStream::~PCMWaveOutAudioOutputStream() {
114 DCHECK(NULL == waveout_); 121 DCHECK(NULL == waveout_);
115 } 122 }
116 123
117 bool PCMWaveOutAudioOutputStream::Open() { 124 bool PCMWaveOutAudioOutputStream::Open() {
118 if (state_ != PCMA_BRAND_NEW) 125 if (state_ != PCMA_BRAND_NEW)
119 return false; 126 return false;
120 if (BufferSize() * num_buffers_ > kMaxOpenBufferSize) 127 if (BufferSize() * num_buffers_ > kMaxOpenBufferSize)
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 buffer, 420 buffer,
414 sizeof(WAVEHDR)); 421 sizeof(WAVEHDR));
415 if (result != MMSYSERR_NOERROR) 422 if (result != MMSYSERR_NOERROR)
416 stream->HandleError(result); 423 stream->HandleError(result);
417 stream->pending_bytes_ += buffer->dwBufferLength; 424 stream->pending_bytes_ += buffer->dwBufferLength;
418 } 425 }
419 } 426 }
420 } 427 }
421 428
422 } // namespace media 429 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698