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

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

Issue 9854031: Replace size_t with int in a few media classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase 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 | « no previous file | media/audio/linux/alsa_output_unittest.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 // THREAD SAFETY 5 // THREAD SAFETY
6 // 6 //
7 // AlsaPcmOutputStream object is *not* thread-safe and should only be used 7 // AlsaPcmOutputStream object is *not* thread-safe and should only be used
8 // from the audio thread. We DCHECK on this assumption whenever we can. 8 // from the audio thread. We DCHECK on this assumption whenever we can.
9 // 9 //
10 // SEMANTICS OF Close() 10 // SEMANTICS OF Close()
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 // Before making a request to source for data we need to determine the 366 // Before making a request to source for data we need to determine the
367 // delay (in bytes) for the requested data to be played. 367 // delay (in bytes) for the requested data to be played.
368 368
369 uint32 buffer_delay = buffer_->forward_bytes() * bytes_per_frame_ / 369 uint32 buffer_delay = buffer_->forward_bytes() * bytes_per_frame_ /
370 bytes_per_output_frame_; 370 bytes_per_output_frame_;
371 371
372 uint32 hardware_delay = GetCurrentDelay() * bytes_per_frame_; 372 uint32 hardware_delay = GetCurrentDelay() * bytes_per_frame_;
373 373
374 scoped_refptr<media::DataBuffer> packet = 374 scoped_refptr<media::DataBuffer> packet =
375 new media::DataBuffer(packet_size_); 375 new media::DataBuffer(packet_size_);
376 size_t packet_size = RunDataCallback(packet->GetWritableData(), 376 int packet_size = RunDataCallback(packet->GetWritableData(),
377 packet->GetBufferSize(), 377 packet->GetBufferSize(),
378 AudioBuffersState(buffer_delay, 378 AudioBuffersState(buffer_delay,
379 hardware_delay)); 379 hardware_delay));
380 CHECK(packet_size <= packet->GetBufferSize()); 380 CHECK_LE(packet_size, packet->GetBufferSize());
381 381
382 // This should not happen, but in case it does, drop any trailing bytes 382 // This should not happen, but in case it does, drop any trailing bytes
383 // that aren't large enough to make a frame. Without this, packet writing 383 // that aren't large enough to make a frame. Without this, packet writing
384 // may stall because the last few bytes in the packet may never get used by 384 // may stall because the last few bytes in the packet may never get used by
385 // WritePacket. 385 // WritePacket.
386 DCHECK(packet_size % bytes_per_frame_ == 0); 386 DCHECK(packet_size % bytes_per_frame_ == 0);
387 packet_size = (packet_size / bytes_per_frame_) * bytes_per_frame_; 387 packet_size = (packet_size / bytes_per_frame_) * bytes_per_frame_;
388 388
389 if (should_downmix_) { 389 if (should_downmix_) {
390 if (media::FoldChannels(packet->GetWritableData(), 390 if (media::FoldChannels(packet->GetWritableData(),
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 buffer_->Clear(); 423 buffer_->Clear();
424 return; 424 return;
425 } 425 }
426 426
427 if (state() == kIsStopped) 427 if (state() == kIsStopped)
428 return; 428 return;
429 429
430 CHECK_EQ(buffer_->forward_bytes() % bytes_per_output_frame_, 0u); 430 CHECK_EQ(buffer_->forward_bytes() % bytes_per_output_frame_, 0u);
431 431
432 const uint8* buffer_data; 432 const uint8* buffer_data;
433 size_t buffer_size; 433 int buffer_size;
434 if (buffer_->GetCurrentChunk(&buffer_data, &buffer_size)) { 434 if (buffer_->GetCurrentChunk(&buffer_data, &buffer_size)) {
435 buffer_size = buffer_size - (buffer_size % bytes_per_output_frame_); 435 buffer_size = buffer_size - (buffer_size % bytes_per_output_frame_);
436 snd_pcm_sframes_t frames = buffer_size / bytes_per_output_frame_; 436 snd_pcm_sframes_t frames = buffer_size / bytes_per_output_frame_;
437 437
438 DCHECK_GT(frames, 0); 438 DCHECK_GT(frames, 0);
439 439
440 snd_pcm_sframes_t frames_written = 440 snd_pcm_sframes_t frames_written =
441 wrapper_->PcmWritei(playback_handle_, buffer_data, frames); 441 wrapper_->PcmWritei(playback_handle_, buffer_data, frames);
442 if (frames_written < 0) { 442 if (frames_written < 0) {
443 // Attempt once to immediately recover from EINTR, 443 // Attempt once to immediately recover from EINTR,
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 if (source_callback_) 790 if (source_callback_)
791 source_callback_->OnError(this, code); 791 source_callback_->OnError(this, code);
792 } 792 }
793 793
794 // Changes the AudioSourceCallback to proxy calls to. Pass in NULL to 794 // Changes the AudioSourceCallback to proxy calls to. Pass in NULL to
795 // release ownership of the currently registered callback. 795 // release ownership of the currently registered callback.
796 void AlsaPcmOutputStream::set_source_callback(AudioSourceCallback* callback) { 796 void AlsaPcmOutputStream::set_source_callback(AudioSourceCallback* callback) {
797 DCHECK(IsOnAudioThread()); 797 DCHECK(IsOnAudioThread());
798 source_callback_ = callback; 798 source_callback_ = callback;
799 } 799 }
OLDNEW
« no previous file with comments | « no previous file | media/audio/linux/alsa_output_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698