| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 // Must be called on the main thread. | 49 // Must be called on the main thread. |
| 50 void decodeAsync(ArrayBuffer* audioData, float sampleRate, PassRefPtr<AudioB
ufferCallback> successCallback, PassRefPtr<AudioBufferCallback> errorCallback); | 50 void decodeAsync(ArrayBuffer* audioData, float sampleRate, PassRefPtr<AudioB
ufferCallback> successCallback, PassRefPtr<AudioBufferCallback> errorCallback); |
| 51 | 51 |
| 52 private: | 52 private: |
| 53 class DecodingTask { | 53 class DecodingTask { |
| 54 WTF_MAKE_NONCOPYABLE(DecodingTask); | 54 WTF_MAKE_NONCOPYABLE(DecodingTask); |
| 55 public: | 55 public: |
| 56 static PassOwnPtr<DecodingTask> create(ArrayBuffer* audioData, float sam
pleRate, PassRefPtr<AudioBufferCallback> successCallback, PassRefPtr<AudioBuffer
Callback> errorCallback); | 56 static PassOwnPtr<DecodingTask> create(ArrayBuffer* audioData, float sam
pleRate, PassRefPtr<AudioBufferCallback> successCallback, PassRefPtr<AudioBuffer
Callback> errorCallback); |
| 57 | 57 |
| 58 void decode(); | 58 void decode(); |
| 59 | 59 |
| 60 private: | 60 private: |
| 61 DecodingTask(ArrayBuffer* audioData, float sampleRate, PassRefPtr<AudioB
ufferCallback> successCallback, PassRefPtr<AudioBufferCallback> errorCallback); | 61 DecodingTask(ArrayBuffer* audioData, float sampleRate, PassRefPtr<AudioB
ufferCallback> successCallback, PassRefPtr<AudioBufferCallback> errorCallback); |
| 62 | 62 |
| 63 ArrayBuffer* audioData() { return m_audioData.get(); } | 63 ArrayBuffer* audioData() { return m_audioData.get(); } |
| 64 float sampleRate() const { return m_sampleRate; } | 64 float sampleRate() const { return m_sampleRate; } |
| 65 AudioBufferCallback* successCallback() { return m_successCallback.get();
} | 65 AudioBufferCallback* successCallback() { return m_successCallback.get();
} |
| 66 AudioBufferCallback* errorCallback() { return m_errorCallback.get(); } | 66 AudioBufferCallback* errorCallback() { return m_errorCallback.get(); } |
| 67 AudioBuffer* audioBuffer() { return m_audioBuffer.get(); } | 67 AudioBuffer* audioBuffer() { return m_audioBuffer.get(); } |
| 68 | 68 |
| 69 static void notifyCompleteDispatch(void* userData); | 69 static void notifyCompleteDispatch(void* userData); |
| 70 void notifyComplete(); | 70 void notifyComplete(); |
| 71 | 71 |
| 72 RefPtr<ArrayBuffer> m_audioData; | 72 RefPtr<ArrayBuffer> m_audioData; |
| 73 float m_sampleRate; | 73 float m_sampleRate; |
| 74 RefPtr<AudioBufferCallback> m_successCallback; | 74 RefPtr<AudioBufferCallback> m_successCallback; |
| 75 RefPtr<AudioBufferCallback> m_errorCallback; | 75 RefPtr<AudioBufferCallback> m_errorCallback; |
| 76 RefPtr<AudioBuffer> m_audioBuffer; | 76 RefPtr<AudioBuffer> m_audioBuffer; |
| 77 }; | 77 }; |
| 78 | 78 |
| 79 static void threadEntry(void* threadData); | 79 static void threadEntry(void* threadData); |
| 80 void runLoop(); | 80 void runLoop(); |
| 81 | 81 |
| 82 WTF::ThreadIdentifier m_threadID; | 82 WTF::ThreadIdentifier m_threadID; |
| 83 Mutex m_threadCreationMutex; | 83 Mutex m_threadCreationMutex; |
| 84 MessageQueue<DecodingTask> m_queue; | 84 MessageQueue<DecodingTask> m_queue; |
| 85 }; | 85 }; |
| 86 | 86 |
| 87 } // namespace WebCore | 87 } // namespace WebCore |
| 88 | 88 |
| 89 #endif // AsyncAudioDecoder_h | 89 #endif // AsyncAudioDecoder_h |
| OLD | NEW |