[Sound] Changed methods for accessing state 90/188090/3
authorMateusz Plesinski <m.plesinski@AMDC2492.digital.local>
Fri, 31 Aug 2018 06:49:41 +0000 (08:49 +0200)
committerMateusz Plesinski <m.plesinski@samsung.com>
Tue, 4 Sep 2018 08:09:49 +0000 (10:09 +0200)
[Feature] Replaced deprecated functions with their equivalents added since tizen 5.0.

Replaced functions :
+ sound_manager_add_device_state_changed_cb with sound_manager_add_device_running_changed_cb
+ sound_manager_remove_device_state_changed_cb with sound_manager_remove_device_running_changed_cb
+ sound_manager_get_device_state with sound_manager_is_device_running

Added mapping for native type SOUND_DEVICE_BLUETOOTH_VOICE, so it is now correctly returned.

[Verification] tct-sound-tizen-tests (both Auto and Manual) pass with 100% on mobile

Change-Id: I0299a26685fb7fdc5e02fa00c87af86726b6ca27
Signed-off-by: Mateusz Plesinski <m.plesinski@samsung.com>
src/sound/sound_manager.cc

index c902d9a4042c957981d6af95d6170e66cca30002..3ff21de9b639b06a213604219e6562e066bca1bf 100644 (file)
@@ -88,6 +88,7 @@ std::string SoundManager::SoundDeviceTypeToString(sound_device_type_e type) {
     case SOUND_DEVICE_AUDIO_JACK:
       return "AUDIO_JACK";
     case SOUND_DEVICE_BLUETOOTH_MEDIA:
+    case SOUND_DEVICE_BLUETOOTH_VOICE:
       return "BLUETOOTH";
     case SOUND_DEVICE_HDMI:
       return "HDMI";
@@ -506,14 +507,14 @@ PlatformResult SoundManager::GetDeviceInfo(sound_device_h device, bool is_connec
   obj->insert(std::make_pair("direction", picojson::value(SoundIOTypeToString(direction))));
 
   // get state
-  sound_device_state_e state = SOUND_DEVICE_STATE_DEACTIVATED;
-  ret = sound_manager_get_device_state(device, &state);
+  bool state = false;
+  ret = sound_manager_is_device_running(device, &state);
   if (SOUND_MANAGER_ERROR_NONE != ret) {
     return LogAndCreateResult(
         ErrorCode::UNKNOWN_ERR, "Getting device state failed",
-        ("sound_manager_get_device_state error: %d (%s)", ret, get_error_message(ret)));
+        ("sound_manager_is_device_running error: %d (%s)", ret, get_error_message(ret)));
   }
-  obj->insert(std::make_pair("isActivated", picojson::value(static_cast<bool>(state))));
+  obj->insert(std::make_pair("isActivated", picojson::value(state)));
 
   // get connection
   if (check_connection) {
@@ -608,7 +609,7 @@ void DeviceConnectionChangedCB(sound_device_h device, bool is_connected, void* u
   h->DeviceChangeCB(device, is_connected, false);
 }
 
-void DeviceStateChangedCB(sound_device_h device, sound_device_state_e unused, void* user_data) {
+void DeviceStateChangedCB(sound_device_h device, bool unused, void* user_data) {
   ScopeLogger();
 
   SoundManager* h = static_cast<SoundManager*>(user_data);
@@ -630,13 +631,13 @@ PlatformResult SoundManager::AddDeviceStateChangeListener() {
                                  ret, get_error_message(ret)));
     }
 
-    ret = sound_manager_add_device_state_changed_cb(mask, DeviceStateChangedCB, this,
-                                                    &sound_device_state_listener_id_);
+    ret = sound_manager_add_device_running_changed_cb(mask, DeviceStateChangedCB, this,
+                                                      &sound_device_state_listener_id_);
     if (SOUND_MANAGER_ERROR_NONE != ret) {
       // silently cleanup connection changed callback registered in previous step
       sound_manager_remove_device_connection_changed_cb(sound_device_connection_listener_id_);
       return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Setting state listener failed",
-                                ("sound_manager_add_device_state_changed_cb error: %d (%s)", ret,
+                                ("sound_manager_add_device_running_changed_cb error: %d (%s)", ret,
                                  get_error_message(ret)));
     }
 
@@ -658,11 +659,11 @@ PlatformResult SoundManager::RemoveDeviceStateChangeListener() {
                                  ret, get_error_message(ret)));
     }
 
-    ret = sound_manager_remove_device_state_changed_cb(sound_device_state_listener_id_);
+    ret = sound_manager_remove_device_running_changed_cb(sound_device_state_listener_id_);
     if (SOUND_MANAGER_ERROR_NONE != ret) {
       return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Removing state listener failed",
-                                ("sound_manager_remove_device_state_changed_cb error: %d (%s)", ret,
-                                 get_error_message(ret)));
+                                ("sound_manager_remove_device_running_changed_cb error: %d (%s)",
+                                 ret, get_error_message(ret)));
     }
 
     is_sound_device_change_listener_ = false;