Chromium Code Reviews| 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 67 PassRefPtr<SecurityOrigin>); | 67 PassRefPtr<SecurityOrigin>); |
| 68 | 68 |
| 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. |
| 78 // the WebAudio rendering pipe line on the web thread. | 78 void RequestRender(size_t frames_requested, |
| 79 void RequestRenderOnWebThread(size_t frames_requested, | 79 size_t frames_to_render, |
| 80 size_t frames_to_render, | 80 double delay, |
| 81 double delay, | 81 double delay_timestamp, |
| 82 double delay_timestamp, | 82 size_t prior_frames_skipped); |
| 83 size_t prior_frames_skipped); | |
| 84 | 83 |
| 85 virtual void Start(); | 84 virtual void Start(); |
| 86 virtual void Stop(); | 85 virtual void Stop(); |
| 87 | 86 |
| 88 // Getters must be accessed from the main thread. | 87 // Getters must be accessed from the main thread. |
| 89 size_t CallbackBufferSize() const; | 88 size_t CallbackBufferSize() const; |
| 90 bool IsPlaying(); | 89 bool IsPlaying(); |
| 91 | 90 |
| 92 // TODO(hongchan): this should not be called by the rendering thread. | 91 // TODO(hongchan): this should not be called by the rendering thread. |
| 93 double SampleRate() const { return web_audio_device_->SampleRate(); } | 92 double SampleRate() const { return web_audio_device_->SampleRate(); } |
| 94 | 93 |
| 95 // Returns the audio buffer size in frames used by the underlying audio | 94 // Returns the audio buffer size in frames used by the underlying audio |
| 96 // hardware. | 95 // hardware. |
| 97 int FramesPerBuffer() const; | 96 int FramesPerBuffer() const; |
| 98 | 97 |
| 98 bool IsAudioWorkletEnabled() const { return is_audio_worklet_enabled; } | |
| 99 | |
| 99 // The information from the actual audio hardware. (via Platform::current) | 100 // The information from the actual audio hardware. (via Platform::current) |
| 100 static float HardwareSampleRate(); | 101 static float HardwareSampleRate(); |
| 101 static unsigned long MaxChannelCount(); | 102 static unsigned long MaxChannelCount(); |
| 102 | 103 |
| 103 private: | 104 private: |
| 104 // Check if the buffer size chosen by the WebAudioDevice is too large. | 105 // Check if the buffer size chosen by the WebAudioDevice is too large. |
| 105 bool CheckBufferSize(); | 106 bool CheckBufferSize(); |
| 106 | 107 |
| 107 size_t HardwareBufferSize(); | 108 size_t HardwareBufferSize(); |
| 108 | 109 |
| 109 bool IsRenderingThread(); | |
| 110 | |
| 111 // Accessed by the main thread. | 110 // Accessed by the main thread. |
| 112 std::unique_ptr<WebAudioDevice> web_audio_device_; | 111 std::unique_ptr<WebAudioDevice> web_audio_device_; |
| 113 const unsigned number_of_output_channels_; | 112 const unsigned number_of_output_channels_; |
| 114 size_t callback_buffer_size_; | 113 size_t callback_buffer_size_; |
| 115 bool is_playing_; | 114 bool is_playing_; |
| 116 | 115 |
| 117 // Accessed by the device thread. Rendering thread for WebAudio graph. | 116 // Accessed by the device thread. Rendering thread for WebAudio graph. |
| 118 std::unique_ptr<WebThread> rendering_thread_; | 117 std::unique_ptr<WebThread> rendering_thread_; |
| 119 | 118 |
| 120 // Accessed by both threads: resolves the buffer size mismatch between the | 119 // Accessed by both threads: resolves the buffer size mismatch between the |
| 121 // WebAudio engine and the callback function from the actual audio device. | 120 // WebAudio engine and the callback function from the actual audio device. |
| 122 std::unique_ptr<PushPullFIFO> fifo_; | 121 std::unique_ptr<PushPullFIFO> fifo_; |
| 123 | 122 |
| 124 // Accessed by device thread: to pass the data from FIFO to the device. | 123 // Accessed by device thread: to pass the data from FIFO to the device. |
| 125 RefPtr<AudioBus> output_bus_; | 124 RefPtr<AudioBus> output_bus_; |
| 126 | 125 |
| 127 // Accessed by rendering thread: to push the rendered result from WebAudio | 126 // Accessed by rendering thread: to push the rendered result from WebAudio |
| 128 // graph into the FIFO. | 127 // graph into the FIFO. |
| 129 RefPtr<AudioBus> render_bus_; | 128 RefPtr<AudioBus> render_bus_; |
| 130 | 129 |
| 131 // Accessed by rendering thread: the render callback function of WebAudio | 130 // Accessed by rendering thread: the render callback function of WebAudio |
| 132 // engine. (i.e. DestinationNode) | 131 // engine. (i.e. DestinationNode) |
| 133 AudioIOCallback& callback_; | 132 AudioIOCallback& callback_; |
| 134 | 133 |
| 135 // Accessed by rendering thread. | 134 // Accessed by rendering thread. |
| 136 size_t frames_elapsed_; | 135 size_t frames_elapsed_; |
| 136 | |
| 137 // For signle thread rendering pipe line. | |
|
Raymond Toy
2017/05/15 17:42:24
"signle"
And the comment doesn't really explain w
| |
| 138 const bool is_audio_worklet_enabled; | |
| 137 }; | 139 }; |
| 138 | 140 |
| 139 } // namespace blink | 141 } // namespace blink |
| 140 | 142 |
| 141 #endif // AudioDestination_h | 143 #endif // AudioDestination_h |
| OLD | NEW |