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_AudioSessionEvent.h"
23 #include "FMedia_AudioSessionEventArg.h"
25 using namespace Tizen::Base;
26 using namespace Tizen::Base::Runtime;
28 namespace Tizen { namespace Media
31 _AudioSessionEvent::_AudioSessionEvent(void)
36 _AudioSessionEvent::~_AudioSessionEvent(void)
41 _AudioSessionEvent::Construct(void)
46 r = _Event::Initialize();
47 SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
53 _AudioSessionEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
55 IAudioSessionEventListener *pAudioSessionEventListener = dynamic_cast<IAudioSessionEventListener*> (&listener);
56 SysTryReturn(NID_MEDIA, pAudioSessionEventListener, , E_SYSTEM, "[E_SYSTEM] A system error has been occureed. The value of listener is null.");
58 __pListener = pAudioSessionEventListener;
60 const Tizen::Base::Runtime::IEventArg* pTempArg = const_cast <const Tizen::Base::Runtime::IEventArg*>(&arg);
62 _AudioSessionEventArg *pArg = (_AudioSessionEventArg*) pTempArg;
64 switch (pArg->GetEventType())
66 case _AUDIO_SESSION_EVENT_INTERRUPTED:
67 pAudioSessionEventListener->OnAudioSessionInterrupted();
69 case _AUDIO_SESSION_EVENT_RELEASED:
70 pAudioSessionEventListener->OnAudioSessionInterruptReleased();
72 case _AUDIO_SESSION_EVENT_AUDIO_FOCUS_CHANGED:
73 pAudioSessionEventListener->OnAudioSessionAudioFocusChanged();
76 SysTryLog(NID_MEDIA, false, "The event type is wrong.");