| 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 16 matching lines...) Expand all Loading... |
| 27 #define AsyncAudioDecoder_h | 27 #define AsyncAudioDecoder_h |
| 28 | 28 |
| 29 #include <memory> | 29 #include <memory> |
| 30 #include "platform/heap/Handle.h" | 30 #include "platform/heap/Handle.h" |
| 31 #include "platform/wtf/build_config.h" | 31 #include "platform/wtf/build_config.h" |
| 32 | 32 |
| 33 namespace blink { | 33 namespace blink { |
| 34 | 34 |
| 35 class BaseAudioContext; | 35 class BaseAudioContext; |
| 36 class AudioBuffer; | 36 class AudioBuffer; |
| 37 class AudioBufferCallback; |
| 37 class AudioBus; | 38 class AudioBus; |
| 38 class DecodeErrorCallback; | |
| 39 class DecodeSuccessCallback; | |
| 40 class DOMArrayBuffer; | 39 class DOMArrayBuffer; |
| 41 class ScriptPromiseResolver; | 40 class ScriptPromiseResolver; |
| 42 | 41 |
| 43 // AsyncAudioDecoder asynchronously decodes audio file data from a | 42 // AsyncAudioDecoder asynchronously decodes audio file data from a |
| 44 // DOMArrayBuffer in the background thread. Upon successful decoding, a | 43 // DOMArrayBuffer in the background thread. Upon successful decoding, a |
| 45 // completion callback will be invoked with the decoded PCM data in an | 44 // completion callback will be invoked with the decoded PCM data in an |
| 46 // AudioBuffer. | 45 // AudioBuffer. |
| 47 | 46 |
| 48 class AsyncAudioDecoder { | 47 class AsyncAudioDecoder { |
| 49 DISALLOW_NEW(); | 48 DISALLOW_NEW(); |
| 50 WTF_MAKE_NONCOPYABLE(AsyncAudioDecoder); | 49 WTF_MAKE_NONCOPYABLE(AsyncAudioDecoder); |
| 51 | 50 |
| 52 public: | 51 public: |
| 53 AsyncAudioDecoder(){}; | 52 AsyncAudioDecoder(){}; |
| 54 ~AsyncAudioDecoder(){}; | 53 ~AsyncAudioDecoder(){}; |
| 55 | 54 |
| 56 // Must be called on the main thread. |decodeAsync| and callees must not | 55 // Must be called on the main thread. |decodeAsync| and callees must not |
| 57 // modify any of the parameters except |audioData|. They are used to | 56 // modify any of the parameters except |audioData|. They are used to |
| 58 // associate this decoding instance with the caller to process the decoding | 57 // associate this decoding instance with the caller to process the decoding |
| 59 // appropriately when finished. | 58 // appropriately when finished. |
| 60 void DecodeAsync(DOMArrayBuffer* audio_data, | 59 void DecodeAsync(DOMArrayBuffer* audio_data, |
| 61 float sample_rate, | 60 float sample_rate, |
| 62 DecodeSuccessCallback*, | 61 AudioBufferCallback* success_callback, |
| 63 DecodeErrorCallback*, | 62 AudioBufferCallback* error_callback, |
| 64 ScriptPromiseResolver*, | 63 ScriptPromiseResolver*, |
| 65 BaseAudioContext*); | 64 BaseAudioContext*); |
| 66 | 65 |
| 67 private: | 66 private: |
| 68 AudioBuffer* CreateAudioBufferFromAudioBus(AudioBus*); | 67 AudioBuffer* CreateAudioBufferFromAudioBus(AudioBus*); |
| 69 static void DecodeOnBackgroundThread(DOMArrayBuffer* audio_data, | 68 static void DecodeOnBackgroundThread(DOMArrayBuffer* audio_data, |
| 70 float sample_rate, | 69 float sample_rate, |
| 71 DecodeSuccessCallback*, | 70 AudioBufferCallback* success_callback, |
| 72 DecodeErrorCallback*, | 71 AudioBufferCallback* error_callback, |
| 73 ScriptPromiseResolver*, | 72 ScriptPromiseResolver*, |
| 74 BaseAudioContext*); | 73 BaseAudioContext*); |
| 75 static void NotifyComplete(DOMArrayBuffer* audio_data, | 74 static void NotifyComplete(DOMArrayBuffer* audio_data, |
| 76 DecodeSuccessCallback*, | 75 AudioBufferCallback* success_callback, |
| 77 DecodeErrorCallback*, | 76 AudioBufferCallback* error_callback, |
| 78 AudioBus*, | 77 AudioBus*, |
| 79 ScriptPromiseResolver*, | 78 ScriptPromiseResolver*, |
| 80 BaseAudioContext*); | 79 BaseAudioContext*); |
| 81 }; | 80 }; |
| 82 | 81 |
| 83 } // namespace blink | 82 } // namespace blink |
| 84 | 83 |
| 85 #endif // AsyncAudioDecoder_h | 84 #endif // AsyncAudioDecoder_h |
| OLD | NEW |