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

Side by Side Diff: media/audio/alsa/alsa_input.cc

Issue 193303002: WeakPtr destruction order cleanup: media edition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « media/audio/alsa/alsa_input.h ('k') | media/audio/alsa/alsa_output.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/alsa/alsa_input.h" 5 #include "media/audio/alsa/alsa_input.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 14 matching lines...) Expand all
25 const char AlsaPcmInputStream::kAutoSelectDevice[] = ""; 25 const char AlsaPcmInputStream::kAutoSelectDevice[] = "";
26 26
27 AlsaPcmInputStream::AlsaPcmInputStream(AudioManagerBase* audio_manager, 27 AlsaPcmInputStream::AlsaPcmInputStream(AudioManagerBase* audio_manager,
28 const std::string& device_name, 28 const std::string& device_name,
29 const AudioParameters& params, 29 const AudioParameters& params,
30 AlsaWrapper* wrapper) 30 AlsaWrapper* wrapper)
31 : audio_manager_(audio_manager), 31 : audio_manager_(audio_manager),
32 device_name_(device_name), 32 device_name_(device_name),
33 params_(params), 33 params_(params),
34 bytes_per_buffer_(params.frames_per_buffer() * 34 bytes_per_buffer_(params.frames_per_buffer() *
35 (params.channels() * params.bits_per_sample()) / 8), 35 (params.channels() * params.bits_per_sample()) /
36 8),
36 wrapper_(wrapper), 37 wrapper_(wrapper),
37 buffer_duration_(base::TimeDelta::FromMicroseconds( 38 buffer_duration_(base::TimeDelta::FromMicroseconds(
38 params.frames_per_buffer() * base::Time::kMicrosecondsPerSecond / 39 params.frames_per_buffer() * base::Time::kMicrosecondsPerSecond /
39 static_cast<float>(params.sample_rate()))), 40 static_cast<float>(params.sample_rate()))),
40 callback_(NULL), 41 callback_(NULL),
41 device_handle_(NULL), 42 device_handle_(NULL),
42 mixer_handle_(NULL), 43 mixer_handle_(NULL),
43 mixer_element_handle_(NULL), 44 mixer_element_handle_(NULL),
44 weak_factory_(this), 45 read_callback_behind_schedule_(false),
45 read_callback_behind_schedule_(false) { 46 weak_factory_(this) {}
46 }
47 47
48 AlsaPcmInputStream::~AlsaPcmInputStream() {} 48 AlsaPcmInputStream::~AlsaPcmInputStream() {}
49 49
50 bool AlsaPcmInputStream::Open() { 50 bool AlsaPcmInputStream::Open() {
51 if (device_handle_) 51 if (device_handle_)
52 return false; // Already open. 52 return false; // Already open.
53 53
54 snd_pcm_format_t pcm_format = alsa_util::BitsToFormat( 54 snd_pcm_format_t pcm_format = alsa_util::BitsToFormat(
55 params_.bits_per_sample()); 55 params_.bits_per_sample());
56 if (pcm_format == SND_PCM_FORMAT_UNKNOWN) { 56 if (pcm_format == SND_PCM_FORMAT_UNKNOWN) {
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 330
331 return static_cast<double>(current_volume); 331 return static_cast<double>(current_volume);
332 } 332 }
333 333
334 void AlsaPcmInputStream::HandleError(const char* method, int error) { 334 void AlsaPcmInputStream::HandleError(const char* method, int error) {
335 LOG(WARNING) << method << ": " << wrapper_->StrError(error); 335 LOG(WARNING) << method << ": " << wrapper_->StrError(error);
336 callback_->OnError(this); 336 callback_->OnError(this);
337 } 337 }
338 338
339 } // namespace media 339 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/alsa/alsa_input.h ('k') | media/audio/alsa/alsa_output.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698