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

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

Issue 10834013: Added DCHECK() to prevent NULL-pointer dereference (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 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/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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 buffer_->dwBufferLength = buffer_size_; 91 buffer_->dwBufferLength = buffer_size_;
92 buffer_->dwBytesRecorded = 0; 92 buffer_->dwBytesRecorded = 0;
93 buffer_->dwUser = reinterpret_cast<DWORD_PTR>(last); 93 buffer_->dwUser = reinterpret_cast<DWORD_PTR>(last);
94 buffer_->dwFlags = WHDR_DONE; 94 buffer_->dwFlags = WHDR_DONE;
95 buffer_->dwLoops = 0; 95 buffer_->dwLoops = 0;
96 if (ix == 0) 96 if (ix == 0)
97 first = buffer_; 97 first = buffer_;
98 last = buffer_; 98 last = buffer_;
99 ::waveInPrepareHeader(wavein_, buffer_, sizeof(WAVEHDR)); 99 ::waveInPrepareHeader(wavein_, buffer_, sizeof(WAVEHDR));
100 } 100 }
101 DCHECK(first);
Tyler Breisacher (Chromium) 2012/07/25 21:18:15 This can only be NULL if num_buffers_ is 0, I thin
Kyle Horimoto 2012/07/25 21:56:40 num_buffers_ is only assigned to within the constr
101 // Fix the first buffer to point to the last one. 102 // Fix the first buffer to point to the last one.
102 first->dwUser = reinterpret_cast<DWORD_PTR>(last); 103 first->dwUser = reinterpret_cast<DWORD_PTR>(last);
103 } 104 }
104 105
105 void PCMWaveInAudioInputStream::FreeBuffers() { 106 void PCMWaveInAudioInputStream::FreeBuffers() {
106 WAVEHDR* current = buffer_; 107 WAVEHDR* current = buffer_;
107 for (int ix = 0; ix != num_buffers_; ++ix) { 108 for (int ix = 0; ix != num_buffers_; ++ix) {
108 WAVEHDR* next = GetNextBuffer(current); 109 WAVEHDR* next = GetNextBuffer(current);
109 if (current->dwFlags & WHDR_PREPARED) 110 if (current->dwFlags & WHDR_PREPARED)
110 ::waveInUnprepareHeader(wavein_, current, sizeof(WAVEHDR)); 111 ::waveInUnprepareHeader(wavein_, current, sizeof(WAVEHDR));
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 } 293 }
293 } else if (msg == WIM_CLOSE) { 294 } else if (msg == WIM_CLOSE) {
294 // We can be closed before calling Start, so it is possible to have a 295 // We can be closed before calling Start, so it is possible to have a
295 // null callback at this point. 296 // null callback at this point.
296 if (obj->callback_) 297 if (obj->callback_)
297 obj->callback_->OnClose(obj); 298 obj->callback_->OnClose(obj);
298 } 299 }
299 } 300 }
300 301
301 } // namespace media 302 } // 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