#define MC_BIT64_UNSET 0x0000000000000000
#define MC_BIT64_SET 0x0000000000000001
-#define MC_BIT64_IS_OK(x) ((x < 64) ? TRUE : FALSE)
-#define MC_BIT64_IS_TRUE(a, b) (((a >> b) & MC_BIT64_SET) ? TRUE : FALSE)
-#define MC_BIT64_SET_BIT(a, b) \
- do { \
- if (MC_BIT64_IS_OK(b)) \
- (a |= ((MC_BIT64_SET << b))); \
- } while (0)
-#define MC_BIT64_UNSET_BIT(a, b) \
- do { \
- if (MC_BIT64_IS_OK(b)) \
- (a &= ~((MC_BIT64_SET << b))); \
- } while (0)
+#define MC_SHIFT_IS_OK(x) ((x < 32) ? TRUE : FALSE)
typedef struct {
void *callback;
MC_SERVER_EVENT_MAX,
} mc_server_receive_event_e;
-#define PLAYBACK_ACTION_ABILITY MC_SERVER_EVENT_PLAYBACK_ACTION + 20
+#define PLAYBACK_ACTION_ABILITY MC_SERVER_EVENT_PLAYBACK_ACTION + 30
typedef struct {
char *server_name;
int mc_util_bundle_to_string(bundle *bundle_data, char **str_data);
gboolean _mc_util_is_valid_playback_action(mc_playback_action_e action);
gboolean _mc_util_is_valid_subscription_type(const mc_subscription_type_e subscription_type);
+void _mc_util_set_bit(int bit_num, gboolean set, unsigned long long *value);
+gboolean _mc_util_is_true_bit(unsigned long long value, int bit_num);
/* for d-bus IPC */
int mc_ipc_get_dbus_connection(GDBusConnection **conn, int *dref_count);
ret = __mc_db_get_ability(handle, server_name, &_decided, &_supported);
mc_retvm_if(ret != MEDIA_CONTROLLER_ERROR_NONE, ret, "__mc_db_get_ability failed");
- mc_secure_debug("IsDecided: %d", MC_BIT64_IS_TRUE(_decided, ability));
- mc_secure_debug("IsSupported: %d", MC_BIT64_IS_TRUE(_supported, ability));
+ mc_secure_debug("IsDecided: %d", _mc_util_is_true_bit(_decided, ability));
+ mc_secure_debug("IsSupported: %d", _mc_util_is_true_bit(_supported, ability));
- if (MC_BIT64_IS_TRUE(_decided, ability)) {
- if (MC_BIT64_IS_TRUE(_supported, ability))
+ if (_mc_util_is_true_bit(_decided, ability)) {
+ if (_mc_util_is_true_bit(_supported, ability))
*supported = MC_ABILITY_SUPPORTED_YES;
else
*supported = MC_ABILITY_SUPPORTED_NO;
mc_retvm_if(!_mc_util_is_valid_playback_action(action), MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Invalid action");
mc_retvm_if(supported == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "supported is NULL");
- mc_secure_debug("IsDecided: %d", MC_BIT64_IS_TRUE(mc_ability->decided, (PLAYBACK_ACTION_ABILITY + action)));
- mc_secure_debug("IsSupported: %d", MC_BIT64_IS_TRUE(mc_ability->supported, (PLAYBACK_ACTION_ABILITY + action)));
+ mc_secure_debug("IsDecided: %d", _mc_util_is_true_bit(mc_ability->decided, (PLAYBACK_ACTION_ABILITY + action)));
+ mc_secure_debug("IsSupported: %d", _mc_util_is_true_bit(mc_ability->supported, (PLAYBACK_ACTION_ABILITY + action)));
- if (MC_BIT64_IS_TRUE(mc_ability->decided, (PLAYBACK_ACTION_ABILITY + action))) {
- if (MC_BIT64_IS_TRUE(mc_ability->supported, (PLAYBACK_ACTION_ABILITY + action)))
+ if (_mc_util_is_true_bit(mc_ability->decided, (PLAYBACK_ACTION_ABILITY + action))) {
+ if (_mc_util_is_true_bit(mc_ability->supported, (PLAYBACK_ACTION_ABILITY + action)))
*supported = MC_ABILITY_SUPPORTED_YES;
else
*supported = MC_ABILITY_SUPPORTED_NO;
mc_retvm_if(((support != MC_ABILITY_SUPPORTED_YES) && (support != MC_ABILITY_SUPPORTED_NO)), MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "support is invalid [%d]", support);
/* Change decided bit to 1(set) */
- MC_BIT64_SET_BIT(mc_server->basic_ability.decided, support_item);
+ _mc_util_set_bit(support_item, TRUE, &mc_server->basic_ability.decided);
/* if support is supported_yes, change supported bit to 1(set), otherwise change supported bit to 0(unset) */
if (support == MC_ABILITY_SUPPORTED_YES)
- MC_BIT64_SET_BIT(mc_server->basic_ability.supported, support_item);
+ _mc_util_set_bit(support_item, TRUE, &mc_server->basic_ability.supported);
else
- MC_BIT64_UNSET_BIT(mc_server->basic_ability.supported, support_item);
+ _mc_util_set_bit(support_item, FALSE, &mc_server->basic_ability.supported);
if (immediate_update)
return mc_db_update_ability_supported(mc_server->server_name, mc_server->basic_ability);
return TRUE;
}
+
+void _mc_util_set_bit(int bit_num, gboolean set, unsigned long long *value)
+{
+ int i = 0;
+ unsigned long long lshift = MC_BIT64_SET;
+
+ mc_retm_if(!value, "Invalid value");
+ mc_retm_if((bit_num < 0 || bit_num >= 64), "Invalid bit [%d]", bit_num);
+
+ if (MC_SHIFT_IS_OK(bit_num)) {
+ lshift = (lshift << bit_num);
+ } else {
+ for (i = 0; i < bit_num; i++)
+ lshift = (lshift << 1);
+ }
+
+ if (set)
+ *value |= lshift;
+ else
+ *value &= ~lshift;
+}
+
+gboolean _mc_util_is_true_bit(unsigned long long value, int bit_num)
+{
+ int i = 0;
+ unsigned long long rshift = value;
+
+ mc_retvm_if((bit_num < 0 || bit_num >= 64), FALSE, "Invalid bit [%d]", bit_num);
+
+ if (MC_SHIFT_IS_OK(bit_num)) {
+ rshift = (rshift >> bit_num);
+ } else {
+ for (i = 0; i < bit_num; i++)
+ rshift = (rshift >> 1);
+ }
+
+ return ((rshift & MC_BIT64_SET) ? TRUE : FALSE);
+}