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