| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012, Google Inc. All rights reserved. | 2 * Copyright (C) 2012, 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 * 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 26 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 namespace blink { | 38 namespace blink { |
| 39 | 39 |
| 40 OfflineAudioContext* OfflineAudioContext::create(ExecutionContext* context, unsi
gned numberOfChannels, size_t numberOfFrames, float sampleRate, ExceptionState&
exceptionState) | 40 OfflineAudioContext* OfflineAudioContext::create(ExecutionContext* context, unsi
gned numberOfChannels, size_t numberOfFrames, float sampleRate, ExceptionState&
exceptionState) |
| 41 { | 41 { |
| 42 // FIXME: add support for workers. | 42 // FIXME: add support for workers. |
| 43 if (!context || !context->isDocument()) { | 43 if (!context || !context->isDocument()) { |
| 44 exceptionState.throwDOMException( | 44 exceptionState.throwDOMException( |
| 45 NotSupportedError, | 45 NotSupportedError, |
| 46 "Workers are not supported."); | 46 "Workers are not supported."); |
| 47 return 0; | 47 return nullptr; |
| 48 } | 48 } |
| 49 | 49 |
| 50 Document* document = toDocument(context); | 50 Document* document = toDocument(context); |
| 51 | 51 |
| 52 if (!numberOfFrames) { | 52 if (!numberOfFrames) { |
| 53 exceptionState.throwDOMException(SyntaxError, "number of frames cannot b
e zero."); | 53 exceptionState.throwDOMException(SyntaxError, "number of frames cannot b
e zero."); |
| 54 return 0; | 54 return nullptr; |
| 55 } | 55 } |
| 56 | 56 |
| 57 if (numberOfChannels > AudioContext::maxNumberOfChannels()) { | 57 if (numberOfChannels > AudioContext::maxNumberOfChannels()) { |
| 58 exceptionState.throwDOMException( | 58 exceptionState.throwDOMException( |
| 59 IndexSizeError, | 59 IndexSizeError, |
| 60 ExceptionMessages::indexOutsideRange<unsigned>( | 60 ExceptionMessages::indexOutsideRange<unsigned>( |
| 61 "number of channels", | 61 "number of channels", |
| 62 numberOfChannels, | 62 numberOfChannels, |
| 63 0, | 63 0, |
| 64 ExceptionMessages::InclusiveBound, | 64 ExceptionMessages::InclusiveBound, |
| 65 AudioContext::maxNumberOfChannels(), | 65 AudioContext::maxNumberOfChannels(), |
| 66 ExceptionMessages::InclusiveBound)); | 66 ExceptionMessages::InclusiveBound)); |
| 67 return 0; | 67 return nullptr; |
| 68 } | 68 } |
| 69 | 69 |
| 70 if (!AudioUtilities::isValidAudioBufferSampleRate(sampleRate)) { | 70 if (!AudioUtilities::isValidAudioBufferSampleRate(sampleRate)) { |
| 71 exceptionState.throwDOMException( | 71 exceptionState.throwDOMException( |
| 72 IndexSizeError, | 72 IndexSizeError, |
| 73 ExceptionMessages::indexOutsideRange( | 73 ExceptionMessages::indexOutsideRange( |
| 74 "sampleRate", sampleRate, | 74 "sampleRate", sampleRate, |
| 75 AudioUtilities::minAudioBufferSampleRate(), ExceptionMessages::I
nclusiveBound, | 75 AudioUtilities::minAudioBufferSampleRate(), ExceptionMessages::I
nclusiveBound, |
| 76 AudioUtilities::maxAudioBufferSampleRate(), ExceptionMessages::I
nclusiveBound)); | 76 AudioUtilities::maxAudioBufferSampleRate(), ExceptionMessages::I
nclusiveBound)); |
| 77 return nullptr; | 77 return nullptr; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 } | 113 } |
| 114 | 114 |
| 115 m_offlineResolver = ScriptPromiseResolver::create(scriptState); | 115 m_offlineResolver = ScriptPromiseResolver::create(scriptState); |
| 116 startRendering(); | 116 startRendering(); |
| 117 return m_offlineResolver->promise(); | 117 return m_offlineResolver->promise(); |
| 118 } | 118 } |
| 119 | 119 |
| 120 } // namespace blink | 120 } // namespace blink |
| 121 | 121 |
| 122 #endif // ENABLE(WEB_AUDIO) | 122 #endif // ENABLE(WEB_AUDIO) |
| OLD | NEW |