summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlfred E. Heggestad <aeh@db.org>2015-06-17 22:01:34 +0200
committerAlfred E. Heggestad <aeh@db.org>2015-06-17 22:01:34 +0200
commitd09e084a046fa3deba6125a599745ff700c9a74e (patch)
tree45c7349221cb5d0164db091a5d20106df41a72b5
parent55fe148705d206d206f61dd9aa119a6672378e07 (diff)
parentd0297e5b60907b3a8011bb9c7f011bb09c68060c (diff)
Merge pull request #43 from alfredh/ausrc_auplay_const
Ausrc auplay const
-rw-r--r--include/baresip.h4
-rw-r--r--mk/modules.mk3
-rw-r--r--modules/alsa/alsa.h4
-rw-r--r--modules/alsa/alsa_play.c7
-rw-r--r--modules/alsa/alsa_src.c7
-rw-r--r--modules/aubridge/aubridge.h8
-rw-r--r--modules/aubridge/play.c5
-rw-r--r--modules/aubridge/src.c5
-rw-r--r--modules/audiounit/audiounit.c7
-rw-r--r--modules/audiounit/audiounit.h4
-rw-r--r--modules/audiounit/player.c7
-rw-r--r--modules/audiounit/recorder.c7
-rw-r--r--modules/aufile/aufile.c7
-rw-r--r--modules/coreaudio/coreaudio.c7
-rw-r--r--modules/coreaudio/coreaudio.h4
-rw-r--r--modules/coreaudio/player.c8
-rw-r--r--modules/coreaudio/recorder.c8
-rw-r--r--modules/gst/gst.c9
-rw-r--r--modules/opensles/opensles.c9
-rw-r--r--modules/opensles/opensles.h4
-rw-r--r--modules/opensles/player.c8
-rw-r--r--modules/opensles/recorder.c8
-rw-r--r--modules/oss/oss.c14
-rw-r--r--modules/portaudio/portaudio.c16
-rw-r--r--modules/rst/audio.c7
-rw-r--r--modules/sndio/sndio.c41
-rw-r--r--modules/winwave/play.c8
-rw-r--r--modules/winwave/src.c8
-rw-r--r--modules/winwave/winwave.h4
-rw-r--r--src/core.h2
30 files changed, 114 insertions, 126 deletions
diff --git a/include/baresip.h b/include/baresip.h
index ac1c6eb..fe0dbab 100644
--- a/include/baresip.h
+++ b/include/baresip.h
@@ -266,7 +266,7 @@ struct ausrc_prm {
typedef void (ausrc_read_h)(const int16_t *sampv, size_t sampc, void *arg);
typedef void (ausrc_error_h)(int err, const char *str, void *arg);
-typedef int (ausrc_alloc_h)(struct ausrc_st **stp, struct ausrc *ausrc,
+typedef int (ausrc_alloc_h)(struct ausrc_st **stp, const struct ausrc *ausrc,
struct media_ctx **ctx,
struct ausrc_prm *prm, const char *device,
ausrc_read_h *rh, ausrc_error_h *errh, void *arg);
@@ -296,7 +296,7 @@ struct auplay_prm {
typedef void (auplay_write_h)(int16_t *sampv, size_t sampc, void *arg);
-typedef int (auplay_alloc_h)(struct auplay_st **stp, struct auplay *ap,
+typedef int (auplay_alloc_h)(struct auplay_st **stp, const struct auplay *ap,
struct auplay_prm *prm, const char *device,
auplay_write_h *wh, void *arg);
diff --git a/mk/modules.mk b/mk/modules.mk
index e938e7b..35695e7 100644
--- a/mk/modules.mk
+++ b/mk/modules.mk
@@ -198,6 +198,9 @@ ifeq ($(OS),win32)
USE_WINWAVE := yes
MODULES += wincons
endif
+ifeq ($(OS),openbsd)
+MODULES += sndio
+endif
endif
diff --git a/modules/alsa/alsa.h b/modules/alsa/alsa.h
index be345c6..a121ebb 100644
--- a/modules/alsa/alsa.h
+++ b/modules/alsa/alsa.h
@@ -9,10 +9,10 @@ extern char alsa_dev[64];
int alsa_reset(snd_pcm_t *pcm, uint32_t srate, uint32_t ch,
uint32_t num_frames);
-int alsa_src_alloc(struct ausrc_st **stp, struct ausrc *as,
+int alsa_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);
-int alsa_play_alloc(struct auplay_st **stp, struct auplay *ap,
+int alsa_play_alloc(struct auplay_st **stp, const struct auplay *ap,
struct auplay_prm *prm, const char *device,
auplay_write_h *wh, void *arg);
diff --git a/modules/alsa/alsa_play.c b/modules/alsa/alsa_play.c
index ebd8146..bcc730b 100644
--- a/modules/alsa/alsa_play.c
+++ b/modules/alsa/alsa_play.c
@@ -17,7 +17,7 @@
struct auplay_st {
- struct auplay *ap; /* inheritance */
+ const struct auplay *ap; /* pointer to base-class (inheritance) */
pthread_t thread;
bool run;
snd_pcm_t *write;
@@ -44,7 +44,6 @@ static void auplay_destructor(void *arg)
snd_pcm_close(st->write);
mem_deref(st->sampv);
- mem_deref(st->ap);
mem_deref(st->device);
}
@@ -85,7 +84,7 @@ static void *write_thread(void *arg)
}
-int alsa_play_alloc(struct auplay_st **stp, struct auplay *ap,
+int alsa_play_alloc(struct auplay_st **stp, const struct auplay *ap,
struct auplay_prm *prm, const char *device,
auplay_write_h *wh, void *arg)
{
@@ -108,7 +107,7 @@ int alsa_play_alloc(struct auplay_st **stp, struct auplay *ap,
goto out;
st->prm = *prm;
- st->ap = mem_ref(ap);
+ st->ap = ap;
st->wh = wh;
st->arg = arg;
diff --git a/modules/alsa/alsa_src.c b/modules/alsa/alsa_src.c
index f95765c..0a5d548 100644
--- a/modules/alsa/alsa_src.c
+++ b/modules/alsa/alsa_src.c
@@ -17,7 +17,7 @@
struct ausrc_st {
- struct ausrc *as; /* inheritance */
+ const struct ausrc *as; /* pointer to base-class (inheritance) */
pthread_t thread;
bool run;
snd_pcm_t *read;
@@ -44,7 +44,6 @@ static void ausrc_destructor(void *arg)
snd_pcm_close(st->read);
mem_deref(st->sampv);
- mem_deref(st->as);
mem_deref(st->device);
}
@@ -83,7 +82,7 @@ static void *read_thread(void *arg)
}
-int alsa_src_alloc(struct ausrc_st **stp, struct ausrc *as,
+int alsa_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)
@@ -109,7 +108,7 @@ int alsa_src_alloc(struct ausrc_st **stp, struct ausrc *as,
goto out;
st->prm = *prm;
- st->as = mem_ref(as);
+ st->as = as;
st->rh = rh;
st->arg = arg;
diff --git a/modules/aubridge/aubridge.h b/modules/aubridge/aubridge.h
index 76ec53f..7e24b6c 100644
--- a/modules/aubridge/aubridge.h
+++ b/modules/aubridge/aubridge.h
@@ -8,7 +8,7 @@
struct device;
struct ausrc_st {
- struct ausrc *as; /* inheritance */
+ const struct ausrc *as; /* inheritance */
struct device *dev;
struct ausrc_prm prm;
ausrc_read_h *rh;
@@ -16,7 +16,7 @@ struct ausrc_st {
};
struct auplay_st {
- struct auplay *ap; /* inheritance */
+ const struct auplay *ap; /* inheritance */
struct device *dev;
struct auplay_prm prm;
auplay_write_h *wh;
@@ -27,10 +27,10 @@ struct auplay_st {
extern struct hash *ht_device;
-int play_alloc(struct auplay_st **stp, struct auplay *ap,
+int play_alloc(struct auplay_st **stp, const struct auplay *ap,
struct auplay_prm *prm, const char *device,
auplay_write_h *wh, void *arg);
-int src_alloc(struct ausrc_st **stp, struct ausrc *as,
+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);
diff --git a/modules/aubridge/play.c b/modules/aubridge/play.c
index c31792c..37c04fa 100644
--- a/modules/aubridge/play.c
+++ b/modules/aubridge/play.c
@@ -15,11 +15,10 @@ static void auplay_destructor(void *arg)
device_stop(st->dev);
mem_deref(st->dev);
- mem_deref(st->ap);
}
-int play_alloc(struct auplay_st **stp, struct auplay *ap,
+int play_alloc(struct auplay_st **stp, const struct auplay *ap,
struct auplay_prm *prm, const char *device,
auplay_write_h *wh, void *arg)
{
@@ -33,7 +32,7 @@ int play_alloc(struct auplay_st **stp, struct auplay *ap,
if (!st)
return ENOMEM;
- st->ap = mem_ref(ap);
+ st->ap = ap;
st->prm = *prm;
st->wh = wh;
st->arg = arg;
diff --git a/modules/aubridge/src.c b/modules/aubridge/src.c
index 6439cdd..22ce13a 100644
--- a/modules/aubridge/src.c
+++ b/modules/aubridge/src.c
@@ -15,11 +15,10 @@ static void ausrc_destructor(void *arg)
device_stop(st->dev);
mem_deref(st->dev);
- mem_deref(st->as);
}
-int src_alloc(struct ausrc_st **stp, struct ausrc *as,
+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)
@@ -36,7 +35,7 @@ int src_alloc(struct ausrc_st **stp, struct ausrc *as,
if (!st)
return ENOMEM;
- st->as = mem_ref(as);
+ st->as = as;
st->prm = *prm;
st->rh = rh;
st->arg = arg;
diff --git a/modules/audiounit/audiounit.c b/modules/audiounit/audiounit.c
index d5bbcc7..74583fc 100644
--- a/modules/audiounit/audiounit.c
+++ b/modules/audiounit/audiounit.c
@@ -10,6 +10,13 @@
#include "audiounit.h"
+/**
+ * @defgroup audiounit audiounit
+ *
+ * Audio driver module for OSX/iOS AudioUnit
+ */
+
+
AudioComponent output_comp = NULL;
static struct auplay *auplay;
diff --git a/modules/audiounit/audiounit.h b/modules/audiounit/audiounit.h
index dd85131..28e4a3a 100644
--- a/modules/audiounit/audiounit.h
+++ b/modules/audiounit/audiounit.h
@@ -18,10 +18,10 @@ int audiosess_alloc(struct audiosess_st **stp,
void audiosess_interrupt(bool interrupted);
-int audiounit_player_alloc(struct auplay_st **stp, struct auplay *ap,
+int audiounit_player_alloc(struct auplay_st **stp, const struct auplay *ap,
struct auplay_prm *prm, const char *device,
auplay_write_h *wh, void *arg);
-int audiounit_recorder_alloc(struct ausrc_st **stp, struct ausrc *as,
+int audiounit_recorder_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);
diff --git a/modules/audiounit/player.c b/modules/audiounit/player.c
index b875568..99b83c9 100644
--- a/modules/audiounit/player.c
+++ b/modules/audiounit/player.c
@@ -12,7 +12,7 @@
struct auplay_st {
- struct auplay *ap; /* inheritance */
+ const struct auplay *ap; /* inheritance */
struct audiosess_st *sess;
AudioUnit au;
pthread_mutex_t mutex;
@@ -34,7 +34,6 @@ static void auplay_destructor(void *arg)
AudioComponentInstanceDispose(st->au);
mem_deref(st->sess);
- mem_deref(st->ap);
pthread_mutex_destroy(&st->mutex);
}
@@ -87,7 +86,7 @@ static void interrupt_handler(bool interrupted, void *arg)
}
-int audiounit_player_alloc(struct auplay_st **stp, struct auplay *ap,
+int audiounit_player_alloc(struct auplay_st **stp, const struct auplay *ap,
struct auplay_prm *prm, const char *device,
auplay_write_h *wh, void *arg)
{
@@ -105,7 +104,7 @@ int audiounit_player_alloc(struct auplay_st **stp, struct auplay *ap,
if (!st)
return ENOMEM;
- st->ap = mem_ref(ap);
+ st->ap = ap;
st->wh = wh;
st->arg = arg;
diff --git a/modules/audiounit/recorder.c b/modules/audiounit/recorder.c
index 83943e3..d46f331 100644
--- a/modules/audiounit/recorder.c
+++ b/modules/audiounit/recorder.c
@@ -12,7 +12,7 @@
struct ausrc_st {
- struct ausrc *as; /* inheritance */
+ const struct ausrc *as; /* inheritance */
struct audiosess_st *sess;
AudioUnit au;
pthread_mutex_t mutex;
@@ -35,7 +35,6 @@ static void ausrc_destructor(void *arg)
AudioComponentInstanceDispose(st->au);
mem_deref(st->sess);
- mem_deref(st->as);
pthread_mutex_destroy(&st->mutex);
}
@@ -95,7 +94,7 @@ static void interrupt_handler(bool interrupted, void *arg)
}
-int audiounit_recorder_alloc(struct ausrc_st **stp, struct ausrc *as,
+int audiounit_recorder_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)
@@ -116,7 +115,7 @@ int audiounit_recorder_alloc(struct ausrc_st **stp, struct ausrc *as,
if (!st)
return ENOMEM;
- st->as = mem_ref(as);
+ st->as = as;
st->rh = rh;
st->arg = arg;
st->ch = prm->ch;
diff --git a/modules/aufile/aufile.c b/modules/aufile/aufile.c
index 0323758..0fc9faa 100644
--- a/modules/aufile/aufile.c
+++ b/modules/aufile/aufile.c
@@ -19,7 +19,7 @@
struct ausrc_st {
- struct ausrc *as; /* base class */
+ const struct ausrc *as; /* base class */
struct tmr tmr;
struct aufile *aufile;
struct aubuf *aubuf;
@@ -49,7 +49,6 @@ static void destructor(void *arg)
mem_deref(st->aufile);
mem_deref(st->aubuf);
- mem_deref(st->as);
}
@@ -139,7 +138,7 @@ static int read_file(struct ausrc_st *st)
}
-static int alloc_handler(struct ausrc_st **stp, struct ausrc *as,
+static int alloc_handler(struct ausrc_st **stp, const struct ausrc *as,
struct media_ctx **ctx,
struct ausrc_prm *prm, const char *dev,
ausrc_read_h *rh, ausrc_error_h *errh, void *arg)
@@ -158,7 +157,7 @@ static int alloc_handler(struct ausrc_st **stp, struct ausrc *as,
if (!st)
return ENOMEM;
- st->as = mem_ref(as);
+ st->as = as;
st->rh = rh;
st->errh = errh;
st->arg = arg;
diff --git a/modules/coreaudio/coreaudio.c b/modules/coreaudio/coreaudio.c
index 0d21e2b..9b2c03e 100644
--- a/modules/coreaudio/coreaudio.c
+++ b/modules/coreaudio/coreaudio.c
@@ -10,6 +10,13 @@
#include "coreaudio.h"
+/**
+ * @defgroup coreaudio coreaudio
+ *
+ * Audio driver module for OSX CoreAudio
+ */
+
+
static struct auplay *auplay;
static struct ausrc *ausrc;
diff --git a/modules/coreaudio/coreaudio.h b/modules/coreaudio/coreaudio.h
index 67cb7d5..a4d4edd 100644
--- a/modules/coreaudio/coreaudio.h
+++ b/modules/coreaudio/coreaudio.h
@@ -9,10 +9,10 @@ int audio_session_enable(void);
void audio_session_disable(void);
-int coreaudio_player_alloc(struct auplay_st **stp, struct auplay *ap,
+int coreaudio_player_alloc(struct auplay_st **stp, const struct auplay *ap,
struct auplay_prm *prm, const char *device,
auplay_write_h *wh, void *arg);
-int coreaudio_recorder_alloc(struct ausrc_st **stp, struct ausrc *as,
+int coreaudio_recorder_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);
diff --git a/modules/coreaudio/player.c b/modules/coreaudio/player.c
index fc53b8c..16cfa33 100644
--- a/modules/coreaudio/player.c
+++ b/modules/coreaudio/player.c
@@ -20,7 +20,7 @@
struct auplay_st {
- struct auplay *ap; /* inheritance */
+ const struct auplay *ap; /* inheritance */
AudioQueueRef queue;
AudioQueueBufferRef buf[BUFC];
pthread_mutex_t mutex;
@@ -51,8 +51,6 @@ static void auplay_destructor(void *arg)
AudioQueueDispose(st->queue, true);
}
- mem_deref(st->ap);
-
pthread_mutex_destroy(&st->mutex);
}
@@ -78,7 +76,7 @@ static void play_handler(void *userData, AudioQueueRef outQ,
}
-int coreaudio_player_alloc(struct auplay_st **stp, struct auplay *ap,
+int coreaudio_player_alloc(struct auplay_st **stp, const struct auplay *ap,
struct auplay_prm *prm, const char *device,
auplay_write_h *wh, void *arg)
{
@@ -94,7 +92,7 @@ int coreaudio_player_alloc(struct auplay_st **stp, struct auplay *ap,
if (!st)
return ENOMEM;
- st->ap = mem_ref(ap);
+ st->ap = ap;
st->wh = wh;
st->arg = arg;
diff --git a/modules/coreaudio/recorder.c b/modules/coreaudio/recorder.c
index 40156fa..c913485 100644
--- a/modules/coreaudio/recorder.c
+++ b/modules/coreaudio/recorder.c
@@ -16,7 +16,7 @@
struct ausrc_st {
- struct ausrc *as; /* inheritance */
+ const struct ausrc *as; /* inheritance */
AudioQueueRef queue;
AudioQueueBufferRef buf[BUFC];
pthread_mutex_t mutex;
@@ -48,8 +48,6 @@ static void ausrc_destructor(void *arg)
AudioQueueDispose(st->queue, true);
}
- mem_deref(st->as);
-
pthread_mutex_destroy(&st->mutex);
}
@@ -89,7 +87,7 @@ static void record_handler(void *userData, AudioQueueRef inQ,
}
-int coreaudio_recorder_alloc(struct ausrc_st **stp, struct ausrc *as,
+int coreaudio_recorder_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)
@@ -112,7 +110,7 @@ int coreaudio_recorder_alloc(struct ausrc_st **stp, struct ausrc *as,
return ENOMEM;
st->ptime = prm->ptime;
- st->as = mem_ref(as);
+ st->as = as;
st->rh = rh;
st->arg = arg;
diff --git a/modules/gst/gst.c b/modules/gst/gst.c
index 46973a4..2817dd0 100644
--- a/modules/gst/gst.c
+++ b/modules/gst/gst.c
@@ -29,7 +29,8 @@
* </pre>
*/
struct ausrc_st {
- struct ausrc *as; /**< Inheritance */
+ const struct ausrc *as; /**< Inheritance */
+
pthread_t tid; /**< Thread ID */
bool run; /**< Running flag */
ausrc_read_h *rh; /**< Read handler */
@@ -342,12 +343,10 @@ static void gst_destructor(void *arg)
mem_deref(st->uri);
mem_deref(st->aubuf);
-
- mem_deref(st->as);
}
-static int gst_alloc(struct ausrc_st **stp, struct ausrc *as,
+static int gst_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)
@@ -367,7 +366,7 @@ static int gst_alloc(struct ausrc_st **stp, struct ausrc *as,
if (!st)
return ENOMEM;
- st->as = mem_ref(as);
+ st->as = as;
st->rh = rh;
st->errh = errh;
st->arg = arg;
diff --git a/modules/opensles/opensles.c b/modules/opensles/opensles.c
index 665288c..055f051 100644
--- a/modules/opensles/opensles.c
+++ b/modules/opensles/opensles.c
@@ -1,7 +1,7 @@
/**
* @file opensles.c OpenSLES audio driver
*
- * Copyright (C) 2010 Creytiv.com
+ * Copyright (C) 2010 - 2015 Creytiv.com
*/
#include <re.h>
#include <baresip.h>
@@ -10,6 +10,13 @@
#include "opensles.h"
+/**
+ * @defgroup opensles opensles
+ *
+ * Audio driver module for Android OpenSLES
+ */
+
+
SLObjectItf engineObject = NULL;
SLEngineItf engineEngine;
diff --git a/modules/opensles/opensles.h b/modules/opensles/opensles.h
index 2970413..a3641e7 100644
--- a/modules/opensles/opensles.h
+++ b/modules/opensles/opensles.h
@@ -9,10 +9,10 @@ extern SLObjectItf engineObject;
extern SLEngineItf engineEngine;
-int opensles_player_alloc(struct auplay_st **stp, struct auplay *ap,
+int opensles_player_alloc(struct auplay_st **stp, const struct auplay *ap,
struct auplay_prm *prm, const char *device,
auplay_write_h *wh, void *arg);
-int opensles_recorder_alloc(struct ausrc_st **stp, struct ausrc *as,
+int opensles_recorder_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);
diff --git a/modules/opensles/player.c b/modules/opensles/player.c
index 797ae48..755ae4f 100644
--- a/modules/opensles/player.c
+++ b/modules/opensles/player.c
@@ -15,7 +15,7 @@
struct auplay_st {
- struct auplay *ap; /* inheritance */
+ const struct auplay *ap; /* inheritance */
auplay_write_h *wh;
void *arg;
int16_t *sampv[N_PLAY_QUEUE_BUFFERS];
@@ -43,8 +43,6 @@ static void auplay_destructor(void *arg)
for (int i=0; i<N_PLAY_QUEUE_BUFFERS; i++) {
mem_deref(st->sampv[i]);
}
-
- mem_deref(st->ap);
}
@@ -141,7 +139,7 @@ static int createPlayer(struct auplay_st *st, struct auplay_prm *prm)
}
-int opensles_player_alloc(struct auplay_st **stp, struct auplay *ap,
+int opensles_player_alloc(struct auplay_st **stp, const struct auplay *ap,
struct auplay_prm *prm, const char *device,
auplay_write_h *wh, void *arg)
{
@@ -156,7 +154,7 @@ int opensles_player_alloc(struct auplay_st **stp, struct auplay *ap,
if (!st)
return ENOMEM;
- st->ap = mem_ref(ap);
+ st->ap = ap;
st->wh = wh;
st->arg = arg;
diff --git a/modules/opensles/recorder.c b/modules/opensles/recorder.c
index 48af5c0..5d4c622 100644
--- a/modules/opensles/recorder.c
+++ b/modules/opensles/recorder.c
@@ -16,7 +16,7 @@
struct ausrc_st {
- struct ausrc *as; /* inheritance */
+ const struct ausrc *as; /* inheritance */
int16_t *sampv[N_REC_QUEUE_BUFFERS];
size_t sampc;
@@ -47,8 +47,6 @@ static void ausrc_destructor(void *arg)
for (int i=0; i<N_REC_QUEUE_BUFFERS; i++) {
mem_deref(st->sampv[i]);
}
-
- mem_deref(st->as);
}
@@ -150,7 +148,7 @@ static int startRecording(struct ausrc_st *st)
}
-int opensles_recorder_alloc(struct ausrc_st **stp, struct ausrc *as,
+int opensles_recorder_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)
@@ -168,7 +166,7 @@ int opensles_recorder_alloc(struct ausrc_st **stp, struct ausrc *as,
if (!st)
return ENOMEM;
- st->as = mem_ref(as);
+ st->as = as;
st->rh = rh;
st->arg = arg;
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);
diff --git a/modules/portaudio/portaudio.c b/modules/portaudio/portaudio.c
index 872c6af..41c8efc 100644
--- a/modules/portaudio/portaudio.c
+++ b/modules/portaudio/portaudio.c
@@ -26,7 +26,7 @@
struct ausrc_st {
- struct ausrc *as; /* inheritance */
+ const struct ausrc *as; /* inheritance */
PaStream *stream_rd;
ausrc_read_h *rh;
void *arg;
@@ -35,7 +35,7 @@ struct ausrc_st {
};
struct auplay_st {
- struct auplay *ap; /* inheritance */
+ const struct auplay *ap; /* inheritance */
PaStream *stream_wr;
auplay_write_h *wh;
void *arg;
@@ -175,8 +175,6 @@ static void ausrc_destructor(void *arg)
Pa_AbortStream(st->stream_rd);
Pa_CloseStream(st->stream_rd);
}
-
- mem_deref(st->as);
}
@@ -190,12 +188,10 @@ static void auplay_destructor(void *arg)
Pa_AbortStream(st->stream_wr);
Pa_CloseStream(st->stream_wr);
}
-
- mem_deref(st->ap);
}
-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)
@@ -220,7 +216,7 @@ static int src_alloc(struct ausrc_st **stp, struct ausrc *as,
if (!st)
return ENOMEM;
- st->as = mem_ref(as);
+ st->as = as;
st->rh = rh;
st->arg = arg;
st->ch = prm->ch;
@@ -241,7 +237,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)
{
@@ -263,7 +259,7 @@ static int play_alloc(struct auplay_st **stp, struct auplay *ap,
if (!st)
return ENOMEM;
- st->ap = mem_ref(ap);
+ st->ap = ap;
st->wh = wh;
st->arg = arg;
st->ch = prm->ch;
diff --git a/modules/rst/audio.c b/modules/rst/audio.c
index 9fbfe26..2eca230 100644
--- a/modules/rst/audio.c
+++ b/modules/rst/audio.c
@@ -17,7 +17,7 @@
struct ausrc_st {
- struct ausrc *as;
+ const struct ausrc *as; /* pointer to base-class (inheritance) */
pthread_t thread;
struct rst *rst;
mpg123_handle *mp3;
@@ -52,7 +52,6 @@ static void destructor(void *arg)
}
mem_deref(st->aubuf);
- mem_deref(st->as);
}
@@ -149,7 +148,7 @@ void rst_audio_feed(struct ausrc_st *st, const uint8_t *buf, size_t sz)
}
-static int alloc_handler(struct ausrc_st **stp, struct ausrc *as,
+static int alloc_handler(struct ausrc_st **stp, const struct ausrc *as,
struct media_ctx **ctx,
struct ausrc_prm *prm, const char *dev,
ausrc_read_h *rh, ausrc_error_h *errh, void *arg)
@@ -164,7 +163,7 @@ static int alloc_handler(struct ausrc_st **stp, struct ausrc *as,
if (!st)
return ENOMEM;
- st->as = mem_ref(as);
+ st->as = as;
st->rh = rh;
st->errh = errh;
st->arg = arg;
diff --git a/modules/sndio/sndio.c b/modules/sndio/sndio.c
index f769481..c7727c7 100644
--- a/modules/sndio/sndio.c
+++ b/modules/sndio/sndio.c
@@ -20,7 +20,7 @@
struct ausrc_st {
- struct ausrc *as;
+ const struct ausrc *as; /* pointer to base-class */
struct sio_hdl *hdl;
pthread_t thread;
int16_t *sampv;
@@ -31,7 +31,7 @@ struct ausrc_st {
};
struct auplay_st {
- struct auplay *ap;
+ const struct auplay *ap; /* pointer to base-class */
struct sio_hdl *hdl;
pthread_t thread;
int16_t *sampv;
@@ -45,12 +45,11 @@ static struct ausrc *ausrc;
static struct auplay *auplay;
-static struct sio_par *sndio_initpar(void *arg)
+static struct sio_par *sndio_initpar(uint32_t srate, uint8_t ch)
{
struct sio_par *par;
- struct auplay_prm *prm = arg;
- if ((par = malloc(sizeof(struct sio_par))) == NULL)
+ if ((par = mem_zalloc(sizeof(*par), NULL)) == NULL)
return NULL;
sio_initpar(par);
@@ -59,11 +58,11 @@ static struct sio_par *sndio_initpar(void *arg)
par->bits = 16;
par->bps = SIO_BPS(par->bits);
par->sig = 1;
- par->le = 1;
+ par->le = SIO_LE_NATIVE;
- par->rchan = prm->ch;
- par->pchan = prm->ch;
- par->rate = prm->srate;
+ par->rchan = ch;
+ par->pchan = ch;
+ par->rate = srate;
return par;
}
@@ -120,7 +119,6 @@ static void ausrc_destructor(void *arg)
sio_close(st->hdl);
mem_deref(st->sampv);
- mem_deref(st->as);
}
@@ -137,11 +135,10 @@ static void auplay_destructor(void *arg)
sio_close(st->hdl);
mem_deref(st->sampv);
- mem_deref(st->ap);
}
-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)
@@ -162,7 +159,7 @@ static int src_alloc(struct ausrc_st **stp, struct ausrc *as,
if ((st = mem_zalloc(sizeof(*st), ausrc_destructor)) == NULL)
return ENOMEM;
- st->as = mem_ref(as);
+ st->as = as;
st->rh = rh;
st->arg = arg;
st->hdl = sio_open(name, SIO_REC, 0);
@@ -173,20 +170,18 @@ static int src_alloc(struct ausrc_st **stp, struct ausrc *as,
goto out;
}
- par = sndio_initpar(prm);
+ par = sndio_initpar(prm->srate, prm->ch);
if (!par) {
err = ENOMEM;
goto out;
}
if (!sio_setpar(st->hdl, par)) {
- free(par);
err = EINVAL;
goto out;
}
if (!sio_getpar(st->hdl, par)) {
- free(par);
err = EINVAL;
goto out;
}
@@ -199,14 +194,13 @@ static int src_alloc(struct ausrc_st **stp, struct ausrc *as,
goto out;
}
- free(par);
-
st->run = true;
err = pthread_create(&st->thread, NULL, read_thread, st);
if (err)
st->run = false;
out:
+ mem_deref(par);
if (err)
mem_deref(st);
else
@@ -216,7 +210,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)
{
@@ -233,7 +227,7 @@ static int play_alloc(struct auplay_st **stp, struct auplay *ap,
if ((st = mem_zalloc(sizeof(*st), auplay_destructor)) == NULL)
return ENOMEM;
- st->ap = mem_ref(ap);
+ st->ap = ap;
st->wh = wh;
st->arg = arg;
st->hdl = sio_open(name, SIO_PLAY, 0);
@@ -244,20 +238,18 @@ static int play_alloc(struct auplay_st **stp, struct auplay *ap,
goto out;
}
- par = sndio_initpar(prm);
+ par = sndio_initpar(prm->srate, prm->ch);
if (!par) {
err = ENOMEM;
goto out;
}
if (!sio_setpar(st->hdl, par)) {
- free(par);
err = EINVAL;
goto out;
}
if (!sio_getpar(st->hdl, par)) {
- free(par);
err = EINVAL;
goto out;
}
@@ -270,14 +262,13 @@ static int play_alloc(struct auplay_st **stp, struct auplay *ap,
goto out;
}
- free(par);
-
st->run = true;
err = pthread_create(&st->thread, NULL, write_thread, st);
if (err)
st->run = false;
out:
+ mem_deref(par);
if (err)
mem_deref(st);
else
diff --git a/modules/winwave/play.c b/modules/winwave/play.c
index 1ca0d44..b9129fa 100644
--- a/modules/winwave/play.c
+++ b/modules/winwave/play.c
@@ -16,7 +16,7 @@
struct auplay_st {
- struct auplay *ap; /* inheritance */
+ const struct auplay *ap; /* inheritance */
struct dspbuf bufs[WRITE_BUFFERS];
int pos;
HWAVEOUT waveout;
@@ -50,8 +50,6 @@ static void auplay_destructor(void *arg)
}
waveOutClose(st->waveout);
-
- mem_deref(st->ap);
}
@@ -194,7 +192,7 @@ static int write_stream_open(struct auplay_st *st,
}
-int winwave_play_alloc(struct auplay_st **stp, struct auplay *ap,
+int winwave_play_alloc(struct auplay_st **stp, const struct auplay *ap,
struct auplay_prm *prm, const char *device,
auplay_write_h *wh, void *arg)
{
@@ -208,7 +206,7 @@ int winwave_play_alloc(struct auplay_st **stp, struct auplay *ap,
if (!st)
return ENOMEM;
- st->ap = mem_ref(ap);
+ st->ap = ap;
st->wh = wh;
st->arg = arg;
diff --git a/modules/winwave/src.c b/modules/winwave/src.c
index 9d8793f..e96915e 100644
--- a/modules/winwave/src.c
+++ b/modules/winwave/src.c
@@ -16,7 +16,7 @@
struct ausrc_st {
- struct ausrc *as; /* inheritance */
+ const struct ausrc *as; /* inheritance */
struct dspbuf bufs[READ_BUFFERS];
int pos;
HWAVEIN wavein;
@@ -44,8 +44,6 @@ static void ausrc_destructor(void *arg)
}
waveInClose(st->wavein);
-
- mem_deref(st->as);
}
@@ -189,7 +187,7 @@ static int read_stream_open(struct ausrc_st *st, const struct ausrc_prm *prm,
}
-int winwave_src_alloc(struct ausrc_st **stp, struct ausrc *as,
+int winwave_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)
@@ -207,7 +205,7 @@ int winwave_src_alloc(struct ausrc_st **stp, struct ausrc *as,
if (!st)
return ENOMEM;
- st->as = mem_ref(as);
+ st->as = as;
st->rh = rh;
st->arg = arg;
diff --git a/modules/winwave/winwave.h b/modules/winwave/winwave.h
index ccccddf..2a49378 100644
--- a/modules/winwave/winwave.h
+++ b/modules/winwave/winwave.h
@@ -11,10 +11,10 @@ struct dspbuf {
};
-int winwave_src_alloc(struct ausrc_st **stp, struct ausrc *as,
+int winwave_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);
-int winwave_play_alloc(struct auplay_st **stp, struct auplay *ap,
+int winwave_play_alloc(struct auplay_st **stp, const struct auplay *ap,
struct auplay_prm *prm, const char *device,
auplay_write_h *wh, void *arg);
diff --git a/src/core.h b/src/core.h
index 4c1c6bb..a9a6b16 100644
--- a/src/core.h
+++ b/src/core.h
@@ -91,7 +91,7 @@ struct auplay {
*/
struct ausrc_st {
- struct ausrc *as;
+ const struct ausrc *as;
};
struct ausrc {