Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 // THREAD SAFETY | 5 // THREAD SAFETY |
| 6 // | 6 // |
| 7 // The AlsaPcmOutputStream object's internal state is accessed by two threads: | 7 // The AlsaPcmOutputStream object's internal state is accessed by two threads: |
| 8 // | 8 // |
| 9 // client thread - creates the object and calls the public APIs. | 9 // client thread - creates the object and calls the public APIs. |
| 10 // message loop thread - executes all the internal tasks including querying | 10 // message loop thread - executes all the internal tasks including querying |
| (...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 622 | 622 |
| 623 // Adjust for timer resolution issues. | 623 // Adjust for timer resolution issues. |
| 624 if (next_fill_time_ms > kSleepErrorMilliseconds) { | 624 if (next_fill_time_ms > kSleepErrorMilliseconds) { |
| 625 next_fill_time_ms -= kSleepErrorMilliseconds; | 625 next_fill_time_ms -= kSleepErrorMilliseconds; |
| 626 } | 626 } |
| 627 | 627 |
| 628 // Avoid busy looping if the data source is exhausted. | 628 // Avoid busy looping if the data source is exhausted. |
| 629 if (current_packet->size == 0) { | 629 if (current_packet->size == 0) { |
| 630 next_fill_time_ms = std::max(next_fill_time_ms, kNoDataSleepMilliseconds); | 630 next_fill_time_ms = std::max(next_fill_time_ms, kNoDataSleepMilliseconds); |
| 631 } | 631 } |
| 632 next_fill_time_ms /= 2; // TODO(fbarchard): Remove this hack. | |
|
scherkus (not reviewing)
2009/10/22 01:42:30
nit: should have two spaces between ; and //
also
| |
| 632 | 633 |
| 633 // Only schedule more reads/writes if we are still in the playing state. | 634 // Only schedule more reads/writes if we are still in the playing state. |
| 634 if (shared_data_.state() == kIsPlaying) { | 635 if (shared_data_.state() == kIsPlaying) { |
| 635 if (next_fill_time_ms <= 0) { | 636 if (next_fill_time_ms <= 0) { |
| 636 message_loop_->PostTask( | 637 message_loop_->PostTask( |
| 637 FROM_HERE, | 638 FROM_HERE, |
| 638 NewRunnableMethod(this, &AlsaPcmOutputStream::WriteTask)); | 639 NewRunnableMethod(this, &AlsaPcmOutputStream::WriteTask)); |
| 639 } else { | 640 } else { |
| 640 // TODO(ajwong): Measure the reliability of the delay interval. Use | 641 // TODO(ajwong): Measure the reliability of the delay interval. Use |
| 641 // base/histogram.h. | 642 // base/histogram.h. |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 936 } | 937 } |
| 937 | 938 |
| 938 // Changes the AudioSourceCallback to proxy calls to. Pass in NULL to | 939 // Changes the AudioSourceCallback to proxy calls to. Pass in NULL to |
| 939 // release ownership of the currently registered callback. | 940 // release ownership of the currently registered callback. |
| 940 void AlsaPcmOutputStream::SharedData::set_source_callback( | 941 void AlsaPcmOutputStream::SharedData::set_source_callback( |
| 941 AudioSourceCallback* callback) { | 942 AudioSourceCallback* callback) { |
| 942 DCHECK_EQ(MessageLoop::current(), state_transition_loop_); | 943 DCHECK_EQ(MessageLoop::current(), state_transition_loop_); |
| 943 AutoLock l(lock_); | 944 AutoLock l(lock_); |
| 944 source_callback_ = callback; | 945 source_callback_ = callback; |
| 945 } | 946 } |
| OLD | NEW |