| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 unsigned numberOfChannels; | 109 unsigned numberOfChannels; |
| 110 size_t numberOfFrames; | 110 size_t numberOfFrames; |
| 111 float sampleRate; | 111 float sampleRate; |
| 112 | 112 |
| 113 if (!options.hasNumberOfChannels()) { | 113 if (!options.hasNumberOfChannels()) { |
| 114 exceptionState.throwDOMException( | 114 exceptionState.throwDOMException( |
| 115 NotFoundError, "AudioBufferOptions: numberOfChannels is required."); | 115 NotFoundError, "AudioBufferOptions: numberOfChannels is required."); |
| 116 return nullptr; | 116 return nullptr; |
| 117 } | 117 } |
| 118 | 118 |
| 119 if (!options.hasLength()) { | |
| 120 exceptionState.throwDOMException(NotFoundError, | |
| 121 "AudioBufferOptions: length is required."); | |
| 122 return nullptr; | |
| 123 } | |
| 124 | |
| 125 numberOfChannels = options.numberOfChannels(); | 119 numberOfChannels = options.numberOfChannels(); |
| 126 numberOfFrames = options.length(); | 120 numberOfFrames = options.length(); |
| 127 | 121 |
| 128 if (options.hasSampleRate()) | 122 if (options.hasSampleRate()) |
| 129 sampleRate = options.sampleRate(); | 123 sampleRate = options.sampleRate(); |
| 130 else | 124 else |
| 131 sampleRate = context->sampleRate(); | 125 sampleRate = context->sampleRate(); |
| 132 | 126 |
| 133 return create(numberOfChannels, numberOfFrames, sampleRate, exceptionState); | 127 return create(numberOfChannels, numberOfFrames, sampleRate, exceptionState); |
| 134 } | 128 } |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 void AudioBuffer::zero() { | 316 void AudioBuffer::zero() { |
| 323 for (unsigned i = 0; i < m_channels.size(); ++i) { | 317 for (unsigned i = 0; i < m_channels.size(); ++i) { |
| 324 if (DOMFloat32Array* array = getChannelData(i)) { | 318 if (DOMFloat32Array* array = getChannelData(i)) { |
| 325 float* data = array->data(); | 319 float* data = array->data(); |
| 326 memset(data, 0, length() * sizeof(*data)); | 320 memset(data, 0, length() * sizeof(*data)); |
| 327 } | 321 } |
| 328 } | 322 } |
| 329 } | 323 } |
| 330 | 324 |
| 331 } // namespace blink | 325 } // namespace blink |
| OLD | NEW |