Skip to content

Commit

Permalink
Fix code to not break non-linux builds; add README
Browse files Browse the repository at this point in the history
  • Loading branch information
falkTX committed Oct 29, 2013
1 parent 1f58910 commit 3413fa2
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 20 deletions.
3 changes: 3 additions & 0 deletions README
@@ -0,0 +1,3 @@
This repo contains a fork of ProTrekkr, now with linux JACK Audio support.

see http://code.google.com/p/protrekkr/
5 changes: 3 additions & 2 deletions release/distrib/replay/lib/replay.cpp
Expand Up @@ -1306,9 +1306,10 @@ int STDCALL Ptk_InitDriver(void)

#if defined(__WIN32__)
if(!AUDIO_Init_Driver(hWnd, &Mixer))
#else
//if(!AUDIO_Init_Driver(&Mixer))
#elif defined(__LINUX__)
if(!AUDIO_Init_DriverFloat(&MixerFloat))
#else
if(!AUDIO_Init_Driver(&Mixer))
#endif
{
return(FALSE);
Expand Down
Expand Up @@ -77,7 +77,7 @@ extern int AUDIO_Milliseconds;
void Message_Error(char *Message);
#endif

//int AUDIO_Init_Driver(void (STDCALL *Mixer)(Uint8 *, Uint32));
int AUDIO_Init_Driver(void (STDCALL *Mixer)(Uint8 *, Uint32));
int AUDIO_Init_DriverFloat(void (STDCALL *Mixer)(float*, float*, Uint32));
int AUDIO_Create_Sound_Buffer(int milliseconds);
void AUDIO_Stop_Sound_Buffer(void);
Expand Down
44 changes: 27 additions & 17 deletions release/distrib/replay/lib/sounddriver/sounddriver_linux.cpp
Expand Up @@ -70,15 +70,18 @@ static int jaudio_process_callback(jack_nframes_t nframes, void*)

if (AUDIO_Play_Flag)
{
#if 0
Uint8 mixerBuf[nframes*2];
AUDIO_Mixer(mixerBuf, nframes*2);

for (jack_nframes_t i=0; i < nframes; ++i)
audioBuf1[i] = audioBuf2[i] = double((signed short)((mixerBuf[2*i+1]<<8) | mixerBuf[2*i]))*2.0/65535.0;
#else
AUDIO_MixerFloat(audioBuf1, audioBuf2, nframes);
#endif
if (AUDIO_MixerFloat)
{
AUDIO_MixerFloat(audioBuf1, audioBuf2, nframes);
}
else
{
Uint8 mixerBuf[nframes*2];
AUDIO_Mixer(mixerBuf, nframes*2);

for (jack_nframes_t i=0; i < nframes; ++i)
audioBuf1[i] = audioBuf2[i] = double((signed short)((mixerBuf[2*i+1]<<8) | mixerBuf[2*i]))*2.0/65535.0;
}

AUDIO_Samples += nframes;
AUDIO_Timer = ((((float) AUDIO_Samples) * (1.0f / (float) AUDIO_Latency)) * 1000.0f);
Expand All @@ -105,15 +108,8 @@ static void jaudio_shutdown_callback(void* arg)
// ------------------------------------------------------
// Name: AUDIO_Init_Driver()
// Desc: Init the audio driver

// int AUDIO_Init_Driver(void (*Mixer)(Uint8 *, Uint32))
// {
// AUDIO_Mixer = Mixer;

int AUDIO_Init_DriverFloat(void (*MixerFloat)(float*, float*, Uint32))
int _init_JACK()
{
AUDIO_MixerFloat = MixerFloat;

jaudio_client = jack_client_open("protrekkr", JackNullOption, NULL);

if (jaudio_client == NULL)
Expand All @@ -130,6 +126,20 @@ int AUDIO_Init_DriverFloat(void (*MixerFloat)(float*, float*, Uint32))
return (jaudio_client != NULL) ? TRUE : FALSE;
}

int AUDIO_Init_Driver(void (*Mixer)(Uint8 *, Uint32))
{
AUDIO_Mixer = Mixer;

return _init_JACK();
}

int AUDIO_Init_DriverFloat(void (*MixerFloat)(float*, float*, Uint32))
{
AUDIO_MixerFloat = MixerFloat;

return _init_JACK();
}

// ------------------------------------------------------
// Name: AUDIO_Play()
// Desc: Play the sound buffer endlessly
Expand Down

0 comments on commit 3413fa2

Please sign in to comment.