OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2011 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 } | 58 } |
59 | 59 |
60 void AudioTrack::RemoveSink(AudioTrackSinkInterface* sink) { | 60 void AudioTrack::RemoveSink(AudioTrackSinkInterface* sink) { |
61 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 61 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
62 if (audio_source_) | 62 if (audio_source_) |
63 audio_source_->RemoveSink(sink); | 63 audio_source_->RemoveSink(sink); |
64 } | 64 } |
65 | 65 |
66 void AudioTrack::OnChanged() { | 66 void AudioTrack::OnChanged() { |
67 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 67 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
68 if (state() == kFailed) | 68 if (audio_source_->state() == MediaSourceInterface::kEnded) { |
69 return; // We can't recover from this state (do we ever set it?). | 69 set_state(kEnded); |
70 | 70 } else { |
71 TrackState new_state = kInitializing; | 71 set_state(kLive); |
72 | |
73 // |audio_source_| must be non-null if we ever get here. | |
74 switch (audio_source_->state()) { | |
75 case MediaSourceInterface::kLive: | |
76 case MediaSourceInterface::kMuted: | |
77 new_state = kLive; | |
78 break; | |
79 case MediaSourceInterface::kEnded: | |
80 new_state = kEnded; | |
81 break; | |
82 case MediaSourceInterface::kInitializing: | |
83 default: | |
84 // use kInitializing. | |
85 break; | |
86 } | 72 } |
87 | |
88 set_state(new_state); | |
89 } | 73 } |
90 | 74 |
91 } // namespace webrtc | 75 } // namespace webrtc |
OLD | NEW |