From bde184cd77e6a17c33b48e8295822d89e4e8bbd9 Mon Sep 17 00:00:00 2001 From: Alexandre Ratchov Date: Fri, 5 Oct 2012 21:27:11 +0200 Subject: [PATCH] save fifo pointers for debug purposes --- libsndio/sio_sun.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/libsndio/sio_sun.c b/libsndio/sio_sun.c index a0bc99e..65f2bc7 100644 --- a/libsndio/sio_sun.c +++ b/libsndio/sio_sun.c @@ -55,6 +55,12 @@ struct sio_sun_hdl { int offset; /* frames play is ahead of record */ int idelta, odelta; /* position reported to client */ int mix_fd, mix_index; /* /dev/mixerN stuff */ +#ifdef DEBUG + /* save these for core dumps */ + int isamples, osamples; + int ixrun, oxrun; + int cpos, rpos, wpos; +#endif }; static void sio_sun_close(struct sio_hdl *); @@ -784,6 +790,9 @@ sio_sun_read(struct sio_hdl *sh, void *buf, size_t len) hdl->sio.eof = 1; return 0; } +#ifdef DEBUG + hdl->rpos += n; +#endif return n; } @@ -845,6 +854,10 @@ sio_sun_wsil(struct sio_sun_hdl *hdl) } hdl->offset += (int)n / (int)hdl->obpf; DPRINTF("sio_sun_wsil: inserted %ld/%ld bytes\n", n, todo); +#ifdef DEBUG + hdl->wpos += n; +#endif + } return 1; } @@ -869,6 +882,9 @@ sio_sun_write(struct sio_hdl *sh, const void *buf, size_t len) } return 0; } +#ifdef DEBUG + hdl->wpos += n; +#endif if (hdl->filling) { if (!sio_sun_autostart(hdl)) return 0; @@ -908,6 +924,9 @@ sio_sun_revents(struct sio_hdl *sh, struct pollfd *pfd) hdl->sio.eof = 1; return POLLHUP; } +#ifdef DEBUG + hdl->osamples = ao.samples; +#endif delta = (ao.samples - hdl->obytes) / hdl->obpf; hdl->obytes = ao.samples; hdl->odelta += delta; @@ -920,6 +939,9 @@ sio_sun_revents(struct sio_hdl *sh, struct pollfd *pfd) hdl->sio.eof = 1; return POLLHUP; } +#ifdef DEBUG + hdl->isamples = hdl->ibytes; +#endif delta = (ao.samples - hdl->ibytes) / hdl->ibpf; hdl->ibytes = ao.samples; hdl->idelta += delta; @@ -932,6 +954,9 @@ sio_sun_revents(struct sio_hdl *sh, struct pollfd *pfd) hdl->sio.eof = 1; return POLLHUP; } +#ifdef DEBUG + hdl->oxrun = xrun; +#endif doerr = xrun - hdl->oerr; hdl->oerr = xrun; if (!(hdl->sio.mode & SIO_REC)) @@ -943,6 +968,9 @@ sio_sun_revents(struct sio_hdl *sh, struct pollfd *pfd) hdl->sio.eof = 1; return POLLHUP; } +#ifdef DEBUG + hdl->ixrun = xrun; +#endif dierr = xrun - hdl->ierr; hdl->ierr = xrun; if (!(hdl->sio.mode & SIO_PLAY)) @@ -955,6 +983,9 @@ sio_sun_revents(struct sio_hdl *sh, struct pollfd *pfd) delta = (hdl->idelta > hdl->odelta) ? hdl->idelta : hdl->odelta; if (delta > 0) { +#ifdef DEBUG + hdl->cpos += delta; +#endif sio_onmove_cb(&hdl->sio, delta); hdl->idelta -= delta; hdl->odelta -= delta;