Bug 1438888 - Update cubeb from upstream to 1d53c3a. r=padenot

This commit is contained in:
Alex Chronopoulos 2018-02-16 18:37:50 +02:00
Родитель 6240b9f6a2
Коммит a9a0f3509a
12 изменённых файлов: 81 добавлений и 14 удалений

Просмотреть файл

@ -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 cc0d538c40b933a5d7d5c5bf5e05de7d51740486 (2018-02-02 18:06:40 +0100)
The git commit ID used was 1d53c3a3779cbeb860b16aa38cc7f51e196b9745 (2018-02-13 12:30:46 +1000)

Просмотреть файл

@ -599,6 +599,11 @@ CUBEB_EXPORT int cubeb_stream_device_destroy(cubeb_stream * stream,
CUBEB_EXPORT int cubeb_stream_register_device_changed_callback(cubeb_stream * stream,
cubeb_device_changed_callback device_changed_callback);
/** Return the user data pointer registered with the stream with cubeb_stream_init.
@param stream the stream for which to retrieve user data pointer.
@retval user data pointer */
CUBEB_EXPORT void * cubeb_stream_user_ptr(cubeb_stream * stream);
/** Returns enumerated devices.
@param context
@param devtype device type to include

Просмотреть файл

@ -19,7 +19,12 @@ struct cubeb {
};
struct cubeb_stream {
/*
* Note: All implementations of cubeb_stream must keep the following
* layout.
*/
struct cubeb * context;
void * user_ptr;
};
#if defined(USE_PULSE)
@ -478,6 +483,15 @@ int cubeb_stream_register_device_changed_callback(cubeb_stream * stream,
return stream->context->ops->stream_register_device_changed_callback(stream, device_changed_callback);
}
void * cubeb_stream_user_ptr(cubeb_stream * stream)
{
if (!stream) {
return NULL;
}
return stream->user_ptr;
}
static
void log_device(cubeb_device_info * device_info)
{

Просмотреть файл

@ -76,12 +76,14 @@ enum stream_state {
};
struct cubeb_stream {
/* Note: Must match cubeb_stream layout in cubeb.c. */
cubeb * context;
void * user_ptr;
/**/
pthread_mutex_t mutex;
snd_pcm_t * pcm;
cubeb_data_callback data_callback;
cubeb_state_callback state_callback;
void * user_ptr;
snd_pcm_uframes_t stream_position;
snd_pcm_uframes_t last_position;
snd_pcm_uframes_t buffer_size;

Просмотреть файл

@ -75,12 +75,14 @@ struct cubeb {
};
struct cubeb_stream {
/* Note: Must match cubeb_stream layout in cubeb.c. */
cubeb * context;
void * user_ptr;
/**/
cubeb_stream_params params;
cubeb_data_callback data_callback;
cubeb_state_callback state_callback;
void * instance;
void * user_ptr;
/* Number of frames that have been passed to the AudioTrack callback */
long unsigned written;
int draining;

Просмотреть файл

@ -132,7 +132,11 @@ struct device_info {
struct cubeb_stream {
explicit cubeb_stream(cubeb * context);
/* Note: Must match cubeb_stream layout in cubeb.c. */
cubeb * context;
void * user_ptr = nullptr;
/**/
cubeb_data_callback data_callback = nullptr;
cubeb_state_callback state_callback = nullptr;
cubeb_device_changed_callback device_changed_callback = nullptr;
@ -142,8 +146,6 @@ struct cubeb_stream {
cubeb_stream_params output_stream_params = { CUBEB_SAMPLE_FLOAT32NE, 0, 0, CUBEB_LAYOUT_UNDEFINED, CUBEB_STREAM_PREF_NONE };
device_info input_device;
device_info output_device;
/* User pointer of data_callback */
void * user_ptr = nullptr;
/* Format descriptions */
AudioStreamBasicDescription input_desc;
AudioStreamBasicDescription output_desc;

Просмотреть файл

@ -139,7 +139,10 @@ static struct cubeb_ops const cbjack_ops = {
};
struct cubeb_stream {
/* Note: Must match cubeb_stream layout in cubeb.c. */
cubeb * context;
void * user_ptr;
/**/
/**< Mutex for each stream */
pthread_mutex_t mutex;
@ -149,7 +152,6 @@ struct cubeb_stream {
cubeb_data_callback data_callback;
cubeb_state_callback state_callback;
void * user_ptr;
cubeb_stream_params in_params;
cubeb_stream_params out_params;

Просмотреть файл

@ -87,7 +87,10 @@ struct cubeb {
#define AUDIO_STREAM_TYPE_MUSIC 3
struct cubeb_stream {
/* Note: Must match cubeb_stream layout in cubeb.c. */
cubeb * context;
void * user_ptr;
/**/
pthread_mutex_t mutex;
SLObjectItf playerObj;
SLPlayItf play;
@ -148,8 +151,6 @@ struct cubeb_stream {
cubeb_data_callback data_callback;
/* Store state callback. */
cubeb_state_callback state_callback;
/* User pointer for data & state callbacks*/
void * user_ptr;
cubeb_resampler * resampler;
unsigned int inputrate;

Просмотреть файл

@ -117,12 +117,14 @@ struct cubeb {
};
struct cubeb_stream {
/* Note: Must match cubeb_stream layout in cubeb.c. */
cubeb * context;
void * user_ptr;
/**/
pa_stream * output_stream;
pa_stream * input_stream;
cubeb_data_callback data_callback;
cubeb_state_callback state_callback;
void * user_ptr;
pa_time_event * drain_timer;
pa_sample_spec output_sample_spec;
pa_sample_spec input_sample_spec;

Просмотреть файл

@ -29,7 +29,10 @@ struct cubeb {
};
struct cubeb_stream {
/* Note: Must match cubeb_stream layout in cubeb.c. */
cubeb * context;
void * arg; /* user arg to {data,state}_cb */
/**/
pthread_t th; /* to run real-time audio i/o */
pthread_mutex_t mtx; /* protects hdl and pos */
struct sio_hdl *hdl; /* link us to sndio */
@ -48,7 +51,6 @@ struct cubeb_stream {
uint64_t swpos; /* number of frames produced/consumed */
cubeb_data_callback data_cb; /* cb to preapare data */
cubeb_state_callback state_cb; /* cb to notify about state changes */
void *arg; /* user arg to {data,state}_cb */
};
static void

Просмотреть файл

@ -189,7 +189,11 @@ class wasapi_endpoint_notification_client;
typedef bool (*wasapi_refill_callback)(cubeb_stream * stm);
struct cubeb_stream {
/* Note: Must match cubeb_stream layout in cubeb.c. */
cubeb * context = nullptr;
void * user_ptr = nullptr;
/**/
/* Mixer pameters. We need to convert the input stream to this
samplerate/channel layout, as WASAPI does not resample nor upmix
itself. */
@ -211,7 +215,6 @@ struct cubeb_stream {
case a dummy output device is opened to drive the loopback, but should not
be exposed. */
bool has_dummy_output = false;
void * user_ptr = nullptr;
/* Lifetime considerations:
- client, render_client, audio_clock and audio_stream_volume are interface
pointer to the IAudioClient.
@ -615,6 +618,8 @@ refill(cubeb_stream * stm, void * input_buffer, long input_frames_count,
return out_frames;
}
int wasapi_stream_reset_default_device(cubeb_stream * stm);
/* This helper grabs all the frames available from a capture client, put them in
* linear_input_buffer. linear_input_buffer should be cleared before the
* callback exits. This helper does not work with exclusive mode streams. */
@ -637,6 +642,13 @@ bool get_input_buffer(cubeb_stream * stm)
for (hr = stm->capture_client->GetNextPacketSize(&next);
next > 0;
hr = stm->capture_client->GetNextPacketSize(&next)) {
if (hr == AUDCLNT_E_DEVICE_INVALIDATED) {
// Application can recover from this error. More info
// https://msdn.microsoft.com/en-us/library/windows/desktop/dd316605(v=vs.85).aspx
LOG("Device invalidated error, reset default device");
wasapi_stream_reset_default_device(stm);
return true;
}
if (FAILED(hr)) {
LOG("cannot get next packet size: %lx", hr);
@ -713,10 +725,19 @@ bool get_output_buffer(cubeb_stream * stm, void *& buffer, size_t & frame_count)
XASSERT(has_output(stm));
hr = stm->output_client->GetCurrentPadding(&padding_out);
if (hr == AUDCLNT_E_DEVICE_INVALIDATED) {
// Application can recover from this error. More info
// https://msdn.microsoft.com/en-us/library/windows/desktop/dd316605(v=vs.85).aspx
LOG("Device invalidated error, reset default device");
wasapi_stream_reset_default_device(stm);
return true;
}
if (FAILED(hr)) {
LOG("Failed to get padding: %lx", hr);
return false;
}
XASSERT(padding_out <= stm->output_buffer_frame_count);
if (stm->draining) {
@ -996,11 +1017,21 @@ wasapi_stream_render_loop(LPVOID stream)
}
XASSERT(stm->output_client || stm->input_client);
if (stm->output_client) {
stm->output_client->Start();
hr = stm->output_client->Start();
if (FAILED(hr)) {
LOG("Error starting output after reconfigure, error: %lx", hr);
is_playing = false;
continue;
}
LOG("Output started after reconfigure.");
}
if (stm->input_client) {
stm->input_client->Start();
hr = stm->input_client->Start();
if (FAILED(hr)) {
LOG("Error starting input after reconfiguring, error: %lx", hr);
is_playing = false;
continue;
}
LOG("Input started after reconfigure.");
}
break;
@ -1957,6 +1988,7 @@ wasapi_stream_init(cubeb * context, cubeb_stream ** stream,
*stream = stm.release();
LOG("Stream init succesfull (%p)", *stream);
return CUBEB_OK;
}
@ -1986,6 +2018,7 @@ void close_wasapi_stream(cubeb_stream * stm)
void wasapi_stream_destroy(cubeb_stream * stm)
{
XASSERT(stm);
LOG("Stream destroy (%p)", stm);
// Only free stm->emergency_bailout if we could join the thread.
// If we could not join the thread, stm->emergency_bailout is true

Просмотреть файл

@ -93,11 +93,13 @@ struct cubeb {
};
struct cubeb_stream {
/* Note: Must match cubeb_stream layout in cubeb.c. */
cubeb * context;
void * user_ptr;
/**/
cubeb_stream_params params;
cubeb_data_callback data_callback;
cubeb_state_callback state_callback;
void * user_ptr;
WAVEHDR buffers[NBUFS];
size_t buffer_size;
int next_buffer;