OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "media/audio/win/audio_unified_win.h" | 5 #include "media/audio/win/audio_unified_win.h" |
6 | 6 |
7 #include <Functiondiscoverykeys_devpkey.h> | 7 #include <Functiondiscoverykeys_devpkey.h> |
8 | 8 |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #ifndef NDEBUG | 10 #ifndef NDEBUG |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 // Create the event which will be set in Stop() when straeming shall stop. | 154 // Create the event which will be set in Stop() when straeming shall stop. |
155 stop_streaming_event_.Set(CreateEvent(NULL, FALSE, FALSE, NULL)); | 155 stop_streaming_event_.Set(CreateEvent(NULL, FALSE, FALSE, NULL)); |
156 } | 156 } |
157 | 157 |
158 WASAPIUnifiedStream::~WASAPIUnifiedStream() { | 158 WASAPIUnifiedStream::~WASAPIUnifiedStream() { |
159 VLOG(1) << "WASAPIUnifiedStream::~WASAPIUnifiedStream()"; | 159 VLOG(1) << "WASAPIUnifiedStream::~WASAPIUnifiedStream()"; |
160 #ifndef NDEBUG | 160 #ifndef NDEBUG |
161 base::FilePath data_file_name; | 161 base::FilePath data_file_name; |
162 PathService::Get(base::DIR_EXE, &data_file_name); | 162 PathService::Get(base::DIR_EXE, &data_file_name); |
163 data_file_name = data_file_name.AppendASCII(kUnifiedAudioDebugFileName); | 163 data_file_name = data_file_name.AppendASCII(kUnifiedAudioDebugFileName); |
164 data_file_ = base::OpenFile(data_file_name, "wt"); | 164 data_file_ = file_util::OpenFile(data_file_name, "wt"); |
165 DVLOG(1) << ">> Output file " << data_file_name.value() << " is created."; | 165 DVLOG(1) << ">> Output file " << data_file_name.value() << " is created."; |
166 | 166 |
167 size_t n = 0; | 167 size_t n = 0; |
168 size_t elements_to_write = *std::min_element( | 168 size_t elements_to_write = *std::min_element( |
169 num_elements_.get(), num_elements_.get() + kMaxNumSampleTypes); | 169 num_elements_.get(), num_elements_.get() + kMaxNumSampleTypes); |
170 while (n < elements_to_write) { | 170 while (n < elements_to_write) { |
171 fprintf(data_file_, "%I64d %d %d %10.9f\n", | 171 fprintf(data_file_, "%I64d %d %d %10.9f\n", |
172 input_time_stamps_[n], | 172 input_time_stamps_[n], |
173 num_frames_in_fifo_[n], | 173 num_frames_in_fifo_[n], |
174 resampler_margin_[n], | 174 resampler_margin_[n], |
175 fifo_rate_comps_[n]); | 175 fifo_rate_comps_[n]); |
176 ++n; | 176 ++n; |
177 } | 177 } |
178 base::CloseFile(data_file_); | 178 file_util::CloseFile(data_file_); |
179 | 179 |
180 base::FilePath param_file_name; | 180 base::FilePath param_file_name; |
181 PathService::Get(base::DIR_EXE, ¶m_file_name); | 181 PathService::Get(base::DIR_EXE, ¶m_file_name); |
182 param_file_name = param_file_name.AppendASCII(kUnifiedAudioParamsFileName); | 182 param_file_name = param_file_name.AppendASCII(kUnifiedAudioParamsFileName); |
183 param_file_ = base::OpenFile(param_file_name, "wt"); | 183 param_file_ = file_util::OpenFile(param_file_name, "wt"); |
184 DVLOG(1) << ">> Output file " << param_file_name.value() << " is created."; | 184 DVLOG(1) << ">> Output file " << param_file_name.value() << " is created."; |
185 fprintf(param_file_, "%d %d\n", input_params_[0], input_params_[1]); | 185 fprintf(param_file_, "%d %d\n", input_params_[0], input_params_[1]); |
186 fprintf(param_file_, "%d %d\n", output_params_[0], output_params_[1]); | 186 fprintf(param_file_, "%d %d\n", output_params_[0], output_params_[1]); |
187 base::CloseFile(param_file_); | 187 file_util::CloseFile(param_file_); |
188 #endif | 188 #endif |
189 } | 189 } |
190 | 190 |
191 bool WASAPIUnifiedStream::Open() { | 191 bool WASAPIUnifiedStream::Open() { |
192 TRACE_EVENT0("audio", "WASAPIUnifiedStream::Open"); | 192 TRACE_EVENT0("audio", "WASAPIUnifiedStream::Open"); |
193 DVLOG(1) << "WASAPIUnifiedStream::Open()"; | 193 DVLOG(1) << "WASAPIUnifiedStream::Open()"; |
194 DCHECK_EQ(GetCurrentThreadId(), creating_thread_id_); | 194 DCHECK_EQ(GetCurrentThreadId(), creating_thread_id_); |
195 if (opened_) | 195 if (opened_) |
196 return true; | 196 return true; |
197 | 197 |
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
975 void WASAPIUnifiedStream::StopAndJoinThread(HRESULT err) { | 975 void WASAPIUnifiedStream::StopAndJoinThread(HRESULT err) { |
976 CHECK(GetCurrentThreadId() == creating_thread_id_); | 976 CHECK(GetCurrentThreadId() == creating_thread_id_); |
977 DCHECK(audio_io_thread_.get()); | 977 DCHECK(audio_io_thread_.get()); |
978 SetEvent(stop_streaming_event_.Get()); | 978 SetEvent(stop_streaming_event_.Get()); |
979 audio_io_thread_->Join(); | 979 audio_io_thread_->Join(); |
980 audio_io_thread_.reset(); | 980 audio_io_thread_.reset(); |
981 HandleError(err); | 981 HandleError(err); |
982 } | 982 } |
983 | 983 |
984 } // namespace media | 984 } // namespace media |
OLD | NEW |