Refactor and add Wayland support.
[platform/core/uifw/dali-adaptor.git] / adaptors / common / sound-player-impl.h
1 #ifndef __DALI_INTERNAL_SOUND_PLAYER_H__
2 #define __DALI_INTERNAL_SOUND_PLAYER_H__
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <string>
23 #include <dali/public-api/object/base-object.h>
24
25 // INTERNAL INCLUDES
26 #include <sound-player.h>
27 #include <feedback/feedback-plugin-proxy.h>
28
29 namespace Dali
30 {
31
32 namespace Internal
33 {
34
35 namespace Adaptor
36 {
37
38 /**
39  * Plays haptic effects.
40  */
41 class SoundPlayer : public Dali::BaseObject
42 {
43
44 public:
45
46   typedef Dali::SoundPlayer::SoundPlayFinishedSignalV2 SoundPlayFinishedSignalV2;
47
48   /**
49    * Create a SoundPlayer.
50    * @return A newly created SoundPlayer.
51    */
52   static Dali::SoundPlayer New();
53
54   /**
55    * Retrieve a handle to the SoundPlayer. This creates an instance if none has been created.
56    * @return A handle to the SoundPlayer.
57    */
58   static Dali::SoundPlayer Get();
59
60   /**
61    * @copydoc Dali::SoundPlayer::PlaySound()
62    */
63   int PlaySound(const std::string fileName);
64
65   /**
66    * @copydoc Dali::SoundPlayer::Stop()
67    */
68   void Stop(int handle);
69
70   /**
71    * @copydoc Dali::SoundPlayer::SoundPlayFinishedSignal()
72    */
73   SoundPlayFinishedSignalV2& SoundPlayFinishedSignal();
74
75   /**
76    * Connects a callback function with the object's signals.
77    * @param[in] object The object providing the signal.
78    * @param[in] tracker Used to disconnect the signal.
79    * @param[in] signalName The signal to connect to.
80    * @param[in] functor A newly allocated FunctorDelegate.
81    * @return True if the signal was connected.
82    * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
83    */
84   static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
85
86 private:
87
88   /**
89    * Private Constructor; see also soundPlayer::New()
90    * @param[in]  soundPlayer  The public sound player class
91    */
92   SoundPlayer();
93
94   /**
95    * Destructor
96    */
97   virtual ~SoundPlayer();
98
99   /**
100    * Emits the SoundPlayFinished signal.
101    */
102   void EmitSoundPlayFinishedSignal();
103
104   // Undefined
105   SoundPlayer(const SoundPlayer&);
106
107   // Undefined
108   SoundPlayer& operator=(SoundPlayer&);
109
110 private:
111
112   FeedbackPluginProxy mPlugin;
113   SoundPlayFinishedSignalV2 mSoundPlayFinishedSignalV2;
114 };
115
116 } // namespace Adaptor
117
118 } // namespace Internal
119
120
121 // Helpers for public-api forwarding methods
122
123 inline Internal::Adaptor::SoundPlayer& GetImplementation(Dali::SoundPlayer& player)
124 {
125   DALI_ASSERT_ALWAYS( player && "SoundPlayer handle is empty" );
126
127   BaseObject& handle = player.GetBaseObject();
128
129   return static_cast<Internal::Adaptor::SoundPlayer&>(handle);
130 }
131
132 inline const Internal::Adaptor::SoundPlayer& GetImplementation(const Dali::SoundPlayer& player)
133 {
134   DALI_ASSERT_ALWAYS( player && "SoundPlayer handle is empty" );
135
136   const BaseObject& handle = player.GetBaseObject();
137
138   return static_cast<const Internal::Adaptor::SoundPlayer&>(handle);
139 }
140
141 } // namespace Dali
142
143 #endif // __DALI_INTERNAL_SOUND_PLAYER_H__