Move some function definitions down

This commit is contained in:
Chris Robinson 2012-03-01 04:12:47 -08:00
parent 85daab0d5e
commit 9602c46809

View File

@ -212,64 +212,6 @@ static ALuint numCaptureDevNames;
static pa_context_flags_t pulse_ctx_flags;
static void context_state_callback(pa_context *context, void *pdata)
{
pa_threaded_mainloop *loop = pdata;
pa_context_state_t state;
state = pa_context_get_state(context);
if(state == PA_CONTEXT_READY || !PA_CONTEXT_IS_GOOD(state))
pa_threaded_mainloop_signal(loop, 0);
}
static pa_context *connect_context(pa_threaded_mainloop *loop, ALboolean silent)
{
const char *name = "OpenAL Soft";
char path_name[PATH_MAX];
pa_context_state_t state;
pa_context *context;
int err;
if(pa_get_binary_name(path_name, sizeof(path_name)))
name = pa_path_get_filename(path_name);
context = pa_context_new(pa_threaded_mainloop_get_api(loop), name);
if(!context)
{
ERR("pa_context_new() failed\n");
return NULL;
}
pa_context_set_state_callback(context, context_state_callback, loop);
if((err=pa_context_connect(context, NULL, pulse_ctx_flags, NULL)) >= 0)
{
while((state=pa_context_get_state(context)) != PA_CONTEXT_READY)
{
if(!PA_CONTEXT_IS_GOOD(state))
{
err = pa_context_errno(context);
if(err > 0) err = -err;
break;
}
pa_threaded_mainloop_wait(loop);
}
}
pa_context_set_state_callback(context, NULL, NULL);
if(err < 0)
{
if(!silent)
ERR("Context did not connect: %s\n", pa_strerror(err));
pa_context_unref(context);
return NULL;
}
return context;
}
static ALCboolean pulse_load(void) //{{{
{
ALCboolean ret = ALC_TRUE;
@ -376,6 +318,16 @@ static ALCboolean pulse_load(void) //{{{
} //}}}
// PulseAudio Event Callbacks //{{{
static void context_state_callback(pa_context *context, void *pdata)
{
pa_threaded_mainloop *loop = pdata;
pa_context_state_t state;
state = pa_context_get_state(context);
if(state == PA_CONTEXT_READY || !PA_CONTEXT_IS_GOOD(state))
pa_threaded_mainloop_signal(loop, 0);
}
static void stream_state_callback(pa_stream *stream, void *pdata) //{{{
{
pa_threaded_mainloop *loop = pdata;
@ -562,6 +514,53 @@ static void source_device_callback(pa_context *context, const pa_source_info *in
//}}}
static pa_context *connect_context(pa_threaded_mainloop *loop, ALboolean silent)
{
const char *name = "OpenAL Soft";
char path_name[PATH_MAX];
pa_context_state_t state;
pa_context *context;
int err;
if(pa_get_binary_name(path_name, sizeof(path_name)))
name = pa_path_get_filename(path_name);
context = pa_context_new(pa_threaded_mainloop_get_api(loop), name);
if(!context)
{
ERR("pa_context_new() failed\n");
return NULL;
}
pa_context_set_state_callback(context, context_state_callback, loop);
if((err=pa_context_connect(context, NULL, pulse_ctx_flags, NULL)) >= 0)
{
while((state=pa_context_get_state(context)) != PA_CONTEXT_READY)
{
if(!PA_CONTEXT_IS_GOOD(state))
{
err = pa_context_errno(context);
if(err > 0) err = -err;
break;
}
pa_threaded_mainloop_wait(loop);
}
}
pa_context_set_state_callback(context, NULL, NULL);
if(err < 0)
{
if(!silent)
ERR("Context did not connect: %s\n", pa_strerror(err));
pa_context_unref(context);
return NULL;
}
return context;
}
static pa_stream *connect_playback_stream(const char *device_name,
pa_threaded_mainloop *loop, pa_context *context,
pa_stream_flags_t flags, pa_buffer_attr *attr, pa_sample_spec *spec,