зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1814359 - Update libcubeb to revision 70b4e3db. r=cubeb-reviewers,kinetik
Depends on D170347 Differential Revision: https://phabricator.services.mozilla.com/D170348
This commit is contained in:
Родитель
779d902668
Коммит
06a40cfefc
|
@ -9,8 +9,8 @@ origin:
|
|||
description: "Cross platform audio library"
|
||||
url: https://github.com/mozilla/cubeb
|
||||
license: ISC
|
||||
release: c96f0d4e7ff8843b96719c15f40f1b8032bccba8 (2023-01-09T16:12:54Z).
|
||||
revision: c96f0d4e7ff8843b96719c15f40f1b8032bccba8
|
||||
release: 70b4e3db7822de4d534959885cda109d6edbee36 (2023-02-01T14:54:51Z).
|
||||
revision: 70b4e3db7822de4d534959885cda109d6edbee36
|
||||
|
||||
vendoring:
|
||||
url: https://github.com/mozilla/cubeb
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
#include "cubeb_resampler.h"
|
||||
#include "cubeb_triple_buffer.h"
|
||||
#include <aaudio/AAudio.h>
|
||||
#include <android/api-level.h>
|
||||
#include <atomic>
|
||||
#include <cassert>
|
||||
#include <chrono>
|
||||
|
@ -1550,9 +1549,6 @@ const static struct cubeb_ops aaudio_ops = {
|
|||
extern "C" /*static*/ int
|
||||
aaudio_init(cubeb ** context, char const * /* context_name */)
|
||||
{
|
||||
if (android_get_device_api_level() <= 30) {
|
||||
return CUBEB_ERROR;
|
||||
}
|
||||
// load api
|
||||
void * libaaudio = NULL;
|
||||
#ifndef DISABLE_LIBAAUDIO_DLOPEN
|
||||
|
|
|
@ -68,7 +68,7 @@ struct cubeb_stream {
|
|||
struct sio_hdl * hdl; /* link us to sndio */
|
||||
int mode; /* bitmap of SIO_{PLAY,REC} */
|
||||
int active; /* cubec_start() called */
|
||||
int conv; /* need float->s16 conversion */
|
||||
int conv; /* need float->s24 conversion */
|
||||
unsigned char * rbuf; /* rec data consumed from here */
|
||||
unsigned char * pbuf; /* play data is prepared here */
|
||||
unsigned int nfr; /* number of frames in ibuf and obuf */
|
||||
|
@ -99,33 +99,33 @@ s16_setvol(void * ptr, long nsamp, float volume)
|
|||
}
|
||||
|
||||
static void
|
||||
float_to_s16(void * ptr, long nsamp, float volume)
|
||||
float_to_s24(void * ptr, long nsamp, float volume)
|
||||
{
|
||||
int16_t * dst = ptr;
|
||||
int32_t * dst = ptr;
|
||||
float * src = ptr;
|
||||
float mult = volume * 32768;
|
||||
float mult = volume * 8388608;
|
||||
int s;
|
||||
|
||||
while (nsamp-- > 0) {
|
||||
s = lrintf(*(src++) * mult);
|
||||
if (s < -32768)
|
||||
s = -32768;
|
||||
else if (s > 32767)
|
||||
s = 32767;
|
||||
if (s < -8388608)
|
||||
s = -8388608;
|
||||
else if (s > 8388607)
|
||||
s = 8388607;
|
||||
*(dst++) = s;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
s16_to_float(void * ptr, long nsamp)
|
||||
s24_to_float(void * ptr, long nsamp)
|
||||
{
|
||||
int16_t * src = ptr;
|
||||
int32_t * src = ptr;
|
||||
float * dst = ptr;
|
||||
|
||||
src += nsamp;
|
||||
dst += nsamp;
|
||||
while (nsamp-- > 0)
|
||||
*(--dst) = (1. / 32768) * *(--src);
|
||||
*(--dst) = (1. / 8388608) * *(--src);
|
||||
}
|
||||
|
||||
static const char *
|
||||
|
@ -213,7 +213,7 @@ sndio_mainloop(void * arg)
|
|||
}
|
||||
|
||||
if ((s->mode & SIO_REC) && s->conv)
|
||||
s16_to_float(s->rbuf, s->nfr * s->rchan);
|
||||
s24_to_float(s->rbuf, s->nfr * s->rchan);
|
||||
|
||||
/* invoke call-back, it returns less that s->nfr if done */
|
||||
pthread_mutex_unlock(&s->mtx);
|
||||
|
@ -244,7 +244,7 @@ sndio_mainloop(void * arg)
|
|||
|
||||
if (s->mode & SIO_PLAY) {
|
||||
if (s->conv)
|
||||
float_to_s16(s->pbuf, nfr * s->pchan, s->volume);
|
||||
float_to_s24(s->pbuf, nfr * s->pchan, s->volume);
|
||||
else
|
||||
s16_setvol(s->pbuf, nfr * s->pchan, s->volume);
|
||||
}
|
||||
|
@ -429,21 +429,25 @@ sndio_stream_init(cubeb * context, cubeb_stream ** stream,
|
|||
}
|
||||
WRAP(sio_initpar)(&wpar);
|
||||
wpar.sig = 1;
|
||||
wpar.bits = 16;
|
||||
switch (format) {
|
||||
case CUBEB_SAMPLE_S16LE:
|
||||
wpar.le = 1;
|
||||
wpar.bits = 16;
|
||||
break;
|
||||
case CUBEB_SAMPLE_S16BE:
|
||||
wpar.le = 0;
|
||||
wpar.bits = 16;
|
||||
break;
|
||||
case CUBEB_SAMPLE_FLOAT32NE:
|
||||
wpar.le = SIO_LE_NATIVE;
|
||||
wpar.bits = 24;
|
||||
wpar.msb = 0;
|
||||
break;
|
||||
default:
|
||||
DPR("sndio_stream_init() unsupported format\n");
|
||||
goto err;
|
||||
}
|
||||
wpar.bps = SIO_BPS(wpar.bits);
|
||||
wpar.rate = rate;
|
||||
if (s->mode & SIO_REC)
|
||||
wpar.rchan = input_stream_params->channels;
|
||||
|
@ -455,6 +459,8 @@ sndio_stream_init(cubeb * context, cubeb_stream ** stream,
|
|||
goto err;
|
||||
}
|
||||
if (rpar.bits != wpar.bits || rpar.le != wpar.le || rpar.sig != wpar.sig ||
|
||||
rpar.bps != wpar.bps ||
|
||||
(wpar.bits < 8 * wpar.bps && rpar.msb != wpar.msb) ||
|
||||
rpar.rate != wpar.rate ||
|
||||
((s->mode & SIO_REC) && rpar.rchan != wpar.rchan) ||
|
||||
((s->mode & SIO_PLAY) && rpar.pchan != wpar.pchan)) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче