pulse-server: split out volume handling

Part of !776.
This commit is contained in:
Barnabás Pőcze 2021-06-18 22:04:45 +02:00
parent 43e2c64307
commit 4496c33751
6 changed files with 59 additions and 38 deletions

View file

@ -22,24 +22,15 @@
* DEALINGS IN THE SOFTWARE.
*/
#include <spa/param/props.h>
#include <spa/param/audio/raw.h>
#include <spa/pod/iter.h>
#include <spa/utils/defs.h>
#include <pipewire/log.h>
#include "volume.h"
static inline bool volume_valid(const struct volume *vol)
{
if (vol->channels == 0 || vol->channels > CHANNELS_MAX)
return false;
return true;
}
static inline void volume_make(struct volume *vol, uint8_t channels)
{
uint8_t i;
for (i = 0; i < channels; i++)
vol->values[i] = 1.0f;
vol->channels = channels;
}
static inline int volume_compare(struct volume *vol, struct volume *other)
int volume_compare(struct volume *vol, struct volume *other)
{
uint8_t i;
if (vol->channels != other->channels) {
@ -55,7 +46,7 @@ static inline int volume_compare(struct volume *vol, struct volume *other)
return 0;
}
static int volume_parse_param(const struct spa_pod *param, struct volume_info *info, bool monitor)
int volume_parse_param(const struct spa_pod *param, struct volume_info *info, bool monitor)
{
struct spa_pod_object *obj = (struct spa_pod_object *) param;
struct spa_pod_prop *prop;
@ -66,7 +57,7 @@ static int volume_parse_param(const struct spa_pod *param, struct volume_info *i
if (spa_pod_get_float(&prop->value, &info->level) < 0)
continue;
SPA_FLAG_UPDATE(info->flags, VOLUME_HW_VOLUME,
prop->flags & SPA_POD_PROP_FLAG_HARDWARE);
prop->flags & SPA_POD_PROP_FLAG_HARDWARE);
break;
case SPA_PROP_mute:
@ -75,7 +66,7 @@ static int volume_parse_param(const struct spa_pod *param, struct volume_info *i
if (spa_pod_get_bool(&prop->value, &info->mute) < 0)
continue;
SPA_FLAG_UPDATE(info->flags, VOLUME_HW_MUTE,
prop->flags & SPA_POD_PROP_FLAG_HARDWARE);
prop->flags & SPA_POD_PROP_FLAG_HARDWARE);
break;
case SPA_PROP_channelVolumes:
if (monitor)
@ -83,7 +74,7 @@ static int volume_parse_param(const struct spa_pod *param, struct volume_info *i
info->volume.channels = spa_pod_copy_array(&prop->value, SPA_TYPE_Float,
info->volume.values, SPA_AUDIO_MAX_CHANNELS);
SPA_FLAG_UPDATE(info->flags, VOLUME_HW_VOLUME,
prop->flags & SPA_POD_PROP_FLAG_HARDWARE);
prop->flags & SPA_POD_PROP_FLAG_HARDWARE);
break;
case SPA_PROP_monitorMute:
if (!monitor)