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

Side by Side Diff: content/renderer/media/audio_device.cc

Issue 8980008: Integrate HTMLMediaElement with Web Audio API's MediaElementAudioSourceNode (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/media/audio_device.h" 5 #include "content/renderer/media/audio_device.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/time.h" 10 #include "base/time.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 } 53 }
54 54
55 void AudioDevice::Initialize(size_t buffer_size, 55 void AudioDevice::Initialize(size_t buffer_size,
56 int channels, 56 int channels,
57 double sample_rate, 57 double sample_rate,
58 AudioParameters::Format latency_format, 58 AudioParameters::Format latency_format,
59 RenderCallback* callback) { 59 RenderCallback* callback) {
60 CHECK_EQ(0, stream_id_) << 60 CHECK_EQ(0, stream_id_) <<
61 "AudioDevice::Initialize() must be called before Start()"; 61 "AudioDevice::Initialize() must be called before Start()";
62 62
63 if (is_initialized_)
64 return;
tommi (sloooow) - chröme 2011/12/19 15:26:24 maybe log a warning/error? If ever we call Initia
Chris Rogers 2011/12/19 21:40:35 Agreed, I've added a DCHECK On 2011/12/19 15:26:2
65
63 buffer_size_ = buffer_size; 66 buffer_size_ = buffer_size;
64 channels_ = channels; 67 channels_ = channels;
65 sample_rate_ = sample_rate; 68 sample_rate_ = sample_rate;
66 latency_format_ = latency_format; 69 latency_format_ = latency_format;
67 callback_ = callback; 70 callback_ = callback;
68 71
69 // Cleanup from any previous initialization. 72 // Cleanup from any previous initialization.
70 for (size_t i = 0; i < audio_data_.size(); ++i) 73 for (size_t i = 0; i < audio_data_.size(); ++i)
71 delete [] audio_data_[i]; 74 delete [] audio_data_[i];
72 75
73 audio_data_.reserve(channels); 76 audio_data_.reserve(channels);
74 for (int i = 0; i < channels; ++i) { 77 for (int i = 0; i < channels; ++i) {
75 float* channel_data = new float[buffer_size]; 78 float* channel_data = new float[buffer_size];
76 audio_data_.push_back(channel_data); 79 audio_data_.push_back(channel_data);
77 } 80 }
78 81
79 is_initialized_ = true; 82 is_initialized_ = true;
80 } 83 }
81 84
82 bool AudioDevice::IsInitialized() {
83 return is_initialized_;
84 }
85
86 AudioDevice::~AudioDevice() { 85 AudioDevice::~AudioDevice() {
87 // The current design requires that the user calls Stop() before deleting 86 // The current design requires that the user calls Stop() before deleting
88 // this class. 87 // this class.
89 CHECK_EQ(0, stream_id_); 88 CHECK_EQ(0, stream_id_);
90 for (int i = 0; i < channels_; ++i) 89 for (int i = 0; i < channels_; ++i)
91 delete [] audio_data_[i]; 90 delete [] audio_data_[i];
92 } 91 }
93 92
94 void AudioDevice::Start() { 93 void AudioDevice::Start() {
95 AudioParameters params; 94 AudioParameters params;
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 if (audio_thread_.get()) { 334 if (audio_thread_.get()) {
336 // Close the socket handler to terminate the main thread function in the 335 // Close the socket handler to terminate the main thread function in the
337 // audio thread. 336 // audio thread.
338 { 337 {
339 base::SyncSocket socket(socket_handle_); 338 base::SyncSocket socket(socket_handle_);
340 } 339 }
341 audio_thread_->Join(); 340 audio_thread_->Join();
342 audio_thread_.reset(NULL); 341 audio_thread_.reset(NULL);
343 } 342 }
344 } 343 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698