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

Side by Side Diff: media/cast/sender/audio_encoder.cc

Issue 2181163002: media: Change auto to not deduce raw pointers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 | « media/base/mac/videotoolbox_helpers.cc ('k') | media/cast/sender/h264_vt_encoder.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/cast/sender/audio_encoder.h" 5 #include "media/cast/sender/audio_encoder.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <limits> 10 #include <limits>
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 int num_samples) final { 535 int num_samples) final {
536 DCHECK_EQ(audio_bus->channels(), input_buffer_->channels()); 536 DCHECK_EQ(audio_bus->channels(), input_buffer_->channels());
537 537
538 // See the comment on |input_bus_| for more on this optimization. Note that 538 // See the comment on |input_bus_| for more on this optimization. Note that
539 // we cannot elide the copy if the source offset would result in an 539 // we cannot elide the copy if the source offset would result in an
540 // unaligned pointer. 540 // unaligned pointer.
541 if (num_samples == kAccessUnitSamples && 541 if (num_samples == kAccessUnitSamples &&
542 source_offset * sizeof(float) % AudioBus::kChannelAlignment == 0) { 542 source_offset * sizeof(float) % AudioBus::kChannelAlignment == 0) {
543 DCHECK_EQ(buffer_fill_offset, 0); 543 DCHECK_EQ(buffer_fill_offset, 0);
544 for (int ch = 0; ch < audio_bus->channels(); ++ch) { 544 for (int ch = 0; ch < audio_bus->channels(); ++ch) {
545 auto samples = const_cast<float*>(audio_bus->channel(ch)); 545 auto* samples = const_cast<float*>(audio_bus->channel(ch));
546 input_bus_->SetChannelData(ch, samples + source_offset); 546 input_bus_->SetChannelData(ch, samples + source_offset);
547 } 547 }
548 return; 548 return;
549 } 549 }
550 550
551 // Copy the samples into the input buffer. 551 // Copy the samples into the input buffer.
552 DCHECK_EQ(input_bus_->channel(0), input_buffer_->channel(0)); 552 DCHECK_EQ(input_bus_->channel(0), input_buffer_->channel(0));
553 audio_bus->CopyPartialFramesTo( 553 audio_bus->CopyPartialFramesTo(
554 source_offset, num_samples, buffer_fill_offset, input_buffer_.get()); 554 source_offset, num_samples, buffer_fill_offset, input_buffer_.get());
555 } 555 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 // can only supply |kAccessUnitSamples| samples as a result of not copying 598 // can only supply |kAccessUnitSamples| samples as a result of not copying
599 // samples or tracking read and write positions. Note that this function is 599 // samples or tracking read and write positions. Note that this function is
600 // called synchronously by |AudioConverterFillComplexBuffer|. 600 // called synchronously by |AudioConverterFillComplexBuffer|.
601 static OSStatus ConverterFillDataCallback( 601 static OSStatus ConverterFillDataCallback(
602 AudioConverterRef in_converter, 602 AudioConverterRef in_converter,
603 UInt32* io_num_packets, 603 UInt32* io_num_packets,
604 AudioBufferList* io_data, 604 AudioBufferList* io_data,
605 AudioStreamPacketDescription** out_packet_desc, 605 AudioStreamPacketDescription** out_packet_desc,
606 void* in_encoder) { 606 void* in_encoder) {
607 DCHECK(in_encoder); 607 DCHECK(in_encoder);
608 auto encoder = reinterpret_cast<AppleAacImpl*>(in_encoder); 608 auto* encoder = reinterpret_cast<AppleAacImpl*>(in_encoder);
609 auto input_buffer = encoder->input_buffer_.get(); 609 auto* input_buffer = encoder->input_buffer_.get();
610 auto input_bus = encoder->input_bus_.get(); 610 auto* input_bus = encoder->input_bus_.get();
611 611
612 DCHECK_EQ(static_cast<int>(*io_num_packets), kAccessUnitSamples); 612 DCHECK_EQ(static_cast<int>(*io_num_packets), kAccessUnitSamples);
613 DCHECK_EQ(io_data->mNumberBuffers, 613 DCHECK_EQ(io_data->mNumberBuffers,
614 static_cast<unsigned>(input_bus->channels())); 614 static_cast<unsigned>(input_bus->channels()));
615 for (int i_buf = 0, end = io_data->mNumberBuffers; i_buf < end; ++i_buf) { 615 for (int i_buf = 0, end = io_data->mNumberBuffers; i_buf < end; ++i_buf) {
616 io_data->mBuffers[i_buf].mNumberChannels = 1; 616 io_data->mBuffers[i_buf].mNumberChannels = 1;
617 io_data->mBuffers[i_buf].mDataByteSize = sizeof(float) * *io_num_packets; 617 io_data->mBuffers[i_buf].mDataByteSize = sizeof(float) * *io_num_packets;
618 io_data->mBuffers[i_buf].mData = input_bus->channel(i_buf); 618 io_data->mBuffers[i_buf].mData = input_bus->channel(i_buf);
619 619
620 // Reset the input bus back to the input buffer. See the comment on 620 // Reset the input bus back to the input buffer. See the comment on
(...skipping 16 matching lines...) Expand all
637 637
638 // The AudioFile write callback function. Appends the data to the encoder's 638 // The AudioFile write callback function. Appends the data to the encoder's
639 // current |output_buffer_|. 639 // current |output_buffer_|.
640 static OSStatus FileWriteCallback(void* in_encoder, 640 static OSStatus FileWriteCallback(void* in_encoder,
641 SInt64 in_position, 641 SInt64 in_position,
642 UInt32 in_size, 642 UInt32 in_size,
643 const void* in_buffer, 643 const void* in_buffer,
644 UInt32* out_size) { 644 UInt32* out_size) {
645 DCHECK(in_encoder); 645 DCHECK(in_encoder);
646 DCHECK(in_buffer); 646 DCHECK(in_buffer);
647 auto encoder = reinterpret_cast<const AppleAacImpl*>(in_encoder); 647 auto* encoder = reinterpret_cast<const AppleAacImpl*>(in_encoder);
648 auto buffer = reinterpret_cast<const std::string::value_type*>(in_buffer); 648 auto* buffer = reinterpret_cast<const std::string::value_type*>(in_buffer);
649 649
650 std::string* const output_buffer = encoder->output_buffer_; 650 std::string* const output_buffer = encoder->output_buffer_;
651 DCHECK(output_buffer); 651 DCHECK(output_buffer);
652 652
653 output_buffer->append(buffer, in_size); 653 output_buffer->append(buffer, in_size);
654 *out_size = in_size; 654 *out_size = in_size;
655 return noErr; 655 return noErr;
656 } 656 }
657 657
658 // The AudioFile getsize callback function. 658 // The AudioFile getsize callback function.
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 cast_environment_->PostTask(CastEnvironment::AUDIO, 835 cast_environment_->PostTask(CastEnvironment::AUDIO,
836 FROM_HERE, 836 FROM_HERE,
837 base::Bind(&AudioEncoder::ImplBase::EncodeAudio, 837 base::Bind(&AudioEncoder::ImplBase::EncodeAudio,
838 impl_, 838 impl_,
839 base::Passed(&audio_bus), 839 base::Passed(&audio_bus),
840 recorded_time)); 840 recorded_time));
841 } 841 }
842 842
843 } // namespace cast 843 } // namespace cast
844 } // namespace media 844 } // namespace media
OLDNEW
« no previous file with comments | « media/base/mac/videotoolbox_helpers.cc ('k') | media/cast/sender/h264_vt_encoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698