summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlfred E. Heggestad <alfred.heggestad@gmail.com>2017-05-26 12:15:19 +0200
committerGitHub <noreply@github.com>2017-05-26 12:15:19 +0200
commit8096fa45a71f0f1cbc93881e3e5733a4e697d75b (patch)
tree0c49e07fd3b58c4797f3604bd4f2124c038bc401 /src
parentebbf920a502d6d460ff3ea8a57db0c624e3a0747 (diff)
Vidisp api reentrant (#258)
* vidisp: make the API re-entrant * vidisp: update all modules to re-entrant API
Diffstat (limited to 'src')
-rw-r--r--src/baresip.c8
-rw-r--r--src/call.c2
-rw-r--r--src/video.c5
-rw-r--r--src/vidisp.c20
4 files changed, 22 insertions, 13 deletions
diff --git a/src/baresip.c b/src/baresip.c
index d1ebc1d..5484f77 100644
--- a/src/baresip.c
+++ b/src/baresip.c
@@ -26,6 +26,7 @@ static struct baresip {
struct list aufiltl;
struct list vidcodecl;
struct list vidsrcl;
+ struct list vidispl;
} baresip;
@@ -45,6 +46,7 @@ int baresip_init(struct config *cfg, bool prefer_ipv6)
list_init(&baresip.auplayl);
list_init(&baresip.vidcodecl);
list_init(&baresip.vidsrcl);
+ list_init(&baresip.vidispl);
/* Initialise Network */
err = net_alloc(&baresip.net, &cfg->net,
@@ -168,3 +170,9 @@ struct list *baresip_vidsrcl(void)
{
return &baresip.vidsrcl;
}
+
+
+struct list *baresip_vidispl(void)
+{
+ return &baresip.vidispl;
+}
diff --git a/src/call.c b/src/call.c
index f164ec1..0cc66b4 100644
--- a/src/call.c
+++ b/src/call.c
@@ -600,7 +600,7 @@ int call_alloc(struct call **callp, const struct config *cfg, struct list *lst,
use_video = (vidmode != VIDMODE_OFF)
&& (list_head(account_vidcodecl(call->acc)) != NULL)
&& (NULL != vidsrc_find(baresip_vidsrcl(), NULL)
- || NULL != vidisp_find(NULL));
+ || NULL != vidisp_find(baresip_vidispl(), NULL));
debug("call: use_video=%d\n", use_video);
diff --git a/src/video.c b/src/video.c
index 6ccfb88..9e767d0 100644
--- a/src/video.c
+++ b/src/video.c
@@ -867,7 +867,8 @@ static int set_vidisp(struct vrx *vrx)
vrx->vidisp = mem_deref(vrx->vidisp);
vrx->vidisp_prm.view = NULL;
- vd = (struct vidisp *)vidisp_find(vrx->video->cfg.disp_mod);
+ vd = (struct vidisp *)vidisp_find(baresip_vidispl(),
+ vrx->video->cfg.disp_mod);
if (!vd)
return ENOENT;
@@ -945,7 +946,7 @@ int video_start(struct video *v, const char *peer)
stream_set_srate(v->strm, SRATE, SRATE);
- if (vidisp_find(NULL)) {
+ if (vidisp_find(baresip_vidispl(), NULL)) {
err = set_vidisp(&v->vrx);
if (err) {
warning("video: could not set vidisp '%s': %m\n",
diff --git a/src/vidisp.c b/src/vidisp.c
index 94ceee5..d267f58 100644
--- a/src/vidisp.c
+++ b/src/vidisp.c
@@ -14,9 +14,6 @@ struct vidisp_st {
};
-static struct list vidispl = LIST_INIT;
-
-
static void destructor(void *arg)
{
struct vidisp *vd = arg;
@@ -29,6 +26,7 @@ static void destructor(void *arg)
* Register a Video output display
*
* @param vp Pointer to allocated Video Display
+ * @param vidispl List of Video-displays
* @param name Name of Video Display
* @param alloch Allocation handler
* @param updateh Update handler
@@ -37,20 +35,20 @@ static void destructor(void *arg)
*
* @return 0 if success, otherwise errorcode
*/
-int vidisp_register(struct vidisp **vp, const char *name,
+int vidisp_register(struct vidisp **vp, struct list *vidispl, const char *name,
vidisp_alloc_h *alloch, vidisp_update_h *updateh,
vidisp_disp_h *disph, vidisp_hide_h *hideh)
{
struct vidisp *vd;
- if (!vp)
+ if (!vp || !vidispl)
return EINVAL;
vd = mem_zalloc(sizeof(*vd), destructor);
if (!vd)
return ENOMEM;
- list_append(&vidispl, &vd->le, vd);
+ list_append(vidispl, &vd->le, vd);
vd->name = name;
vd->alloch = alloch;
@@ -65,11 +63,11 @@ int vidisp_register(struct vidisp **vp, const char *name,
}
-const struct vidisp *vidisp_find(const char *name)
+const struct vidisp *vidisp_find(const struct list *vidispl, const char *name)
{
struct le *le;
- for (le = vidispl.head; le; le = le->next) {
+ for (le = list_head(vidispl); le; le = le->next) {
struct vidisp *vd = le->data;
if (str_isset(name) && 0 != str_casecmp(name, vd->name))
@@ -87,6 +85,7 @@ const struct vidisp *vidisp_find(const char *name)
* Allocate a video display state
*
* @param stp Pointer to allocated display state
+ * @param vidispl List of Video-displays
* @param name Name of video display
* @param prm Video display parameters (optional)
* @param dev Display device
@@ -95,11 +94,12 @@ const struct vidisp *vidisp_find(const char *name)
*
* @return 0 if success, otherwise errorcode
*/
-int vidisp_alloc(struct vidisp_st **stp, const char *name,
+int vidisp_alloc(struct vidisp_st **stp, struct list *vidispl,
+ const char *name,
struct vidisp_prm *prm, const char *dev,
vidisp_resize_h *resizeh, void *arg)
{
- struct vidisp *vd = (struct vidisp *)vidisp_find(name);
+ struct vidisp *vd = (struct vidisp *)vidisp_find(vidispl, name);
if (!vd)
return ENOENT;