Commit 2002913d authored by David Reid's avatar David Reid Committed by GitHub

Merge pull request #372 from orx/dev-0.11

Fixed compilation warnings & errors on iOS
parents 19a3eb69 7d84ec56
...@@ -3302,6 +3302,23 @@ extern "C" { ...@@ -3302,6 +3302,23 @@ extern "C" {
#endif #endif
#endif #endif
#if defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
#include <stdalign.h>
#define MA_ALIGN_TYPE(n) alignas(n)
#define MA_ALIGN_MEMBER(align, type) MA_ALIGN_TYPE(align) type
#else
#if defined(__GNUC__)
#define MA_ALIGN_TYPE(n) __attribute__((aligned(n)))
#define MA_ALIGN_MEMBER(align, type) type MA_ALIGN_TYPE(align)
#elif defined(_MSC_VER)
#define MA_ALIGN_TYPE(n) __declspec(align(n))
#define MA_ALIGN_MEMBER(align, type) MA_ALIGN_TYPE(align) type
#else
#define MA_ALIGN_TYPE(n) /* disabled */
#define MA_ALIGN_MEMBER(align, type) /* disabled */
#endif
#endif
/* Platform/backend detection. */ /* Platform/backend detection. */
#ifdef _WIN32 #ifdef _WIN32
#define MA_WIN32 #define MA_WIN32
...@@ -8898,7 +8915,7 @@ typedef struct ...@@ -8898,7 +8915,7 @@ typedef struct
} breakup; } breakup;
ma_uint64 allocation; ma_uint64 allocation;
} toc; /* 8 bytes. We encode the job code into the slot allocation data to save space. */ } toc; /* 8 bytes. We encode the job code into the slot allocation data to save space. */
ma_uint64 next; /* refcount + slot for the next item. Does not include the job code. */ MA_ATOMIC MA_ALIGN_MEMBER(8, ma_uint64) next; /* refcount + slot for the next item. Does not include the job code. */
ma_uint32 order; /* Execution order. Used to create a data dependency and ensure a job is executed in order. Usage is contextual depending on the job type. */ ma_uint32 order; /* Execution order. Used to create a data dependency and ensure a job is executed in order. Usage is contextual depending on the job type. */
union union
...@@ -9003,7 +9020,7 @@ typedef struct ...@@ -9003,7 +9020,7 @@ typedef struct
{ {
ma_uint32 flags; /* Flags passed in at initialization time. */ ma_uint32 flags; /* Flags passed in at initialization time. */
ma_uint32 capacity; /* The maximum number of jobs that can fit in the queue at a time. Set by the config. */ ma_uint32 capacity; /* The maximum number of jobs that can fit in the queue at a time. Set by the config. */
MA_ATOMIC ma_uint64 head; /* The first item in the list. Required for removing from the top of the list. */ MA_ATOMIC MA_ALIGN_MEMBER(8, ma_uint64) head; /* The first item in the list. Required for removing from the top of the list. */
MA_ATOMIC ma_uint64 tail; /* The last item in the list. Required for appending to the end of the list. */ MA_ATOMIC ma_uint64 tail; /* The last item in the list. Required for appending to the end of the list. */
#ifndef MA_NO_THREADING #ifndef MA_NO_THREADING
ma_semaphore sem; /* Only used when MA_RESOURCE_MANAGER_JOB_QUEUE_FLAG_NON_BLOCKING is unset. */ ma_semaphore sem; /* Only used when MA_RESOURCE_MANAGER_JOB_QUEUE_FLAG_NON_BLOCKING is unset. */
...@@ -9133,7 +9150,7 @@ struct ma_resource_manager_data_stream ...@@ -9133,7 +9150,7 @@ struct ma_resource_manager_data_stream
ma_bool32 isDecoderInitialized; /* Required for determining whether or not the decoder should be uninitialized in MA_RESOURCE_MANAGER_JOB_FREE_DATA_STREAM. */ ma_bool32 isDecoderInitialized; /* Required for determining whether or not the decoder should be uninitialized in MA_RESOURCE_MANAGER_JOB_FREE_DATA_STREAM. */
ma_uint64 totalLengthInPCMFrames; /* This is calculated when first loaded by the MA_RESOURCE_MANAGER_JOB_LOAD_DATA_STREAM. */ ma_uint64 totalLengthInPCMFrames; /* This is calculated when first loaded by the MA_RESOURCE_MANAGER_JOB_LOAD_DATA_STREAM. */
ma_uint32 relativeCursor; /* The playback cursor, relative to the current page. Only ever accessed by the public API. Never accessed by the job thread. */ ma_uint32 relativeCursor; /* The playback cursor, relative to the current page. Only ever accessed by the public API. Never accessed by the job thread. */
ma_uint64 absoluteCursor; /* The playback cursor, in absolute position starting from the start of the file. */ MA_ATOMIC MA_ALIGN_MEMBER(8, ma_uint64) absoluteCursor; /* The playback cursor, in absolute position starting from the start of the file. */
ma_uint32 currentPageIndex; /* Toggles between 0 and 1. Index 0 is the first half of pPageData. Index 1 is the second half. Only ever accessed by the public API. Never accessed by the job thread. */ ma_uint32 currentPageIndex; /* Toggles between 0 and 1. Index 0 is the first half of pPageData. Index 1 is the second half. Only ever accessed by the public API. Never accessed by the job thread. */
MA_ATOMIC ma_uint32 executionCounter; /* For allocating execution orders for jobs. */ MA_ATOMIC ma_uint32 executionCounter; /* For allocating execution orders for jobs. */
MA_ATOMIC ma_uint32 executionPointer; /* For managing the order of execution for asynchronous jobs relating to this object. Incremented as jobs complete processing. */ MA_ATOMIC ma_uint32 executionPointer; /* For managing the order of execution for asynchronous jobs relating to this object. Incremented as jobs complete processing. */
...@@ -9423,8 +9440,8 @@ struct ma_node_base ...@@ -9423,8 +9440,8 @@ struct ma_node_base
/* These variables are read and written between different threads. */ /* These variables are read and written between different threads. */
MA_ATOMIC ma_node_state state; /* When set to stopped, nothing will be read, regardless of the times in stateTimes. */ MA_ATOMIC ma_node_state state; /* When set to stopped, nothing will be read, regardless of the times in stateTimes. */
MA_ATOMIC ma_uint64 stateTimes[2]; /* Indexed by ma_node_state. Specifies the time based on the global clock that a node should be considered to be in the relevant state. */ MA_ATOMIC MA_ALIGN_MEMBER(8, ma_uint64) stateTimes[2]; /* Indexed by ma_node_state. Specifies the time based on the global clock that a node should be considered to be in the relevant state. */
MA_ATOMIC ma_uint64 localTime; /* The node's local clock. This is just a running sum of the number of output frames that have been processed. Can be modified by any thread with `ma_node_set_time()`. */ MA_ATOMIC MA_ALIGN_MEMBER(8, ma_uint64) localTime; /* The node's local clock. This is just a running sum of the number of output frames that have been processed. Can be modified by any thread with `ma_node_set_time()`. */
ma_uint32 inputBusCount; ma_uint32 inputBusCount;
ma_uint32 outputBusCount; ma_uint32 outputBusCount;
ma_node_input_bus* pInputBuses; ma_node_input_bus* pInputBuses;
...@@ -28589,6 +28606,13 @@ References ...@@ -28589,6 +28606,13 @@ References
#if defined(TARGET_OS_WATCH) && TARGET_OS_WATCH == 1 #if defined(TARGET_OS_WATCH) && TARGET_OS_WATCH == 1
#define MA_APPLE_WATCH #define MA_APPLE_WATCH
#endif #endif
#if __has_feature(objc_arc)
#define MA_BRIDGE_TRANSFER __bridge_transfer
#define MA_BRIDGE_RETAINED __bridge_retained
#else
#define MA_BRIDGE_TRANSFER
#define MA_BRIDGE_RETAINED
#endif
#else #else
#define MA_APPLE_DESKTOP #define MA_APPLE_DESKTOP
#endif #endif
...@@ -30164,7 +30188,7 @@ static OSStatus ma_on_output__coreaudio(void* pUserData, AudioUnitRenderActionFl ...@@ -30164,7 +30188,7 @@ static OSStatus ma_on_output__coreaudio(void* pUserData, AudioUnitRenderActionFl
MA_ASSERT(pDevice != NULL); MA_ASSERT(pDevice != NULL);
ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "INFO: Output Callback: busNumber=%d, frameCount=%d, mNumberBuffers=%d\n", busNumber, frameCount, pBufferList->mNumberBuffers); ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "INFO: Output Callback: busNumber=%d, frameCount=%d, mNumberBuffers=%d\n", (int)busNumber, (int)frameCount, (int)pBufferList->mNumberBuffers);
/* We need to check whether or not we are outputting interleaved or non-interleaved samples. The way we do this is slightly different for each type. */ /* We need to check whether or not we are outputting interleaved or non-interleaved samples. The way we do this is slightly different for each type. */
layout = ma_stream_layout_interleaved; layout = ma_stream_layout_interleaved;
...@@ -30182,7 +30206,7 @@ static OSStatus ma_on_output__coreaudio(void* pUserData, AudioUnitRenderActionFl ...@@ -30182,7 +30206,7 @@ static OSStatus ma_on_output__coreaudio(void* pUserData, AudioUnitRenderActionFl
ma_device_handle_backend_data_callback(pDevice, pBufferList->mBuffers[iBuffer].mData, NULL, frameCountForThisBuffer); ma_device_handle_backend_data_callback(pDevice, pBufferList->mBuffers[iBuffer].mData, NULL, frameCountForThisBuffer);
} }
ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, " frameCount=%d, mNumberChannels=%d, mDataByteSize=%d\n", frameCount, pBufferList->mBuffers[iBuffer].mNumberChannels, pBufferList->mBuffers[iBuffer].mDataByteSize); ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, " frameCount=%d, mNumberChannels=%d, mDataByteSize=%d\n", (int)frameCount, (int)pBufferList->mBuffers[iBuffer].mNumberChannels, (int)pBufferList->mBuffers[iBuffer].mDataByteSize);
} else { } else {
/* /*
This case is where the number of channels in the output buffer do not match our internal channels. It could mean that it's This case is where the number of channels in the output buffer do not match our internal channels. It could mean that it's
...@@ -30190,7 +30214,7 @@ static OSStatus ma_on_output__coreaudio(void* pUserData, AudioUnitRenderActionFl ...@@ -30190,7 +30214,7 @@ static OSStatus ma_on_output__coreaudio(void* pUserData, AudioUnitRenderActionFl
output silence here. output silence here.
*/ */
MA_ZERO_MEMORY(pBufferList->mBuffers[iBuffer].mData, pBufferList->mBuffers[iBuffer].mDataByteSize); MA_ZERO_MEMORY(pBufferList->mBuffers[iBuffer].mData, pBufferList->mBuffers[iBuffer].mDataByteSize);
ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, " WARNING: Outputting silence. frameCount=%d, mNumberChannels=%d, mDataByteSize=%d\n", frameCount, pBufferList->mBuffers[iBuffer].mNumberChannels, pBufferList->mBuffers[iBuffer].mDataByteSize); ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, " WARNING: Outputting silence. frameCount=%d, mNumberChannels=%d, mDataByteSize=%d\n", (int)frameCount, (int)pBufferList->mBuffers[iBuffer].mNumberChannels, (int)pBufferList->mBuffers[iBuffer].mDataByteSize);
} }
} }
} else { } else {
...@@ -30259,7 +30283,7 @@ static OSStatus ma_on_input__coreaudio(void* pUserData, AudioUnitRenderActionFla ...@@ -30259,7 +30283,7 @@ static OSStatus ma_on_input__coreaudio(void* pUserData, AudioUnitRenderActionFla
layout = ma_stream_layout_deinterleaved; layout = ma_stream_layout_deinterleaved;
} }
ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "INFO: Input Callback: busNumber=%d, frameCount=%d, mNumberBuffers=%d\n", busNumber, frameCount, pRenderedBufferList->mNumberBuffers); ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, "INFO: Input Callback: busNumber=%d, frameCount=%d, mNumberBuffers=%d\n", (int)busNumber, (int)frameCount, (int)pRenderedBufferList->mNumberBuffers);
/* /*
There has been a situation reported where frame count passed into this function is greater than the capacity of There has been a situation reported where frame count passed into this function is greater than the capacity of
...@@ -30287,7 +30311,7 @@ static OSStatus ma_on_input__coreaudio(void* pUserData, AudioUnitRenderActionFla ...@@ -30287,7 +30311,7 @@ static OSStatus ma_on_input__coreaudio(void* pUserData, AudioUnitRenderActionFla
status = ((ma_AudioUnitRender_proc)pDevice->pContext->coreaudio.AudioUnitRender)((AudioUnit)pDevice->coreaudio.audioUnitCapture, pActionFlags, pTimeStamp, busNumber, frameCount, pRenderedBufferList); status = ((ma_AudioUnitRender_proc)pDevice->pContext->coreaudio.AudioUnitRender)((AudioUnit)pDevice->coreaudio.audioUnitCapture, pActionFlags, pTimeStamp, busNumber, frameCount, pRenderedBufferList);
if (status != noErr) { if (status != noErr) {
ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, " ERROR: AudioUnitRender() failed with %d\n", status); ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, " ERROR: AudioUnitRender() failed with %d\n", (int)status);
return status; return status;
} }
...@@ -30295,7 +30319,7 @@ static OSStatus ma_on_input__coreaudio(void* pUserData, AudioUnitRenderActionFla ...@@ -30295,7 +30319,7 @@ static OSStatus ma_on_input__coreaudio(void* pUserData, AudioUnitRenderActionFla
for (iBuffer = 0; iBuffer < pRenderedBufferList->mNumberBuffers; ++iBuffer) { for (iBuffer = 0; iBuffer < pRenderedBufferList->mNumberBuffers; ++iBuffer) {
if (pRenderedBufferList->mBuffers[iBuffer].mNumberChannels == pDevice->capture.internalChannels) { if (pRenderedBufferList->mBuffers[iBuffer].mNumberChannels == pDevice->capture.internalChannels) {
ma_device_handle_backend_data_callback(pDevice, NULL, pRenderedBufferList->mBuffers[iBuffer].mData, frameCount); ma_device_handle_backend_data_callback(pDevice, NULL, pRenderedBufferList->mBuffers[iBuffer].mData, frameCount);
ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, " mDataByteSize=%d\n", pRenderedBufferList->mBuffers[iBuffer].mDataByteSize); ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, " mDataByteSize=%d\n", (int)pRenderedBufferList->mBuffers[iBuffer].mDataByteSize);
} else { } else {
/* /*
This case is where the number of channels in the output buffer do not match our internal channels. It could mean that it's This case is where the number of channels in the output buffer do not match our internal channels. It could mean that it's
...@@ -30318,7 +30342,7 @@ static OSStatus ma_on_input__coreaudio(void* pUserData, AudioUnitRenderActionFla ...@@ -30318,7 +30342,7 @@ static OSStatus ma_on_input__coreaudio(void* pUserData, AudioUnitRenderActionFla
framesRemaining -= framesToSend; framesRemaining -= framesToSend;
} }
ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, " WARNING: Outputting silence. frameCount=%d, mNumberChannels=%d, mDataByteSize=%d\n", frameCount, pRenderedBufferList->mBuffers[iBuffer].mNumberChannels, pRenderedBufferList->mBuffers[iBuffer].mDataByteSize); ma_log_postf(ma_device_get_log(pDevice), MA_LOG_LEVEL_DEBUG, " WARNING: Outputting silence. frameCount=%d, mNumberChannels=%d, mDataByteSize=%d\n", (int)frameCount, (int)pRenderedBufferList->mBuffers[iBuffer].mNumberChannels, (int)pRenderedBufferList->mBuffers[iBuffer].mDataByteSize);
} }
} }
} else { } else {
...@@ -30672,6 +30696,7 @@ static ma_result ma_device__untrack__coreaudio(ma_device* pDevice) ...@@ -30672,6 +30696,7 @@ static ma_result ma_device__untrack__coreaudio(ma_device* pDevice)
-(void)dealloc -(void)dealloc
{ {
[self remove_handler]; [self remove_handler];
[super dealloc];
} }
-(void)remove_handler -(void)remove_handler
...@@ -30766,7 +30791,7 @@ static ma_result ma_device_uninit__coreaudio(ma_device* pDevice) ...@@ -30766,7 +30791,7 @@ static ma_result ma_device_uninit__coreaudio(ma_device* pDevice)
#endif #endif
#if defined(MA_APPLE_MOBILE) #if defined(MA_APPLE_MOBILE)
if (pDevice->coreaudio.pRouteChangeHandler != NULL) { if (pDevice->coreaudio.pRouteChangeHandler != NULL) {
ma_router_change_handler* pRouteChangeHandler = (__bridge_transfer ma_router_change_handler*)pDevice->coreaudio.pRouteChangeHandler; ma_router_change_handler* pRouteChangeHandler = (MA_BRIDGE_TRANSFER ma_router_change_handler*)pDevice->coreaudio.pRouteChangeHandler;
[pRouteChangeHandler remove_handler]; [pRouteChangeHandler remove_handler];
} }
#endif #endif
...@@ -31087,7 +31112,7 @@ static ma_result ma_device_init_internal__coreaudio(ma_context* pContext, ma_dev ...@@ -31087,7 +31112,7 @@ static ma_result ma_device_init_internal__coreaudio(ma_context* pContext, ma_dev
} }
#else #else
/* TODO: Figure out how to get the channel map using AVAudioSession. */ /* TODO: Figure out how to get the channel map using AVAudioSession. */
ma_channel_map_init_standard(ma_standard_channel_map_default, pData->channelMap, ma_countof(pData->channelMap), pData->channelsOut); ma_channel_map_init_standard(ma_standard_channel_map_default, pData->channelMapOut, ma_countof(pData->channelMapOut), pData->channelsOut);
#endif #endif
...@@ -31440,7 +31465,7 @@ static ma_result ma_device_init__coreaudio(ma_device* pDevice, const ma_device_c ...@@ -31440,7 +31465,7 @@ static ma_result ma_device_init__coreaudio(ma_device* pDevice, const ma_device_c
differently on non-Desktop Apple platforms. differently on non-Desktop Apple platforms.
*/ */
#if defined(MA_APPLE_MOBILE) #if defined(MA_APPLE_MOBILE)
pDevice->coreaudio.pRouteChangeHandler = (__bridge_retained void*)[[ma_router_change_handler alloc] init:pDevice]; pDevice->coreaudio.pRouteChangeHandler = (MA_BRIDGE_RETAINED void*)[[ma_router_change_handler alloc] init:pDevice];
#endif #endif
return MA_SUCCESS; return MA_SUCCESS;
...@@ -58534,7 +58559,7 @@ MA_API ma_result ma_stbvorbis_read_pcm_frames(ma_stbvorbis* pVorbis, void* pFram ...@@ -58534,7 +58559,7 @@ MA_API ma_result ma_stbvorbis_read_pcm_frames(ma_stbvorbis* pVorbis, void* pFram
framesRead = stb_vorbis_get_samples_float_interleaved(pVorbis->stb, channels, (float*)ma_offset_pcm_frames_ptr(pFramesOut, totalFramesRead, format, channels), (int)framesRemaining * channels); /* Safe cast. */ framesRead = stb_vorbis_get_samples_float_interleaved(pVorbis->stb, channels, (float*)ma_offset_pcm_frames_ptr(pFramesOut, totalFramesRead, format, channels), (int)framesRemaining * channels); /* Safe cast. */
totalFramesRead += framesRead; totalFramesRead += framesRead;
if (framesRead < framesRemaining) { if (framesRead < (int)framesRemaining) {
break; /* Nothing left to read. Get out. */ break; /* Nothing left to read. Get out. */
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment