OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007, 2009, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2009, 2010 Apple 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 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 } | 58 } |
59 | 59 |
60 void TimeRanges::invert() { | 60 void TimeRanges::invert() { |
61 TimeRanges* inverted = TimeRanges::create(); | 61 TimeRanges* inverted = TimeRanges::create(); |
62 double posInf = std::numeric_limits<double>::infinity(); | 62 double posInf = std::numeric_limits<double>::infinity(); |
63 double negInf = -std::numeric_limits<double>::infinity(); | 63 double negInf = -std::numeric_limits<double>::infinity(); |
64 | 64 |
65 if (!m_ranges.size()) { | 65 if (!m_ranges.size()) { |
66 inverted->add(negInf, posInf); | 66 inverted->add(negInf, posInf); |
67 } else { | 67 } else { |
68 double start = m_ranges.first().m_start; | 68 double start = m_ranges.front().m_start; |
69 if (start != negInf) | 69 if (start != negInf) |
70 inverted->add(negInf, start); | 70 inverted->add(negInf, start); |
71 | 71 |
72 for (size_t index = 0; index + 1 < m_ranges.size(); ++index) | 72 for (size_t index = 0; index + 1 < m_ranges.size(); ++index) |
73 inverted->add(m_ranges[index].m_end, m_ranges[index + 1].m_start); | 73 inverted->add(m_ranges[index].m_end, m_ranges[index + 1].m_start); |
74 | 74 |
75 double end = m_ranges.back().m_end; | 75 double end = m_ranges.back().m_end; |
76 if (end != posInf) | 76 if (end != posInf) |
77 inverted->add(end, posInf); | 77 inverted->add(end, posInf); |
78 } | 78 } |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 if (delta < bestDelta || | 202 if (delta < bestDelta || |
203 (delta == bestDelta && | 203 (delta == bestDelta && |
204 std::abs(currentPlaybackPosition - match) < | 204 std::abs(currentPlaybackPosition - match) < |
205 std::abs(currentPlaybackPosition - bestMatch))) { | 205 std::abs(currentPlaybackPosition - bestMatch))) { |
206 bestDelta = delta; | 206 bestDelta = delta; |
207 bestMatch = match; | 207 bestMatch = match; |
208 } | 208 } |
209 } | 209 } |
210 return bestMatch; | 210 return bestMatch; |
211 } | 211 } |
OLD | NEW |