gboolean gst_sndio_unprepare (struct gstsndio *sio) { if (sio->hdl) sio_stop (sio->hdl); return TRUE; }
static PaError StopStream(PaStream *stream) { PaSndioStream *s = (PaSndioStream *)stream; void *ret; int err; DPR("StopStream: s=%d, a=%d\n", s->stopped, s->active); if (s->stopped) { DPR("StartStream: already started\n"); return paNoError; } s->stopped = 1; if (s->base.streamCallback) { err = pthread_join(s->thread, &ret); if (err) { DPR("SndioStop: couldn't join thread\n"); return paUnanticipatedHostError; } } if (!sio_stop(s->hdl)) return paUnanticipatedHostError; return paNoError; }
/* * stop playing and empty buffers (for seeking/pause) */ static void reset(struct ao *ao) { struct priv *p = ao->priv; if (!sio_stop(p->hdl)) MP_ERR(ao, "reset: couldn't stop\n"); p->delay = 0; if (!sio_start(p->hdl)) MP_ERR(ao, "reset: couldn't start\n"); }
void CAESinkSNDIO::Stop() { if (!m_hdl) return; if (!sio_stop(m_hdl)) CLog::Log(LOGERROR, "CAESinkSNDIO::Stop - Failed"); m_written = m_played = 0; }
static int sndio_pause(void) { if (!sndio_paused) { if (!sio_stop(hdl)) return -OP_ERROR_INTERNAL; sndio_paused = 1; } return OP_ERROR_SUCCESS; }
void CAESinkSNDIO::Drain() { if(!m_hdl) return; if (!sio_stop(m_hdl) || !sio_start(m_hdl)) CLog::Log(LOGERROR, "CAESinkSNDIO::Drain - failed"); m_written = m_played = 0; }
int SndioSink::setAudioConfiguration(const AudioConfiguration* config) { d->config = *config; if (d->valid) sio_stop(d->hdl); sio_initpar(&d->par); if (config->sample_width < 0) { d->par.bits = 16; d->par.sig = 1; } else { d->par.bits = config->sample_width; if (d->par.bits == 8) d->par.sig = 0; else d->par.sig = 1; } d->par.pchan = config->channels; d->par.rate = config->sample_rate; if (!sio_setpar(d->hdl, &d->par)) { d->valid = false; return -1; } if (!sio_getpar(d->hdl, &d->par)) { d->valid = false; return -1; } d->config.sample_width = d->par.bits; d->config.sample_rate = d->par.rate; d->config.channels = d->par.pchan; if (d->config.channels <= 2) d->config.channel_config = MonoStereo; if (!sio_start(d->hdl)) { std::cerr << "akode: could not restart sndio device\n"; d->valid = false; return -1; } if (d->config == *config) return 0; else return 1; }
static void ao_sndio_close(ao_driver_t *this_gen) { sndio_driver_t *this = (sndio_driver_t *) this_gen; xprintf (this->xine, XINE_VERBOSITY_DEBUG, "audio_sndio_out: ao_sndio_close called\n"); if (!sio_stop(this->hdl)) { xprintf (this->xine, XINE_VERBOSITY_DEBUG, "audio_sndio_out: ao_sndio_close could not stop\n"); } sio_close(this->hdl); this->hdl = NULL; }
/* * stop playing and empty buffers (for seeking/pause) */ static void reset(struct ao *ao) { struct priv *p = ao->priv; if (p->playing) { MP_WARN(ao, "Blocking until remaining audio is played... (sndio design bug).\n"); p->playing = false; if (!sio_stop(p->hdl)) MP_ERR(ao, "reset: couldn't stop\n"); p->delay = 0; if (!sio_start(p->hdl)) MP_ERR(ao, "reset: couldn't start\n"); } }
static void sndio_stop_playback(ALCdevice *device) { sndio_data *data = device->ExtraData; int res; if(data->killNow) return; data->killNow = 1; althrd_join(data->thread, &res); if(!sio_stop(data->sndHandle)) ERR("Error stopping device\n"); free(data->mix_data); data->mix_data = NULL; }
static void sndio_stop_playback(ALCdevice *device) { sndio_data *data = device->ExtraData; if(!data->thread) return; data->killNow = 1; StopThread(data->thread); data->thread = NULL; data->killNow = 0; if(!sio_stop(data->sndHandle)) ERR("Error stopping device\n"); free(data->mix_data); data->mix_data = NULL; }
void dev_sio_stop(struct dev *d) { if (!sio_eof(d->sio.hdl) && !sio_stop(d->sio.hdl)) { if (log_level >= 1) { dev_log(d); log_puts(": failed to stop device\n"); } return; } #ifdef DEBUG if (log_level >= 3) { dev_log(d); log_puts(": stopped, load avg = "); log_puti(d->sio.sum_utime / 1000); log_puts(" / "); log_puti(d->sio.sum_wtime / 1000); log_puts("\n"); } #endif timo_del(&d->sio.watchdog); }
void siofile_stop(struct file *file) { struct siofile *f = (struct siofile *)file; f->started = 0; f->onmove = NULL; if (!sio_eof(f->hdl) && !sio_stop(f->hdl)) { #ifdef DEBUG dbg_puts(f->file.name); dbg_puts(": failed to stop device\n"); #endif file_close(file); return; } #ifdef DEBUG if (debug_level >= 3) { file_dbg(&f->file); dbg_puts(": stopped\n"); } #endif }
static ALCboolean sndio_start_playback(ALCdevice *device) { sndio_data *data = device->ExtraData; if(!sio_start(data->sndHandle)) { ERR("Error starting playback\n"); return ALC_FALSE; } data->data_size = device->UpdateSize * FrameSizeFromDevFmt(device->FmtChans, device->FmtType); data->mix_data = calloc(1, data->data_size); if(!StartThread(&data->thread, sndio_proc, device)) { sio_stop(data->sndHandle); free(data->mix_data); data->mix_data = NULL; return ALC_FALSE; } return ALC_TRUE; }
static void stop(void) { sio_stop(sio); }
static void * sndio_mainloop(void *arg) { #define MAXFDS 8 struct pollfd pfds[MAXFDS]; cubeb_stream *s = arg; int n, nfds, revents, state = CUBEB_STATE_STARTED; size_t start = 0, end = 0; long nfr; DPR("sndio_mainloop()\n"); s->state_cb(s, s->arg, CUBEB_STATE_STARTED); pthread_mutex_lock(&s->mtx); if (!sio_start(s->hdl)) { pthread_mutex_unlock(&s->mtx); return NULL; } DPR("sndio_mainloop(), started\n"); start = end = s->nfr; for (;;) { if (!s->active) { DPR("sndio_mainloop() stopped\n"); state = CUBEB_STATE_STOPPED; break; } if (start == end) { if (end < s->nfr) { DPR("sndio_mainloop() drained\n"); state = CUBEB_STATE_DRAINED; break; } pthread_mutex_unlock(&s->mtx); nfr = s->data_cb(s, s->arg, NULL, s->buf, s->nfr); pthread_mutex_lock(&s->mtx); if (nfr < 0) { DPR("sndio_mainloop() cb err\n"); state = CUBEB_STATE_ERROR; break; } if (s->conv) float_to_s16(s->buf, nfr * s->pchan); start = 0; end = nfr * s->bpf; } if (end == 0) continue; nfds = sio_pollfd(s->hdl, pfds, POLLOUT); if (nfds > 0) { pthread_mutex_unlock(&s->mtx); n = poll(pfds, nfds, -1); pthread_mutex_lock(&s->mtx); if (n < 0) continue; } revents = sio_revents(s->hdl, pfds); if (revents & POLLHUP) break; if (revents & POLLOUT) { n = sio_write(s->hdl, s->buf + start, end - start); if (n == 0) { DPR("sndio_mainloop() werr\n"); state = CUBEB_STATE_ERROR; break; } s->wrpos += n; start += n; } } sio_stop(s->hdl); s->rdpos = s->wrpos; pthread_mutex_unlock(&s->mtx); s->state_cb(s, s->arg, state); return NULL; }
static void * sndio_mainloop(void *arg) { #define MAXFDS 8 struct pollfd pfds[MAXFDS]; cubeb_stream *s = arg; int n, eof = 0, prime, nfds, events, revents, state = CUBEB_STATE_STARTED; size_t pstart = 0, pend = 0, rstart = 0, rend = 0; long nfr; DPR("sndio_mainloop()\n"); s->state_cb(s, s->arg, CUBEB_STATE_STARTED); pthread_mutex_lock(&s->mtx); if (!sio_start(s->hdl)) { pthread_mutex_unlock(&s->mtx); return NULL; } DPR("sndio_mainloop(), started\n"); if (s->mode & SIO_PLAY) { pstart = pend = s->nfr * s->pbpf; prime = s->nblks; if (s->mode & SIO_REC) { memset(s->rbuf, 0, s->nfr * s->rbpf); rstart = rend = s->nfr * s->rbpf; } } else { prime = 0; rstart = 0; rend = s->nfr * s->rbpf; } for (;;) { if (!s->active) { DPR("sndio_mainloop() stopped\n"); state = CUBEB_STATE_STOPPED; break; } /* do we have a complete block? */ if ((!(s->mode & SIO_PLAY) || pstart == pend) && (!(s->mode & SIO_REC) || rstart == rend)) { if (eof) { DPR("sndio_mainloop() drained\n"); state = CUBEB_STATE_DRAINED; break; } if ((s->mode & SIO_REC) && s->conv) s16_to_float(s->rbuf, s->nfr * s->rchan); /* invoke call-back, it returns less that s->nfr if done */ pthread_mutex_unlock(&s->mtx); nfr = s->data_cb(s, s->arg, s->rbuf, s->pbuf, s->nfr); pthread_mutex_lock(&s->mtx); if (nfr < 0) { DPR("sndio_mainloop() cb err\n"); state = CUBEB_STATE_ERROR; break; } s->swpos += nfr; /* was this last call-back invocation (aka end-of-stream) ? */ if (nfr < s->nfr) { if (!(s->mode & SIO_PLAY) || nfr == 0) { state = CUBEB_STATE_DRAINED; break; } /* need to write (aka drain) the partial play block we got */ pend = nfr * s->pbpf; eof = 1; } if (prime > 0) prime--; if ((s->mode & SIO_PLAY) && s->conv) float_to_s16(s->pbuf, nfr * s->pchan); if (s->mode & SIO_REC) rstart = 0; if (s->mode & SIO_PLAY) pstart = 0; } events = 0; if ((s->mode & SIO_REC) && rstart < rend && prime == 0) events |= POLLIN; if ((s->mode & SIO_PLAY) && pstart < pend) events |= POLLOUT; nfds = sio_pollfd(s->hdl, pfds, events); if (nfds > 0) { pthread_mutex_unlock(&s->mtx); n = poll(pfds, nfds, -1); pthread_mutex_lock(&s->mtx); if (n < 0) continue; } revents = sio_revents(s->hdl, pfds); if (revents & POLLHUP) { state = CUBEB_STATE_ERROR; break; } if (revents & POLLOUT) { n = sio_write(s->hdl, s->pbuf + pstart, pend - pstart); if (n == 0 && sio_eof(s->hdl)) { DPR("sndio_mainloop() werr\n"); state = CUBEB_STATE_ERROR; break; } pstart += n; } if (revents & POLLIN) { n = sio_read(s->hdl, s->rbuf + rstart, rend - rstart); if (n == 0 && sio_eof(s->hdl)) { DPR("sndio_mainloop() rerr\n"); state = CUBEB_STATE_ERROR; break; } rstart += n; } /* skip rec block, if not recording (yet) */ if (prime > 0 && (s->mode & SIO_REC)) rstart = rend; } sio_stop(s->hdl); s->hwpos = s->swpos; pthread_mutex_unlock(&s->mtx); s->state_cb(s, s->arg, state); return NULL; }