зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1674825 - Update libcubeb to 4e851e. r=cubeb-reviewers,kinetik
Differential Revision: https://phabricator.services.mozilla.com/D95549
This commit is contained in:
Родитель
2ab836d606
Коммит
ab551c6519
|
@ -242,6 +242,10 @@ typedef enum {
|
|||
should persist across restarts of the stream
|
||||
and/or application. May not be honored for
|
||||
all backends and platforms. */
|
||||
|
||||
CUBEB_STREAM_PREF_JACK_NO_AUTO_CONNECT = 0x20 /**< Don't automatically try to connect
|
||||
ports. Only affects the jack
|
||||
backend. */
|
||||
} cubeb_stream_prefs;
|
||||
|
||||
/** Stream format initialization parameters. */
|
||||
|
@ -505,7 +509,9 @@ CUBEB_EXPORT void cubeb_destroy(cubeb * context);
|
|||
cubeb_devid allows the stream to follow that device type's
|
||||
OS default.
|
||||
@param output_stream_params Parameters for the output side of the stream, or
|
||||
NULL if this stream is input only.
|
||||
NULL if this stream is input only. When input
|
||||
and output stream parameters are supplied, their
|
||||
rate has to be the same.
|
||||
@param latency_frames Stream latency in frames. Valid range
|
||||
is [1, 96000].
|
||||
@param data_callback Will be called to preroll data before playback is
|
||||
|
|
|
@ -19,5 +19,5 @@ origin:
|
|||
license: "ISC"
|
||||
|
||||
# update.sh will update this value
|
||||
release: "a7e83aa2b1571b842a555158e8f25aeb1419ebd1 (2020-10-13 12:05:17 +0100)"
|
||||
release: "4e851e996031381d03acd26b93e0578101eade33 (2020-11-03 16:36:58 +0100)"
|
||||
|
||||
|
|
|
@ -63,6 +63,9 @@ int opensl_init(cubeb ** context, char const * context_name);
|
|||
#if defined(USE_OSS)
|
||||
int oss_init(cubeb ** context, char const * context_name);
|
||||
#endif
|
||||
#if defined(USE_AAUDIO)
|
||||
int aaudio_init(cubeb ** context, char const * context_name);
|
||||
#endif
|
||||
#if defined(USE_AUDIOTRACK)
|
||||
int audiotrack_init(cubeb ** context, char const * context_name);
|
||||
#endif
|
||||
|
@ -172,6 +175,10 @@ cubeb_init(cubeb ** context, char const * context_name, char const * backend_nam
|
|||
} else if (!strcmp(backend_name, "oss")) {
|
||||
#if defined(USE_OSS)
|
||||
init_oneshot = oss_init;
|
||||
#endif
|
||||
} else if (!strcmp(backend_name, "aaudio")) {
|
||||
#if defined(USE_AAUDIO)
|
||||
init_oneshot = aaudio_init;
|
||||
#endif
|
||||
} else if (!strcmp(backend_name, "audiotrack")) {
|
||||
#if defined(USE_AUDIOTRACK)
|
||||
|
@ -227,6 +234,11 @@ cubeb_init(cubeb ** context, char const * context_name, char const * backend_nam
|
|||
#endif
|
||||
#if defined(USE_OPENSL)
|
||||
opensl_init,
|
||||
#endif
|
||||
// TODO: should probably be preferred over OpenSLES when available.
|
||||
// Initialization will fail on old android devices.
|
||||
#if defined(USE_AAUDIO)
|
||||
aaudio_init,
|
||||
#endif
|
||||
#if defined(USE_AUDIOTRACK)
|
||||
audiotrack_init,
|
||||
|
@ -700,3 +712,4 @@ int cubeb_set_log_callback(cubeb_log_level log_level,
|
|||
|
||||
return CUBEB_OK;
|
||||
}
|
||||
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,17 @@
|
|||
#ifndef CUBEB_ANDROID_H
|
||||
#define CUBEB_ANDROID_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
// If the latency requested is above this threshold, this stream is considered
|
||||
// intended for playback (vs. real-time). Tell Android it should favor saving
|
||||
// power over performance or latency.
|
||||
// This is around 100ms at 44100 or 48000
|
||||
const uint16_t POWERSAVE_LATENCY_FRAMES_THRESHOLD = 4000;
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif // CUBEB_ANDROID_H
|
|
@ -1513,6 +1513,7 @@ audiounit_set_channel_layout(AudioUnit unit,
|
|||
return CUBEB_OK;
|
||||
}
|
||||
|
||||
|
||||
OSStatus r;
|
||||
uint32_t nb_channels = cubeb_channel_layout_nb_channels(layout);
|
||||
|
||||
|
@ -2069,6 +2070,7 @@ audiounit_create_unit(AudioUnit * unit, device_info * device)
|
|||
return CUBEB_OK;
|
||||
}
|
||||
|
||||
|
||||
if (device->flags & DEV_INPUT) {
|
||||
r = audiounit_enable_unit_scope(unit, io_side::INPUT, ENABLE);
|
||||
if (r != CUBEB_OK) {
|
||||
|
@ -2215,6 +2217,7 @@ buffer_size_changed_callback(void * inClientData,
|
|||
}
|
||||
|
||||
switch (inPropertyID) {
|
||||
|
||||
case kAudioDevicePropertyBufferFrameSize: {
|
||||
if (inScope != au_scope) {
|
||||
break;
|
||||
|
@ -2728,6 +2731,7 @@ audiounit_setup_stream(cubeb_stream * stm)
|
|||
LOG("(%p) Could not install all device change callback.", stm);
|
||||
}
|
||||
|
||||
|
||||
return CUBEB_OK;
|
||||
}
|
||||
|
||||
|
@ -3208,6 +3212,7 @@ audiounit_get_available_samplerate(AudioObjectID devid, AudioObjectPropertyScope
|
|||
} else {
|
||||
*min = *max = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static UInt32
|
||||
|
|
|
@ -400,6 +400,7 @@ cbjack_process(jack_nframes_t nframes, void * arg)
|
|||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
// try to lock stream mutex
|
||||
if (pthread_mutex_trylock(&stm->mutex) == 0) {
|
||||
|
||||
|
@ -906,10 +907,12 @@ cbjack_stream_init(cubeb * context, cubeb_stream ** stream, char const * stream_
|
|||
}
|
||||
}
|
||||
|
||||
if (cbjack_connect_ports(stm) != CUBEB_OK) {
|
||||
pthread_mutex_unlock(&stm->mutex);
|
||||
cbjack_stream_destroy(stm);
|
||||
return CUBEB_ERROR;
|
||||
if (!input_stream_params->prefs & CUBEB_STREAM_PREF_JACK_NO_AUTO_CONNECT) {
|
||||
if (cbjack_connect_ports(stm) != CUBEB_OK) {
|
||||
pthread_mutex_unlock(&stm->mutex);
|
||||
cbjack_stream_destroy(stm);
|
||||
return CUBEB_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
*stream = stm;
|
||||
|
|
|
@ -46,6 +46,7 @@ void cubeb_async_log_reset_threads();
|
|||
} while(0)
|
||||
|
||||
/* Asynchronous verbose logging, to log in real-time callbacks. */
|
||||
/* Should not be used on android due to the use of global/static variables. */
|
||||
#define ALOGV(fmt, ...) \
|
||||
do { \
|
||||
cubeb_async_log(fmt, ##__VA_ARGS__); \
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "cubeb-sles.h"
|
||||
#include "cubeb_array_queue.h"
|
||||
#include "android/cubeb-output-latency.h"
|
||||
#include "cubeb_android.h"
|
||||
|
||||
#if defined(__ANDROID__)
|
||||
#ifdef LOG
|
||||
|
@ -65,11 +66,6 @@
|
|||
|
||||
#define DEFAULT_SAMPLE_RATE 48000
|
||||
#define DEFAULT_NUM_OF_FRAMES 480
|
||||
// If the latency requested is above this threshold, this stream is considered
|
||||
// intended for playback (vs. real-time). Tell Android it should favor saving
|
||||
// power over performance or latency.
|
||||
// This is around 100ms at 44100 or 48000
|
||||
#define POWERSAVE_LATENCY_FRAMES_THRESHOLD 4000
|
||||
|
||||
static struct cubeb_ops const opensl_ops;
|
||||
|
||||
|
@ -943,6 +939,7 @@ opensl_configure_capture(cubeb_stream * stm, cubeb_stream_params * params)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
if (get_android_version() > ANDROID_VERSION_JELLY_BEAN) {
|
||||
SLAndroidConfigurationItf recorderConfig;
|
||||
res = (*stm->recorderObj)
|
||||
|
@ -1701,7 +1698,7 @@ opensl_stream_get_latency(cubeb_stream * stm, uint32_t * latency)
|
|||
assert(latency);
|
||||
|
||||
uint32_t stream_latency_frames =
|
||||
stm->user_output_rate * (stm->output_latency_ms / 1000);
|
||||
stm->user_output_rate * stm->output_latency_ms / 1000;
|
||||
|
||||
return stream_latency_frames + cubeb_resampler_latency(stm->resampler);
|
||||
}
|
||||
|
|
|
@ -138,17 +138,6 @@ cubeb_resampler_speex<T, InputProcessor, OutputProcessor>
|
|||
, user_ptr(ptr)
|
||||
{
|
||||
if (input_processor && output_processor) {
|
||||
// Add some delay on the processor that has the lowest delay so that the
|
||||
// streams are synchronized.
|
||||
uint32_t in_latency = input_processor->latency();
|
||||
uint32_t out_latency = output_processor->latency();
|
||||
if (in_latency > out_latency) {
|
||||
uint32_t latency_diff = in_latency - out_latency;
|
||||
output_processor->add_latency(latency_diff);
|
||||
} else if (in_latency < out_latency) {
|
||||
uint32_t latency_diff = out_latency - in_latency;
|
||||
input_processor->add_latency(latency_diff);
|
||||
}
|
||||
fill_internal = &cubeb_resampler_speex::fill_internal_duplex;
|
||||
} else if (input_processor) {
|
||||
fill_internal = &cubeb_resampler_speex::fill_internal_input;
|
||||
|
|
|
@ -213,17 +213,6 @@ public:
|
|||
speex_resampler_destroy(speex_resampler);
|
||||
}
|
||||
|
||||
/** Sometimes, it is necessary to add latency on one way of a two-way
|
||||
* resampler so that the stream are synchronized. This must be called only on
|
||||
* a fresh resampler, otherwise, silent samples will be inserted in the
|
||||
* stream.
|
||||
* @param frames the number of frames of latency to add. */
|
||||
void add_latency(size_t frames)
|
||||
{
|
||||
additional_latency += frames;
|
||||
resampling_in_buffer.push_silence(frames_to_samples(frames));
|
||||
}
|
||||
|
||||
/* Fill the resampler with `input_frame_count` frames. */
|
||||
void input(T * input_buffer, size_t input_frame_count)
|
||||
{
|
||||
|
@ -307,9 +296,11 @@ public:
|
|||
uint32_t input_needed_for_output(int32_t output_frame_count) const
|
||||
{
|
||||
assert(output_frame_count >= 0); // Check overflow
|
||||
int32_t unresampled_frames_left = samples_to_frames(resampling_in_buffer.length());
|
||||
int32_t resampled_frames_left = samples_to_frames(resampling_out_buffer.length());
|
||||
float input_frames_needed =
|
||||
output_frame_count * resampling_ratio - resampled_frames_left;
|
||||
float input_frames_needed =
|
||||
(output_frame_count - unresampled_frames_left) * resampling_ratio
|
||||
- resampled_frames_left;
|
||||
if (input_frames_needed < 0) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -412,13 +403,6 @@ public:
|
|||
/* Fill the delay line with some silent frames to add latency. */
|
||||
delay_input_buffer.push_silence(frames * channels);
|
||||
}
|
||||
/* Add some latency to the delay line.
|
||||
* @param frames the number of frames of latency to add. */
|
||||
void add_latency(size_t frames)
|
||||
{
|
||||
length += frames;
|
||||
delay_input_buffer.push_silence(frames_to_samples(frames));
|
||||
}
|
||||
/** Push some frames into the delay line.
|
||||
* @parameter buffer the frames to push.
|
||||
* @parameter frame_count the number of frames in #buffer. */
|
||||
|
|
|
@ -220,6 +220,7 @@ sndio_mainloop(void *arg)
|
|||
|
||||
/* 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;
|
||||
|
|
Загрузка…
Ссылка в новой задаче