| OLD | NEW |
| 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/base/audio_bus.h" | 5 #include "media/base/audio_bus.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "media/audio/audio_parameters.h" | 10 #include "media/audio/audio_parameters.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 if (sample > kMaxValue) | 83 if (sample > kMaxValue) |
| 84 sample = kMaxValue; | 84 sample = kMaxValue; |
| 85 else if (sample < kMinValue) | 85 else if (sample < kMinValue) |
| 86 sample = kMinValue; | 86 sample = kMinValue; |
| 87 | 87 |
| 88 dest[offset] = static_cast<Format>(sample) + kBias; | 88 dest[offset] = static_cast<Format>(sample) + kBias; |
| 89 } | 89 } |
| 90 } | 90 } |
| 91 } | 91 } |
| 92 | 92 |
| 93 static void ValidateConfig(int channels, int frames) { | 93 static void ValidateConfig(size_t channels, int frames) { |
| 94 CHECK_GT(frames, 0); | 94 CHECK_GT(frames, 0); |
| 95 CHECK_GT(channels, 0); | 95 CHECK_LE(channels, static_cast<size_t>(limits::kMaxChannels)); |
| 96 CHECK_LE(channels, limits::kMaxChannels); | |
| 97 } | 96 } |
| 98 | 97 |
| 99 static void CheckOverflow(int start_frame, int frames, int total_frames) { | 98 static void CheckOverflow(int start_frame, int frames, int total_frames) { |
| 100 CHECK_GE(start_frame, 0); | 99 CHECK_GE(start_frame, 0); |
| 101 CHECK_GE(frames, 0); | 100 CHECK_GE(frames, 0); |
| 102 CHECK_GT(total_frames, 0); | 101 CHECK_GT(total_frames, 0); |
| 103 int sum = start_frame + frames; | 102 int sum = start_frame + frames; |
| 104 CHECK_LE(sum, total_frames); | 103 CHECK_LE(sum, total_frames); |
| 105 CHECK_GE(sum, 0); | 104 CHECK_GE(sum, 0); |
| 106 } | 105 } |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 CHECK_EQ(channels(), dest->channels()); | 298 CHECK_EQ(channels(), dest->channels()); |
| 300 CHECK_EQ(frames(), dest->frames()); | 299 CHECK_EQ(frames(), dest->frames()); |
| 301 | 300 |
| 302 // Since we don't know if the other AudioBus is wrapped or not (and we don't | 301 // Since we don't know if the other AudioBus is wrapped or not (and we don't |
| 303 // want to care), just copy using the public channel() accessors. | 302 // want to care), just copy using the public channel() accessors. |
| 304 for (int i = 0; i < channels(); ++i) | 303 for (int i = 0; i < channels(); ++i) |
| 305 memcpy(dest->channel(i), channel(i), sizeof(*channel(i)) * frames()); | 304 memcpy(dest->channel(i), channel(i), sizeof(*channel(i)) * frames()); |
| 306 } | 305 } |
| 307 | 306 |
| 308 } // namespace media | 307 } // namespace media |
| OLD | NEW |