| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 // FIXME: add support for workers. | 52 // FIXME: add support for workers. |
| 53 if (!context || !context->isDocument()) { | 53 if (!context || !context->isDocument()) { |
| 54 exceptionState.throwDOMException(NotSupportedError, | 54 exceptionState.throwDOMException(NotSupportedError, |
| 55 "Workers are not supported."); | 55 "Workers are not supported."); |
| 56 return nullptr; | 56 return nullptr; |
| 57 } | 57 } |
| 58 | 58 |
| 59 Document* document = toDocument(context); | 59 Document* document = toDocument(context); |
| 60 | 60 |
| 61 if (!numberOfFrames) { | 61 if (!numberOfFrames) { |
| 62 exceptionState.throwDOMException(SyntaxError, | 62 exceptionState.throwDOMException( |
| 63 "number of frames cannot be zero."); | 63 NotSupportedError, |
| 64 ExceptionMessages::indexExceedsMinimumBound<unsigned>( |
| 65 "number of frames", numberOfFrames, 1)); |
| 64 return nullptr; | 66 return nullptr; |
| 65 } | 67 } |
| 66 | 68 |
| 67 if (numberOfChannels > BaseAudioContext::maxNumberOfChannels()) { | 69 if (numberOfChannels == 0 || |
| 70 numberOfChannels > BaseAudioContext::maxNumberOfChannels()) { |
| 68 exceptionState.throwDOMException( | 71 exceptionState.throwDOMException( |
| 69 IndexSizeError, ExceptionMessages::indexOutsideRange<unsigned>( | 72 NotSupportedError, ExceptionMessages::indexOutsideRange<unsigned>( |
| 70 "number of channels", numberOfChannels, 0, | 73 "number of channels", numberOfChannels, 1, |
| 71 ExceptionMessages::InclusiveBound, | 74 ExceptionMessages::InclusiveBound, |
| 72 BaseAudioContext::maxNumberOfChannels(), | 75 BaseAudioContext::maxNumberOfChannels(), |
| 73 ExceptionMessages::InclusiveBound)); | 76 ExceptionMessages::InclusiveBound)); |
| 74 return nullptr; | 77 return nullptr; |
| 75 } | 78 } |
| 76 | 79 |
| 77 if (!AudioUtilities::isValidAudioBufferSampleRate(sampleRate)) { | 80 if (!AudioUtilities::isValidAudioBufferSampleRate(sampleRate)) { |
| 78 exceptionState.throwDOMException( | 81 exceptionState.throwDOMException( |
| 79 IndexSizeError, ExceptionMessages::indexOutsideRange( | 82 NotSupportedError, ExceptionMessages::indexOutsideRange( |
| 80 "sampleRate", sampleRate, | 83 "sampleRate", sampleRate, |
| 81 AudioUtilities::minAudioBufferSampleRate(), | 84 AudioUtilities::minAudioBufferSampleRate(), |
| 82 ExceptionMessages::InclusiveBound, | 85 ExceptionMessages::InclusiveBound, |
| 83 AudioUtilities::maxAudioBufferSampleRate(), | 86 AudioUtilities::maxAudioBufferSampleRate(), |
| 84 ExceptionMessages::InclusiveBound)); | 87 ExceptionMessages::InclusiveBound)); |
| 85 return nullptr; | 88 return nullptr; |
| 86 } | 89 } |
| 87 | 90 |
| 88 OfflineAudioContext* audioContext = new OfflineAudioContext( | 91 OfflineAudioContext* audioContext = new OfflineAudioContext( |
| 89 document, numberOfChannels, numberOfFrames, sampleRate, exceptionState); | 92 document, numberOfChannels, numberOfFrames, sampleRate, exceptionState); |
| 90 | 93 |
| 91 if (!audioContext->destination()) { | 94 if (!audioContext->destination()) { |
| 92 exceptionState.throwDOMException( | 95 exceptionState.throwDOMException( |
| 93 NotSupportedError, "OfflineAudioContext(" + | 96 NotSupportedError, "OfflineAudioContext(" + |
| 94 String::number(numberOfChannels) + ", " + | 97 String::number(numberOfChannels) + ", " + |
| 95 String::number(numberOfFrames) + ", " + | 98 String::number(numberOfFrames) + ", " + |
| 96 String::number(sampleRate) + ")"); | 99 String::number(sampleRate) + ")"); |
| 100 return nullptr; |
| 97 } | 101 } |
| 98 | 102 |
| 99 #if DEBUG_AUDIONODE_REFERENCES | 103 #if DEBUG_AUDIONODE_REFERENCES |
| 100 fprintf(stderr, "[%16p]: OfflineAudioContext::OfflineAudioContext()\n", | 104 fprintf(stderr, "[%16p]: OfflineAudioContext::OfflineAudioContext()\n", |
| 101 audioContext); | 105 audioContext); |
| 102 #endif | 106 #endif |
| 103 DEFINE_STATIC_LOCAL(SparseHistogram, offlineContextChannelCountHistogram, | 107 DEFINE_STATIC_LOCAL(SparseHistogram, offlineContextChannelCountHistogram, |
| 104 ("WebAudio.OfflineAudioContext.ChannelCount")); | 108 ("WebAudio.OfflineAudioContext.ChannelCount")); |
| 105 // Arbitrarly limit the maximum length to 1 million frames (about 20 sec | 109 // Arbitrarly limit the maximum length to 1 million frames (about 20 sec |
| 106 // at 48kHz). The number of buckets is fairly arbitrary. | 110 // at 48kHz). The number of buckets is fairly arbitrary. |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 | 447 |
| 444 // Note that the GraphLock is required before this check. Since this needs | 448 // Note that the GraphLock is required before this check. Since this needs |
| 445 // to run on the audio thread, OfflineGraphAutoLocker must be used. | 449 // to run on the audio thread, OfflineGraphAutoLocker must be used. |
| 446 if (m_scheduledSuspends.contains(currentSampleFrame())) | 450 if (m_scheduledSuspends.contains(currentSampleFrame())) |
| 447 return true; | 451 return true; |
| 448 | 452 |
| 449 return false; | 453 return false; |
| 450 } | 454 } |
| 451 | 455 |
| 452 } // namespace blink | 456 } // namespace blink |
| OLD | NEW |