summaryrefslogtreecommitdiffstats
path: root/media/audio/alsa
diff options
context:
space:
mode:
authordalecurtis@google.com <dalecurtis@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-18 21:36:22 +0000
committerdalecurtis@google.com <dalecurtis@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-18 21:36:22 +0000
commitde39b02352680506013f3802f75dc95b0eeb694e (patch)
treee61ee5cdd4b04736975260544c613b485ce6a670 /media/audio/alsa
parent4dd49e7dd6e6eaa40c16798b4974e006941ccb5e (diff)
downloadchromium_src-de39b02352680506013f3802f75dc95b0eeb694e.zip
chromium_src-de39b02352680506013f3802f75dc95b0eeb694e.tar.gz
chromium_src-de39b02352680506013f3802f75dc95b0eeb694e.tar.bz2
WeakPtr destruction order cleanup: media edition.
Per WeakPtrFactory documentation it must be the first member variable destructed to avoid invalid member variable access during destruction. Additional cleanups: - Removes "weak_this_" usage when there is no manual factory invalidation. - Adds DISALLOW_COPY_AND_ASSIGN to SendProcess. - Removes unused WeakPtr from FFmpegVideoDecoder, VpxVideoDecoder, FFMpegAudioDecoder, OpusAudioDecoder BUG=351048 TEST=compiles, passes CQ. R=fischman@chromium.org Review URL: https://codereview.chromium.org/193303002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@257765 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/audio/alsa')
-rw-r--r--media/audio/alsa/alsa_input.cc8
-rw-r--r--media/audio/alsa/alsa_input.h4
-rw-r--r--media/audio/alsa/alsa_output.cc4
-rw-r--r--media/audio/alsa/alsa_output.h9
4 files changed, 14 insertions, 11 deletions
diff --git a/media/audio/alsa/alsa_input.cc b/media/audio/alsa/alsa_input.cc
index bf31f51..9cde236 100644
--- a/media/audio/alsa/alsa_input.cc
+++ b/media/audio/alsa/alsa_input.cc
@@ -32,7 +32,8 @@ AlsaPcmInputStream::AlsaPcmInputStream(AudioManagerBase* audio_manager,
device_name_(device_name),
params_(params),
bytes_per_buffer_(params.frames_per_buffer() *
- (params.channels() * params.bits_per_sample()) / 8),
+ (params.channels() * params.bits_per_sample()) /
+ 8),
wrapper_(wrapper),
buffer_duration_(base::TimeDelta::FromMicroseconds(
params.frames_per_buffer() * base::Time::kMicrosecondsPerSecond /
@@ -41,9 +42,8 @@ AlsaPcmInputStream::AlsaPcmInputStream(AudioManagerBase* audio_manager,
device_handle_(NULL),
mixer_handle_(NULL),
mixer_element_handle_(NULL),
- weak_factory_(this),
- read_callback_behind_schedule_(false) {
-}
+ read_callback_behind_schedule_(false),
+ weak_factory_(this) {}
AlsaPcmInputStream::~AlsaPcmInputStream() {}
diff --git a/media/audio/alsa/alsa_input.h b/media/audio/alsa/alsa_input.h
index 6e9aad90..90c3883 100644
--- a/media/audio/alsa/alsa_input.h
+++ b/media/audio/alsa/alsa_input.h
@@ -80,10 +80,12 @@ class AlsaPcmInputStream : public AgcAudioStream<AudioInputStream> {
snd_pcm_t* device_handle_; // Handle to the ALSA PCM recording device.
snd_mixer_t* mixer_handle_; // Handle to the ALSA microphone mixer.
snd_mixer_elem_t* mixer_element_handle_; // Handle to the capture element.
- base::WeakPtrFactory<AlsaPcmInputStream> weak_factory_;
scoped_ptr<uint8[]> audio_buffer_; // Buffer used for reading audio data.
bool read_callback_behind_schedule_;
+ // NOTE: Weak pointers must be invalidated before all other member variables.
+ base::WeakPtrFactory<AlsaPcmInputStream> weak_factory_;
+
DISALLOW_COPY_AND_ASSIGN(AlsaPcmInputStream);
};
diff --git a/media/audio/alsa/alsa_output.cc b/media/audio/alsa/alsa_output.cc
index 308bedc..690d738 100644
--- a/media/audio/alsa/alsa_output.cc
+++ b/media/audio/alsa/alsa_output.cc
@@ -153,11 +153,11 @@ AlsaPcmOutputStream::AlsaPcmOutputStream(const std::string& device_name,
message_loop_(base::MessageLoop::current()),
playback_handle_(NULL),
frames_per_packet_(packet_size_ / bytes_per_frame_),
- weak_factory_(this),
state_(kCreated),
volume_(1.0f),
source_callback_(NULL),
- audio_bus_(AudioBus::Create(params)) {
+ audio_bus_(AudioBus::Create(params)),
+ weak_factory_(this) {
DCHECK(manager_->GetTaskRunner()->BelongsToCurrentThread());
DCHECK_EQ(audio_bus_->frames() * bytes_per_frame_, packet_size_);
diff --git a/media/audio/alsa/alsa_output.h b/media/audio/alsa/alsa_output.h
index 65a23f7..1805645 100644
--- a/media/audio/alsa/alsa_output.h
+++ b/media/audio/alsa/alsa_output.h
@@ -201,10 +201,6 @@ class MEDIA_EXPORT AlsaPcmOutputStream : public AudioOutputStream {
scoped_ptr<media::SeekableBuffer> buffer_;
uint32 frames_per_packet_;
- // Allows us to run tasks on the AlsaPcmOutputStream instance which are
- // bound by its lifetime.
- base::WeakPtrFactory<AlsaPcmOutputStream> weak_factory_;
-
InternalState state_;
float volume_; // Volume level from 0.0 to 1.0.
@@ -217,6 +213,11 @@ class MEDIA_EXPORT AlsaPcmOutputStream : public AudioOutputStream {
scoped_ptr<ChannelMixer> channel_mixer_;
scoped_ptr<AudioBus> mixed_audio_bus_;
+ // Allows us to run tasks on the AlsaPcmOutputStream instance which are
+ // bound by its lifetime.
+ // NOTE: Weak pointers must be invalidated before all other member variables.
+ base::WeakPtrFactory<AlsaPcmOutputStream> weak_factory_;
+
DISALLOW_COPY_AND_ASSIGN(AlsaPcmOutputStream);
};