btrfs: Attempt to fix GCC2 build.
[haiku.git] / src / apps / mediaplayer / ControllerObserver.cpp
blob3474d8e8226315cca81a4e0315559a70b1d04179
1 /*
2 * Copyright 2007-2009, Haiku. All rights reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Stephan Aßmus <superstippi@gmx.de>
7 */
10 #include "ControllerObserver.h"
12 #include <Message.h>
14 #include "PlaylistItem.h"
17 ControllerObserver::ControllerObserver(BHandler* target, uint32 observeFlags)
19 AbstractLOAdapter(target),
20 fObserveFlags(observeFlags)
25 ControllerObserver::~ControllerObserver()
30 void
31 ControllerObserver::FileFinished()
33 if (!(fObserveFlags & OBSERVE_FILE_CHANGES))
34 return;
36 BMessage message(MSG_CONTROLLER_FILE_FINISHED);
38 DeliverMessage(message);
42 void
43 ControllerObserver::FileChanged(PlaylistItem* item, status_t result)
45 if (!(fObserveFlags & OBSERVE_FILE_CHANGES))
46 return;
48 PlaylistItemRef reference(item);
49 // pass the reference along with the message
51 BMessage message(MSG_CONTROLLER_FILE_CHANGED);
52 message.AddInt32("result", result);
53 if (message.AddPointer("item", item) == B_OK)
54 reference.Detach();
56 DeliverMessage(message);
60 void
61 ControllerObserver::VideoTrackChanged(int32 index)
63 if (!(fObserveFlags & OBSERVE_TRACK_CHANGES))
64 return;
66 BMessage message(MSG_CONTROLLER_VIDEO_TRACK_CHANGED);
67 message.AddInt32("index", index);
69 DeliverMessage(message);
73 void
74 ControllerObserver::AudioTrackChanged(int32 index)
76 if (!(fObserveFlags & OBSERVE_TRACK_CHANGES))
77 return;
79 BMessage message(MSG_CONTROLLER_AUDIO_TRACK_CHANGED);
80 message.AddInt32("index", index);
82 DeliverMessage(message);
86 void
87 ControllerObserver::SubTitleTrackChanged(int32 index)
89 if (!(fObserveFlags & OBSERVE_TRACK_CHANGES))
90 return;
92 BMessage message(MSG_CONTROLLER_SUB_TITLE_TRACK_CHANGED);
93 message.AddInt32("index", index);
95 DeliverMessage(message);
99 void
100 ControllerObserver::VideoStatsChanged()
102 if (!(fObserveFlags & OBSERVE_STAT_CHANGES))
103 return;
105 BMessage message(MSG_CONTROLLER_VIDEO_STATS_CHANGED);
107 DeliverMessage(message);
111 void
112 ControllerObserver::AudioStatsChanged()
114 if (!(fObserveFlags & OBSERVE_STAT_CHANGES))
115 return;
117 BMessage message(MSG_CONTROLLER_AUDIO_STATS_CHANGED);
119 DeliverMessage(message);
123 void
124 ControllerObserver::PlaybackStateChanged(uint32 state)
126 if (!(fObserveFlags & OBSERVE_PLAYBACK_STATE_CHANGES))
127 return;
129 BMessage message(MSG_CONTROLLER_PLAYBACK_STATE_CHANGED);
130 message.AddInt32("state", state);
132 DeliverMessage(message);
136 void
137 ControllerObserver::PositionChanged(float position)
139 if (!(fObserveFlags & OBSERVE_POSITION_CHANGES))
140 return;
142 BMessage message(MSG_CONTROLLER_POSITION_CHANGED);
143 message.AddFloat("position", position);
145 DeliverMessage(message);
149 void
150 ControllerObserver::SeekHandled(int64 seekFrame)
152 if (!(fObserveFlags & OBSERVE_POSITION_CHANGES))
153 return;
155 BMessage message(MSG_CONTROLLER_SEEK_HANDLED);
156 message.AddInt64("seek frame", seekFrame);
158 DeliverMessage(message);
162 void
163 ControllerObserver::VolumeChanged(float volume)
165 if (!(fObserveFlags & OBSERVE_VOLUME_CHANGES))
166 return;
168 BMessage message(MSG_CONTROLLER_VOLUME_CHANGED);
169 message.AddFloat("volume", volume);
171 DeliverMessage(message);
175 void
176 ControllerObserver::MutedChanged(bool muted)
178 if (!(fObserveFlags & OBSERVE_VOLUME_CHANGES))
179 return;
181 BMessage message(MSG_CONTROLLER_MUTED_CHANGED);
182 message.AddBool("muted", muted);
184 DeliverMessage(message);