Commit 419af5a2 authored by Julian Bouzas's avatar Julian Bouzas
Browse files

spa-pod: respect the SPA size for long and int APIs

Fixes some issues for 32bit architectures
parent e1faf3f0
Pipeline #318208 passed with stages
in 1 minute and 35 seconds
......@@ -484,7 +484,7 @@ wp_spa_pod_new_id (guint32 value)
* Returns: (transfer full): The new spa pod
*/
WpSpaPod *
wp_spa_pod_new_int (gint value)
wp_spa_pod_new_int (gint32 value)
{
WpSpaPod *self = g_slice_new0 (WpSpaPod);
g_ref_count_init (&self->ref);
......@@ -503,7 +503,7 @@ wp_spa_pod_new_int (gint value)
* Returns: (transfer full): The new spa pod
*/
WpSpaPod *
wp_spa_pod_new_long (glong value)
wp_spa_pod_new_long (gint64 value)
{
WpSpaPod *self = g_slice_new0 (WpSpaPod);
g_ref_count_init (&self->ref);
......@@ -1141,7 +1141,7 @@ wp_spa_pod_get_id (WpSpaPod *self, guint32 *value)
* Returns: TRUE if the value was obtained, FALSE otherwise
*/
gboolean
wp_spa_pod_get_int (WpSpaPod *self, gint *value)
wp_spa_pod_get_int (WpSpaPod *self, gint32 *value)
{
g_return_val_if_fail (self, FALSE);
g_return_val_if_fail (value, FALSE);
......@@ -1158,7 +1158,7 @@ wp_spa_pod_get_int (WpSpaPod *self, gint *value)
* Returns: TRUE if the value was obtained, FALSE otherwise
*/
gboolean
wp_spa_pod_get_long (WpSpaPod *self, glong *value)
wp_spa_pod_get_long (WpSpaPod *self, gint64 *value)
{
g_return_val_if_fail (self, FALSE);
g_return_val_if_fail (value, FALSE);
......@@ -1363,7 +1363,7 @@ wp_spa_pod_set_id (WpSpaPod *self, guint32 value)
* Returns: TRUE if the value could be set, FALSE othewrise.
*/
gboolean
wp_spa_pod_set_int (WpSpaPod *self, gint value)
wp_spa_pod_set_int (WpSpaPod *self, gint32 value)
{
g_return_val_if_fail (wp_spa_pod_is_int (self), FALSE);
g_return_val_if_fail (!(self->flags & FLAG_CONSTANT), FALSE);
......@@ -1381,7 +1381,7 @@ wp_spa_pod_set_int (WpSpaPod *self, gint value)
* Returns: TRUE if the value could be set, FALSE othewrise.
*/
gboolean
wp_spa_pod_set_long (WpSpaPod *self, glong value)
wp_spa_pod_set_long (WpSpaPod *self, gint64 value)
{
g_return_val_if_fail (wp_spa_pod_is_long (self), FALSE);
g_return_val_if_fail (!(self->flags & FLAG_CONSTANT), FALSE);
......@@ -2047,7 +2047,7 @@ wp_spa_pod_builder_add_id (WpSpaPodBuilder *self, guint32 value)
* Adds a int value into the builder
*/
void
wp_spa_pod_builder_add_int (WpSpaPodBuilder *self, gint value)
wp_spa_pod_builder_add_int (WpSpaPodBuilder *self, gint32 value)
{
spa_pod_builder_int (&self->builder, value);
}
......@@ -2060,7 +2060,7 @@ wp_spa_pod_builder_add_int (WpSpaPodBuilder *self, gint value)
* Adds a long value into the builder
*/
void
wp_spa_pod_builder_add_long (WpSpaPodBuilder *self, glong value)
wp_spa_pod_builder_add_long (WpSpaPodBuilder *self, gint64 value)
{
spa_pod_builder_long (&self->builder, value);
}
......@@ -2504,7 +2504,7 @@ wp_spa_pod_parser_get_id (WpSpaPodParser *self, guint32 *value)
* Returns: TRUE if the value was obtained, FALSE otherwise
*/
gboolean
wp_spa_pod_parser_get_int (WpSpaPodParser *self, gint *value)
wp_spa_pod_parser_get_int (WpSpaPodParser *self, gint32 *value)
{
g_return_val_if_fail (value, FALSE);
return spa_pod_parser_get_int (&self->parser, value) >= 0;
......@@ -2520,7 +2520,7 @@ wp_spa_pod_parser_get_int (WpSpaPodParser *self, gint *value)
* Returns: TRUE if the value was obtained, FALSE otherwise
*/
gboolean
wp_spa_pod_parser_get_long (WpSpaPodParser *self, glong *value)
wp_spa_pod_parser_get_long (WpSpaPodParser *self, gint64 *value)
{
g_return_val_if_fail (value, FALSE);
return spa_pod_parser_get_long (&self->parser, value) >= 0;
......
......@@ -70,10 +70,10 @@ WP_API
WpSpaPod *wp_spa_pod_new_id (guint32 value);
WP_API
WpSpaPod *wp_spa_pod_new_int (gint value);
WpSpaPod *wp_spa_pod_new_int (gint32 value);
WP_API
WpSpaPod *wp_spa_pod_new_long (glong value);
WpSpaPod *wp_spa_pod_new_long (gint64 value);
WP_API
WpSpaPod *wp_spa_pod_new_float (float value);
......@@ -187,10 +187,10 @@ WP_API
gboolean wp_spa_pod_get_id (WpSpaPod *self, guint32 *value);
WP_API
gboolean wp_spa_pod_get_int (WpSpaPod *self, gint *value);
gboolean wp_spa_pod_get_int (WpSpaPod *self, gint32 *value);
WP_API
gboolean wp_spa_pod_get_long (WpSpaPod *self, glong *value);
gboolean wp_spa_pod_get_long (WpSpaPod *self, gint64 *value);
WP_API
gboolean wp_spa_pod_get_float (WpSpaPod *self, float *value);
......@@ -225,10 +225,10 @@ WP_API
gboolean wp_spa_pod_set_id (WpSpaPod *self, guint32 value);
WP_API
gboolean wp_spa_pod_set_int (WpSpaPod *self, gint value);
gboolean wp_spa_pod_set_int (WpSpaPod *self, gint32 value);
WP_API
gboolean wp_spa_pod_set_long (WpSpaPod *self, glong value);
gboolean wp_spa_pod_set_long (WpSpaPod *self, gint64 value);
WP_API
gboolean wp_spa_pod_set_float (WpSpaPod *self, float value);
......@@ -333,10 +333,10 @@ WP_API
void wp_spa_pod_builder_add_id (WpSpaPodBuilder *self, guint32 value);
WP_API
void wp_spa_pod_builder_add_int (WpSpaPodBuilder *self, gint value);
void wp_spa_pod_builder_add_int (WpSpaPodBuilder *self, gint32 value);
WP_API
void wp_spa_pod_builder_add_long (WpSpaPodBuilder *self, glong value);
void wp_spa_pod_builder_add_long (WpSpaPodBuilder *self, gint64 value);
WP_API
void wp_spa_pod_builder_add_float (WpSpaPodBuilder *self, float value);
......@@ -422,10 +422,10 @@ WP_API
gboolean wp_spa_pod_parser_get_id (WpSpaPodParser *self, guint32 *value);
WP_API
gboolean wp_spa_pod_parser_get_int (WpSpaPodParser *self, gint *value);
gboolean wp_spa_pod_parser_get_int (WpSpaPodParser *self, gint32 *value);
WP_API
gboolean wp_spa_pod_parser_get_long (WpSpaPodParser *self, glong *value);
gboolean wp_spa_pod_parser_get_long (WpSpaPodParser *self, gint64 *value);
WP_API
gboolean wp_spa_pod_parser_get_float (WpSpaPodParser *self, float *value);
......
......@@ -945,7 +945,7 @@ push_luapod (lua_State *L, WpSpaPod *pod, WpSpaIdValue field_idval)
/* Long */
else if (wp_spa_pod_is_long (pod)) {
glong value = 0;
gint64 value = 0;
wp_spa_pod_get_long (pod, &value);
lua_pushinteger (L, value);
}
......
......@@ -83,7 +83,7 @@ test_spa_pod_basic (void)
g_autoptr (WpSpaPod) pod = wp_spa_pod_new_int (-12);
g_assert_nonnull (pod);
g_assert_true (wp_spa_pod_is_int (pod));
gint value = 0;
gint32 value = 0;
g_assert_true (wp_spa_pod_get_int (pod, &value));
g_assert_cmpint (value, ==, -12);
g_assert_cmpstr ("Spa:Int", ==,
......@@ -103,7 +103,7 @@ test_spa_pod_basic (void)
g_autoptr (WpSpaPod) pod = wp_spa_pod_new_long (LONG_MAX);
g_assert_nonnull (pod);
g_assert_true (wp_spa_pod_is_long (pod));
long value = 0;
gint64 value = 0;
g_assert_true (wp_spa_pod_get_long (pod, &value));
g_assert_cmpint (value, ==, LONG_MAX);
g_assert_cmpstr ("Spa:Long", ==,
......@@ -313,7 +313,7 @@ test_spa_pod_choice (void)
g_assert_nonnull (child);
g_assert_cmpstr ("Spa:Int", ==,
wp_spa_type_name (wp_spa_pod_get_spa_type (child)));
gint value = 1;
gint32 value = 1;
g_assert_true (wp_spa_pod_get_int (child, &value));
g_assert_cmpint (value, ==, 0);
g_assert_true (wp_spa_pod_set_int (child, 3));
......@@ -429,7 +429,7 @@ test_spa_pod_object (void)
const char *id_name;
gboolean mute = TRUE;
float vol = 0.0;
gint frequency;
gint32 frequency;
const char *device;
gint64 device_fd;
g_assert_true (wp_spa_pod_get_object (pod,
......@@ -471,7 +471,7 @@ test_spa_pod_object (void)
const char *id_name;
gboolean mute = TRUE;
float vol = 0.0;
gint frequency;
gint32 frequency;
const char *device;
gint64 device_fd;
g_autoptr (WpSpaPodParser) p = wp_spa_pod_parser_new_object (pod, &id_name);
......@@ -537,11 +537,11 @@ test_spa_pod_struct (void)
g_assert_true (wp_spa_pod_parser_get_id (p, &value_id));
g_assert_cmpuint (value_id, ==, 2);
gint value_int;
gint32 value_int;
g_assert_true (wp_spa_pod_parser_get_int (p, &value_int));
g_assert_cmpint (value_int, ==, 8);
glong value_long;
gint64 value_long;
g_assert_true (wp_spa_pod_parser_get_long (p, &value_long));
g_assert_cmpint (value_long, ==, 64);
......@@ -638,16 +638,16 @@ test_spa_pod_sequence (void)
static void
choice_foreach (const GValue *item, gpointer data)
{
gint *total = data;
const gint *value = g_value_get_pointer (item);
gint32 *total = data;
const gint32 *value = g_value_get_pointer (item);
*total += *value;
}
static void
array_foreach (const GValue *item, gpointer data)
{
gint *total = data;
const gint *value = g_value_get_pointer (item);
gint32 *total = data;
const gint32 *value = g_value_get_pointer (item);
*total += *value;
}
......@@ -724,7 +724,7 @@ test_spa_pod_iterator (void)
g_assert_false (wp_iterator_next (it, NULL));
}
gint total = 0;
gint32 total = 0;
g_assert_true (wp_iterator_foreach (it, choice_foreach, &total));
g_assert_cmpint (total, ==, 3);
......@@ -1012,8 +1012,8 @@ test_spa_pod_unique_owner (void)
static void
test_spa_pod_port_config (void)
{
const gint rate = 48000;
const gint channels = 2;
const gint32 rate = 48000;
const gint32 channels = 2;
/* Build the format to make sure the types exist */
g_autoptr (WpSpaPodBuilder) builder = wp_spa_pod_builder_new_object (
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment