зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 2 changesets (bug 1828894) for cubeb related bp-hybrid bustages. CLOSED TREE
Backed out changeset 3200eba0be97 (bug 1828894) Backed out changeset 6426d03a45ce (bug 1828894)
This commit is contained in:
Родитель
4ea1fca123
Коммит
2c574db450
|
@ -1,3 +1,13 @@
|
|||
# HG changeset patch
|
||||
# User Paul Adenot <paul@paul.cx>
|
||||
# Date 1675704257 -3600
|
||||
# Mon Feb 06 18:24:17 2023 +0100
|
||||
# Node ID af331fb1ade15fff3f042f7881c12fdca6d86349
|
||||
# Parent 56d3f31673a0d096e34564b0734d202a89d2ba47
|
||||
Bug 1812120 - Disable the AAudio backend when running on Android <= 30. r?kinetik
|
||||
|
||||
Differential Revision: https://phabricator.services.mozilla.com/D168979
|
||||
|
||||
diff --git a/src/cubeb_aaudio.cpp b/src/cubeb_aaudio.cpp
|
||||
--- a/src/cubeb_aaudio.cpp
|
||||
+++ b/src/cubeb_aaudio.cpp
|
||||
|
@ -15,11 +25,11 @@ diff --git a/src/cubeb_aaudio.cpp b/src/cubeb_aaudio.cpp
|
|||
#include <cassert>
|
||||
#include <chrono>
|
||||
#include <condition_variable>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <dlfcn.h>
|
||||
#include <inttypes.h>
|
||||
@@ -1600,16 +1601,19 @@ const static struct cubeb_ops aaudio_ops
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
@@ -1544,16 +1545,19 @@ const static struct cubeb_ops aaudio_ops
|
||||
/*.stream_get_current_device =*/NULL,
|
||||
/*.stream_device_destroy =*/NULL,
|
||||
/*.stream_register_device_changed_callback =*/NULL,
|
||||
|
|
|
@ -9,8 +9,8 @@ origin:
|
|||
description: "Cross platform audio library"
|
||||
url: https://github.com/mozilla/cubeb
|
||||
license: ISC
|
||||
release: 479f8c5dec2c31ced12dbc4c64ff86ffb4ed50b7 (2023-04-19T11:37:43Z).
|
||||
revision: 479f8c5dec2c31ced12dbc4c64ff86ffb4ed50b7
|
||||
release: 2071354a69aca7ed6df3b4222e305746c2113f60 (2023-03-21T20:02:06Z).
|
||||
revision: 2071354a69aca7ed6df3b4222e305746c2113f60
|
||||
|
||||
vendoring:
|
||||
url: https://github.com/mozilla/cubeb
|
||||
|
|
|
@ -16,10 +16,8 @@
|
|||
#include <cassert>
|
||||
#include <chrono>
|
||||
#include <condition_variable>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <dlfcn.h>
|
||||
#include <inttypes.h>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
|
@ -103,7 +101,6 @@ LIBAAUDIO_API_VISIT(MAKE_TYPEDEF)
|
|||
#endif
|
||||
|
||||
const uint8_t MAX_STREAMS = 16;
|
||||
const int64_t NS_PER_S = static_cast<int64_t>(1e9);
|
||||
|
||||
using unique_lock = std::unique_lock<std::mutex>;
|
||||
using lock_guard = std::lock_guard<std::mutex>;
|
||||
|
@ -138,7 +135,6 @@ struct cubeb_stream {
|
|||
std::atomic<bool> in_use{false};
|
||||
std::atomic<bool> latency_metrics_available{false};
|
||||
std::atomic<stream_state> state{stream_state::INIT};
|
||||
std::atomic<bool> in_data_callback{false};
|
||||
triple_buffer<AAudioTimingInfo> timing_info;
|
||||
|
||||
AAudioStream * ostream{};
|
||||
|
@ -184,47 +180,9 @@ struct cubeb {
|
|||
struct cubeb_stream streams[MAX_STREAMS];
|
||||
};
|
||||
|
||||
struct AutoInCallback {
|
||||
AutoInCallback(cubeb_stream * stm) : stm(stm)
|
||||
{
|
||||
stm->in_data_callback.store(true);
|
||||
}
|
||||
~AutoInCallback() { stm->in_data_callback.store(false); }
|
||||
cubeb_stream * stm;
|
||||
};
|
||||
|
||||
// Returns when aaudio_stream's state is equal to desired_state.
|
||||
// poll_frequency_ns is the duration that is slept in between asking for
|
||||
// state updates and getting the new state.
|
||||
// When waiting for a stream to stop, it is best to pick a value similar
|
||||
// to the callback time because STOPPED will happen after
|
||||
// draining.
|
||||
static int
|
||||
wait_for_state_change(AAudioStream * aaudio_stream,
|
||||
aaudio_stream_state_t desired_state,
|
||||
int64_t poll_frequency_ns)
|
||||
{
|
||||
aaudio_stream_state_t new_state;
|
||||
do {
|
||||
aaudio_result_t res = WRAP(AAudioStream_waitForStateChange)(
|
||||
aaudio_stream, AAUDIO_STREAM_STATE_UNKNOWN, &new_state,
|
||||
poll_frequency_ns);
|
||||
if (res != AAUDIO_OK) {
|
||||
LOG("AAudioStream_waitForStateChanged: %s",
|
||||
WRAP(AAudio_convertResultToText)(res));
|
||||
return CUBEB_ERROR;
|
||||
}
|
||||
} while (new_state != desired_state);
|
||||
|
||||
LOG("wait_for_state_change: current state now: %s",
|
||||
cubeb_AAudio_convertStreamStateToText(new_state));
|
||||
|
||||
return CUBEB_OK;
|
||||
}
|
||||
|
||||
// Only allowed from state thread, while mutex on stm is locked
|
||||
static void
|
||||
shutdown_with_error(cubeb_stream * stm)
|
||||
shutdown(cubeb_stream * stm)
|
||||
{
|
||||
if (stm->istream) {
|
||||
WRAP(AAudioStream_requestStop)(stm->istream);
|
||||
|
@ -233,17 +191,6 @@ shutdown_with_error(cubeb_stream * stm)
|
|||
WRAP(AAudioStream_requestStop)(stm->ostream);
|
||||
}
|
||||
|
||||
int64_t poll_frequency_ns = NS_PER_S * stm->out_frame_size / stm->sample_rate;
|
||||
if (stm->istream) {
|
||||
wait_for_state_change(stm->istream, AAUDIO_STREAM_STATE_STOPPED,
|
||||
poll_frequency_ns);
|
||||
}
|
||||
if (stm->ostream) {
|
||||
wait_for_state_change(stm->ostream, AAUDIO_STREAM_STATE_STOPPED,
|
||||
poll_frequency_ns);
|
||||
}
|
||||
|
||||
assert(!stm->in_data_callback.load());
|
||||
stm->state_callback(stm, stm->user_ptr, CUBEB_STATE_ERROR);
|
||||
stm->state.store(stream_state::SHUTDOWN);
|
||||
}
|
||||
|
@ -301,7 +248,7 @@ update_state(cubeb_stream * stm)
|
|||
}
|
||||
|
||||
if (old_state == stream_state::ERROR) {
|
||||
shutdown_with_error(stm);
|
||||
shutdown(stm);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -346,7 +293,7 @@ update_state(cubeb_stream * stm)
|
|||
istate == AAUDIO_STREAM_STATE_DISCONNECTED) {
|
||||
LOG("Unexpected android input stream state %s",
|
||||
WRAP(AAudio_convertStreamStateToText)(istate));
|
||||
shutdown_with_error(stm);
|
||||
shutdown(stm);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -358,7 +305,7 @@ update_state(cubeb_stream * stm)
|
|||
ostate == AAUDIO_STREAM_STATE_DISCONNECTED) {
|
||||
LOG("Unexpected android output stream state %s",
|
||||
WRAP(AAudio_convertStreamStateToText)(istate));
|
||||
shutdown_with_error(stm);
|
||||
shutdown(stm);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -665,7 +612,6 @@ aaudio_duplex_data_cb(AAudioStream * astream, void * user_data,
|
|||
void * audio_data, int32_t num_frames)
|
||||
{
|
||||
cubeb_stream * stm = (cubeb_stream *)user_data;
|
||||
AutoInCallback aic(stm);
|
||||
assert(stm->ostream == astream);
|
||||
assert(stm->istream);
|
||||
assert(num_frames >= 0);
|
||||
|
@ -747,7 +693,6 @@ aaudio_output_data_cb(AAudioStream * astream, void * user_data,
|
|||
void * audio_data, int32_t num_frames)
|
||||
{
|
||||
cubeb_stream * stm = (cubeb_stream *)user_data;
|
||||
AutoInCallback aic(stm);
|
||||
assert(stm->ostream == astream);
|
||||
assert(!stm->istream);
|
||||
assert(num_frames >= 0);
|
||||
|
@ -796,7 +741,6 @@ aaudio_input_data_cb(AAudioStream * astream, void * user_data,
|
|||
void * audio_data, int32_t num_frames)
|
||||
{
|
||||
cubeb_stream * stm = (cubeb_stream *)user_data;
|
||||
AutoInCallback aic(stm);
|
||||
assert(stm->istream == astream);
|
||||
assert(!stm->ostream);
|
||||
assert(num_frames >= 0);
|
||||
|
@ -1263,8 +1207,8 @@ aaudio_stream_start(cubeb_stream * stm)
|
|||
break;
|
||||
|
||||
// If the state switched [DRAINING -> STOPPING] or [DRAINING/STOPPING ->
|
||||
// STOPPED] in the meantime, we can simply overwrite that since we
|
||||
// restarted the stream.
|
||||
// STOPPED] in the meantime, we can simply overwrite that since we restarted
|
||||
// the stream.
|
||||
case stream_state::STOPPING:
|
||||
case stream_state::STOPPED:
|
||||
continue;
|
||||
|
@ -1442,7 +1386,7 @@ aaudio_stream_get_position(cubeb_stream * stm, uint64_t * position)
|
|||
stm->previous_clock = *position;
|
||||
}
|
||||
|
||||
LOG("aaudio_stream_get_position: %" PRIu64 " frames", *position);
|
||||
LOG("aaudio_stream_get_position: %ld", *position);
|
||||
|
||||
return CUBEB_OK;
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ ARRAY_LENGTH(T(&)[N])
|
|||
return N;
|
||||
}
|
||||
|
||||
void delay(unsigned int ms)
|
||||
inline void delay(unsigned int ms)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
Sleep(ms);
|
||||
|
@ -48,7 +48,7 @@ typedef struct {
|
|||
uint32_t const layout;
|
||||
} layout_info;
|
||||
|
||||
int has_available_input_device(cubeb * ctx)
|
||||
inline int has_available_input_device(cubeb * ctx)
|
||||
{
|
||||
cubeb_device_collection devices;
|
||||
int input_device_available = 0;
|
||||
|
@ -80,7 +80,7 @@ int has_available_input_device(cubeb * ctx)
|
|||
return !!input_device_available;
|
||||
}
|
||||
|
||||
void print_log(const char * msg, ...)
|
||||
inline void print_log(const char * msg, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, msg);
|
||||
|
@ -91,7 +91,7 @@ void print_log(const char * msg, ...)
|
|||
/** Initialize cubeb with backend override.
|
||||
* Create call cubeb_init passing value for CUBEB_BACKEND env var as
|
||||
* override. */
|
||||
int common_init(cubeb ** ctx, char const * ctx_name)
|
||||
inline int common_init(cubeb ** ctx, char const * ctx_name)
|
||||
{
|
||||
#ifdef ENABLE_NORMAL_LOG
|
||||
if (cubeb_set_log_callback(CUBEB_LOG_NORMAL, print_log) != CUBEB_OK) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче