2013-09-28 16:01:12 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <sndio.h>
|
|
|
|
#include "audio_in.h"
|
2013-12-17 01:39:45 +00:00
|
|
|
#include "common/msg.h"
|
2013-09-28 16:01:12 +00:00
|
|
|
|
|
|
|
int ai_sndio_setup(audio_in_t *ai)
|
|
|
|
{
|
|
|
|
struct sio_par par;
|
|
|
|
|
|
|
|
sio_initpar(&par);
|
|
|
|
|
|
|
|
par.bits = 16;
|
|
|
|
par.sig = 1;
|
|
|
|
par.le = 1;
|
|
|
|
par.rchan = ai->req_channels;
|
|
|
|
par.rate = ai->req_samplerate;
|
2014-04-13 16:00:51 +00:00
|
|
|
par.appbufsz = ai->req_samplerate; /* 1 sec */
|
2013-09-28 16:01:12 +00:00
|
|
|
|
|
|
|
if (!sio_setpar(ai->sndio.hdl, &par) || !sio_getpar(ai->sndio.hdl, &par)) {
|
2014-04-13 16:00:51 +00:00
|
|
|
MP_ERR(ai, "could not configure sndio audio");
|
|
|
|
return -1;
|
2013-09-28 16:01:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ai->channels = par.rchan;
|
|
|
|
ai->samplerate = par.rate;
|
|
|
|
ai->samplesize = par.bits;
|
|
|
|
ai->bytes_per_sample = par.bps;
|
|
|
|
ai->blocksize = par.round * par.bps;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ai_sndio_init(audio_in_t *ai)
|
|
|
|
{
|
|
|
|
int err;
|
|
|
|
|
|
|
|
if ((ai->sndio.hdl = sio_open(ai->sndio.device, SIO_REC, 0)) == NULL) {
|
2014-04-13 16:00:51 +00:00
|
|
|
MP_ERR(ai, "could not open sndio audio");
|
|
|
|
return -1;
|
2013-09-28 16:01:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
err = ai_sndio_setup(ai);
|
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|