| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 new AudioDestination(callback, number_of_output_channels, latency_hint, | 60 new AudioDestination(callback, number_of_output_channels, latency_hint, |
| 61 std::move(security_origin))); | 61 std::move(security_origin))); |
| 62 } | 62 } |
| 63 | 63 |
| 64 AudioDestination::AudioDestination(AudioIOCallback& callback, | 64 AudioDestination::AudioDestination(AudioIOCallback& callback, |
| 65 unsigned number_of_output_channels, | 65 unsigned number_of_output_channels, |
| 66 const WebAudioLatencyHint& latency_hint, | 66 const WebAudioLatencyHint& latency_hint, |
| 67 PassRefPtr<SecurityOrigin> security_origin) | 67 PassRefPtr<SecurityOrigin> security_origin) |
| 68 : number_of_output_channels_(number_of_output_channels), | 68 : number_of_output_channels_(number_of_output_channels), |
| 69 is_playing_(false), | 69 is_playing_(false), |
| 70 rendering_thread_( | 70 rendering_thread_(WTF::WrapUnique( |
| 71 Platform::Current()->CreateThread("WebAudio Rendering Thread")), | 71 Platform::Current()->CreateThread("WebAudio Rendering Thread"))), |
| 72 fifo_(WTF::WrapUnique( | 72 fifo_(WTF::WrapUnique( |
| 73 new PushPullFIFO(number_of_output_channels, kFIFOSize))), | 73 new PushPullFIFO(number_of_output_channels, kFIFOSize))), |
| 74 output_bus_(AudioBus::Create(number_of_output_channels, | 74 output_bus_(AudioBus::Create(number_of_output_channels, |
| 75 AudioUtilities::kRenderQuantumFrames, | 75 AudioUtilities::kRenderQuantumFrames, |
| 76 false)), | 76 false)), |
| 77 render_bus_(AudioBus::Create(number_of_output_channels, | 77 render_bus_(AudioBus::Create(number_of_output_channels, |
| 78 AudioUtilities::kRenderQuantumFrames)), | 78 AudioUtilities::kRenderQuantumFrames)), |
| 79 callback_(callback), | 79 callback_(callback), |
| 80 frames_elapsed_(0) { | 80 frames_elapsed_(0) { |
| 81 // Create WebAudioDevice. blink::WebAudioDevice is designed to support the | 81 // Create WebAudioDevice. blink::WebAudioDevice is designed to support the |
| 82 // local input (e.g. loopback from OS audio system), but Chromium's media | 82 // local input (e.g. loopback from OS audio system), but Chromium's media |
| 83 // renderer does not support it currently. Thus, we use zero for the number | 83 // renderer does not support it currently. Thus, we use zero for the number |
| 84 // of input channels. | 84 // of input channels. |
| 85 web_audio_device_ = Platform::Current()->CreateAudioDevice( | 85 web_audio_device_ = WTF::WrapUnique(Platform::Current()->CreateAudioDevice( |
| 86 0, number_of_output_channels, latency_hint, this, String(), | 86 0, number_of_output_channels, latency_hint, this, String(), |
| 87 std::move(security_origin)); | 87 std::move(security_origin))); |
| 88 DCHECK(web_audio_device_); | 88 DCHECK(web_audio_device_); |
| 89 | 89 |
| 90 callback_buffer_size_ = web_audio_device_->FramesPerBuffer(); | 90 callback_buffer_size_ = web_audio_device_->FramesPerBuffer(); |
| 91 if (!CheckBufferSize()) { | 91 if (!CheckBufferSize()) { |
| 92 NOTREACHED(); | 92 NOTREACHED(); |
| 93 } | 93 } |
| 94 } | 94 } |
| 95 | 95 |
| 96 AudioDestination::~AudioDestination() { | 96 AudioDestination::~AudioDestination() { |
| 97 Stop(); | 97 Stop(); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 DCHECK(is_buffer_size_valid); | 218 DCHECK(is_buffer_size_valid); |
| 219 return is_buffer_size_valid; | 219 return is_buffer_size_valid; |
| 220 } | 220 } |
| 221 | 221 |
| 222 bool AudioDestination::IsRenderingThread() { | 222 bool AudioDestination::IsRenderingThread() { |
| 223 return static_cast<ThreadIdentifier>(rendering_thread_->ThreadId()) == | 223 return static_cast<ThreadIdentifier>(rendering_thread_->ThreadId()) == |
| 224 CurrentThread(); | 224 CurrentThread(); |
| 225 } | 225 } |
| 226 | 226 |
| 227 } // namespace blink | 227 } // namespace blink |
| OLD | NEW |