mirror of
https://github.com/mpv-player/mpv
synced 2024-12-25 16:33:02 +00:00
b745c2d005
Until now, the audio chain could handle both little endian and big endian formats. This actually doesn't make much sense, since the audio API and the HW will most likely prefer native formats. Or at the very least, it should be trivial for audio drivers to do the byte swapping themselves. From now on, the audio chain contains native-endian formats only. All AOs and some filters are adjusted. af_convertsignendian.c is now wrongly named, but the filter name is adjusted. In some cases, the audio infrastructure was reused on the demuxer side, but that is relatively easy to rectify. This is a quite intrusive and radical change. It's possible that it will break some things (especially if they're obscure or not Linux), so watch out for regressions. It's probably still better to do it the bulldozer way, since slow transition and researching foreign platforms would take a lot of time and effort.
50 lines
997 B
C
50 lines
997 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
#include "config.h"
|
|
|
|
#include <sndio.h>
|
|
#include "audio_in.h"
|
|
#include "common/msg.h"
|
|
|
|
int ai_sndio_setup(audio_in_t *ai)
|
|
{
|
|
struct sio_par par;
|
|
|
|
sio_initpar(&par);
|
|
|
|
par.bits = 16;
|
|
par.sig = 1;
|
|
par.le = SIO_LE_NATIVE;
|
|
par.rchan = ai->req_channels;
|
|
par.rate = ai->req_samplerate;
|
|
par.appbufsz = ai->req_samplerate; /* 1 sec */
|
|
|
|
if (!sio_setpar(ai->sndio.hdl, &par) || !sio_getpar(ai->sndio.hdl, &par)) {
|
|
MP_ERR(ai, "could not configure sndio audio");
|
|
return -1;
|
|
}
|
|
|
|
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) {
|
|
MP_ERR(ai, "could not open sndio audio");
|
|
return -1;
|
|
}
|
|
|
|
err = ai_sndio_setup(ai);
|
|
|
|
return err;
|
|
}
|