| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 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 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 double deltaTime = time2 - time1; | 414 double deltaTime = time2 - time1; |
| 415 float k = deltaTime > 0 ? 1 / deltaTime : 0; | 415 float k = deltaTime > 0 ? 1 / deltaTime : 0; |
| 416 | 416 |
| 417 // |fillToEndFrame| is the exclusive upper bound of the last frame to be
computed for this | 417 // |fillToEndFrame| is the exclusive upper bound of the last frame to be
computed for this |
| 418 // event. It's either the last desired frame (|endFrame|) or derived fr
om the end time of | 418 // event. It's either the last desired frame (|endFrame|) or derived fr
om the end time of |
| 419 // the next event (time2). We compute ceil(time2*sampleRate) because fil
lToEndFrame is the | 419 // the next event (time2). We compute ceil(time2*sampleRate) because fil
lToEndFrame is the |
| 420 // exclusive upper bound. Consider the case where |startFrame| = 128 an
d time2 = 128.1 | 420 // exclusive upper bound. Consider the case where |startFrame| = 128 an
d time2 = 128.1 |
| 421 // (assuming sampleRate = 1). Since time2 is greater than 128, we want
to output a value | 421 // (assuming sampleRate = 1). Since time2 is greater than 128, we want
to output a value |
| 422 // for frame 128. This requires that fillToEndFrame be at least 129. T
his is achieved by | 422 // for frame 128. This requires that fillToEndFrame be at least 129. T
his is achieved by |
| 423 // ceil(time2). | 423 // ceil(time2). |
| 424 size_t fillToEndFrame = std::min(endFrame, static_cast<size_t>(ceil(time
2 * sampleRate))); | 424 // |
| 425 // However, time2 can be very large, so compute this carefully in the ca
se where time2 |
| 426 // exceeds the size of a size_t. |
| 427 |
| 428 size_t fillToEndFrame = endFrame; |
| 429 if (endFrame > time2 * sampleRate) |
| 430 fillToEndFrame = static_cast<size_t>(ceil(time2 * sampleRate)); |
| 431 |
| 425 ASSERT(fillToEndFrame >= startFrame); | 432 ASSERT(fillToEndFrame >= startFrame); |
| 426 size_t fillToFrame = fillToEndFrame - startFrame; | 433 size_t fillToFrame = fillToEndFrame - startFrame; |
| 427 fillToFrame = std::min(fillToFrame, static_cast<size_t>(numberOfValues))
; | 434 fillToFrame = std::min(fillToFrame, static_cast<size_t>(numberOfValues))
; |
| 428 | 435 |
| 429 ParamEvent::Type nextEventType = nextEvent ? static_cast<ParamEvent::Typ
e>(nextEvent->type()) : ParamEvent::LastType /* unknown */; | 436 ParamEvent::Type nextEventType = nextEvent ? static_cast<ParamEvent::Typ
e>(nextEvent->type()) : ParamEvent::LastType /* unknown */; |
| 430 | 437 |
| 431 // First handle linear and exponential ramps which require looking ahead
to the next event. | 438 // First handle linear and exponential ramps which require looking ahead
to the next event. |
| 432 if (nextEventType == ParamEvent::LinearRampToValue) { | 439 if (nextEventType == ParamEvent::LinearRampToValue) { |
| 433 const float valueDelta = value2 - value1; | 440 const float valueDelta = value2 - value1; |
| 434 #if CPU(X86) || CPU(X86_64) | 441 #if CPU(X86) || CPU(X86_64) |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 764 // to the end of the values buffer. | 771 // to the end of the values buffer. |
| 765 for (; writeIndex < numberOfValues; ++writeIndex) | 772 for (; writeIndex < numberOfValues; ++writeIndex) |
| 766 values[writeIndex] = value; | 773 values[writeIndex] = value; |
| 767 | 774 |
| 768 // This value is used to set the .value attribute of the AudioParam. | 775 // This value is used to set the .value attribute of the AudioParam. |
| 769 return value; | 776 return value; |
| 770 } | 777 } |
| 771 | 778 |
| 772 } // namespace blink | 779 } // namespace blink |
| 773 | 780 |
| OLD | NEW |