summaryrefslogtreecommitdiff
path: root/src/auplay.c
diff options
context:
space:
mode:
authorAlfred E. Heggestad <alfred.heggestad@gmail.com>2017-03-22 12:52:14 +0100
committerGitHub <noreply@github.com>2017-03-22 12:52:14 +0100
commit4afc7980a64dcd4abd1bb79d048f7ea363e99cd1 (patch)
treebbcb5134490682b6157afbdaa68180a725f636ae /src/auplay.c
parentc3edc6136aabada7fbbe04e038918b833c1c32c1 (diff)
Ausrc auplay reentrant (#227)
* ausrc: re-entrant api * fix ausrc api for linux * fix ccheck * auplay: make it re-entrant * auplay: update more modules
Diffstat (limited to 'src/auplay.c')
-rw-r--r--src/auplay.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/src/auplay.c b/src/auplay.c
index a1247b6..38a7010 100644
--- a/src/auplay.c
+++ b/src/auplay.c
@@ -9,9 +9,6 @@
#include "core.h"
-static struct list auplayl = LIST_INIT;
-
-
static void destructor(void *arg)
{
struct auplay *ap = arg;
@@ -24,13 +21,14 @@ static void destructor(void *arg)
* Register an Audio Player
*
* @param app Pointer to allocated Audio Player object
+ * @param auplayl List of Audio Players
* @param name Audio Player name
* @param alloch Allocation handler
*
* @return 0 if success, otherwise errorcode
*/
-int auplay_register(struct auplay **app, const char *name,
- auplay_alloc_h *alloch)
+int auplay_register(struct auplay **app, struct list *auplayl,
+ const char *name, auplay_alloc_h *alloch)
{
struct auplay *ap;
@@ -41,7 +39,7 @@ int auplay_register(struct auplay **app, const char *name,
if (!ap)
return ENOMEM;
- list_append(&auplayl, &ap->le, ap);
+ list_append(auplayl, &ap->le, ap);
ap->name = name;
ap->alloch = alloch;
@@ -57,15 +55,16 @@ int auplay_register(struct auplay **app, const char *name,
/**
* Find an Audio Player by name
*
- * @param name Name of the Audio Player to find
+ * @param auplayl List of Audio Players
+ * @param name Name of the Audio Player to find
*
* @return Matching Audio Player if found, otherwise NULL
*/
-const struct auplay *auplay_find(const char *name)
+const struct auplay *auplay_find(const struct list *auplayl, const char *name)
{
struct le *le;
- for (le=auplayl.head; le; le=le->next) {
+ for (le=list_head(auplayl); le; le=le->next) {
struct auplay *ap = le->data;
@@ -82,22 +81,24 @@ const struct auplay *auplay_find(const char *name)
/**
* Allocate an Audio Player state
*
- * @param stp Pointer to allocated Audio Player state
- * @param name Name of Audio Player
- * @param prm Audio Player parameters
- * @param device Name of Audio Player device (driver specific)
- * @param wh Write handler
- * @param arg Handler argument
+ * @param stp Pointer to allocated Audio Player state
+ * @param auplayl List of Audio Players
+ * @param name Name of Audio Player
+ * @param prm Audio Player parameters
+ * @param device Name of Audio Player device (driver specific)
+ * @param wh Write handler
+ * @param arg Handler argument
*
* @return 0 if success, otherwise errorcode
*/
-int auplay_alloc(struct auplay_st **stp, const char *name,
+int auplay_alloc(struct auplay_st **stp, struct list *auplayl,
+ const char *name,
struct auplay_prm *prm, const char *device,
auplay_write_h *wh, void *arg)
{
struct auplay *ap;
- ap = (struct auplay *)auplay_find(name);
+ ap = (struct auplay *)auplay_find(auplayl, name);
if (!ap)
return ENOENT;