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

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

Issue 16286010: Removed the IsRecordingInProcess check for speech since it is not needed (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: removed unused error code and relevant resource, cleaned up include Created 7 years, 6 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/mock_audio_manager.cc ('k') | 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/wavein_input_win.h" 5 #include "media/audio/win/wavein_input_win.h"
6 6
7 #pragma comment(lib, "winmm.lib") 7 #pragma comment(lib, "winmm.lib")
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "media/audio/audio_io.h" 10 #include "media/audio/audio_io.h"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 QueueNextPacket(buffer); 126 QueueNextPacket(buffer);
127 buffer = GetNextBuffer(buffer); 127 buffer = GetNextBuffer(buffer);
128 } 128 }
129 buffer = buffer_; 129 buffer = buffer_;
130 130
131 MMRESULT result = ::waveInStart(wavein_); 131 MMRESULT result = ::waveInStart(wavein_);
132 if (result != MMSYSERR_NOERROR) { 132 if (result != MMSYSERR_NOERROR) {
133 HandleError(result); 133 HandleError(result);
134 state_ = kStateReady; 134 state_ = kStateReady;
135 callback_ = NULL; 135 callback_ = NULL;
136 } else {
137 manager_->IncreaseActiveInputStreamCount();
138 } 136 }
139 } 137 }
140 138
141 // Stopping is tricky. First, no buffer should be locked by the audio driver 139 // Stopping is tricky. First, no buffer should be locked by the audio driver
142 // or else the waveInReset() will deadlock and secondly, the callback should 140 // or else the waveInReset() will deadlock and secondly, the callback should
143 // not be inside the AudioInputCallback's OnData because waveInReset() 141 // not be inside the AudioInputCallback's OnData because waveInReset()
144 // forcefully kills the callback thread. 142 // forcefully kills the callback thread.
145 void PCMWaveInAudioInputStream::Stop() { 143 void PCMWaveInAudioInputStream::Stop() {
146 DVLOG(1) << "PCMWaveInAudioInputStream::Stop()"; 144 DVLOG(1) << "PCMWaveInAudioInputStream::Stop()";
147 DCHECK(thread_checker_.CalledOnValidThread()); 145 DCHECK(thread_checker_.CalledOnValidThread());
(...skipping 15 matching lines...) Expand all
163 // Wait for the callback to finish, it will signal us when ready to be reset. 161 // Wait for the callback to finish, it will signal us when ready to be reset.
164 DWORD wait = ::WaitForSingleObject(stopped_event_, INFINITE); 162 DWORD wait = ::WaitForSingleObject(stopped_event_, INFINITE);
165 DCHECK_EQ(wait, WAIT_OBJECT_0); 163 DCHECK_EQ(wait, WAIT_OBJECT_0);
166 164
167 // Stop input and reset the current position to zero for |wavein_|. 165 // Stop input and reset the current position to zero for |wavein_|.
168 // All pending buffers are marked as done and returned to the application. 166 // All pending buffers are marked as done and returned to the application.
169 MMRESULT res = ::waveInReset(wavein_); 167 MMRESULT res = ::waveInReset(wavein_);
170 DCHECK_EQ(res, static_cast<MMRESULT>(MMSYSERR_NOERROR)); 168 DCHECK_EQ(res, static_cast<MMRESULT>(MMSYSERR_NOERROR));
171 169
172 state_ = kStateReady; 170 state_ = kStateReady;
173 manager_->DecreaseActiveInputStreamCount();
174 } 171 }
175 172
176 void PCMWaveInAudioInputStream::Close() { 173 void PCMWaveInAudioInputStream::Close() {
177 DVLOG(1) << "PCMWaveInAudioInputStream::Close()"; 174 DVLOG(1) << "PCMWaveInAudioInputStream::Close()";
178 DCHECK(thread_checker_.CalledOnValidThread()); 175 DCHECK(thread_checker_.CalledOnValidThread());
179 176
180 // We should not call Close() while recording. Catch it with DCHECK and 177 // We should not call Close() while recording. Catch it with DCHECK and
181 // implement auto-stop just in case. 178 // implement auto-stop just in case.
182 DCHECK_NE(state_, kStateRecording); 179 DCHECK_NE(state_, kStateRecording);
183 Stop(); 180 Stop();
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 ::SetEvent(obj->stopped_event_); 307 ::SetEvent(obj->stopped_event_);
311 } 308 }
312 } else if (msg == WIM_CLOSE) { 309 } else if (msg == WIM_CLOSE) {
313 // Intentionaly no-op for now. 310 // Intentionaly no-op for now.
314 } else if (msg == WIM_OPEN) { 311 } else if (msg == WIM_OPEN) {
315 // Intentionaly no-op for now. 312 // Intentionaly no-op for now.
316 } 313 }
317 } 314 }
318 315
319 } // namespace media 316 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/mock_audio_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698