Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'jb17974' into 'master'
Re-send device infos when policy decision point restarts. See merge request !7
- Loading branch information
Showing
9 changed files
with
135 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
#include <stdio.h> | ||
#include <sys/types.h> | ||
#include <unistd.h> | ||
#include <errno.h> | ||
|
||
#ifdef HAVE_CONFIG_H | ||
#include <config.h> | ||
#endif | ||
|
||
#include <pulsecore/log.h> | ||
|
||
#include "policy.h" | ||
#include "dbusif.h" | ||
#include "classify.h" | ||
|
||
void pa_policy_send_device_state(struct userdata *u, const char *state, | ||
char *typelist) | ||
{ | ||
#define MAX_TYPE 256 | ||
|
||
const char *types[MAX_TYPE]; | ||
int ntype; | ||
char buf[1024]; | ||
char *p, *q, c; | ||
|
||
if (typelist && typelist[0]) { | ||
|
||
ntype = 0; | ||
|
||
p = typelist - 1; | ||
q = buf; | ||
|
||
do { | ||
p++; | ||
|
||
if (ntype < MAX_TYPE) | ||
types[ntype] = q; | ||
else { | ||
pa_log("%s() list overflow", __FUNCTION__); | ||
return; | ||
} | ||
|
||
while ((c = *p) != ' ' && c != '\0') { | ||
if (q < buf + sizeof(buf)-1) | ||
*q++ = *p++; | ||
else { | ||
pa_log("%s() buffer overflow", __FUNCTION__); | ||
return; | ||
} | ||
} | ||
*q++ = '\0'; | ||
ntype++; | ||
|
||
} while (*p); | ||
|
||
pa_policy_dbusif_send_device_state(u, state, types, ntype); | ||
} | ||
|
||
#undef MAX_TYPE | ||
} | ||
|
||
void pa_policy_send_device_state_full(struct userdata *u) | ||
{ | ||
void *state = NULL; | ||
pa_idxset *idxset; | ||
struct pa_card *card; | ||
struct pa_sink *sink; | ||
struct pa_source *source; | ||
const char *typelist; | ||
char buf[1024]; | ||
int len; | ||
|
||
pa_assert(u); | ||
pa_assert(u->core); | ||
|
||
/* cards */ | ||
pa_assert_se((idxset = u->core->cards)); | ||
state = NULL; | ||
|
||
while ((card = pa_idxset_iterate(idxset, &state, NULL))) { | ||
len = pa_classify_card(u, card, PA_POLICY_DISABLE_NOTIFY, 0, | ||
buf, sizeof(buf)); | ||
if (len > 0) | ||
pa_policy_send_device_state(u, PA_POLICY_CONNECTED, buf); | ||
} | ||
|
||
/* sinks */ | ||
pa_assert_se((idxset = u->core->sinks)); | ||
state = NULL; | ||
|
||
while ((sink = pa_idxset_iterate(idxset, &state, NULL))) { | ||
len = pa_classify_sink(u, sink, PA_POLICY_DISABLE_NOTIFY, 0, | ||
buf, sizeof(buf)); | ||
if (len > 0) | ||
pa_policy_send_device_state(u, PA_POLICY_CONNECTED, buf); | ||
} | ||
|
||
/* sources */ | ||
pa_assert_se((idxset = u->core->sources)); | ||
state = NULL; | ||
|
||
while ((source = pa_idxset_iterate(idxset, &state, NULL))) { | ||
len = pa_classify_source(u, source, PA_POLICY_DISABLE_NOTIFY, 0, | ||
buf, sizeof(buf)); | ||
if (len > 0) | ||
pa_policy_send_device_state(u, PA_POLICY_CONNECTED, buf); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#ifndef foopolicyfoo | ||
#define foopolicyfoo | ||
|
||
#include "userdata.h" | ||
|
||
#define PA_POLICY_CONNECTED "1" | ||
#define PA_POLICY_DISCONNECTED "0" | ||
|
||
void pa_policy_send_device_state(struct userdata *u, const char *state, | ||
char *typelist); | ||
void pa_policy_send_device_state_full(struct userdata *u); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters