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

Unified Diff: media/audio/sounds/sounds_manager.cc

Issue 1453233002: Improve input handling for WaveAudioHandler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Address comments Created 5 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 side-by-side diff with in-line comments
Download patch
Index: media/audio/sounds/sounds_manager.cc
diff --git a/media/audio/sounds/sounds_manager.cc b/media/audio/sounds/sounds_manager.cc
index 17f0dd874368f89c23c2aab57749e9c771b8282f..9774ce8f7a1a0aa9483541fc9c65060a4ae82bb9 100644
--- a/media/audio/sounds/sounds_manager.cc
+++ b/media/audio/sounds/sounds_manager.cc
@@ -64,19 +64,13 @@ bool SoundsManagerImpl::Initialize(SoundKey key,
bool SoundsManagerImpl::Play(SoundKey key) {
DCHECK(CalledOnValidThread());
linked_ptr<AudioStreamHandler> handler = GetHandler(key);
- if (!handler.get())
- return false;
- if (!handler->IsInitialized())
- return false;
- return handler->Play();
+ return handler.get() && handler->IsInitialized() && handler->Play();
}
bool SoundsManagerImpl::Stop(SoundKey key) {
DCHECK(CalledOnValidThread());
linked_ptr<AudioStreamHandler> handler = GetHandler(key);
- if (!handler.get())
- return false;
- if (!handler->IsInitialized())
+ if (!handler.get() || !handler->IsInitialized())
return false;
handler->Stop();
return true;
@@ -85,12 +79,9 @@ bool SoundsManagerImpl::Stop(SoundKey key) {
base::TimeDelta SoundsManagerImpl::GetDuration(SoundKey key) {
DCHECK(CalledOnValidThread());
linked_ptr<AudioStreamHandler> handler = GetHandler(key);
- if (!handler.get())
+ if (!handler.get() || !handler->IsInitialized())
return base::TimeDelta();
- if (!handler->IsInitialized())
- return base::TimeDelta();
- const WavAudioHandler& wav_audio = handler->wav_audio_handler();
- return wav_audio.GetDuration();
+ return handler->duration();
}
linked_ptr<AudioStreamHandler> SoundsManagerImpl::GetHandler(SoundKey key) {

Powered by Google App Engine
This is Rietveld 408576698