Skip to content

Commit

Permalink
ifdef guards
Browse files Browse the repository at this point in the history
  • Loading branch information
martincohen committed Sep 2, 2019
1 parent d476a22 commit 3eff120
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 17 deletions.
3 changes: 2 additions & 1 deletion sokol_app.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma once
#ifndef SOKOL_APP_INCLUDED
/*
sokol_app.h -- cross-platform application wrapper
Expand Down Expand Up @@ -794,6 +794,7 @@ SOKOL_API_DECL const void* sapp_android_get_native_activity(void);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif // SOKOL_APP_INCLUDED

/*-- IMPLEMENTATION ----------------------------------------------------------*/
#ifdef SOKOL_IMPL
Expand Down
3 changes: 2 additions & 1 deletion sokol_args.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma once
#ifndef SOKOL_ARGS_INCLUDED
/*
sokol_args.h -- cross-platform key/value arg-parsing for web and native
Expand Down Expand Up @@ -295,6 +295,7 @@ SOKOL_API_DECL const char* sargs_value_at(int index);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif // SOKOL_ARGS_INCLUDED

/*--- IMPLEMENTATION ---------------------------------------------------------*/
#ifdef SOKOL_IMPL
Expand Down
25 changes: 13 additions & 12 deletions sokol_audio.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma once
#ifndef SOKOL_AUDIO_INCLUDED
/*
sokol_audio.h -- cross-platform audio-streaming API
Expand Down Expand Up @@ -418,6 +418,7 @@ SOKOL_API_DECL int saudio_push(const float* frames, int num_frames);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif // SOKOL_AUDIO_INCLUDED

/*=== IMPLEMENTATION =========================================================*/
#ifdef SOKOL_IMPL
Expand Down Expand Up @@ -569,8 +570,8 @@ typedef struct {

typedef struct {
pthread_mutex_t mutex;
pthread_cond_t cond;
int count;
pthread_cond_t cond;
int count;
} _saudio_semaphore_t;

typedef struct {
Expand Down Expand Up @@ -1472,12 +1473,12 @@ _SOKOL_PRIVATE void* _saudio_opensles_thread_fn(void* param) {
/* get next output buffer, advance, next buffer. */
int16_t* out_buffer = _saudio.backend.output_buffers[_saudio.backend.active_buffer];
_saudio.backend.active_buffer = (_saudio.backend.active_buffer + 1) % SAUDIO_NUM_BUFFERS;
int16_t* next_buffer = _saudio.backend.output_buffers[_saudio.backend.active_buffer];
int16_t* next_buffer = _saudio.backend.output_buffers[_saudio.backend.active_buffer];

/* queue this buffer */
const int buffer_size_bytes = _saudio.buffer_frames * _saudio.num_channels * sizeof(short);
(*_saudio.backend.player_buffer_queue)->Enqueue(_saudio.backend.player_buffer_queue, out_buffer, buffer_size_bytes);

/* fill the next buffer */
_saudio_opensles_fill_buffer();
const int num_samples = _saudio.num_channels * _saudio.buffer_frames;
Expand All @@ -1491,7 +1492,7 @@ _SOKOL_PRIVATE void* _saudio_opensles_thread_fn(void* param) {
return 0;
}

_SOKOL_PRIVATE void _saudio_backend_shutdown(void) {
_SOKOL_PRIVATE void _saudio_backend_shutdown(void) {
_saudio.backend.thread_stop = 1;
pthread_join(_saudio.backend.thread, 0);

Expand All @@ -1509,11 +1510,11 @@ _SOKOL_PRIVATE void _saudio_backend_shutdown(void) {

for (int i = 0; i < SAUDIO_NUM_BUFFERS; i++) {
SOKOL_FREE(_saudio.backend.output_buffers[i]);
}
}
SOKOL_FREE(_saudio.backend.src_buffer);
}

_SOKOL_PRIVATE bool _saudio_backend_init(void) {
_SOKOL_PRIVATE bool _saudio_backend_init(void) {
_saudio.bytes_per_frame = sizeof(float) * _saudio.num_channels;

for (int i = 0; i < SAUDIO_NUM_BUFFERS; ++i) {
Expand Down Expand Up @@ -1590,19 +1591,19 @@ _SOKOL_PRIVATE bool _saudio_backend_init(void) {
/* Output mix. */
_saudio.backend.out_locator.locatorType = SL_DATALOCATOR_OUTPUTMIX;
_saudio.backend.out_locator.outputMix = _saudio.backend.output_mix_obj;

_saudio.backend.dst_data_sink.pLocator = &_saudio.backend.out_locator;
_saudio.backend.dst_data_sink.pFormat = NULL;
_saudio.backend.dst_data_sink.pFormat = NULL;

/* setup player */
{
const SLInterfaceID ids[] = { SL_IID_VOLUME, SL_IID_ANDROIDSIMPLEBUFFERQUEUE };
const SLboolean req[] = { SL_BOOLEAN_FALSE, SL_BOOLEAN_TRUE };

(*_saudio.backend.engine)->CreateAudioPlayer(_saudio.backend.engine, &_saudio.backend.player_obj, &src, &_saudio.backend.dst_data_sink, sizeof(ids) / sizeof(ids[0]), ids, req);

(*_saudio.backend.player_obj)->Realize(_saudio.backend.player_obj, SL_BOOLEAN_FALSE);

(*_saudio.backend.player_obj)->GetInterface(_saudio.backend.player_obj, SL_IID_PLAY, &_saudio.backend.player);
(*_saudio.backend.player_obj)->GetInterface(_saudio.backend.player_obj, SL_IID_VOLUME, &_saudio.backend.player_vol);

Expand Down
3 changes: 2 additions & 1 deletion sokol_fetch.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma once
#ifndef SOKOL_FETCH_INCLUDED
/*
sokol_fetch.h -- asynchronous data loading/streaming
Expand Down Expand Up @@ -937,6 +937,7 @@ SOKOL_API_DECL void sfetch_continue(sfetch_handle_t h);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif // SOKOL_FETCH_INCLUDED

/*--- IMPLEMENTATION ---------------------------------------------------------*/
#ifdef SOKOL_IMPL
Expand Down
3 changes: 2 additions & 1 deletion sokol_gfx.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma once
#ifndef SOKOL_GFX_INCLUDED
/*
sokol_gfx.h -- simple 3D API wrapper
Expand Down Expand Up @@ -2036,6 +2036,7 @@ SOKOL_API_DECL void sg_discard_context(sg_context ctx_id);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif // SOKOL_GFX_INCLUDED

/*--- IMPLEMENTATION ---------------------------------------------------------*/
#ifdef SOKOL_IMPL
Expand Down
3 changes: 2 additions & 1 deletion sokol_time.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma once
#ifndef SOKOL_TIME_INCLUDED
/*
sokol_time.h -- simple cross-platform time measurement
Expand Down Expand Up @@ -119,6 +119,7 @@ SOKOL_API_DECL double stm_ns(uint64_t ticks);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif // SOKOL_TIME_INCLUDED

/*-- IMPLEMENTATION ----------------------------------------------------------*/
#ifdef SOKOL_IMPL
Expand Down

0 comments on commit 3eff120

Please sign in to comment.