Fix indentation to match everything else.
This commit is contained in:
@@ -15,10 +15,10 @@ REGISTER_SOUND_DRIVER_CLASS2( Pulse, PulseAudio );
|
|||||||
|
|
||||||
/* Constructor */
|
/* Constructor */
|
||||||
RageSoundDriver_PulseAudio::RageSoundDriver_PulseAudio()
|
RageSoundDriver_PulseAudio::RageSoundDriver_PulseAudio()
|
||||||
: RageSoundDriver(),
|
: RageSoundDriver(),
|
||||||
m_LastPosition(0), m_SampleRate(0), m_Error(NULL),
|
m_LastPosition(0), m_SampleRate(0), m_Error(NULL),
|
||||||
m_Sem("Pulseaudio Synchronization Semaphore"),
|
m_Sem("Pulseaudio Synchronization Semaphore"),
|
||||||
m_PulseMainLoop(NULL), m_PulseCtx(NULL), m_PulseStream(NULL)
|
m_PulseMainLoop(NULL), m_PulseCtx(NULL), m_PulseStream(NULL)
|
||||||
{
|
{
|
||||||
m_SampleRate = PREFSMAN->m_iSoundPreferredSampleRate;
|
m_SampleRate = PREFSMAN->m_iSoundPreferredSampleRate;
|
||||||
if( m_SampleRate == 0 )
|
if( m_SampleRate == 0 )
|
||||||
@@ -31,6 +31,7 @@ RageSoundDriver_PulseAudio::~RageSoundDriver_PulseAudio()
|
|||||||
pa_context_unref(m_PulseCtx);
|
pa_context_unref(m_PulseCtx);
|
||||||
pa_threaded_mainloop_stop(m_PulseMainLoop);
|
pa_threaded_mainloop_stop(m_PulseMainLoop);
|
||||||
pa_threaded_mainloop_free(m_PulseMainLoop);
|
pa_threaded_mainloop_free(m_PulseMainLoop);
|
||||||
|
|
||||||
if(m_Error != NULL)
|
if(m_Error != NULL)
|
||||||
{
|
{
|
||||||
free(m_Error);
|
free(m_Error);
|
||||||
@@ -54,11 +55,14 @@ RString RageSoundDriver_PulseAudio::Init()
|
|||||||
pa_proplist_sets(plist, PA_PROP_APPLICATION_NAME, PACKAGE_NAME);
|
pa_proplist_sets(plist, PA_PROP_APPLICATION_NAME, PACKAGE_NAME);
|
||||||
pa_proplist_sets(plist, PA_PROP_APPLICATION_VERSION, PACKAGE_VERSION);
|
pa_proplist_sets(plist, PA_PROP_APPLICATION_VERSION, PACKAGE_VERSION);
|
||||||
pa_proplist_sets(plist, PA_PROP_MEDIA_ROLE, "game");
|
pa_proplist_sets(plist, PA_PROP_MEDIA_ROLE, "game");
|
||||||
|
|
||||||
LOG->Trace("Pulse: pa_context_new_with_proplist()...");
|
LOG->Trace("Pulse: pa_context_new_with_proplist()...");
|
||||||
|
|
||||||
m_PulseCtx = pa_context_new_with_proplist(
|
m_PulseCtx = pa_context_new_with_proplist(
|
||||||
pa_threaded_mainloop_get_api(m_PulseMainLoop),
|
pa_threaded_mainloop_get_api(m_PulseMainLoop),
|
||||||
"StepMania", plist);
|
"StepMania", plist);
|
||||||
pa_proplist_free(plist);
|
pa_proplist_free(plist);
|
||||||
|
|
||||||
if(m_PulseCtx == NULL)
|
if(m_PulseCtx == NULL)
|
||||||
{
|
{
|
||||||
return "pa_context_new_with_proplist() failed!";
|
return "pa_context_new_with_proplist() failed!";
|
||||||
@@ -77,8 +81,8 @@ RString RageSoundDriver_PulseAudio::Init()
|
|||||||
pa_context_set_state_callback(m_PulseCtx, StaticCtxStateCb, this);
|
pa_context_set_state_callback(m_PulseCtx, StaticCtxStateCb, this);
|
||||||
|
|
||||||
LOG->Trace("Pulse: pa_context_connect()...");
|
LOG->Trace("Pulse: pa_context_connect()...");
|
||||||
error = pa_context_connect(m_PulseCtx, NULL,
|
error = pa_context_connect(m_PulseCtx, NULL, (pa_context_flags_t)0, NULL);
|
||||||
(pa_context_flags_t)0, NULL);
|
|
||||||
if(error < 0)
|
if(error < 0)
|
||||||
{
|
{
|
||||||
return ssprintf("pa_contect_connect(): %s",
|
return ssprintf("pa_contect_connect(): %s",
|
||||||
@@ -89,8 +93,7 @@ RString RageSoundDriver_PulseAudio::Init()
|
|||||||
error = pa_threaded_mainloop_start(m_PulseMainLoop);
|
error = pa_threaded_mainloop_start(m_PulseMainLoop);
|
||||||
if(error < 0)
|
if(error < 0)
|
||||||
{
|
{
|
||||||
return ssprintf("pa_threaded_mainloop_start() returned %i",
|
return ssprintf("pa_threaded_mainloop_start() returned %i", error);
|
||||||
error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create the decode thread, this will be needed for Mix(), that we
|
/* Create the decode thread, this will be needed for Mix(), that we
|
||||||
@@ -150,8 +153,7 @@ void RageSoundDriver_PulseAudio::m_InitStream(void)
|
|||||||
m_PulseStream = pa_stream_new(m_PulseCtx, "Stepmania Audio", &ss, &map);
|
m_PulseStream = pa_stream_new(m_PulseCtx, "Stepmania Audio", &ss, &map);
|
||||||
if(m_PulseStream == NULL)
|
if(m_PulseStream == NULL)
|
||||||
{
|
{
|
||||||
if(asprintf(&m_Error, "pa_stream_new(): %s",
|
if(asprintf(&m_Error, "pa_stream_new(): %s", pa_strerror(pa_context_errno(m_PulseCtx))) == -1)
|
||||||
pa_strerror(pa_context_errno(m_PulseCtx))) == -1)
|
|
||||||
{
|
{
|
||||||
m_Error = NULL;
|
m_Error = NULL;
|
||||||
}
|
}
|
||||||
@@ -162,6 +164,7 @@ void RageSoundDriver_PulseAudio::m_InitStream(void)
|
|||||||
/* set the write callback, it will be called when the sound server
|
/* set the write callback, it will be called when the sound server
|
||||||
* needs data */
|
* needs data */
|
||||||
pa_stream_set_write_callback(m_PulseStream, StaticStreamWriteCb, this);
|
pa_stream_set_write_callback(m_PulseStream, StaticStreamWriteCb, this);
|
||||||
|
|
||||||
/* set the state callback, it will be called the the stream state will
|
/* set the state callback, it will be called the the stream state will
|
||||||
* change */
|
* change */
|
||||||
pa_stream_set_state_callback(m_PulseStream, StaticStreamStateCb, this);
|
pa_stream_set_state_callback(m_PulseStream, StaticStreamStateCb, this);
|
||||||
@@ -217,8 +220,7 @@ void RageSoundDriver_PulseAudio::m_InitStream(void)
|
|||||||
attr.prebuf = (uint32_t)-1;
|
attr.prebuf = (uint32_t)-1;
|
||||||
|
|
||||||
/* log the used target buffer length */
|
/* log the used target buffer length */
|
||||||
LOG->Trace("Pulse: using target buffer length of %i bytes",
|
LOG->Trace("Pulse: using target buffer length of %i bytes", attr.tlength);
|
||||||
attr.tlength);
|
|
||||||
|
|
||||||
/* connect the stream for playback */
|
/* connect the stream for playback */
|
||||||
LOG->Trace("Pulse: pa_stream_connect_playback()...");
|
LOG->Trace("Pulse: pa_stream_connect_playback()...");
|
||||||
@@ -257,9 +259,7 @@ void RageSoundDriver_PulseAudio::CtxStateCb(pa_context *c)
|
|||||||
break;
|
break;
|
||||||
case PA_CONTEXT_TERMINATED:
|
case PA_CONTEXT_TERMINATED:
|
||||||
case PA_CONTEXT_FAILED:
|
case PA_CONTEXT_FAILED:
|
||||||
if(asprintf(&m_Error, "context connection failed: %s",
|
if(asprintf(&m_Error, "context connection failed: %s", pa_strerror(pa_context_errno(m_PulseCtx))) == -1)
|
||||||
pa_strerror(pa_context_errno(m_PulseCtx)))
|
|
||||||
== -1)
|
|
||||||
{
|
{
|
||||||
m_Error = NULL;
|
m_Error = NULL;
|
||||||
}
|
}
|
||||||
@@ -285,8 +285,7 @@ void RageSoundDriver_PulseAudio::StreamStateCb(pa_stream *s)
|
|||||||
case PA_STREAM_TERMINATED:
|
case PA_STREAM_TERMINATED:
|
||||||
case PA_STREAM_FAILED:
|
case PA_STREAM_FAILED:
|
||||||
if(asprintf(&m_Error, "stream connection failed: %s",
|
if(asprintf(&m_Error, "stream connection failed: %s",
|
||||||
pa_strerror(pa_context_errno(m_PulseCtx)))
|
pa_strerror(pa_context_errno(m_PulseCtx))) == -1)
|
||||||
== -1)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
m_Sem.Post();
|
m_Sem.Post();
|
||||||
@@ -321,7 +320,6 @@ void RageSoundDriver_PulseAudio::StreamWriteCb(pa_stream *s, size_t length)
|
|||||||
|
|
||||||
/* Static wrappers, because pulseaudio is a C API, it uses callbacks.
|
/* Static wrappers, because pulseaudio is a C API, it uses callbacks.
|
||||||
* So we have to write wrappers that will call our objects callbacks. */
|
* So we have to write wrappers that will call our objects callbacks. */
|
||||||
|
|
||||||
void RageSoundDriver_PulseAudio::StaticCtxStateCb(pa_context *c, void *user)
|
void RageSoundDriver_PulseAudio::StaticCtxStateCb(pa_context *c, void *user)
|
||||||
{
|
{
|
||||||
RageSoundDriver_PulseAudio *obj = (RageSoundDriver_PulseAudio*)user;
|
RageSoundDriver_PulseAudio *obj = (RageSoundDriver_PulseAudio*)user;
|
||||||
@@ -332,8 +330,7 @@ void RageSoundDriver_PulseAudio::StaticStreamStateCb(pa_stream *s, void *user)
|
|||||||
RageSoundDriver_PulseAudio *obj = (RageSoundDriver_PulseAudio*)user;
|
RageSoundDriver_PulseAudio *obj = (RageSoundDriver_PulseAudio*)user;
|
||||||
obj->StreamStateCb(s);
|
obj->StreamStateCb(s);
|
||||||
}
|
}
|
||||||
void RageSoundDriver_PulseAudio::StaticStreamWriteCb(pa_stream *s,
|
void RageSoundDriver_PulseAudio::StaticStreamWriteCb(pa_stream *s, size_t length, void *user)
|
||||||
size_t length, void *user)
|
|
||||||
{
|
{
|
||||||
RageSoundDriver_PulseAudio *obj = (RageSoundDriver_PulseAudio*)user;
|
RageSoundDriver_PulseAudio *obj = (RageSoundDriver_PulseAudio*)user;
|
||||||
obj->StreamWriteCb(s, length);
|
obj->StreamWriteCb(s, length);
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
#include "RageSoundDriver.h"
|
#include "RageSoundDriver.h"
|
||||||
#include <pulse/pulseaudio.h>
|
#include <pulse/pulseaudio.h>
|
||||||
|
|
||||||
class RageSoundDriver_PulseAudio: public RageSoundDriver
|
class RageSoundDriver_PulseAudio : public RageSoundDriver
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RageSoundDriver_PulseAudio();
|
RageSoundDriver_PulseAudio();
|
||||||
@@ -36,8 +36,7 @@ public:
|
|||||||
|
|
||||||
static void StaticCtxStateCb(pa_context *c, void *user);
|
static void StaticCtxStateCb(pa_context *c, void *user);
|
||||||
static void StaticStreamStateCb(pa_stream *s, void *user);
|
static void StaticStreamStateCb(pa_stream *s, void *user);
|
||||||
static void StaticStreamWriteCb(pa_stream *s,
|
static void StaticStreamWriteCb(pa_stream *s, size_t length, void *user);
|
||||||
size_t length, void *user);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* RAGE_SOUND_PULSEAUDIO_H */
|
#endif /* RAGE_SOUND_PULSEAUDIO_H */
|
||||||
|
|||||||
Reference in New Issue
Block a user