summaryrefslogtreecommitdiff
path: root/modules/oss
diff options
context:
space:
mode:
authorAlfred E. Heggestad <aeh@db.org>2015-06-16 21:49:43 +0200
committerAlfred E. Heggestad <aeh@db.org>2015-06-16 21:49:43 +0200
commit500a7d1de384e37d609476f84dce207cccf88dc2 (patch)
tree496ad61eb5d19117470fabcb8bdb62587a374769 /modules/oss
parent55fe148705d206d206f61dd9aa119a6672378e07 (diff)
change ausrc/auplay base-class to pointer
- change from a memory-reference to a const pointer - this saves one mem_deref() in the destructor and also decreases the chance of introducing memory leaks - test on debian
Diffstat (limited to 'modules/oss')
-rw-r--r--modules/oss/oss.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/modules/oss/oss.c b/modules/oss/oss.c
index 3a3e938..3d02154 100644
--- a/modules/oss/oss.c
+++ b/modules/oss/oss.c
@@ -33,7 +33,7 @@
struct ausrc_st {
- struct ausrc *as; /* inheritance */
+ const struct ausrc *as; /* inheritance */
int fd;
int16_t *sampv;
size_t sampc;
@@ -43,7 +43,7 @@ struct ausrc_st {
};
struct auplay_st {
- struct auplay *ap; /* inheritance */
+ const struct auplay *ap; /* inheritance */
pthread_t thread;
bool run;
int fd;
@@ -153,7 +153,6 @@ static void auplay_destructor(void *arg)
}
mem_deref(st->sampv);
- mem_deref(st->ap);
}
@@ -167,7 +166,6 @@ static void ausrc_destructor(void *arg)
}
mem_deref(st->sampv);
- mem_deref(st->as);
}
@@ -205,7 +203,7 @@ static void *play_thread(void *arg)
}
-static int src_alloc(struct ausrc_st **stp, struct ausrc *as,
+static int src_alloc(struct ausrc_st **stp, const struct ausrc *as,
struct media_ctx **ctx,
struct ausrc_prm *prm, const char *device,
ausrc_read_h *rh, ausrc_error_h *errh, void *arg)
@@ -253,7 +251,7 @@ static int src_alloc(struct ausrc_st **stp, struct ausrc *as,
if (err)
goto out;
- st->as = mem_ref(as);
+ st->as = as;
out:
if (err)
@@ -265,7 +263,7 @@ static int src_alloc(struct ausrc_st **stp, struct ausrc *as,
}
-static int play_alloc(struct auplay_st **stp, struct auplay *ap,
+static int play_alloc(struct auplay_st **stp, const struct auplay *ap,
struct auplay_prm *prm, const char *device,
auplay_write_h *wh, void *arg)
{
@@ -304,7 +302,7 @@ static int play_alloc(struct auplay_st **stp, struct auplay *ap,
if (err)
goto out;
- st->ap = mem_ref(ap);
+ st->ap = ap;
st->run = true;
err = pthread_create(&st->thread, NULL, play_thread, st);