Skip to content

Commit

Permalink
Merge pull request #12 from dtmuller/add-int-type
Browse files Browse the repository at this point in the history
add pod type int
  • Loading branch information
Curve authored Feb 24, 2025
2 parents f34a784 + 7fc4348 commit ff5a36d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions include/rohrkabel/spa/pod/pod.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ namespace pipewire::spa
string = 8,
boolean = 2,
object = 15,
num_int = 4,
num_float = 6,
array = 13,
};
Expand Down Expand Up @@ -99,6 +100,8 @@ namespace pipewire::spa
template <>
bool pod::as() const;
template <>
int pod::as() const;
template <>
float pod::as() const;
template <>
pod_object pod::as() const;
Expand All @@ -108,6 +111,8 @@ namespace pipewire::spa
template <>
void pod::write(const bool &);
template <>
void pod::write(const int &);
template <>
void pod::write(const float &);
} // namespace pipewire::spa

Expand Down
14 changes: 14 additions & 0 deletions src/spa/spa.pod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,13 @@ namespace pipewire::spa
return reinterpret_cast<spa_pod_bool *>(m_impl->pod.get())->value;
}

template <>
int pod::as() const
{
assert(type() == spa::type::num_int);
return reinterpret_cast<spa_pod_int *>(m_impl->pod.get())->value;
}

template <>
float pod::as() const
{
Expand Down Expand Up @@ -156,6 +163,13 @@ namespace pipewire::spa
reinterpret_cast<spa_pod_bool *>(m_impl->pod.get())->value = value;
}

template <>
void pod::write(const int &value)
{
assert(type() == spa::type::num_int);
reinterpret_cast<spa_pod_int *>(m_impl->pod.get())->value = value;
}

template <>
void pod::write(const float &value)
{
Expand Down

0 comments on commit ff5a36d

Please sign in to comment.