Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(624)

Side by Side Diff: third_party/WebKit/Source/platform/audio/AudioDestination.h

Issue 2854463002: Fix data race in AudioDestination.cpp (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 RequestRenderOnWebThread(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();
86 virtual void Stop(); 86 virtual void Stop();
87 87
88 size_t CallbackBufferSize() const { return callback_buffer_size_; } 88 size_t CallbackBufferSize() const { return callback_buffer_size_; }
nhiroki 2017/05/01 01:56:39 |callback_buffer_size_| must be accessed by the ma
hongchan 2017/05/01 16:43:08 Done.
89 bool IsPlaying() { return is_playing_; } 89 bool IsPlaying() { return is_playing_; }
nhiroki 2017/05/01 01:56:39 ditto.
hongchan 2017/05/01 16:43:08 Done.
90 90
91 double SampleRate() const { return web_audio_device_->SampleRate(); } 91 double SampleRate() const { return web_audio_device_->SampleRate(); }
nhiroki 2017/05/01 01:56:39 ditto.
hongchan 2017/05/01 16:43:08 Done.
92 92
93 // Returns the audio buffer size in frames used by the underlying audio 93 // Returns the audio buffer size in frames used by the underlying audio
94 // hardware. 94 // hardware.
95 int FramesPerBuffer() const { return web_audio_device_->FramesPerBuffer(); } 95 int FramesPerBuffer() const { return web_audio_device_->FramesPerBuffer(); }
nhiroki 2017/05/01 01:56:39 ditto.
hongchan 2017/05/01 16:43:08 Done.
96 96
97 // The information from the actual audio hardware. (via Platform::current) 97 // The information from the actual audio hardware. (via Platform::current)
98 static float HardwareSampleRate(); 98 static float HardwareSampleRate();
99 static unsigned long MaxChannelCount(); 99 static unsigned long MaxChannelCount();
100 100
101 private: 101 private:
102 // Check if the buffer size chosen by the WebAudioDevice is too large. 102 // Check if the buffer size chosen by the WebAudioDevice is too large.
103 bool CheckBufferSize(); 103 bool CheckBufferSize();
104 104
105 size_t HardwareBufferSize(); 105 size_t HardwareBufferSize();
106 106
107 bool IsRenderingThread(); 107 bool IsRenderingThread();
108 108
109 // Accessed by the main thread.
109 std::unique_ptr<WebAudioDevice> web_audio_device_; 110 std::unique_ptr<WebAudioDevice> web_audio_device_;
110 const unsigned number_of_output_channels_; 111 const unsigned number_of_output_channels_;
111 size_t callback_buffer_size_; 112 size_t callback_buffer_size_;
112 bool is_playing_; 113 bool is_playing_;
113 114
114 // Rendering thread for WebAudio graph. 115 // Accessed by device and rendering threads: resolves the buffer size mismatch
116 // between the WebAudio engine and the callback function from the actual audio
117 // device.
118 std::unique_ptr<PushPullFIFO> fifo_;
119
120 // Accessed by the device thread. Rendering thread for WebAudio graph.
115 std::unique_ptr<WebThread> rendering_thread_; 121 std::unique_ptr<WebThread> rendering_thread_;
116 122
117 // Accessed by both threads: resolves the buffer size mismatch between the
118 // WebAudio engine and the callback function from the actual audio device.
119 std::unique_ptr<PushPullFIFO> fifo_;
120
121 // 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.
122 RefPtr<AudioBus> output_bus_; 124 RefPtr<AudioBus> output_bus_;
123 125
124 // Accessed by rendering thread: to push the rendered result from WebAudio 126 // Accessed by rendering thread: to push the rendered result from WebAudio
125 // graph into the FIFO. 127 // graph into the FIFO.
126 RefPtr<AudioBus> render_bus_; 128 RefPtr<AudioBus> render_bus_;
127 129
128 // Accessed by rendering thread: the render callback function of WebAudio 130 // Accessed by rendering thread: the render callback function of WebAudio
129 // engine. (i.e. DestinationNode) 131 // engine. (i.e. DestinationNode)
130 AudioIOCallback& callback_; 132 AudioIOCallback& callback_;
131 133
132 // Accessed by rendering thread. 134 // Accessed by rendering thread.
133 size_t frames_elapsed_; 135 size_t frames_elapsed_;
134 }; 136 };
135 137
136 } // namespace blink 138 } // namespace blink
137 139
138 #endif // AudioDestination_h 140 #endif // AudioDestination_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698