Chromium Code Reviews| 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 * 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 46 } | 46 } |
| 47 | 47 |
| 48 void AsyncAudioDecoder::decodeAsync(DOMArrayBuffer* audioData, float sampleRate, AudioBufferCallback* successCallback, AudioBufferCallback* errorCallback, Scrip tPromiseResolver* resolver, AbstractAudioContext* context) | 48 void AsyncAudioDecoder::decodeAsync(DOMArrayBuffer* audioData, float sampleRate, AudioBufferCallback* successCallback, AudioBufferCallback* errorCallback, Scrip tPromiseResolver* resolver, AbstractAudioContext* context) |
| 49 { | 49 { |
| 50 ASSERT(isMainThread()); | 50 ASSERT(isMainThread()); |
| 51 ASSERT(audioData); | 51 ASSERT(audioData); |
| 52 if (!audioData) | 52 if (!audioData) |
| 53 return; | 53 return; |
| 54 | 54 |
| 55 // The leak references to successCallback and errorCallback are picked up on notifyComplete. | 55 // The leak references to successCallback and errorCallback are picked up on notifyComplete. |
| 56 m_thread->getWebTaskRunner()->postTask(BLINK_FROM_HERE, threadSafeBind(&Asyn cAudioDecoder::decode, AllowCrossThreadAccess(audioData), sampleRate, successCal lback, errorCallback, resolver, context)); | 56 m_thread->getWebTaskRunner()->postTask(BLINK_FROM_HERE, threadSafeBind(&Asyn cAudioDecoder::decode, AllowCrossThreadAccess(audioData), sampleRate, wrapCrossT hreadPersistent(successCallback), wrapCrossThreadPersistent(errorCallback), wrap CrossThreadPersistent(resolver), wrapCrossThreadPersistent(context))); |
|
kinuko
2016/05/13 09:27:27
If it's not too much work could we break lines for
hiroshige
2016/05/13 16:47:19
I'll keep this as-is to make the changes mechanica
| |
| 57 } | 57 } |
| 58 | 58 |
| 59 void AsyncAudioDecoder::decode(DOMArrayBuffer* audioData, float sampleRate, Audi oBufferCallback* successCallback, AudioBufferCallback* errorCallback, ScriptProm iseResolver* resolver, AbstractAudioContext* context) | 59 void AsyncAudioDecoder::decode(DOMArrayBuffer* audioData, float sampleRate, Audi oBufferCallback* successCallback, AudioBufferCallback* errorCallback, ScriptProm iseResolver* resolver, AbstractAudioContext* context) |
| 60 { | 60 { |
| 61 RefPtr<AudioBus> bus = createBusFromInMemoryAudioFile(audioData->data(), aud ioData->byteLength(), false, sampleRate); | 61 RefPtr<AudioBus> bus = createBusFromInMemoryAudioFile(audioData->data(), aud ioData->byteLength(), false, sampleRate); |
| 62 | 62 |
| 63 // Decoding is finished, but we need to do the callbacks on the main thread. | 63 // Decoding is finished, but we need to do the callbacks on the main thread. |
| 64 // The leaked reference to audioBuffer is picked up in notifyComplete. | 64 // The leaked reference to audioBuffer is picked up in notifyComplete. |
| 65 Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FROM_H ERE, threadSafeBind(&AsyncAudioDecoder::notifyComplete, AllowCrossThreadAccess(a udioData), successCallback, errorCallback, bus.release().leakRef(), resolver, co ntext)); | 65 Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FROM_H ERE, threadSafeBind(&AsyncAudioDecoder::notifyComplete, AllowCrossThreadAccess(a udioData), wrapCrossThreadPersistent(successCallback), wrapCrossThreadPersistent (errorCallback), bus.release().leakRef(), wrapCrossThreadPersistent(resolver), w rapCrossThreadPersistent(context))); |
| 66 } | 66 } |
| 67 | 67 |
| 68 void AsyncAudioDecoder::notifyComplete(DOMArrayBuffer*, AudioBufferCallback* suc cessCallback, AudioBufferCallback* errorCallback, AudioBus* audioBus, ScriptProm iseResolver* resolver, AbstractAudioContext* context) | 68 void AsyncAudioDecoder::notifyComplete(DOMArrayBuffer*, AudioBufferCallback* suc cessCallback, AudioBufferCallback* errorCallback, AudioBus* audioBus, ScriptProm iseResolver* resolver, AbstractAudioContext* context) |
| 69 { | 69 { |
| 70 ASSERT(isMainThread()); | 70 ASSERT(isMainThread()); |
| 71 | 71 |
| 72 // Adopt references, so everything gets correctly dereffed. | 72 // Adopt references, so everything gets correctly dereffed. |
| 73 RefPtr<AudioBus> audioBusRef = adoptRef(audioBus); | 73 RefPtr<AudioBus> audioBusRef = adoptRef(audioBus); |
| 74 | 74 |
| 75 AudioBuffer* audioBuffer = AudioBuffer::createFromAudioBus(audioBus); | 75 AudioBuffer* audioBuffer = AudioBuffer::createFromAudioBus(audioBus); |
| 76 | 76 |
| 77 // Let the context finish the notification. | 77 // Let the context finish the notification. |
| 78 context->handleDecodeAudioData(audioBuffer, resolver, successCallback, error Callback); | 78 context->handleDecodeAudioData(audioBuffer, resolver, successCallback, error Callback); |
| 79 } | 79 } |
| 80 | 80 |
| 81 } // namespace blink | 81 } // namespace blink |
| OLD | NEW |