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

Side by Side Diff: media/audio/linux/cras_output.cc

Issue 10917161: cras_output: Fix calculation of bytes per sample. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 3 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
« 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 // The object has one error state: |state_| == kInError. When |state_| == 5 // The object has one error state: |state_| == kInError. When |state_| ==
6 // kInError, all public API functions will fail with an error (Start() will call 6 // kInError, all public API functions will fail with an error (Start() will call
7 // the OnError() function on the callback immediately), or no-op themselves with 7 // the OnError() function on the callback immediately), or no-op themselves with
8 // the exception of Close(). Even if an error state has been entered, if Open() 8 // the exception of Close(). Even if an error state has been entered, if Open()
9 // has previously returned successfully, Close() must be called. 9 // has previously returned successfully, Close() must be called.
10 10
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 latency_ts.tv_nsec / 1000; 278 latency_ts.tv_nsec / 1000;
279 279
280 uint32 frames_latency = latency_usec * frame_rate_ / 1000000; 280 uint32 frames_latency = latency_usec * frame_rate_ / 1000000;
281 uint32 bytes_latency = frames_latency * bytes_per_frame_; 281 uint32 bytes_latency = frames_latency * bytes_per_frame_;
282 DCHECK_EQ(frames, static_cast<size_t>(audio_bus_->frames())); 282 DCHECK_EQ(frames, static_cast<size_t>(audio_bus_->frames()));
283 int frames_filled = source_callback_->OnMoreData( 283 int frames_filled = source_callback_->OnMoreData(
284 audio_bus_.get(), AudioBuffersState(0, bytes_latency)); 284 audio_bus_.get(), AudioBuffersState(0, bytes_latency));
285 // Note: If this ever changes to output raw float the data must be clipped and 285 // Note: If this ever changes to output raw float the data must be clipped and
286 // sanitized since it may come from an untrusted source such as NaCl. 286 // sanitized since it may come from an untrusted source such as NaCl.
287 audio_bus_->ToInterleaved( 287 audio_bus_->ToInterleaved(
288 frames_filled, bytes_per_frame_ / (frames * num_channels_), buffer); 288 frames_filled, bytes_per_frame_ / num_channels_, buffer);
289 return frames_filled; 289 return frames_filled;
290 } 290 }
291 291
292 void CrasOutputStream::NotifyStreamError(int err) { 292 void CrasOutputStream::NotifyStreamError(int err) {
293 // This will remove the stream from the client. 293 // This will remove the stream from the client.
294 if (state_ == kIsClosed || state_ == kInError) 294 if (state_ == kIsClosed || state_ == kInError)
295 return; // Don't care about error if we aren't using it. 295 return; // Don't care about error if we aren't using it.
296 TransitionTo(kInError); 296 TransitionTo(kInError);
297 if (source_callback_) 297 if (source_callback_)
298 source_callback_->OnError(this, err); 298 source_callback_->OnError(this, err);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 state_ = to; 332 state_ = to;
333 } 333 }
334 return state_; 334 return state_;
335 } 335 }
336 336
337 CrasOutputStream::InternalState CrasOutputStream::state() { 337 CrasOutputStream::InternalState CrasOutputStream::state() {
338 return state_; 338 return state_;
339 } 339 }
340 340
341 } // namespace media 341 } // 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