2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
18 #include <FBaseRtThread.h>
19 #include <FBaseRtIEventListener.h>
20 #include <FBaseSysLog.h>
21 #include <FBaseRtIEventArg.h>
22 #include "FMedia_AudioRouteEvent.h"
23 #include "FMedia_AudioRouteEventArg.h"
25 using namespace Tizen::Base;
26 using namespace Tizen::Base::Runtime;
28 namespace Tizen { namespace Media
31 _AudioRouteEvent::_AudioRouteEvent(void)
36 _AudioRouteEvent::~_AudioRouteEvent(void)
41 _AudioRouteEvent::Construct(void)
46 r = _Event::Initialize();
47 SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
53 _AudioRouteEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
55 IAudioRouteEventListener *pAudioRouteEventListener = dynamic_cast<IAudioRouteEventListener*> (&listener);
56 SysTryReturn(NID_MEDIA, pAudioRouteEventListener, , E_SYSTEM,
57 "[E_SYSTEM] A system error has been occurred. The value of pAudioRouteEventListener is null.");
59 __pListener = pAudioRouteEventListener;
61 const Tizen::Base::Runtime::IEventArg* pTempArg = const_cast <const Tizen::Base::Runtime::IEventArg*>(&arg);
62 AudioRouteInfo routeInfo(INPUT_AUDIO_DEVICE_NONE, OUTPUT_AUDIO_DEVICE_NONE);
64 _AudioRouteEventArg *pArg = (_AudioRouteEventArg*) pTempArg;
65 switch (pArg->GetEventType())
67 case _AUDIO_ROUTE_EVENT_ADDED:
68 ((_AudioRouteEventArg *) pArg)->GetAudioRouteInfo(routeInfo);
69 SysLog(NID_MEDIA, "Input Device is %d, Output device is %d", routeInfo.GetInputAudioDevice(), routeInfo.GetOutputAudioDevice());
70 pAudioRouteEventListener->OnAudioRouteAdded(routeInfo);
72 case _AUDIO_ROUTE_EVENT_REMOVED:
73 ((_AudioRouteEventArg *) pArg)->GetAudioRouteInfo(routeInfo);
74 SysLog(NID_MEDIA, "Input Device is %d, Output device is %d ", routeInfo.GetInputAudioDevice(), routeInfo.GetOutputAudioDevice());
75 pAudioRouteEventListener->OnAudioRouteRemoved(routeInfo);
77 case _AUDIO_ROUTE_EVENT_ACTIVE_CHANGED:
78 ((_AudioRouteEventArg *) pArg)->GetAudioRouteInfo(routeInfo);
79 SysLog(NID_MEDIA, "Input Device is %d, Output device is %d ", routeInfo.GetInputAudioDevice(), routeInfo.GetOutputAudioDevice());
80 pAudioRouteEventListener->OnActiveAudioRouteChanged(routeInfo);
83 SysTryLog(NID_MEDIA, false, "Event type is wrong.");