mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
parent
43e2c64307
commit
4496c33751
6 changed files with 59 additions and 38 deletions
|
|
@ -136,6 +136,7 @@ pipewire_module_protocol_pulse_sources = [
|
|||
'module-protocol-pulse/format.c',
|
||||
'module-protocol-pulse/manager.c',
|
||||
'module-protocol-pulse/pulse-server.c',
|
||||
'module-protocol-pulse/volume.c',
|
||||
'module-protocol-pulse/modules/module-combine-sink.c',
|
||||
'module-protocol-pulse/modules/module-echo-cancel.c',
|
||||
'module-protocol-pulse/modules/module-ladspa-sink.c',
|
||||
|
|
|
|||
|
|
@ -29,6 +29,9 @@
|
|||
#include "format.h"
|
||||
#include "volume.h"
|
||||
|
||||
struct pw_manager;
|
||||
struct pw_manager_object;
|
||||
|
||||
struct device_info {
|
||||
uint32_t direction;
|
||||
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@
|
|||
#include <pipewire/private.h>
|
||||
|
||||
#include "format.h"
|
||||
#include "volume.h"
|
||||
|
||||
struct defs {
|
||||
struct spa_fraction min_req;
|
||||
|
|
@ -123,15 +124,6 @@ struct buffer_attr {
|
|||
uint32_t fragsize;
|
||||
};
|
||||
|
||||
struct volume {
|
||||
uint8_t channels;
|
||||
float values[CHANNELS_MAX];
|
||||
};
|
||||
|
||||
#define VOLUME_INIT (struct volume) { \
|
||||
.channels = 0, \
|
||||
}
|
||||
|
||||
struct stream {
|
||||
uint32_t create_tag;
|
||||
uint32_t channel; /* index in map */
|
||||
|
|
|
|||
|
|
@ -84,6 +84,7 @@
|
|||
#include "defs.h"
|
||||
#include "format.h"
|
||||
#include "internal.h"
|
||||
#include "volume.h"
|
||||
|
||||
#define DEFAULT_MIN_REQ "256/48000"
|
||||
#define DEFAULT_DEFAULT_REQ "960/48000"
|
||||
|
|
@ -99,7 +100,6 @@
|
|||
#define MAX_FORMATS 32
|
||||
#define MAX_CLIENTS 64
|
||||
|
||||
#include "volume.c"
|
||||
#include "message.c"
|
||||
#include "manager.h"
|
||||
#include "dbus-name.c"
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -26,7 +26,22 @@
|
|||
#ifndef PULSE_SERVER_VOLUME_H
|
||||
#define PULSE_SERVER_VOLUME_H
|
||||
|
||||
#include "internal.h"
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "format.h"
|
||||
|
||||
struct spa_pod;
|
||||
|
||||
struct volume {
|
||||
uint8_t channels;
|
||||
float values[CHANNELS_MAX];
|
||||
};
|
||||
|
||||
#define VOLUME_INIT \
|
||||
(struct volume) { \
|
||||
.channels = 0, \
|
||||
}
|
||||
|
||||
struct volume_info {
|
||||
struct volume volume;
|
||||
|
|
@ -40,12 +55,31 @@ struct volume_info {
|
|||
uint32_t flags;
|
||||
};
|
||||
|
||||
#define VOLUME_INFO_INIT (struct volume_info) { \
|
||||
.volume = VOLUME_INIT, \
|
||||
.mute = false, \
|
||||
.level = 1.0, \
|
||||
.base = 1.0, \
|
||||
.steps = 256, \
|
||||
}
|
||||
#define VOLUME_INFO_INIT \
|
||||
(struct volume_info) { \
|
||||
.volume = VOLUME_INIT, \
|
||||
.mute = false, \
|
||||
.level = 1.0, \
|
||||
.base = 1.0, \
|
||||
.steps = 256, \
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
int volume_compare(struct volume *vol, struct volume *other);
|
||||
int volume_parse_param(const struct spa_pod *param, struct volume_info *info, bool monitor);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue