| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 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 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 #include "platform/wtf/Noncopyable.h" | 36 #include "platform/wtf/Noncopyable.h" |
| 37 #include "platform/wtf/text/WTFString.h" | 37 #include "platform/wtf/text/WTFString.h" |
| 38 #include "public/platform/WebAudioDevice.h" | 38 #include "public/platform/WebAudioDevice.h" |
| 39 #include "public/platform/WebVector.h" | 39 #include "public/platform/WebVector.h" |
| 40 | 40 |
| 41 namespace blink { | 41 namespace blink { |
| 42 | 42 |
| 43 class PushPullFIFO; | 43 class PushPullFIFO; |
| 44 class SecurityOrigin; | 44 class SecurityOrigin; |
| 45 class WebAudioLatencyHint; | 45 class WebAudioLatencyHint; |
| 46 class WebThread; | 46 class WebThreadSupportingGC; |
| 47 | 47 |
| 48 // The AudioDestination class is an audio sink interface between the media | 48 // The AudioDestination class is an audio sink interface between the media |
| 49 // renderer and the Blink's WebAudio module. It has a FIFO to adapt the | 49 // renderer and the Blink's WebAudio module. It has a FIFO to adapt the |
| 50 // different processing block sizes of WebAudio renderer and actual hardware | 50 // different processing block sizes of WebAudio renderer and actual hardware |
| 51 // audio callback. | 51 // audio callback. |
| 52 class PLATFORM_EXPORT AudioDestination : public WebAudioDevice::RenderCallback { | 52 class PLATFORM_EXPORT AudioDestination : public WebAudioDevice::RenderCallback { |
| 53 USING_FAST_MALLOC(AudioDestination); | 53 USING_FAST_MALLOC(AudioDestination); |
| 54 WTF_MAKE_NONCOPYABLE(AudioDestination); | 54 WTF_MAKE_NONCOPYABLE(AudioDestination); |
| 55 | 55 |
| 56 public: | 56 public: |
| (...skipping 12 matching lines...) Expand all Loading... |
| 69 // The actual render function (WebAudioDevice::RenderCallback) isochronously | 69 // The actual render function (WebAudioDevice::RenderCallback) isochronously |
| 70 // invoked by the media renderer. | 70 // invoked by the media renderer. |
| 71 void Render(const WebVector<float*>& destination_data, | 71 void Render(const WebVector<float*>& destination_data, |
| 72 size_t number_of_frames, | 72 size_t number_of_frames, |
| 73 double delay, | 73 double delay, |
| 74 double delay_timestamp, | 74 double delay_timestamp, |
| 75 size_t prior_frames_skipped) override; | 75 size_t prior_frames_skipped) override; |
| 76 | 76 |
| 77 // The actual render request to the WebAudio destination node. This triggers | 77 // The actual render request to the WebAudio destination node. This triggers |
| 78 // the WebAudio rendering pipe line on the web thread. | 78 // the WebAudio rendering pipe line on the web thread. |
| 79 void RequestRenderOnWebThread(size_t frames_requested, | 79 void RequestRenderOnWorkerThread(size_t frames_requested, |
| 80 size_t frames_to_render, | 80 size_t frames_to_render, |
| 81 double delay, | 81 double delay, |
| 82 double delay_timestamp, | 82 double delay_timestamp, |
| 83 size_t prior_frames_skipped); | 83 size_t prior_frames_skipped); |
| 84 | 84 |
| 85 virtual void Start(); | 85 virtual void Start(WebThreadSupportingGC*); |
| 86 virtual void Stop(); | 86 virtual void Stop(); |
| 87 | 87 |
| 88 // Getters must be accessed from the main thread. | 88 // Getters must be accessed from the main thread. |
| 89 size_t CallbackBufferSize() const; | 89 size_t CallbackBufferSize() const; |
| 90 bool IsPlaying(); | 90 bool IsPlaying(); |
| 91 | 91 |
| 92 // TODO(hongchan): this should not be called by the rendering thread. | 92 // TODO(hongchan): this should not be called by the rendering thread. |
| 93 double SampleRate() const { return web_audio_device_->SampleRate(); } | 93 double SampleRate() const { return web_audio_device_->SampleRate(); } |
| 94 | 94 |
| 95 // Returns the audio buffer size in frames used by the underlying audio | 95 // Returns the audio buffer size in frames used by the underlying audio |
| (...skipping 12 matching lines...) Expand all Loading... |
| 108 | 108 |
| 109 bool IsRenderingThread(); | 109 bool IsRenderingThread(); |
| 110 | 110 |
| 111 // Accessed by the main thread. | 111 // Accessed by the main thread. |
| 112 std::unique_ptr<WebAudioDevice> web_audio_device_; | 112 std::unique_ptr<WebAudioDevice> web_audio_device_; |
| 113 const unsigned number_of_output_channels_; | 113 const unsigned number_of_output_channels_; |
| 114 size_t callback_buffer_size_; | 114 size_t callback_buffer_size_; |
| 115 bool is_playing_; | 115 bool is_playing_; |
| 116 | 116 |
| 117 // Accessed by the device thread. Rendering thread for WebAudio graph. | 117 // Accessed by the device thread. Rendering thread for WebAudio graph. |
| 118 std::unique_ptr<WebThread> rendering_thread_; | 118 WebThreadSupportingGC* rendering_thread_; |
| 119 | 119 |
| 120 // Accessed by both threads: resolves the buffer size mismatch between the | 120 // Accessed by both threads: resolves the buffer size mismatch between the |
| 121 // WebAudio engine and the callback function from the actual audio device. | 121 // WebAudio engine and the callback function from the actual audio device. |
| 122 std::unique_ptr<PushPullFIFO> fifo_; | 122 std::unique_ptr<PushPullFIFO> fifo_; |
| 123 | 123 |
| 124 // Accessed by device thread: to pass the data from FIFO to the device. | 124 // Accessed by device thread: to pass the data from FIFO to the device. |
| 125 RefPtr<AudioBus> output_bus_; | 125 RefPtr<AudioBus> output_bus_; |
| 126 | 126 |
| 127 // Accessed by rendering thread: to push the rendered result from WebAudio | 127 // Accessed by rendering thread: to push the rendered result from WebAudio |
| 128 // graph into the FIFO. | 128 // graph into the FIFO. |
| 129 RefPtr<AudioBus> render_bus_; | 129 RefPtr<AudioBus> render_bus_; |
| 130 | 130 |
| 131 // Accessed by rendering thread: the render callback function of WebAudio | 131 // Accessed by rendering thread: the render callback function of WebAudio |
| 132 // engine. (i.e. DestinationNode) | 132 // engine. (i.e. DestinationNode) |
| 133 AudioIOCallback& callback_; | 133 AudioIOCallback& callback_; |
| 134 | 134 |
| 135 // Accessed by rendering thread. | 135 // Accessed by rendering thread. |
| 136 size_t frames_elapsed_; | 136 size_t frames_elapsed_; |
| 137 }; | 137 }; |
| 138 | 138 |
| 139 } // namespace blink | 139 } // namespace blink |
| 140 | 140 |
| 141 #endif // AudioDestination_h | 141 #endif // AudioDestination_h |
| OLD | NEW |