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

Side by Side Diff: media/audio/win/wavein_input_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/audio_manager_win.cc ('k') | media/audio/win/waveout_output_win.cc » ('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/wavein_input_win.h" 5 #include "media/audio/win/wavein_input_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 18 matching lines...) Expand all
29 PCMWaveInAudioInputStream::PCMWaveInAudioInputStream( 29 PCMWaveInAudioInputStream::PCMWaveInAudioInputStream(
30 AudioManagerWin* manager, const AudioParameters& params, int num_buffers, 30 AudioManagerWin* manager, const AudioParameters& params, int num_buffers,
31 const std::string& device_id) 31 const std::string& device_id)
32 : state_(kStateEmpty), 32 : state_(kStateEmpty),
33 manager_(manager), 33 manager_(manager),
34 device_id_(device_id), 34 device_id_(device_id),
35 wavein_(NULL), 35 wavein_(NULL),
36 callback_(NULL), 36 callback_(NULL),
37 num_buffers_(num_buffers), 37 num_buffers_(num_buffers),
38 buffer_(NULL), 38 buffer_(NULL),
39 channels_(params.channels) { 39 channels_(params.channels()) {
40 format_.wFormatTag = WAVE_FORMAT_PCM; 40 format_.wFormatTag = WAVE_FORMAT_PCM;
41 format_.nChannels = params.channels > 2 ? 2 : params.channels; 41 format_.nChannels = params.channels() > 2 ? 2 : params.channels();
42 format_.nSamplesPerSec = params.sample_rate; 42 format_.nSamplesPerSec = params.sample_rate();
43 format_.wBitsPerSample = params.bits_per_sample; 43 format_.wBitsPerSample = params.bits_per_sample();
44 format_.cbSize = 0; 44 format_.cbSize = 0;
45 format_.nBlockAlign = (format_.nChannels * format_.wBitsPerSample) / 8; 45 format_.nBlockAlign = (format_.nChannels * format_.wBitsPerSample) / 8;
46 format_.nAvgBytesPerSec = format_.nBlockAlign * format_.nSamplesPerSec; 46 format_.nAvgBytesPerSec = format_.nBlockAlign * format_.nSamplesPerSec;
47 buffer_size_ = params.samples_per_packet * format_.nBlockAlign; 47 buffer_size_ = params.frames_per_buffer() * format_.nBlockAlign;
48 // If we don't have a packet size we use 100ms. 48 // If we don't have a packet size we use 100ms.
49 if (!buffer_size_) 49 if (!buffer_size_)
50 buffer_size_ = format_.nAvgBytesPerSec / 10; 50 buffer_size_ = format_.nAvgBytesPerSec / 10;
51 // The event is auto-reset. 51 // The event is auto-reset.
52 stopped_event_.Set(::CreateEventW(NULL, FALSE, FALSE, NULL)); 52 stopped_event_.Set(::CreateEventW(NULL, FALSE, FALSE, NULL));
53 } 53 }
54 54
55 PCMWaveInAudioInputStream::~PCMWaveInAudioInputStream() { 55 PCMWaveInAudioInputStream::~PCMWaveInAudioInputStream() {
56 DCHECK(NULL == wavein_); 56 DCHECK(NULL == wavein_);
57 } 57 }
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 // waveInPrepareHeader. 278 // waveInPrepareHeader.
279 obj->QueueNextPacket(buffer); 279 obj->QueueNextPacket(buffer);
280 } 280 }
281 } else if (msg == WIM_CLOSE) { 281 } else if (msg == WIM_CLOSE) {
282 // We can be closed before calling Start, so it is possible to have a 282 // We can be closed before calling Start, so it is possible to have a
283 // null callback at this point. 283 // null callback at this point.
284 if (obj->callback_) 284 if (obj->callback_)
285 obj->callback_->OnClose(obj); 285 obj->callback_->OnClose(obj);
286 } 286 }
287 } 287 }
OLDNEW
« no previous file with comments | « media/audio/win/audio_manager_win.cc ('k') | media/audio/win/waveout_output_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698