| 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 25 matching lines...) Expand all Loading... |
| 36 | 36 |
| 37 namespace WebCore { | 37 namespace WebCore { |
| 38 | 38 |
| 39 PassRefPtr<OfflineAudioContext> OfflineAudioContext::create(ExecutionContext* co
ntext, unsigned numberOfChannels, size_t numberOfFrames, float sampleRate, Excep
tionState& exceptionState) | 39 PassRefPtr<OfflineAudioContext> OfflineAudioContext::create(ExecutionContext* co
ntext, unsigned numberOfChannels, size_t numberOfFrames, float sampleRate, Excep
tionState& exceptionState) |
| 40 { | 40 { |
| 41 // FIXME: add support for workers. | 41 // FIXME: add support for workers. |
| 42 if (!context || !context->isDocument()) { | 42 if (!context || !context->isDocument()) { |
| 43 exceptionState.throwDOMException( | 43 exceptionState.throwDOMException( |
| 44 NotSupportedError, | 44 NotSupportedError, |
| 45 "Workers are not supported."); | 45 "Workers are not supported."); |
| 46 return 0; | 46 return nullptr; |
| 47 } | 47 } |
| 48 | 48 |
| 49 Document* document = toDocument(context); | 49 Document* document = toDocument(context); |
| 50 | 50 |
| 51 if (!numberOfFrames) { | 51 if (!numberOfFrames) { |
| 52 exceptionState.throwDOMException(SyntaxError, "number of frames cannot b
e zero."); | 52 exceptionState.throwDOMException(SyntaxError, "number of frames cannot b
e zero."); |
| 53 return 0; | 53 return nullptr; |
| 54 } | 54 } |
| 55 | 55 |
| 56 if (numberOfChannels > 10) { | 56 if (numberOfChannels > 10) { |
| 57 exceptionState.throwDOMException(SyntaxError, "number of channels (" + S
tring::number(numberOfChannels) + ") exceeds maximum (10)."); | 57 exceptionState.throwDOMException(SyntaxError, "number of channels (" + S
tring::number(numberOfChannels) + ") exceeds maximum (10)."); |
| 58 return 0; | 58 return nullptr; |
| 59 } | 59 } |
| 60 | 60 |
| 61 if (!isSampleRateRangeGood(sampleRate)) { | 61 if (!isSampleRateRangeGood(sampleRate)) { |
| 62 exceptionState.throwDOMException(SyntaxError, "sample rate (" + String::
number(sampleRate) + ") must be in the range 44100-96000 Hz."); | 62 exceptionState.throwDOMException(SyntaxError, "sample rate (" + String::
number(sampleRate) + ") must be in the range 44100-96000 Hz."); |
| 63 return 0; | 63 return nullptr; |
| 64 } | 64 } |
| 65 | 65 |
| 66 RefPtr<OfflineAudioContext> audioContext(adoptRef(new OfflineAudioContext(do
cument, numberOfChannels, numberOfFrames, sampleRate))); | 66 RefPtr<OfflineAudioContext> audioContext(adoptRef(new OfflineAudioContext(do
cument, numberOfChannels, numberOfFrames, sampleRate))); |
| 67 audioContext->suspendIfNeeded(); | 67 audioContext->suspendIfNeeded(); |
| 68 return audioContext.release(); | 68 return audioContext.release(); |
| 69 } | 69 } |
| 70 | 70 |
| 71 OfflineAudioContext::OfflineAudioContext(Document* document, unsigned numberOfCh
annels, size_t numberOfFrames, float sampleRate) | 71 OfflineAudioContext::OfflineAudioContext(Document* document, unsigned numberOfCh
annels, size_t numberOfFrames, float sampleRate) |
| 72 : AudioContext(document, numberOfChannels, numberOfFrames, sampleRate) | 72 : AudioContext(document, numberOfChannels, numberOfFrames, sampleRate) |
| 73 { | 73 { |
| 74 ScriptWrappable::init(this); | 74 ScriptWrappable::init(this); |
| 75 } | 75 } |
| 76 | 76 |
| 77 OfflineAudioContext::~OfflineAudioContext() | 77 OfflineAudioContext::~OfflineAudioContext() |
| 78 { | 78 { |
| 79 } | 79 } |
| 80 | 80 |
| 81 } // namespace WebCore | 81 } // namespace WebCore |
| 82 | 82 |
| 83 #endif // ENABLE(WEB_AUDIO) | 83 #endif // ENABLE(WEB_AUDIO) |
| OLD | NEW |