зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1791900 - Update libcubeb 93d1fa3fcc. r=cubeb-reviewers,kinetik
Differential Revision: https://phabricator.services.mozilla.com/D157987
This commit is contained in:
Родитель
e497d5abef
Коммит
d598d84141
|
@ -9,8 +9,8 @@ origin:
|
|||
description: "Cross platform audio library"
|
||||
url: https://github.com/mozilla/cubeb
|
||||
license: ISC
|
||||
release: bc0450628e120dbee89fb8ad0b29abbd24dc3729 (2022-09-21T20:32:32Z).
|
||||
revision: bc0450628e120dbee89fb8ad0b29abbd24dc3729
|
||||
release: 93d1fa3fccdc22da37aa59f67b213591797db369 (2022-09-22T21:52:54Z).
|
||||
revision: 93d1fa3fccdc22da37aa59f67b213591797db369
|
||||
|
||||
vendoring:
|
||||
url: https://github.com/mozilla/cubeb
|
||||
|
|
|
@ -639,7 +639,7 @@ cubeb_enumerate_devices(cubeb * context, cubeb_device_type devtype,
|
|||
|
||||
rv = context->ops->enumerate_devices(context, devtype, collection);
|
||||
|
||||
if (g_cubeb_log_callback) {
|
||||
if (cubeb_log_get_callback()) {
|
||||
for (size_t i = 0; i < collection->count; i++) {
|
||||
log_device(&collection->device[i]);
|
||||
}
|
||||
|
@ -701,21 +701,11 @@ cubeb_set_log_callback(cubeb_log_level log_level,
|
|||
return CUBEB_ERROR_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (g_cubeb_log_callback && log_callback) {
|
||||
if (cubeb_log_get_callback() && log_callback) {
|
||||
return CUBEB_ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
g_cubeb_log_callback = log_callback;
|
||||
g_cubeb_log_level = log_level;
|
||||
|
||||
// Logging a message here allows to initialize the asynchronous logger from a
|
||||
// thread that is not the audio rendering thread, and especially to not
|
||||
// initialize it the first time we find a verbose log, which is often in the
|
||||
// audio rendering callback, that runs from the audio rendering thread, and
|
||||
// that is high priority, and that we don't want to block.
|
||||
if (log_level >= CUBEB_LOG_VERBOSE) {
|
||||
ALOGV("Starting cubeb log");
|
||||
}
|
||||
cubeb_log_set(log_level, log_callback);
|
||||
|
||||
return CUBEB_OK;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#define _XOPEN_SOURCE 500
|
||||
#include "cubeb-internal.h"
|
||||
#include "cubeb/cubeb.h"
|
||||
#include "cubeb_tracing.h"
|
||||
#include <alsa/asoundlib.h>
|
||||
#include <assert.h>
|
||||
#include <dlfcn.h>
|
||||
|
@ -579,10 +580,14 @@ alsa_run_thread(void * context)
|
|||
cubeb * ctx = context;
|
||||
int r;
|
||||
|
||||
CUBEB_REGISTER_THREAD("cubeb rendering thread");
|
||||
|
||||
do {
|
||||
r = alsa_run(ctx);
|
||||
} while (r >= 0);
|
||||
|
||||
CUBEB_UNREGISTER_THREAD();
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
#include <time.h>
|
||||
#endif
|
||||
|
||||
cubeb_log_level g_cubeb_log_level;
|
||||
cubeb_log_callback g_cubeb_log_callback;
|
||||
std::atomic<cubeb_log_level> g_cubeb_log_level;
|
||||
std::atomic<cubeb_log_callback> g_cubeb_log_callback;
|
||||
|
||||
/** The maximum size of a log message, after having been formatted. */
|
||||
const size_t CUBEB_LOG_MESSAGE_MAX_SIZE = 256;
|
||||
|
@ -74,7 +74,7 @@ public:
|
|||
while (true) {
|
||||
cubeb_log_message msg;
|
||||
while (msg_queue.dequeue(&msg, 1)) {
|
||||
LOG_INTERNAL_NO_FORMAT(CUBEB_LOG_NORMAL, "%s", msg.get());
|
||||
cubeb_log_internal_no_format(msg.get());
|
||||
}
|
||||
#ifdef _WIN32
|
||||
Sleep(CUBEB_LOG_BATCH_PRINT_INTERVAL_MS);
|
||||
|
@ -108,12 +108,26 @@ private:
|
|||
lock_free_queue<cubeb_log_message> msg_queue;
|
||||
};
|
||||
|
||||
void
|
||||
cubeb_log_internal(char const * file, uint32_t line, char const * fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
char msg[CUBEB_LOG_MESSAGE_MAX_SIZE];
|
||||
vsnprintf(msg, CUBEB_LOG_MESSAGE_MAX_SIZE, fmt, args);
|
||||
g_cubeb_log_callback.load()("%s:%d:%s", file, line, msg);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void
|
||||
cubeb_log_internal_no_format(const char * msg)
|
||||
{
|
||||
g_cubeb_log_callback.load()(msg);
|
||||
}
|
||||
|
||||
void
|
||||
cubeb_async_log(char const * fmt, ...)
|
||||
{
|
||||
if (!g_cubeb_log_callback) {
|
||||
return;
|
||||
}
|
||||
// This is going to copy a 256 bytes array around, which is fine.
|
||||
// We don't want to allocate memory here, because this is made to
|
||||
// be called from a real-time callback.
|
||||
|
@ -133,3 +147,22 @@ cubeb_async_log_reset_threads(void)
|
|||
}
|
||||
cubeb_async_logger::get().reset_producer_thread();
|
||||
}
|
||||
|
||||
void
|
||||
cubeb_log_set(cubeb_log_level log_level, cubeb_log_callback log_callback)
|
||||
{
|
||||
g_cubeb_log_level = log_level;
|
||||
g_cubeb_log_callback = log_callback;
|
||||
}
|
||||
|
||||
cubeb_log_level
|
||||
cubeb_log_get_level()
|
||||
{
|
||||
return g_cubeb_log_level;
|
||||
}
|
||||
|
||||
cubeb_log_callback
|
||||
cubeb_log_get_callback()
|
||||
{
|
||||
return g_cubeb_log_callback;
|
||||
}
|
||||
|
|
|
@ -30,8 +30,16 @@ extern "C" {
|
|||
(strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
|
||||
#endif
|
||||
|
||||
extern cubeb_log_level g_cubeb_log_level;
|
||||
extern cubeb_log_callback g_cubeb_log_callback PRINTF_FORMAT(1, 2);
|
||||
void
|
||||
cubeb_log_set(cubeb_log_level log_level, cubeb_log_callback log_callback);
|
||||
cubeb_log_level
|
||||
cubeb_log_get_level();
|
||||
cubeb_log_callback
|
||||
cubeb_log_get_callback();
|
||||
void
|
||||
cubeb_log_internal_no_format(const char * msg);
|
||||
void
|
||||
cubeb_log_internal(const char * filename, uint32_t line, const char * fmt, ...);
|
||||
void
|
||||
cubeb_async_log(const char * fmt, ...);
|
||||
void
|
||||
|
@ -44,24 +52,16 @@ cubeb_async_log_reset_threads(void);
|
|||
#define LOGV(msg, ...) LOG_INTERNAL(CUBEB_LOG_VERBOSE, msg, ##__VA_ARGS__)
|
||||
#define LOG(msg, ...) LOG_INTERNAL(CUBEB_LOG_NORMAL, msg, ##__VA_ARGS__)
|
||||
|
||||
#define LOG_INTERNAL_NO_FORMAT(level, fmt, ...) \
|
||||
do { \
|
||||
if (g_cubeb_log_callback && level <= g_cubeb_log_level) { \
|
||||
g_cubeb_log_callback(fmt, __VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define LOG_INTERNAL(level, fmt, ...) \
|
||||
do { \
|
||||
if (g_cubeb_log_callback && level <= g_cubeb_log_level) { \
|
||||
g_cubeb_log_callback("%s:%d: " fmt "\n", __FILENAME__, __LINE__, \
|
||||
##__VA_ARGS__); \
|
||||
if (cubeb_log_get_level() <= level && cubeb_log_get_callback()) { \
|
||||
cubeb_log_internal(__FILENAME__, __LINE__, fmt, ##__VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define ALOG_INTERNAL(level, fmt, ...) \
|
||||
do { \
|
||||
if (level <= g_cubeb_log_level) { \
|
||||
if (cubeb_log_get_level() <= level && cubeb_log_get_callback()) { \
|
||||
cubeb_async_log(fmt, ##__VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "cubeb/cubeb.h"
|
||||
#include "cubeb_mixer.h"
|
||||
#include "cubeb_strings.h"
|
||||
#include "cubeb_tracing.h"
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
|
@ -975,6 +976,8 @@ oss_io_routine(void * arg)
|
|||
cubeb_state new_state;
|
||||
int stopped;
|
||||
|
||||
CUBEB_REGISTER_THREAD("cubeb rendering thread");
|
||||
|
||||
do {
|
||||
pthread_mutex_lock(&s->mtx);
|
||||
if (s->destroying) {
|
||||
|
@ -1005,6 +1008,9 @@ oss_io_routine(void * arg)
|
|||
pthread_mutex_lock(&s->mtx);
|
||||
s->thread_created = false;
|
||||
pthread_mutex_unlock(&s->mtx);
|
||||
|
||||
CUBEB_UNREGISTER_THREAD();
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
#include "cubeb-internal.h"
|
||||
#include "cubeb/cubeb.h"
|
||||
#include "cubeb_tracing.h"
|
||||
#include <assert.h>
|
||||
#include <dlfcn.h>
|
||||
#include <inttypes.h>
|
||||
|
@ -161,10 +162,14 @@ sndio_mainloop(void * arg)
|
|||
size_t pstart = 0, pend = 0, rstart = 0, rend = 0;
|
||||
long nfr;
|
||||
|
||||
CUBEB_REGISTER_THREAD("cubeb rendering thread");
|
||||
|
||||
nfds = WRAP(sio_nfds)(s->hdl);
|
||||
pfds = calloc(nfds, sizeof(struct pollfd));
|
||||
if (pfds == NULL)
|
||||
if (pfds == NULL) {
|
||||
CUBEB_UNREGISTER_THREAD();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DPR("sndio_mainloop()\n");
|
||||
s->state_cb(s, s->arg, CUBEB_STATE_STARTED);
|
||||
|
@ -172,6 +177,7 @@ sndio_mainloop(void * arg)
|
|||
if (!WRAP(sio_start)(s->hdl)) {
|
||||
pthread_mutex_unlock(&s->mtx);
|
||||
free(pfds);
|
||||
CUBEB_UNREGISTER_THREAD();
|
||||
return NULL;
|
||||
}
|
||||
DPR("sndio_mainloop(), started\n");
|
||||
|
@ -300,6 +306,7 @@ sndio_mainloop(void * arg)
|
|||
pthread_mutex_unlock(&s->mtx);
|
||||
s->state_cb(s, s->arg, state);
|
||||
free(pfds);
|
||||
CUBEB_UNREGISTER_THREAD();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
#include "cubeb-internal.h"
|
||||
#include "cubeb/cubeb.h"
|
||||
#include "cubeb_tracing.h"
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
#include <pthread.h>
|
||||
|
@ -428,6 +429,8 @@ sun_io_routine(void * arg)
|
|||
size_t read_ofs = 0;
|
||||
int drain = 0;
|
||||
|
||||
CUBEB_REGISTER_THREAD("cubeb rendering thread");
|
||||
|
||||
s->state_cb(s, s->user_ptr, CUBEB_STATE_STARTED);
|
||||
while (state != CUBEB_STATE_ERROR) {
|
||||
pthread_mutex_lock(&s->mutex);
|
||||
|
@ -505,6 +508,7 @@ sun_io_routine(void * arg)
|
|||
}
|
||||
}
|
||||
s->state_cb(s, s->user_ptr, state);
|
||||
CUBEB_UNREGISTER_THREAD();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "cubeb_mixer.h"
|
||||
#include "cubeb_resampler.h"
|
||||
#include "cubeb_strings.h"
|
||||
#include "cubeb_tracing.h"
|
||||
#include "cubeb_utils.h"
|
||||
|
||||
// Windows 10 exposes the IAudioClient3 interface to create low-latency streams.
|
||||
|
@ -223,6 +224,11 @@ private:
|
|||
com_heap_ptr<wchar_t> capture_comms_id;
|
||||
};
|
||||
|
||||
struct AutoRegisterThread {
|
||||
AutoRegisterThread(const char * name) { CUBEB_REGISTER_THREAD(name); }
|
||||
~AutoRegisterThread() { CUBEB_UNREGISTER_THREAD(); }
|
||||
};
|
||||
|
||||
int
|
||||
wasapi_stream_stop(cubeb_stream * stm);
|
||||
int
|
||||
|
@ -463,6 +469,7 @@ public:
|
|||
private:
|
||||
static unsigned int __stdcall thread_proc(LPVOID args)
|
||||
{
|
||||
AutoRegisterThread raii("WASAPI device notification thread");
|
||||
XASSERT(args);
|
||||
auto mdn = static_cast<monitor_device_notifications *>(args);
|
||||
mdn->notification_thread_loop();
|
||||
|
@ -1337,6 +1344,8 @@ handle_emergency_bailout(cubeb_stream * stm)
|
|||
|
||||
static unsigned int __stdcall wasapi_stream_render_loop(LPVOID stream)
|
||||
{
|
||||
AutoRegisterThread raii("cubeb rendering thread");
|
||||
|
||||
cubeb_stream * stm = static_cast<cubeb_stream *>(stream);
|
||||
|
||||
bool is_playing = true;
|
||||
|
|
Загрузка…
Ссылка в новой задаче