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

Side by Side Diff: media/audio/null_audio_sink.cc

Issue 11275087: Move OnDecoderInitDone() from decoder to pipeline thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Missed AutoUnlock. Created 8 years, 1 month 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) 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/null_audio_sink.h" 5 #include "media/audio/null_audio_sink.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/stringprintf.h" 8 #include "base/stringprintf.h"
9 #include "base/sys_byteorder.h" 9 #include "base/sys_byteorder.h"
10 #include "base/threading/platform_thread.h" 10 #include "base/threading/platform_thread.h"
(...skipping 27 matching lines...) Expand all
38 38
39 void NullAudioSink::Start() { 39 void NullAudioSink::Start() {
40 if (!thread_.Start()) 40 if (!thread_.Start())
41 return; 41 return;
42 42
43 thread_.message_loop()->PostTask(FROM_HERE, base::Bind( 43 thread_.message_loop()->PostTask(FROM_HERE, base::Bind(
44 &NullAudioSink::FillBufferTask, this)); 44 &NullAudioSink::FillBufferTask, this));
45 } 45 }
46 46
47 void NullAudioSink::Stop() { 47 void NullAudioSink::Stop() {
48 SetPlaying(false); 48 playing_ = false;
49 thread_.Stop(); 49 thread_.Stop();
50 } 50 }
51 51
52 void NullAudioSink::Play() { 52 void NullAudioSink::Play() {
53 SetPlaying(true); 53 playing_ = true;
54 } 54 }
55 55
56 void NullAudioSink::Pause(bool /* flush */) { 56 void NullAudioSink::Pause(bool /* flush */) {
57 SetPlaying(false); 57 playing_ = false;
58 } 58 }
59 59
60 bool NullAudioSink::SetVolume(double volume) { 60 bool NullAudioSink::SetVolume(double volume) {
61 // Audio is always muted. 61 // Audio is always muted.
62 return volume == 0.0; 62 return volume == 0.0;
63 } 63 }
64 64
65 void NullAudioSink::SetPlaying(bool is_playing) {
66 base::AutoLock auto_lock(lock_);
67 playing_ = is_playing;
68 }
69
70 NullAudioSink::~NullAudioSink() { 65 NullAudioSink::~NullAudioSink() {
71 DCHECK(!thread_.IsRunning()); 66 DCHECK(!thread_.IsRunning());
72 } 67 }
73 68
74 void NullAudioSink::FillBufferTask() { 69 void NullAudioSink::FillBufferTask() {
75 base::AutoLock auto_lock(lock_);
76
77 base::TimeDelta delay; 70 base::TimeDelta delay;
78 // Only consume buffers when actually playing. 71 // Only consume buffers when actually playing.
79 if (playing_) { 72 if (playing_) {
Ami GONE FROM CHROMIUM 2012/11/01 19:57:01 This variable is set on the pipeline thread but is
DaleCurtis 2012/11/01 22:02:59 Normally we don't want to lock on the audio thread
80 int frames_received = callback_->Render(audio_bus_.get(), 0); 73 int frames_received = callback_->Render(audio_bus_.get(), 0);
81 int frames_per_millisecond = 74 int frames_per_millisecond =
82 params_.sample_rate() / base::Time::kMillisecondsPerSecond; 75 params_.sample_rate() / base::Time::kMillisecondsPerSecond;
83 76
84 if (hash_audio_for_testing_ && frames_received > 0) { 77 if (hash_audio_for_testing_ && frames_received > 0) {
85 DCHECK_EQ(sizeof(float), sizeof(uint32)); 78 DCHECK_EQ(sizeof(float), sizeof(uint32));
86 int channels = audio_bus_->channels(); 79 int channels = audio_bus_->channels();
87 for (int channel_idx = 0; channel_idx < channels; ++channel_idx) { 80 for (int channel_idx = 0; channel_idx < channels; ++channel_idx) {
88 float* channel = audio_bus_->channel(channel_idx); 81 float* channel = audio_bus_->channel(channel_idx);
89 for (int frame_idx = 0; frame_idx < frames_received; frame_idx++) { 82 for (int frame_idx = 0; frame_idx < frames_received; frame_idx++) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 base::MD5Final(&digest, &md5_channel_contexts_[i]); 128 base::MD5Final(&digest, &md5_channel_contexts_[i]);
136 base::MD5Update(&md5_channel_contexts_[0], base::StringPiece( 129 base::MD5Update(&md5_channel_contexts_[0], base::StringPiece(
137 reinterpret_cast<char*>(&digest), sizeof(base::MD5Digest))); 130 reinterpret_cast<char*>(&digest), sizeof(base::MD5Digest)));
138 } 131 }
139 132
140 base::MD5Final(&digest, &md5_channel_contexts_[0]); 133 base::MD5Final(&digest, &md5_channel_contexts_[0]);
141 return base::MD5DigestToBase16(digest); 134 return base::MD5DigestToBase16(digest);
142 } 135 }
143 136
144 } // namespace media 137 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698