| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   73                                    AudioUtilities::kRenderQuantumFrames, |   73                                    AudioUtilities::kRenderQuantumFrames, | 
|   74                                    false)), |   74                                    false)), | 
|   75       render_bus_(AudioBus::Create(number_of_output_channels, |   75       render_bus_(AudioBus::Create(number_of_output_channels, | 
|   76                                    AudioUtilities::kRenderQuantumFrames)), |   76                                    AudioUtilities::kRenderQuantumFrames)), | 
|   77       callback_(callback), |   77       callback_(callback), | 
|   78       frames_elapsed_(0) { |   78       frames_elapsed_(0) { | 
|   79   // Create WebAudioDevice. blink::WebAudioDevice is designed to support the |   79   // Create WebAudioDevice. blink::WebAudioDevice is designed to support the | 
|   80   // local input (e.g. loopback from OS audio system), but Chromium's media |   80   // local input (e.g. loopback from OS audio system), but Chromium's media | 
|   81   // renderer does not support it currently. Thus, we use zero for the number |   81   // renderer does not support it currently. Thus, we use zero for the number | 
|   82   // of input channels. |   82   // of input channels. | 
|   83   web_audio_device_ = WTF::WrapUnique(Platform::Current()->CreateAudioDevice( |   83   web_audio_device_ = Platform::Current()->CreateAudioDevice( | 
|   84       0, number_of_output_channels, latency_hint, this, String(), |   84       0, number_of_output_channels, latency_hint, this, String(), | 
|   85       std::move(security_origin))); |   85       std::move(security_origin)); | 
|   86   DCHECK(web_audio_device_); |   86   DCHECK(web_audio_device_); | 
|   87  |   87  | 
|   88   callback_buffer_size_ = web_audio_device_->FramesPerBuffer(); |   88   callback_buffer_size_ = web_audio_device_->FramesPerBuffer(); | 
|   89   if (!CheckBufferSize()) { |   89   if (!CheckBufferSize()) { | 
|   90     NOTREACHED(); |   90     NOTREACHED(); | 
|   91   } |   91   } | 
|   92 } |   92 } | 
|   93  |   93  | 
|   94 AudioDestination::~AudioDestination() { |   94 AudioDestination::~AudioDestination() { | 
|   95   Stop(); |   95   Stop(); | 
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  169   } |  169   } | 
|  170  |  170  | 
|  171   frames_elapsed_ += frames_requested; |  171   frames_elapsed_ += frames_requested; | 
|  172 } |  172 } | 
|  173  |  173  | 
|  174 void AudioDestination::Start() { |  174 void AudioDestination::Start() { | 
|  175   DCHECK(IsMainThread()); |  175   DCHECK(IsMainThread()); | 
|  176  |  176  | 
|  177   // Start the "audio device" after the rendering thread is ready. |  177   // Start the "audio device" after the rendering thread is ready. | 
|  178   if (web_audio_device_ && !is_playing_) { |  178   if (web_audio_device_ && !is_playing_) { | 
|  179     rendering_thread_ = WTF::WrapUnique( |  179     rendering_thread_ = | 
|  180         Platform::Current()->CreateThread("WebAudio Rendering Thread")); |  180         Platform::Current()->CreateThread("WebAudio Rendering Thread"); | 
|  181     web_audio_device_->Start(); |  181     web_audio_device_->Start(); | 
|  182     is_playing_ = true; |  182     is_playing_ = true; | 
|  183   } |  183   } | 
|  184 } |  184 } | 
|  185  |  185  | 
|  186 void AudioDestination::Stop() { |  186 void AudioDestination::Stop() { | 
|  187   DCHECK(IsMainThread()); |  187   DCHECK(IsMainThread()); | 
|  188  |  188  | 
|  189   // This assumes stopping the "audio device" is synchronous and dumping the |  189   // This assumes stopping the "audio device" is synchronous and dumping the | 
|  190   // rendering thread is safe after that. |  190   // rendering thread is safe after that. | 
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  244   DCHECK(is_buffer_size_valid); |  244   DCHECK(is_buffer_size_valid); | 
|  245   return is_buffer_size_valid; |  245   return is_buffer_size_valid; | 
|  246 } |  246 } | 
|  247  |  247  | 
|  248 bool AudioDestination::IsRenderingThread() { |  248 bool AudioDestination::IsRenderingThread() { | 
|  249   return static_cast<ThreadIdentifier>(rendering_thread_->ThreadId()) == |  249   return static_cast<ThreadIdentifier>(rendering_thread_->ThreadId()) == | 
|  250          CurrentThread(); |  250          CurrentThread(); | 
|  251 } |  251 } | 
|  252  |  252  | 
|  253 }  // namespace blink |  253 }  // namespace blink | 
| OLD | NEW |