pulse-server: init volume/channelmap correctly in stream-restore

This commit is contained in:
Wim Taymans 2020-11-24 09:54:42 +01:00
parent edbec5d4ba
commit 0c66b5677b
4 changed files with 20 additions and 11 deletions

View file

@ -115,21 +115,19 @@ static int key_to_name(const char *key, char *name, size_t maxlen)
static int do_extension_stream_restore_read(struct client *client, uint32_t command, uint32_t tag, struct message *m) static int do_extension_stream_restore_read(struct client *client, uint32_t command, uint32_t tag, struct message *m)
{ {
struct message *reply; struct message *reply;
struct volume vol = VOLUME_INIT;
struct channel_map map;
float volume;
char device_name[1024] = "\0";
const struct spa_dict_item *item; const struct spa_dict_item *item;
spa_zero(map);
reply = reply_new(client, tag); reply = reply_new(client, tag);
spa_dict_for_each(item, &client->routes->dict) { spa_dict_for_each(item, &client->routes->dict) {
struct spa_json it[3]; struct spa_json it[3];
const char *value; const char *value;
char name[1024]; char name[1024];
char device_name[1024] = "\0";
bool mute = false; bool mute = false;
struct volume vol = VOLUME_INIT;
struct channel_map map = CHANNEL_MAP_INIT;
float volume = 0.0f;
int len; int len;
if (key_to_name(item->key, name, sizeof(name)) < 0) if (key_to_name(item->key, name, sizeof(name)) < 0)
@ -178,7 +176,6 @@ static int do_extension_stream_restore_read(struct client *client, uint32_t comm
else if (spa_json_next(&it[1], &value) <= 0) else if (spa_json_next(&it[1], &value) <= 0)
break; break;
} }
map.channels = vol.channels;
message_put(reply, message_put(reply,
TAG_STRING, name, TAG_STRING, name,
TAG_CHANNEL_MAP, &map, TAG_CHANNEL_MAP, &map,

View file

@ -108,6 +108,11 @@ struct sample_spec {
uint8_t channels; uint8_t channels;
}; };
#define SAMPLE_SPEC_INIT (struct sample_spec) { \ #define SAMPLE_SPEC_INIT (struct sample_spec) { \
.format = SPA_AUDIO_FORMAT_UNKNOWN, \
.rate = 0, \
.channels = 0, \
}
#define SAMPLE_SPEC_DEFAULT (struct sample_spec) { \
.format = SPA_AUDIO_FORMAT_F32, \ .format = SPA_AUDIO_FORMAT_F32, \
.rate = 44100, \ .rate = 44100, \
.channels = 2, \ .channels = 2, \
@ -279,6 +284,9 @@ struct channel_map {
}; };
#define CHANNEL_MAP_INIT (struct channel_map) { \ #define CHANNEL_MAP_INIT (struct channel_map) { \
.channels = 0, \
}
#define CHANNEL_MAP_DEFAULT (struct channel_map) { \
.channels = 2, \ .channels = 2, \
.map[0] = SPA_AUDIO_CHANNEL_FL, \ .map[0] = SPA_AUDIO_CHANNEL_FL, \
.map[1] = SPA_AUDIO_CHANNEL_FR, \ .map[1] = SPA_AUDIO_CHANNEL_FR, \

View file

@ -3101,8 +3101,8 @@ static int do_get_server_info(struct client *client, uint32_t command, uint32_t
pw_log_info(NAME" %p: [%s] GET_SERVER_INFO tag:%u", impl, client->name, tag); pw_log_info(NAME" %p: [%s] GET_SERVER_INFO tag:%u", impl, client->name, tag);
ss = SAMPLE_SPEC_INIT; ss = SAMPLE_SPEC_DEFAULT;
map = CHANNEL_MAP_INIT; map = CHANNEL_MAP_DEFAULT;
if (info != NULL) { if (info != NULL) {
if (info->props && if (info->props &&

View file

@ -28,6 +28,10 @@ struct volume {
}; };
#define VOLUME_INIT (struct volume) { \ #define VOLUME_INIT (struct volume) { \
.channels = 0, \
}
#define VOLUME_DEFAULT (struct volume) { \
.channels = 2, \ .channels = 2, \
.values[0] = 1.0f, \ .values[0] = 1.0f, \
.values[1] = 1.0f, \ .values[1] = 1.0f, \