Skip to content
Snippets Groups Projects
Commit ac0a6fd9 authored by Wes Kocher's avatar Wes Kocher
Browse files

Backed out 2 changesets (bug 1286041) for asan failures in cubeb_pulse.c

Backed out changeset 72e5792fe990 (bug 1286041)
Backed out changeset 14d4b1e011ad (bug 1286041)

--HG--
extra : rebase_source : 1db28655abbb337e537a67d09e2af243ae94f081
parent a5dd4da9
No related branches found
No related tags found
No related merge requests found
......@@ -400,9 +400,6 @@ AudioStream::Start()
{
MonitorAutoLock mon(mMonitor);
MOZ_ASSERT(mState == INITIALIZED);
// Callback might start before the return of the invoke
// change state to avoid any assert break.
mState = STARTED;
auto r = InvokeCubeb(cubeb_stream_start);
mState = r == CUBEB_OK ? STARTED : ERRORED;
LOG("started, state %s", mState == STARTED ? "STARTED" : "ERRORED");
......@@ -596,7 +593,13 @@ AudioStream::DataCallback(void* aBuffer, long aFrames)
auto writer = AudioBufferWriter(
reinterpret_cast<AudioDataValue*>(aBuffer), mOutChannels, aFrames);
MOZ_ASSERT(mState != INITIALIZED);
// FIXME: cubeb_pulse sometimes calls us before cubeb_stream_start() is called.
// We don't want to consume audio data until Start() is called by the client.
if (mState == INITIALIZED) {
NS_WARNING("data callback fires before cubeb_stream_start() is called");
mAudioClock.UpdateFrameHistory(0, aFrames);
return writer.WriteZeros(aFrames);
}
// NOTE: wasapi (others?) can call us back *after* stop()/Shutdown() (mState == SHUTDOWN)
// Bug 996162
......
......@@ -5,4 +5,4 @@ Makefile.in build files for the Mozilla build system.
The cubeb git repository is: git://github.com/kinetiknz/cubeb.git
The git commit ID used was 50b92089d92ca9e5d1bc222849d199cc0686867b.
The git commit ID used was e4074131e4d422bfe260d29ab0a49fc368406ef4.
......@@ -11,29 +11,6 @@
#include <stdio.h>
#include <string.h>
#ifdef __clang__
#ifndef CLANG_ANALYZER_NORETURN
#if __has_feature(attribute_analyzer_noreturn)
#define CLANG_ANALYZER_NORETURN __attribute__((analyzer_noreturn))
#else
#define CLANG_ANALYZER_NORETURN
#endif // ifndef CLANG_ANALYZER_NORETURN
#endif // __has_feature(attribute_analyzer_noreturn)
#else // __clang__
#define CLANG_ANALYZER_NORETURN
#endif
#if defined(__cplusplus)
extern "C" {
#endif
/* Crash the caller. */
void cubeb_crash() CLANG_ANALYZER_NORETURN;
#if defined(__cplusplus)
}
#endif
struct cubeb_ops {
int (* init)(cubeb ** context, char const * context_name);
char const * (* get_backend_id)(cubeb * context);
......@@ -75,11 +52,12 @@ struct cubeb_ops {
void * user_ptr);
};
#define XASSERT(expr) do { \
if (!(expr)) { \
#define XASSERT(expr) do { \
if (!(expr)) { \
fprintf(stderr, "%s:%d - fatal error: %s\n", __FILE__, __LINE__, #expr); \
cubeb_crash(); \
} \
*((volatile int *) NULL) = 0; \
abort(); \
} \
} while (0)
#endif /* CUBEB_INTERNAL_0eb56756_4e20_4404_a76d_42bf88cd15a5 */
......@@ -454,10 +454,3 @@ int cubeb_register_device_collection_changed(cubeb * context,
return context->ops->register_device_collection_changed(context, devtype, callback, user_ptr);
}
void cubeb_crash()
{
abort();
*((volatile int *) NULL) = 0;
}
......@@ -73,14 +73,12 @@
X(pa_stream_set_read_callback) \
X(pa_stream_connect_record) \
X(pa_stream_readable_size) \
X(pa_stream_writable_size) \
X(pa_stream_peek) \
X(pa_stream_drop) \
X(pa_stream_get_buffer_attr) \
X(pa_stream_get_device_name) \
X(pa_context_set_subscribe_callback) \
X(pa_context_subscribe) \
X(pa_mainloop_api_once) \
#define MAKE_TYPEDEF(x) static typeof(x) * cubeb_##x;
LIBPULSE_API_VISIT(MAKE_TYPEDEF);
......@@ -122,7 +120,6 @@ struct cubeb_stream {
pa_sample_spec input_sample_spec;
int shutdown;
float volume;
cubeb_state state;
};
const float PULSE_NO_GAIN = -1.0;
......@@ -175,13 +172,6 @@ stream_success_callback(pa_stream * s, int success, void * u)
WRAP(pa_threaded_mainloop_signal)(stm->context->mainloop, 0);
}
static void
stream_state_change_callback(cubeb_stream * stm, cubeb_state s)
{
stm->state = s;
stm->state_callback(stm, stm->user_ptr, s);
}
static void
stream_drain_callback(pa_mainloop_api * a, pa_time_event * e, struct timeval const * tv, void * u)
{
......@@ -189,7 +179,7 @@ stream_drain_callback(pa_mainloop_api * a, pa_time_event * e, struct timeval con
/* there's no pa_rttime_free, so use this instead. */
a->time_free(stm->drain_timer);
stm->drain_timer = NULL;
stream_state_change_callback(stm, CUBEB_STATE_DRAINED);
stm->state_callback(stm, stm->user_ptr, CUBEB_STATE_DRAINED);
}
static void
......@@ -197,7 +187,7 @@ stream_state_callback(pa_stream * s, void * u)
{
cubeb_stream * stm = u;
if (!PA_STREAM_IS_GOOD(WRAP(pa_stream_get_state)(s))) {
stream_state_change_callback(stm, CUBEB_STATE_ERROR);
stm->state_callback(stm, stm->user_ptr, CUBEB_STATE_ERROR);
}
WRAP(pa_threaded_mainloop_signal)(stm->context->mainloop, 0);
}
......@@ -296,8 +286,7 @@ stream_write_callback(pa_stream * s, size_t nbytes, void * u)
{
LOG("Output callback to be written buffer size %zd\n", nbytes);
cubeb_stream * stm = u;
if (stm->shutdown ||
stm->state != CUBEB_STATE_STARTED) {
if (stm->shutdown) {
return;
}
......@@ -435,8 +424,8 @@ stream_cork(cubeb_stream * stm, enum cork_state state)
WRAP(pa_threaded_mainloop_unlock)(stm->context->mainloop);
if (state & NOTIFY) {
stream_state_change_callback(stm, state & CORK ? CUBEB_STATE_STOPPED
: CUBEB_STATE_STARTED);
stm->state_callback(stm, stm->user_ptr,
state & CORK ? CUBEB_STATE_STOPPED : CUBEB_STATE_STARTED);
}
}
......@@ -730,7 +719,6 @@ pulse_stream_init(cubeb * context,
stm->state_callback = state_callback;
stm->user_ptr = user_ptr;
stm->volume = PULSE_NO_GAIN;
stm->state = -1;
WRAP(pa_threaded_mainloop_lock)(stm->context->mainloop);
if (output_stream_params) {
......@@ -842,29 +830,10 @@ pulse_stream_destroy(cubeb_stream * stm)
free(stm);
}
void
pulse_defer_event_cb(pa_mainloop_api * a, void * userdata)
{
cubeb_stream * stm = userdata;
size_t writable_size = WRAP(pa_stream_writable_size)(stm->output_stream);
trigger_user_callback(stm->output_stream, NULL, writable_size, stm);
}
static int
pulse_stream_start(cubeb_stream * stm)
{
stream_cork(stm, UNCORK | NOTIFY);
if (stm->output_stream && !stm->input_stream) {
/* On output only case need to manually call user cb once in order to make
* things roll. This is done via a defer event in order to execute it
* from PA server thread. */
WRAP(pa_threaded_mainloop_lock)(stm->context->mainloop);
WRAP(pa_mainloop_api_once)(WRAP(pa_threaded_mainloop_get_api)(stm->context->mainloop),
pulse_defer_event_cb, stm);
WRAP(pa_threaded_mainloop_unlock)(stm->context->mainloop);
}
return CUBEB_OK;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment