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

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

Issue 9655018: Make AudioParameters a class instead of a struct (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix copyright years Created 8 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/audio/win/wavein_input_win.cc ('k') | media/base/audio_renderer_sink.h » ('j') | 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
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 77
78 PCMWaveOutAudioOutputStream::PCMWaveOutAudioOutputStream( 78 PCMWaveOutAudioOutputStream::PCMWaveOutAudioOutputStream(
79 AudioManagerWin* manager, const AudioParameters& params, int num_buffers, 79 AudioManagerWin* manager, const AudioParameters& params, int num_buffers,
80 UINT device_id) 80 UINT device_id)
81 : state_(PCMA_BRAND_NEW), 81 : state_(PCMA_BRAND_NEW),
82 manager_(manager), 82 manager_(manager),
83 device_id_(device_id), 83 device_id_(device_id),
84 waveout_(NULL), 84 waveout_(NULL),
85 callback_(NULL), 85 callback_(NULL),
86 num_buffers_(num_buffers), 86 num_buffers_(num_buffers),
87 buffer_size_(params.GetPacketSize()), 87 buffer_size_(params.GetBytesPerBuffer()),
88 volume_(1), 88 volume_(1),
89 channels_(params.channels), 89 channels_(params.channels()),
90 pending_bytes_(0) { 90 pending_bytes_(0) {
91 format_.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE; 91 format_.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
92 format_.Format.nChannels = params.channels; 92 format_.Format.nChannels = params.channels();
93 format_.Format.nSamplesPerSec = params.sample_rate; 93 format_.Format.nSamplesPerSec = params.sample_rate();
94 format_.Format.wBitsPerSample = params.bits_per_sample; 94 format_.Format.wBitsPerSample = params.bits_per_sample();
95 format_.Format.cbSize = sizeof(format_) - sizeof(WAVEFORMATEX); 95 format_.Format.cbSize = sizeof(format_) - sizeof(WAVEFORMATEX);
96 // The next are computed from above. 96 // The next are computed from above.
97 format_.Format.nBlockAlign = (format_.Format.nChannels * 97 format_.Format.nBlockAlign = (format_.Format.nChannels *
98 format_.Format.wBitsPerSample) / 8; 98 format_.Format.wBitsPerSample) / 8;
99 format_.Format.nAvgBytesPerSec = format_.Format.nBlockAlign * 99 format_.Format.nAvgBytesPerSec = format_.Format.nBlockAlign *
100 format_.Format.nSamplesPerSec; 100 format_.Format.nSamplesPerSec;
101 if (params.channels > kMaxChannelsToMask) { 101 if (params.channels() > kMaxChannelsToMask) {
102 format_.dwChannelMask = kChannelsToMask[kMaxChannelsToMask]; 102 format_.dwChannelMask = kChannelsToMask[kMaxChannelsToMask];
103 } else { 103 } else {
104 format_.dwChannelMask = kChannelsToMask[params.channels]; 104 format_.dwChannelMask = kChannelsToMask[params.channels()];
105 } 105 }
106 format_.SubFormat = KSDATAFORMAT_SUBTYPE_PCM; 106 format_.SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
107 format_.Samples.wValidBitsPerSample = params.bits_per_sample; 107 format_.Samples.wValidBitsPerSample = params.bits_per_sample();
108 } 108 }
109 109
110 PCMWaveOutAudioOutputStream::~PCMWaveOutAudioOutputStream() { 110 PCMWaveOutAudioOutputStream::~PCMWaveOutAudioOutputStream() {
111 DCHECK(NULL == waveout_); 111 DCHECK(NULL == waveout_);
112 } 112 }
113 113
114 bool PCMWaveOutAudioOutputStream::Open() { 114 bool PCMWaveOutAudioOutputStream::Open() {
115 if (state_ != PCMA_BRAND_NEW) 115 if (state_ != PCMA_BRAND_NEW)
116 return false; 116 return false;
117 if (BufferSize() * num_buffers_ > kMaxOpenBufferSize) 117 if (BufferSize() * num_buffers_ > kMaxOpenBufferSize)
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 // the same buffers we can get away without calling waveOutPrepareHeader. 404 // the same buffers we can get away without calling waveOutPrepareHeader.
405 MMRESULT result = ::waveOutWrite(stream->waveout_, 405 MMRESULT result = ::waveOutWrite(stream->waveout_,
406 buffer, 406 buffer,
407 sizeof(WAVEHDR)); 407 sizeof(WAVEHDR));
408 if (result != MMSYSERR_NOERROR) 408 if (result != MMSYSERR_NOERROR)
409 stream->HandleError(result); 409 stream->HandleError(result);
410 stream->pending_bytes_ += buffer->dwBufferLength; 410 stream->pending_bytes_ += buffer->dwBufferLength;
411 } 411 }
412 } 412 }
413 } 413 }
OLDNEW
« no previous file with comments | « media/audio/win/wavein_input_win.cc ('k') | media/base/audio_renderer_sink.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698