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

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

Issue 481193003: Remove AudioBuffersState usage in Chromium (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix audio muter build buster. Created 6 years, 2 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/alsa/alsa_output.h ('k') | media/audio/alsa/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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 // Request more data only when we run out of data in the buffer, because 353 // Request more data only when we run out of data in the buffer, because
354 // WritePacket() comsumes only the current chunk of data. 354 // WritePacket() comsumes only the current chunk of data.
355 if (!buffer_->forward_bytes()) { 355 if (!buffer_->forward_bytes()) {
356 // Before making a request to source for data we need to determine the 356 // Before making a request to source for data we need to determine the
357 // delay (in bytes) for the requested data to be played. 357 // delay (in bytes) for the requested data to be played.
358 const uint32 hardware_delay = GetCurrentDelay() * bytes_per_frame_; 358 const uint32 hardware_delay = GetCurrentDelay() * bytes_per_frame_;
359 359
360 scoped_refptr<media::DataBuffer> packet = 360 scoped_refptr<media::DataBuffer> packet =
361 new media::DataBuffer(packet_size_); 361 new media::DataBuffer(packet_size_);
362 int frames_filled = RunDataCallback( 362 int frames_filled = RunDataCallback(
363 audio_bus_.get(), AudioBuffersState(0, hardware_delay)); 363 audio_bus_.get(), hardware_delay);
364 364
365 size_t packet_size = frames_filled * bytes_per_frame_; 365 size_t packet_size = frames_filled * bytes_per_frame_;
366 DCHECK_LE(packet_size, packet_size_); 366 DCHECK_LE(packet_size, packet_size_);
367 367
368 // TODO(dalecurtis): Channel downmixing, upmixing, should be done in mixer; 368 // TODO(dalecurtis): Channel downmixing, upmixing, should be done in mixer;
369 // volume adjust should use SSE optimized vector_fmul() prior to interleave. 369 // volume adjust should use SSE optimized vector_fmul() prior to interleave.
370 AudioBus* output_bus = audio_bus_.get(); 370 AudioBus* output_bus = audio_bus_.get();
371 if (channel_mixer_) { 371 if (channel_mixer_) {
372 output_bus = mixed_audio_bus_.get(); 372 output_bus = mixed_audio_bus_.get();
373 channel_mixer_->Transform(audio_bus_.get(), output_bus); 373 channel_mixer_->Transform(audio_bus_.get(), output_bus);
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 733
734 AlsaPcmOutputStream::InternalState AlsaPcmOutputStream::state() { 734 AlsaPcmOutputStream::InternalState AlsaPcmOutputStream::state() {
735 return state_; 735 return state_;
736 } 736 }
737 737
738 bool AlsaPcmOutputStream::IsOnAudioThread() const { 738 bool AlsaPcmOutputStream::IsOnAudioThread() const {
739 return message_loop_ && message_loop_ == base::MessageLoop::current(); 739 return message_loop_ && message_loop_ == base::MessageLoop::current();
740 } 740 }
741 741
742 int AlsaPcmOutputStream::RunDataCallback(AudioBus* audio_bus, 742 int AlsaPcmOutputStream::RunDataCallback(AudioBus* audio_bus,
743 AudioBuffersState buffers_state) { 743 uint32 total_bytes_delay) {
744 TRACE_EVENT0("audio", "AlsaPcmOutputStream::RunDataCallback"); 744 TRACE_EVENT0("audio", "AlsaPcmOutputStream::RunDataCallback");
745 745
746 if (source_callback_) 746 if (source_callback_)
747 return source_callback_->OnMoreData(audio_bus, buffers_state); 747 return source_callback_->OnMoreData(audio_bus, total_bytes_delay);
748 748
749 return 0; 749 return 0;
750 } 750 }
751 751
752 void AlsaPcmOutputStream::RunErrorCallback(int code) { 752 void AlsaPcmOutputStream::RunErrorCallback(int code) {
753 if (source_callback_) 753 if (source_callback_)
754 source_callback_->OnError(this); 754 source_callback_->OnError(this);
755 } 755 }
756 756
757 // Changes the AudioSourceCallback to proxy calls to. Pass in NULL to 757 // Changes the AudioSourceCallback to proxy calls to. Pass in NULL to
758 // release ownership of the currently registered callback. 758 // release ownership of the currently registered callback.
759 void AlsaPcmOutputStream::set_source_callback(AudioSourceCallback* callback) { 759 void AlsaPcmOutputStream::set_source_callback(AudioSourceCallback* callback) {
760 DCHECK(IsOnAudioThread()); 760 DCHECK(IsOnAudioThread());
761 source_callback_ = callback; 761 source_callback_ = callback;
762 } 762 }
763 763
764 } // namespace media 764 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/alsa/alsa_output.h ('k') | media/audio/alsa/alsa_output_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698