ozone: evdev: Sync caps lock LED state to evdev
[chromium-blink-merge.git] / chromecast / media / cma / backend / media_clock_device.cc
blob853e5bafbd0cdd1ae12575a517371700e0c5f4c4
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chromecast/media/cma/backend/media_clock_device.h"
7 #include "base/logging.h"
9 namespace chromecast {
10 namespace media {
12 MediaClockDevice::MediaClockDevice() {
15 MediaClockDevice::~MediaClockDevice() {
18 // static
19 bool MediaClockDevice::IsValidStateTransition(State state1, State state2) {
20 if (state2 == state1)
21 return true;
23 // All states can transition to |kStateError|.
24 bool is_transition_valid = (state2 == kStateError);
26 // All the other valid FSM transitions.
27 is_transition_valid = is_transition_valid ||
28 (state1 == kStateUninitialized && (state2 == kStateIdle)) ||
29 (state1 == kStateIdle && (state2 == kStateRunning ||
30 state2 == kStateUninitialized)) ||
31 (state1 == kStateRunning && (state2 == kStateIdle)) ||
32 (state1 == kStateError && (state2 == kStateUninitialized));
34 return is_transition_valid;
37 // static
38 std::string MediaClockDevice::StateToString(const State& state) {
39 switch (state) {
40 case kStateUninitialized:
41 return "Uninitialized";
42 case kStateIdle:
43 return "Idle";
44 case kStateRunning:
45 return "Running";
46 case kStateError:
47 return "Error";
48 default:
49 NOTREACHED() << "Unknown MediaClockDevice::State: " << state;
50 return "";
54 } // namespace media
55 } // namespace chromecast