Bug 818364 - Update libcubeb to 0.2. r=doublec

This commit is contained in:
Matthew Gregan 2012-12-05 17:20:47 +13:00
Родитель 5f0b9ead28
Коммит 023547f5e6
3 изменённых файлов: 40 добавлений и 9 удалений

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

@ -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 98769a7861b067125a76c97ddb51c5db8f528b75.
The git commit ID used was 0f53b9b70c4e6af9da4a7eb0d38a7757c5a10edd..

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

@ -8,7 +8,6 @@
#include <assert.h>
#include <pthread.h>
#include <stdlib.h>
#include <CoreServices/CoreServices.h>
#include <AudioUnit/AudioUnit.h>
#include "cubeb/cubeb.h"
@ -64,7 +63,7 @@ audio_unit_output_callback(void * user_ptr, AudioUnitRenderActionFlags * flags,
return noErr;
}
if (got < nframes) {
if ((UInt32) got < nframes) {
size_t got_bytes = got * stm->sample_spec.mBytesPerFrame;
size_t rem_bytes = (nframes - got) * stm->sample_spec.mBytesPerFrame;
@ -106,9 +105,14 @@ cubeb_stream_init(cubeb * context, cubeb_stream ** stream, char const * stream_n
void * user_ptr)
{
AudioStreamBasicDescription ss;
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
ComponentDescription desc;
cubeb_stream * stm;
Component comp;
#else
AudioComponentDescription desc;
AudioComponent comp;
#endif
cubeb_stream * stm;
AURenderCallbackStruct input;
unsigned int buffer_size;
OSStatus r;
@ -162,7 +166,11 @@ cubeb_stream_init(cubeb * context, cubeb_stream ** stream, char const * stream_n
desc.componentManufacturer = kAudioUnitManufacturer_Apple;
desc.componentFlags = 0;
desc.componentFlagsMask = 0;
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
comp = FindNextComponent(NULL, &desc);
#else
comp = AudioComponentFindNext(NULL, &desc);
#endif
assert(comp);
stm = calloc(1, sizeof(*stm));
@ -180,7 +188,11 @@ cubeb_stream_init(cubeb * context, cubeb_stream ** stream, char const * stream_n
stm->frames_played = 0;
stm->frames_queued = 0;
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
r = OpenAComponent(comp, &stm->unit);
#else
r = AudioComponentInstanceNew(comp, &stm->unit);
#endif
if (r != 0) {
cubeb_stream_destroy(stm);
return CUBEB_ERROR;
@ -229,7 +241,11 @@ cubeb_stream_destroy(cubeb_stream * stm)
if (stm->unit) {
AudioOutputUnitStop(stm->unit);
AudioUnitUninitialize(stm->unit);
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
CloseComponent(stm->unit);
#else
AudioComponentInstanceDispose(stm->unit);
#endif
}
r = pthread_mutex_destroy(&stm->mutex);

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

@ -5,6 +5,10 @@
* accompanying file LICENSE for details.
*/
#undef NDEBUG
#define __MSVCRT_VERSION__ 0x0700
#define WINVER 0x0501
#define WIN32_LEAN_AND_MEAN
#include <malloc.h>
#include <assert.h>
#include <windows.h>
#include <mmreg.h>
@ -13,6 +17,11 @@
#include <stdlib.h>
#include "cubeb/cubeb.h"
/* This is missing from the MinGW headers. Use a safe fallback. */
#ifndef MEMORY_ALLOCATION_ALIGNMENT
#define MEMORY_ALLOCATION_ALIGNMENT 16
#endif
#define CUBEB_STREAM_MAX 32
#define NBUFS 4
@ -33,7 +42,7 @@ struct cubeb {
PSLIST_HEADER work;
CRITICAL_SECTION lock;
unsigned int active_streams;
int minimum_latency;
unsigned int minimum_latency;
};
struct cubeb_stream {
@ -160,9 +169,15 @@ cubeb_buffer_thread(void * user_ptr)
rv = WaitForSingleObject(ctx->event, INFINITE);
assert(rv == WAIT_OBJECT_0);
while ((item = InterlockedPopEntrySList(ctx->work)) != NULL) {
cubeb_refill_stream(((struct cubeb_stream_item *) item)->stream);
_aligned_free(item);
/* Process work items in batches so that a single stream can't
starve the others by continuously adding new work to the top of
the work item stack. */
item = InterlockedFlushSList(ctx->work);
while (item != NULL) {
PSLIST_ENTRY tmp = item;
cubeb_refill_stream(((struct cubeb_stream_item *) tmp)->stream);
item = item->Next;
_aligned_free(tmp);
}
if (ctx->shutdown) {
@ -191,7 +206,7 @@ cubeb_buffer_callback(HWAVEOUT waveout, UINT msg, DWORD_PTR user_ptr, DWORD_PTR
SetEvent(stm->context->event);
}
static int
static unsigned int
calculate_minimum_latency(void)
{
OSVERSIONINFOEX osvi;