From 686dd7065eb57091caae0cf53a81592cc2cf054f Mon Sep 17 00:00:00 2001 From: Alexandre Ratchov Date: Tue, 12 Nov 2013 09:49:28 +0100 Subject: [PATCH] cleanup namespace --- libsndio/aucat.c | 58 ++++++++++++++++++++++---------------------- libsndio/aucat.h | 18 +++++++------- libsndio/debug.c | 12 ++++----- libsndio/debug.h | 12 ++++----- libsndio/mio.c | 26 ++++++++++---------- libsndio/mio_alsa.c | 2 +- libsndio/mio_aucat.c | 20 +++++++-------- libsndio/mio_priv.h | 8 +++--- libsndio/mio_rmidi.c | 6 ++--- libsndio/sio.c | 38 ++++++++++++++--------------- libsndio/sio_alsa.c | 10 ++++---- libsndio/sio_aucat.c | 40 +++++++++++++++--------------- libsndio/sio_priv.h | 16 ++++++------ libsndio/sio_sun.c | 12 ++++----- 14 files changed, 139 insertions(+), 139 deletions(-) diff --git a/libsndio/aucat.c b/libsndio/aucat.c index 0134738..c19f195 100644 --- a/libsndio/aucat.c +++ b/libsndio/aucat.c @@ -78,13 +78,13 @@ random_bytes(unsigned char *buf, int len) * read a message, return 0 if not completed */ int -aucat_rmsg(struct aucat *hdl, int *eof) +_aucat_rmsg(struct aucat *hdl, int *eof) { ssize_t n; unsigned char *data; if (hdl->rstate != RSTATE_MSG) { - DPRINTF("aucat_rmsg: bad state\n"); + DPRINTF("_aucat_rmsg: bad state\n"); abort(); } while (hdl->rtodo > 0) { @@ -95,12 +95,12 @@ aucat_rmsg(struct aucat *hdl, int *eof) continue; if (errno != EAGAIN) { *eof = 1; - DPERROR("aucat_rmsg: read"); + DPERROR("_aucat_rmsg: read"); } return 0; } if (n == 0) { - DPRINTF("aucat_rmsg: eof\n"); + DPRINTF("_aucat_rmsg: eof\n"); *eof = 1; return 0; } @@ -120,7 +120,7 @@ aucat_rmsg(struct aucat *hdl, int *eof) * write a message, return 0 if not completed */ int -aucat_wmsg(struct aucat *hdl, int *eof) +_aucat_wmsg(struct aucat *hdl, int *eof) { ssize_t n; unsigned char *data; @@ -129,7 +129,7 @@ aucat_wmsg(struct aucat *hdl, int *eof) hdl->wstate = WSTATE_MSG; hdl->wtodo = sizeof(struct amsg); if (hdl->wstate != WSTATE_MSG) { - DPRINTF("aucat_wmsg: bad state\n"); + DPRINTF("_aucat_wmsg: bad state\n"); abort(); } while (hdl->wtodo > 0) { @@ -140,7 +140,7 @@ aucat_wmsg(struct aucat *hdl, int *eof) continue; if (errno != EAGAIN) { *eof = 1; - DPERROR("aucat_wmsg: write"); + DPERROR("_aucat_wmsg: write"); } return 0; } @@ -157,12 +157,12 @@ aucat_wmsg(struct aucat *hdl, int *eof) } size_t -aucat_rdata(struct aucat *hdl, void *buf, size_t len, int *eof) +_aucat_rdata(struct aucat *hdl, void *buf, size_t len, int *eof) { ssize_t n; if (hdl->rstate != RSTATE_DATA) { - DPRINTF("aucat_rdata: bad state\n"); + DPRINTF("_aucat_rdata: bad state\n"); abort(); } if (len > hdl->rtodo) @@ -172,12 +172,12 @@ aucat_rdata(struct aucat *hdl, void *buf, size_t len, int *eof) continue; if (errno != EAGAIN) { *eof = 1; - DPERROR("aucat_rdata: read"); + DPERROR("_aucat_rdata: read"); } return 0; } if (n == 0) { - DPRINTF("aucat_rdata: eof\n"); + DPRINTF("_aucat_rdata: eof\n"); *eof = 1; return 0; } @@ -186,12 +186,12 @@ aucat_rdata(struct aucat *hdl, void *buf, size_t len, int *eof) hdl->rstate = RSTATE_MSG; hdl->rtodo = sizeof(struct amsg); } - DPRINTFN(2, "aucat_rdata: read: n = %zd\n", n); + DPRINTFN(2, "_aucat_rdata: read: n = %zd\n", n); return n; } size_t -aucat_wdata(struct aucat *hdl, const void *buf, size_t len, +_aucat_wdata(struct aucat *hdl, const void *buf, size_t len, unsigned int wbpf, int *eof) { ssize_t n; @@ -211,13 +211,13 @@ aucat_wdata(struct aucat *hdl, const void *buf, size_t len, hdl->wstate = WSTATE_MSG; /* FALLTHROUGH */ case WSTATE_MSG: - if (!aucat_wmsg(hdl, eof)) + if (!_aucat_wmsg(hdl, eof)) return 0; } if (len > hdl->wtodo) len = hdl->wtodo; if (len == 0) { - DPRINTF("aucat_wdata: len == 0\n"); + DPRINTF("_aucat_wdata: len == 0\n"); abort(); } while ((n = write(hdl->fd, buf, len)) < 0) { @@ -225,11 +225,11 @@ aucat_wdata(struct aucat *hdl, const void *buf, size_t len, continue; if (errno != EAGAIN) { *eof = 1; - DPERROR("aucat_wdata: write"); + DPERROR("_aucat_wdata: write"); } return 0; } - DPRINTFN(2, "aucat_wdata: write: n = %zd\n", n); + DPRINTFN(2, "_aucat_wdata: write: n = %zd\n", n); hdl->wtodo -= n; if (hdl->wtodo == 0) { hdl->wstate = WSTATE_IDLE; @@ -449,7 +449,7 @@ parsestr(const char *str, char *rstr, unsigned int max) } int -aucat_open(struct aucat *hdl, const char *str, unsigned int mode, +_aucat_open(struct aucat *hdl, const char *str, unsigned int mode, unsigned int type) { extern char *__progname; @@ -488,7 +488,7 @@ aucat_open(struct aucat *hdl, const char *str, unsigned int mode, return 0; } devnum += type * 16; /* XXX */ - DPRINTF("aucat_open: host=%s unit=%u devnum=%u opt=%s\n", + DPRINTF("_aucat_open: host=%s unit=%u devnum=%u opt=%s\n", host, unit, devnum, opt); if (host[0] != '\0') { if (!aucat_connect_tcp(hdl, host, unit)) @@ -515,7 +515,7 @@ aucat_open(struct aucat *hdl, const char *str, unsigned int mode, if (!aucat_mkcookie(hdl->wmsg.u.auth.cookie)) goto bad_connect; hdl->wtodo = sizeof(struct amsg); - if (!aucat_wmsg(hdl, &eof)) + if (!_aucat_wmsg(hdl, &eof)) goto bad_connect; AMSG_INIT(&hdl->wmsg); hdl->wmsg.cmd = htonl(AMSG_HELLO); @@ -527,10 +527,10 @@ aucat_open(struct aucat *hdl, const char *str, unsigned int mode, strlcpy(hdl->wmsg.u.hello.opt, opt, sizeof(hdl->wmsg.u.hello.opt)); hdl->wtodo = sizeof(struct amsg); - if (!aucat_wmsg(hdl, &eof)) + if (!_aucat_wmsg(hdl, &eof)) goto bad_connect; hdl->rtodo = sizeof(struct amsg); - if (!aucat_rmsg(hdl, &eof)) { + if (!_aucat_rmsg(hdl, &eof)) { DPRINTF("aucat_init: mode refused\n"); goto bad_connect; } @@ -546,7 +546,7 @@ aucat_open(struct aucat *hdl, const char *str, unsigned int mode, } void -aucat_close(struct aucat *hdl, int eof) +_aucat_close(struct aucat *hdl, int eof) { char dummy[1]; @@ -554,7 +554,7 @@ aucat_close(struct aucat *hdl, int eof) AMSG_INIT(&hdl->wmsg); hdl->wmsg.cmd = htonl(AMSG_BYE); hdl->wtodo = sizeof(struct amsg); - if (!aucat_wmsg(hdl, &eof)) + if (!_aucat_wmsg(hdl, &eof)) goto bad_close; while (read(hdl->fd, dummy, 1) < 0 && errno == EINTR) ; /* nothing */ @@ -565,10 +565,10 @@ aucat_close(struct aucat *hdl, int eof) } int -aucat_setfl(struct aucat *hdl, int nbio, int *eof) +_aucat_setfl(struct aucat *hdl, int nbio, int *eof) { if (fcntl(hdl->fd, F_SETFL, nbio ? O_NONBLOCK : 0) < 0) { - DPERROR("aucat_setfl: fcntl"); + DPERROR("_aucat_setfl: fcntl"); *eof = 1; return 0; } @@ -576,7 +576,7 @@ aucat_setfl(struct aucat *hdl, int nbio, int *eof) } int -aucat_pollfd(struct aucat *hdl, struct pollfd *pfd, int events) +_aucat_pollfd(struct aucat *hdl, struct pollfd *pfd, int events) { if (hdl->rstate == RSTATE_MSG) events |= POLLIN; @@ -586,10 +586,10 @@ aucat_pollfd(struct aucat *hdl, struct pollfd *pfd, int events) } int -aucat_revents(struct aucat *hdl, struct pollfd *pfd) +_aucat_revents(struct aucat *hdl, struct pollfd *pfd) { int revents = pfd->revents; - DPRINTFN(2, "aucat_revents: revents: %x\n", revents); + DPRINTFN(2, "_aucat_revents: revents: %x\n", revents); return revents; } diff --git a/libsndio/aucat.h b/libsndio/aucat.h index d7dd4d9..8c3966c 100644 --- a/libsndio/aucat.h +++ b/libsndio/aucat.h @@ -17,14 +17,14 @@ struct aucat { unsigned maxwrite; /* bytes we're allowed to write */ }; -int aucat_rmsg(struct aucat *, int *); -int aucat_wmsg(struct aucat *, int *); -size_t aucat_rdata(struct aucat *, void *, size_t, int *); -size_t aucat_wdata(struct aucat *, const void *, size_t, unsigned, int *); -int aucat_open(struct aucat *, const char *, unsigned, unsigned); -void aucat_close(struct aucat *, int); -int aucat_pollfd(struct aucat *, struct pollfd *, int); -int aucat_revents(struct aucat *, struct pollfd *); -int aucat_setfl(struct aucat *, int, int *); +int _aucat_rmsg(struct aucat *, int *); +int _aucat_wmsg(struct aucat *, int *); +size_t _aucat_rdata(struct aucat *, void *, size_t, int *); +size_t _aucat_wdata(struct aucat *, const void *, size_t, unsigned, int *); +int _aucat_open(struct aucat *, const char *, unsigned, unsigned); +void _aucat_close(struct aucat *, int); +int _aucat_pollfd(struct aucat *, struct pollfd *, int); +int _aucat_revents(struct aucat *, struct pollfd *); +int _aucat_setfl(struct aucat *, int, int *); #endif /* !defined(AUCAT_H) */ diff --git a/libsndio/debug.c b/libsndio/debug.c index d03bfb7..c02508c 100644 --- a/libsndio/debug.c +++ b/libsndio/debug.c @@ -26,23 +26,23 @@ /* * debug level, -1 means uninitialized */ -int sndio_debug = -1; +int _sndio_debug = -1; void -sndio_debug_init(void) +_sndio_debug_init(void) { char *dbg; - if (sndio_debug < 0) { + if (_sndio_debug < 0) { dbg = issetugid() ? NULL : getenv("SNDIO_DEBUG"); - if (!dbg || sscanf(dbg, "%u", &sndio_debug) != 1) - sndio_debug = 0; + if (!dbg || sscanf(dbg, "%u", &_sndio_debug) != 1) + _sndio_debug = 0; } } #endif const char * -sndio_parsetype(const char *str, char *type) +_sndio_parsetype(const char *str, char *type) { while (*type) { if (*type != *str) diff --git a/libsndio/debug.h b/libsndio/debug.h index 46bc8b7..7594784 100644 --- a/libsndio/debug.h +++ b/libsndio/debug.h @@ -22,30 +22,30 @@ #define DPRINTFN(n, ...) \ do { \ - if (sndio_debug >= (n)) \ + if (_sndio_debug >= (n)) \ fprintf(stderr, __VA_ARGS__); \ } while(0) #define DPRINTF(...) \ do { \ - if (sndio_debug > 0) \ + if (_sndio_debug > 0) \ fprintf(stderr, __VA_ARGS__); \ } while(0) #define DPERROR(s) \ do { \ - if (sndio_debug > 0) \ + if (_sndio_debug > 0) \ perror(s); \ } while(0) -void sndio_debug_init(void); -extern int sndio_debug; +void _sndio_debug_init(void); +extern int _sndio_debug; #else #define DPRINTF(...) do {} while(0) #define DPRINTFN(...) do {} while(0) #define DPERROR(s) do {} while(0) #endif -const char *sndio_parsetype(const char *, char *); +const char *_sndio_parsetype(const char *, char *); #endif diff --git a/libsndio/mio.c b/libsndio/mio.c index d88b898..bfd2d87 100644 --- a/libsndio/mio.c +++ b/libsndio/mio.c @@ -40,7 +40,7 @@ mio_open(const char *str, unsigned int mode, int nbio) const char *p; #ifdef DEBUG - sndio_debug_init(); + _sndio_debug_init(); #endif if ((mode & (MIO_OUT | MIO_IN)) == 0) return NULL; @@ -52,28 +52,28 @@ mio_open(const char *str, unsigned int mode, int nbio) str = portany; } if (strcmp(str, portany) == 0) { - hdl = mio_aucat_open("/0", mode, nbio, 1); + hdl = _mio_aucat_open("/0", mode, nbio, 1); if (hdl != NULL) return hdl; #if defined(USE_RMIDI) - return mio_rmidi_open("/0", mode, nbio); + return _mio_rmidi_open("/0", mode, nbio); #elif defined(USE_ALSA) return mio_alsa_open("/0", mode, nbio); #else return NULL; #endif } - if ((p = sndio_parsetype(str, "snd")) != NULL || - (p = sndio_parsetype(str, "aucat")) != NULL) - return mio_aucat_open(p, mode, nbio, 0); - if ((p = sndio_parsetype(str, "midithru")) != NULL) - return mio_aucat_open(p, mode, nbio, 1); - if ((p = sndio_parsetype(str, "midi")) != NULL) - return mio_aucat_open(p, mode, nbio, 2); + if ((p = _sndio_parsetype(str, "snd")) != NULL || + (p = _sndio_parsetype(str, "aucat")) != NULL) + return _mio_aucat_open(p, mode, nbio, 0); + if ((p = _sndio_parsetype(str, "midithru")) != NULL) + return _mio_aucat_open(p, mode, nbio, 1); + if ((p = _sndio_parsetype(str, "midi")) != NULL) + return _mio_aucat_open(p, mode, nbio, 2); #if defined(USE_RMIDI) || defined(USE_ALSA) - if ((p = sndio_parsetype(str, "rmidi")) != NULL) { + if ((p = _sndio_parsetype(str, "rmidi")) != NULL) { #if defined(USE_SUN) - return mio_rmidi_open(p, mode, nbio); + return _mio_rmidi_open(p, mode, nbio); #elif defined(USE_ALSA) return mio_alsa_open(p, mode, nbio); #endif @@ -84,7 +84,7 @@ mio_open(const char *str, unsigned int mode, int nbio) } void -mio_create(struct mio_hdl *hdl, struct mio_ops *ops, +_mio_create(struct mio_hdl *hdl, struct mio_ops *ops, unsigned int mode, int nbio) { hdl->ops = ops; diff --git a/libsndio/mio_alsa.c b/libsndio/mio_alsa.c index 7efd4be..6f8a287 100644 --- a/libsndio/mio_alsa.c +++ b/libsndio/mio_alsa.c @@ -79,7 +79,7 @@ mio_alsa_open(const char *str, unsigned int mode, int nbio) hdl = malloc(sizeof(struct mio_alsa_hdl)); if (hdl == NULL) return NULL; - mio_create(&hdl->mio, &mio_alsa_ops, mode, nbio); + _mio_create(&hdl->mio, &mio_alsa_ops, mode, nbio); #ifdef DEBUG rc = snd_output_stdio_attach(&output, stderr, 0); if (rc < 0) diff --git a/libsndio/mio_aucat.c b/libsndio/mio_aucat.c index eacdf0a..00a164f 100644 --- a/libsndio/mio_aucat.c +++ b/libsndio/mio_aucat.c @@ -63,7 +63,7 @@ mio_aucat_runmsg(struct mio_aucat_hdl *hdl) { int delta; - if (!aucat_rmsg(&hdl->aucat, &hdl->mio.eof)) + if (!_aucat_rmsg(&hdl->aucat, &hdl->mio.eof)) return 0; switch (ntohl(hdl->aucat.rmsg.cmd)) { case AMSG_DATA: @@ -85,7 +85,7 @@ mio_aucat_runmsg(struct mio_aucat_hdl *hdl) } struct mio_hdl * -mio_aucat_open(const char *str, unsigned int mode, +_mio_aucat_open(const char *str, unsigned int mode, int nbio, unsigned int type) { struct mio_aucat_hdl *hdl; @@ -93,10 +93,10 @@ mio_aucat_open(const char *str, unsigned int mode, hdl = malloc(sizeof(struct mio_aucat_hdl)); if (hdl == NULL) return NULL; - if (!aucat_open(&hdl->aucat, str, mode, type)) + if (!_aucat_open(&hdl->aucat, str, mode, type)) goto bad; - mio_create(&hdl->mio, &mio_aucat_ops, mode, nbio); - if (!aucat_setfl(&hdl->aucat, 1, &hdl->mio.eof)) + _mio_create(&hdl->mio, &mio_aucat_ops, mode, nbio); + if (!_aucat_setfl(&hdl->aucat, 1, &hdl->mio.eof)) goto bad; return (struct mio_hdl *)hdl; bad: @@ -110,8 +110,8 @@ mio_aucat_close(struct mio_hdl *sh) struct mio_aucat_hdl *hdl = (struct mio_aucat_hdl *)sh; if (!hdl->mio.eof) - aucat_setfl(&hdl->aucat, 0, &hdl->mio.eof); - aucat_close(&hdl->aucat, hdl->mio.eof); + _aucat_setfl(&hdl->aucat, 0, &hdl->mio.eof); + _aucat_close(&hdl->aucat, hdl->mio.eof); free(hdl); } @@ -124,7 +124,7 @@ mio_aucat_read(struct mio_hdl *sh, void *buf, size_t len) if (!mio_aucat_runmsg(hdl)) return 0; } - return aucat_rdata(&hdl->aucat, buf, len, &hdl->mio.eof); + return _aucat_rdata(&hdl->aucat, buf, len, &hdl->mio.eof); } static size_t @@ -137,7 +137,7 @@ mio_aucat_write(struct mio_hdl *sh, const void *buf, size_t len) return 0; if (len > hdl->aucat.maxwrite) len = hdl->aucat.maxwrite; - n = aucat_wdata(&hdl->aucat, buf, len, 1, &hdl->mio.eof); + n = _aucat_wdata(&hdl->aucat, buf, len, 1, &hdl->mio.eof); hdl->aucat.maxwrite -= n; return n; } @@ -156,7 +156,7 @@ mio_aucat_pollfd(struct mio_hdl *sh, struct pollfd *pfd, int events) hdl->events = events; if (hdl->aucat.maxwrite <= 0) events &= ~POLLOUT; - return aucat_pollfd(&hdl->aucat, pfd, events); + return _aucat_pollfd(&hdl->aucat, pfd, events); } static int diff --git a/libsndio/mio_priv.h b/libsndio/mio_priv.h index 41e2d51..3078857 100644 --- a/libsndio/mio_priv.h +++ b/libsndio/mio_priv.h @@ -44,12 +44,12 @@ struct mio_ops { int (*revents)(struct mio_hdl *, struct pollfd *); }; -struct mio_hdl *mio_rmidi_open(const char *, unsigned, int); +struct mio_hdl *_mio_rmidi_open(const char *, unsigned, int); #ifdef USE_ALSA struct mio_hdl *mio_alsa_open(const char *, unsigned, int); #endif -struct mio_hdl *mio_aucat_open(const char *, unsigned, int, unsigned); -void mio_create(struct mio_hdl *, struct mio_ops *, unsigned, int); -void mio_destroy(struct mio_hdl *); +struct mio_hdl *_mio_aucat_open(const char *, unsigned, int, unsigned); +void _mio_create(struct mio_hdl *, struct mio_ops *, unsigned, int); +void _mio_destroy(struct mio_hdl *); #endif /* !defined(MIO_PRIV_H) */ diff --git a/libsndio/mio_rmidi.c b/libsndio/mio_rmidi.c index b460497..4a1fefd 100644 --- a/libsndio/mio_rmidi.c +++ b/libsndio/mio_rmidi.c @@ -52,7 +52,7 @@ static struct mio_ops mio_rmidi_ops = { }; struct mio_hdl * -mio_rmidi_open(const char *str, unsigned int mode, int nbio) +_mio_rmidi_open(const char *str, unsigned int mode, int nbio) { int fd, flags; struct mio_rmidi_hdl *hdl; @@ -64,13 +64,13 @@ mio_rmidi_open(const char *str, unsigned int mode, int nbio) str++; break; default: - DPRINTF("sio_sun_open: %s: '/' expected\n", str); + DPRINTF("_sio_sun_open: %s: '/' expected\n", str); return NULL; } hdl = malloc(sizeof(struct mio_rmidi_hdl)); if (hdl == NULL) return NULL; - mio_create(&hdl->mio, &mio_rmidi_ops, mode, nbio); + _mio_create(&hdl->mio, &mio_rmidi_ops, mode, nbio); snprintf(path, sizeof(path), "/dev/rmidi%s", str); if (mode == (MIO_OUT | MIO_IN)) diff --git a/libsndio/sio.c b/libsndio/sio.c index 8c72599..bad67c5 100644 --- a/libsndio/sio.c +++ b/libsndio/sio.c @@ -49,7 +49,7 @@ sio_open(const char *str, unsigned int mode, int nbio) const char *p; #ifdef DEBUG - sndio_debug_init(); + _sndio_debug_init(); #endif if ((mode & (SIO_PLAY | SIO_REC)) == 0) return NULL; @@ -61,27 +61,27 @@ sio_open(const char *str, unsigned int mode, int nbio) str = devany; } if (strcmp(str, devany) == 0) { - hdl = sio_aucat_open("/0", mode, nbio); + hdl = _sio_aucat_open("/0", mode, nbio); if (hdl != NULL) return hdl; #if defined(USE_SUN) - return sio_sun_open("/0", mode, nbio); + return _sio_sun_open("/0", mode, nbio); #elif defined(USE_ALSA) - return sio_alsa_open("/0", mode, nbio); + return _sio_alsa_open("/0", mode, nbio); #else return NULL; #endif } - if ((p = sndio_parsetype(str, "snd")) != NULL || - (p = sndio_parsetype(str, "aucat")) != NULL) - return sio_aucat_open(p, mode, nbio); + if ((p = _sndio_parsetype(str, "snd")) != NULL || + (p = _sndio_parsetype(str, "aucat")) != NULL) + return _sio_aucat_open(p, mode, nbio); #if defined(USE_ALSA) || defined(USE_SUN) - if ((p = sndio_parsetype(str, "rsnd")) != NULL || - (p = sndio_parsetype(str, "sun")) != NULL) { + if ((p = _sndio_parsetype(str, "rsnd")) != NULL || + (p = _sndio_parsetype(str, "sun")) != NULL) { #if defined(USE_SUN) - return sio_sun_open(p, mode, nbio); + return _sio_sun_open(p, mode, nbio); #elif defined(USE_ALSA) - return sio_alsa_open(p, mode, nbio); + return _sio_alsa_open(p, mode, nbio); #endif } #endif @@ -90,7 +90,7 @@ sio_open(const char *str, unsigned int mode, int nbio) } void -sio_create(struct sio_hdl *hdl, struct sio_ops *ops, +_sio_create(struct sio_hdl *hdl, struct sio_ops *ops, unsigned int mode, int nbio) { hdl->ops = ops; @@ -398,7 +398,7 @@ sio_revents(struct sio_hdl *hdl, struct pollfd *pfd) #ifdef DEBUG struct timespec ts0, ts1; - if (sndio_debug >= 2) + if (_sndio_debug >= 2) clock_gettime(CLOCK_MONOTONIC, &ts0); #endif if (hdl->eof) @@ -410,7 +410,7 @@ sio_revents(struct sio_hdl *hdl, struct pollfd *pfd) if (!hdl->started) return revents & POLLHUP; #ifdef DEBUG - if (sndio_debug >= 3) { + if (_sndio_debug >= 3) { clock_gettime(CLOCK_MONOTONIC, &ts1); DPRINTF("%09lld: sio_revents: revents = 0x%x, took %lldns\n", 1000000000LL * ts0.tv_sec + @@ -447,7 +447,7 @@ sio_onmove(struct sio_hdl *hdl, void (*cb)(void *, int), void *addr) #ifdef DEBUG void -sio_printpos(struct sio_hdl *hdl) +_sio_printpos(struct sio_hdl *hdl) { struct timespec ts; long long rpos, rdiff; @@ -487,12 +487,12 @@ sio_printpos(struct sio_hdl *hdl) #endif void -sio_onmove_cb(struct sio_hdl *hdl, int delta) +_sio_onmove_cb(struct sio_hdl *hdl, int delta) { #ifdef DEBUG hdl->cpos += delta; - if (sndio_debug >= 2) - sio_printpos(hdl); + if (_sndio_debug >= 2) + _sio_printpos(hdl); #endif if (hdl->move_cb) hdl->move_cb(hdl->move_addr, delta); @@ -528,7 +528,7 @@ sio_onvol(struct sio_hdl *hdl, void (*cb)(void *, unsigned int), void *addr) } void -sio_onvol_cb(struct sio_hdl *hdl, unsigned int ctl) +_sio_onvol_cb(struct sio_hdl *hdl, unsigned int ctl) { if (hdl->vol_cb) hdl->vol_cb(hdl->vol_addr, ctl); diff --git a/libsndio/sio_alsa.c b/libsndio/sio_alsa.c index e4b000b..4c08973 100644 --- a/libsndio/sio_alsa.c +++ b/libsndio/sio_alsa.c @@ -220,7 +220,7 @@ sio_alsa_getcap(struct sio_hdl *sh, struct sio_cap *cap) } struct sio_hdl * -sio_alsa_open(const char *str, unsigned mode, int nbio) +_sio_alsa_open(const char *str, unsigned mode, int nbio) { struct sio_alsa_hdl *hdl; char path[PATH_MAX]; @@ -233,13 +233,13 @@ sio_alsa_open(const char *str, unsigned mode, int nbio) str++; break; default: - DPRINTF("sio_sun_open: %s: '/' expected\n", str); + DPRINTF("_sio_sun_open: %s: '/' expected\n", str); return NULL; } hdl = malloc(sizeof(struct sio_alsa_hdl)); if (hdl == NULL) return NULL; - sio_create(&hdl->sio, &sio_alsa_ops, mode, nbio); + _sio_create(&hdl->sio, &sio_alsa_ops, mode, nbio); #ifdef DEBUG err = snd_output_stdio_attach(&output, stderr, 0); @@ -407,7 +407,7 @@ sio_alsa_xrun(struct sio_alsa_hdl *hdl) int wsil, rdrop, cmove; DPRINTF("sio_alsa_xrun:\n"); - sio_printpos(&hdl->sio); + _sio_printpos(&hdl->sio); rpos = (hdl->sio.mode & SIO_REC) ? hdl->sio.rcnt / hdl->ibpf : hdl->sio.cpos; @@ -836,7 +836,7 @@ sio_alsa_onmove(struct sio_alsa_hdl *hdl) delta = 0; hdl->running = 1; } - sio_onmove_cb(&hdl->sio, delta); + _sio_onmove_cb(&hdl->sio, delta); if (hdl->sio.mode & SIO_PLAY) hdl->odelta -= delta; if (hdl->sio.mode & SIO_REC) diff --git a/libsndio/sio_aucat.c b/libsndio/sio_aucat.c index cc58aff..5f1494a 100644 --- a/libsndio/sio_aucat.c +++ b/libsndio/sio_aucat.c @@ -86,7 +86,7 @@ sio_aucat_runmsg(struct sio_aucat_hdl *hdl) int delta; unsigned int size, ctl; - if (!aucat_rmsg(&hdl->aucat, &hdl->sio.eof)) + if (!_aucat_rmsg(&hdl->aucat, &hdl->sio.eof)) return 0; switch (ntohl(hdl->aucat.rmsg.cmd)) { case AMSG_DATA: @@ -109,14 +109,14 @@ sio_aucat_runmsg(struct sio_aucat_hdl *hdl) DPRINTFN(2, "aucat: move = %d, delta = %d, maxwrite = %d\n", delta, hdl->delta, hdl->aucat.maxwrite); if (hdl->delta >= 0) { - sio_onmove_cb(&hdl->sio, hdl->delta); + _sio_onmove_cb(&hdl->sio, hdl->delta); hdl->delta = 0; } break; case AMSG_SETVOL: ctl = ntohl(hdl->aucat.rmsg.u.vol.ctl); hdl->curvol = hdl->reqvol = ctl; - sio_onvol_cb(&hdl->sio, ctl); + _sio_onvol_cb(&hdl->sio, ctl); break; case AMSG_STOP: hdl->pstate = PSTATE_INIT; @@ -140,24 +140,24 @@ sio_aucat_buildmsg(struct sio_aucat_hdl *hdl) hdl->aucat.wmsg.cmd = htonl(AMSG_SETVOL); hdl->aucat.wmsg.u.vol.ctl = htonl(hdl->reqvol); hdl->curvol = hdl->reqvol; - return aucat_wmsg(&hdl->aucat, &hdl->sio.eof); + return _aucat_wmsg(&hdl->aucat, &hdl->sio.eof); } return 0; } struct sio_hdl * -sio_aucat_open(const char *str, unsigned int mode, int nbio) +_sio_aucat_open(const char *str, unsigned int mode, int nbio) { struct sio_aucat_hdl *hdl; hdl = malloc(sizeof(struct sio_aucat_hdl)); if (hdl == NULL) return NULL; - if (!aucat_open(&hdl->aucat, str, mode, 0)) { + if (!_aucat_open(&hdl->aucat, str, mode, 0)) { free(hdl); return NULL; } - sio_create(&hdl->sio, &sio_aucat_ops, mode, nbio); + _sio_create(&hdl->sio, &sio_aucat_ops, mode, nbio); hdl->curvol = SIO_MAXVOL; hdl->reqvol = SIO_MAXVOL; hdl->pstate = PSTATE_INIT; @@ -173,7 +173,7 @@ sio_aucat_close(struct sio_hdl *sh) if (!hdl->sio.eof && hdl->sio.started) (void)sio_aucat_stop(&hdl->sio); - aucat_close(&hdl->aucat, hdl->sio.eof); + _aucat_close(&hdl->aucat, hdl->sio.eof); free(hdl); } @@ -198,11 +198,11 @@ sio_aucat_start(struct sio_hdl *sh) AMSG_INIT(&hdl->aucat.wmsg); hdl->aucat.wmsg.cmd = htonl(AMSG_START); hdl->aucat.wtodo = sizeof(struct amsg); - if (!aucat_wmsg(&hdl->aucat, &hdl->sio.eof)) + if (!_aucat_wmsg(&hdl->aucat, &hdl->sio.eof)) return 0; hdl->aucat.rstate = RSTATE_MSG; hdl->aucat.rtodo = sizeof(struct amsg); - if (!aucat_setfl(&hdl->aucat, 1, &hdl->sio.eof)) + if (!_aucat_setfl(&hdl->aucat, 1, &hdl->sio.eof)) return 0; hdl->walign = hdl->round * hdl->wbpf; hdl->pstate = PSTATE_RUN; @@ -217,13 +217,13 @@ sio_aucat_stop(struct sio_hdl *sh) struct sio_aucat_hdl *hdl = (struct sio_aucat_hdl *)sh; unsigned int n, count; - if (!aucat_setfl(&hdl->aucat, 0, &hdl->sio.eof)) + if (!_aucat_setfl(&hdl->aucat, 0, &hdl->sio.eof)) return 0; /* * complete message or data block in progress */ if (hdl->aucat.wstate == WSTATE_MSG) { - if (!aucat_wmsg(&hdl->aucat, &hdl->sio.eof)) + if (!_aucat_wmsg(&hdl->aucat, &hdl->sio.eof)) return 0; } if (hdl->aucat.wstate == WSTATE_DATA) { @@ -244,7 +244,7 @@ sio_aucat_stop(struct sio_hdl *sh) AMSG_INIT(&hdl->aucat.wmsg); hdl->aucat.wmsg.cmd = htonl(AMSG_STOP); hdl->aucat.wtodo = sizeof(struct amsg); - if (!aucat_wmsg(&hdl->aucat, &hdl->sio.eof)) + if (!_aucat_wmsg(&hdl->aucat, &hdl->sio.eof)) return 0; /* @@ -285,7 +285,7 @@ sio_aucat_setpar(struct sio_hdl *sh, struct sio_par *par) if (hdl->sio.mode & SIO_PLAY) hdl->aucat.wmsg.u.par.pchan = htons(par->pchan); hdl->aucat.wtodo = sizeof(struct amsg); - if (!aucat_wmsg(&hdl->aucat, &hdl->sio.eof)) + if (!_aucat_wmsg(&hdl->aucat, &hdl->sio.eof)) return 0; return 1; } @@ -298,10 +298,10 @@ sio_aucat_getpar(struct sio_hdl *sh, struct sio_par *par) AMSG_INIT(&hdl->aucat.wmsg); hdl->aucat.wmsg.cmd = htonl(AMSG_GETPAR); hdl->aucat.wtodo = sizeof(struct amsg); - if (!aucat_wmsg(&hdl->aucat, &hdl->sio.eof)) + if (!_aucat_wmsg(&hdl->aucat, &hdl->sio.eof)) return 0; hdl->aucat.rtodo = sizeof(struct amsg); - if (!aucat_rmsg(&hdl->aucat, &hdl->sio.eof)) + if (!_aucat_rmsg(&hdl->aucat, &hdl->sio.eof)) return 0; if (ntohl(hdl->aucat.rmsg.cmd) != AMSG_GETPAR) { DPRINTF("sio_aucat_getpar: protocol err\n"); @@ -408,7 +408,7 @@ sio_aucat_read(struct sio_hdl *sh, void *buf, size_t len) if (!sio_aucat_runmsg(hdl)) return 0; } - return aucat_rdata(&hdl->aucat, buf, len, &hdl->sio.eof); + return _aucat_rdata(&hdl->aucat, buf, len, &hdl->sio.eof); } static size_t @@ -427,7 +427,7 @@ sio_aucat_write(struct sio_hdl *sh, const void *buf, size_t len) len = hdl->aucat.maxwrite; if (len > hdl->walign) len = hdl->walign; - n = aucat_wdata(&hdl->aucat, buf, len, hdl->wbpf, &hdl->sio.eof); + n = _aucat_wdata(&hdl->aucat, buf, len, hdl->wbpf, &hdl->sio.eof); hdl->aucat.maxwrite -= n; hdl->walign -= n; if (hdl->walign == 0) @@ -449,7 +449,7 @@ sio_aucat_pollfd(struct sio_hdl *sh, struct pollfd *pfd, int events) hdl->events = events; if (hdl->aucat.maxwrite <= 0) events &= ~POLLOUT; - return aucat_pollfd(&hdl->aucat, pfd, events); + return _aucat_pollfd(&hdl->aucat, pfd, events); } static int @@ -490,6 +490,6 @@ sio_aucat_getvol(struct sio_hdl *sh) { struct sio_aucat_hdl *hdl = (struct sio_aucat_hdl *)sh; - sio_onvol_cb(&hdl->sio, hdl->reqvol); + _sio_onvol_cb(&hdl->sio, hdl->reqvol); return; } diff --git a/libsndio/sio_priv.h b/libsndio/sio_priv.h index c70716d..c3a9675 100644 --- a/libsndio/sio_priv.h +++ b/libsndio/sio_priv.h @@ -66,19 +66,19 @@ struct sio_ops { void (*getvol)(struct sio_hdl *); }; -struct sio_hdl *sio_aucat_open(const char *, unsigned, int); +struct sio_hdl *_sio_aucat_open(const char *, unsigned, int); #ifdef USE_SUN -struct sio_hdl *sio_sun_open(const char *, unsigned, int); +struct sio_hdl *_sio_sun_open(const char *, unsigned, int); #endif #ifdef USE_ALSA -struct sio_hdl *sio_alsa_open(const char *, unsigned, int); +struct sio_hdl *_sio_alsa_open(const char *, unsigned, int); #endif -void sio_create(struct sio_hdl *, struct sio_ops *, unsigned, int); -void sio_destroy(struct sio_hdl *); -void sio_onmove_cb(struct sio_hdl *, int); -void sio_onvol_cb(struct sio_hdl *, unsigned); +void _sio_create(struct sio_hdl *, struct sio_ops *, unsigned, int); +void _sio_destroy(struct sio_hdl *); +void _sio_onmove_cb(struct sio_hdl *, int); +void _sio_onvol_cb(struct sio_hdl *, unsigned); #ifdef DEBUG -void sio_printpos(struct sio_hdl *); +void _sio_printpos(struct sio_hdl *); #endif #endif /* !defined(SNDIO_PRIV_H) */ diff --git a/libsndio/sio_sun.c b/libsndio/sio_sun.c index cc9f154..29e1a6f 100644 --- a/libsndio/sio_sun.c +++ b/libsndio/sio_sun.c @@ -337,7 +337,7 @@ sio_sun_getcap(struct sio_hdl *sh, struct sio_cap *cap) } struct sio_hdl * -sio_sun_open(const char *str, unsigned int mode, int nbio) +_sio_sun_open(const char *str, unsigned int mode, int nbio) { int fd, flags, fullduplex; struct audio_info aui; @@ -351,13 +351,13 @@ sio_sun_open(const char *str, unsigned int mode, int nbio) str++; break; default: - DPRINTF("sio_sun_open: %s: '/' expected\n", str); + DPRINTF("_sio_sun_open: %s: '/' expected\n", str); return NULL; } hdl = malloc(sizeof(struct sio_sun_hdl)); if (hdl == NULL) return NULL; - sio_create(&hdl->sio, &sio_sun_ops, mode, nbio); + _sio_create(&hdl->sio, &sio_sun_ops, mode, nbio); snprintf(path, sizeof(path), "/dev/audio%s", str); if (mode == (SIO_PLAY | SIO_REC)) @@ -472,7 +472,7 @@ sio_sun_start(struct sio_hdl *sh) return 0; } hdl->filling = 0; - sio_onmove_cb(&hdl->sio, 0); + _sio_onmove_cb(&hdl->sio, 0); } return 1; } @@ -775,7 +775,7 @@ sio_sun_autostart(struct sio_sun_hdl *hdl) hdl->sio.eof = 1; return 0; } - sio_onmove_cb(&hdl->sio, 0); + _sio_onmove_cb(&hdl->sio, 0); } return 1; } @@ -895,7 +895,7 @@ sio_sun_revents(struct sio_hdl *sh, struct pollfd *pfd) delta = (hdl->idelta > hdl->odelta) ? hdl->idelta : hdl->odelta; if (delta > 0) { - sio_onmove_cb(&hdl->sio, delta); + _sio_onmove_cb(&hdl->sio, delta); hdl->idelta -= delta; hdl->odelta -= delta; }