A log level will automatically include the lower levels. For example, verbose logging will enable everything. The warning log level will only include warnings
and errors, but will ignore informational and verbose logging. If you only want to handle a specific log level, implement a custom log callback (see
ma_context_init() for details) and interrogate the `logLevel` parameter.
Log levels are only used to give logging callbacks some context as to the severity of a log message
so they can do filtering. All log levels will be posted to registered logging callbacks, except for
MA_LOG_LEVEL_DEBUG which will only get processed if MA_DEBUG_OUTPUT is enabled.
By default the log level will be set to MA_LOG_LEVEL_ERROR, but you can change this by defining MA_LOG_LEVEL before the implementation of miniaudio.
MA_LOG_LEVEL_VERBOSE
Mainly intended for debugging. This will enable all log levels and can be triggered from within the data callback so care must be taken when enabling this
in production environments.
MA_LOG_LEVEL_DEBUG
Used for debugging. These log messages are only posted when `MA_DEBUG_OUTPUT` is enabled.
MA_LOG_LEVEL_INFO
Informational logging. Useful for debugging. This will also enable warning and error logs. This will never be called from within the data callback.
Informational logging. Useful for debugging. This will also enable warning and error logs. This
will never be called from within the data callback.
MA_LOG_LEVEL_WARNING
Warnings. You should enable this in you development builds and action them when encounted. This will also enable error logs. These logs usually indicate a
potential problem or misconfiguration, but still allow you to keep running. This will never be called from within the data callback.
Warnings. You should enable this in you development builds and action them when encounted. This
will also enable error logs. These logs usually indicate a potential problem or
misconfiguration, but still allow you to keep running. This will never be called from within
the data callback.
MA_LOG_LEVEL_ERROR
Error logging. This will be fired when an operation fails and is subsequently aborted. This can be fired from within the data callback, in which case the
device will be stopped. You should always have this log level enabled.
Error logging. This will be fired when an operation fails and is subsequently aborted. This can
be fired from within the data callback, in which case the device will be stopped. You should
always have this log level enabled.
*/
#define MA_LOG_LEVEL_VERBOSE 4
#define MA_LOG_LEVEL_INFO 3
#define MA_LOG_LEVEL_WARNING 2
#define MA_LOG_LEVEL_ERROR 1
#define MA_LOG_LEVEL_DEBUG 4
#define MA_LOG_LEVEL_INFO 3
#define MA_LOG_LEVEL_WARNING 2
#define MA_LOG_LEVEL_ERROR 1
/* Deprecated. */
#define MA_LOG_LEVEL_VERBOSE MA_LOG_LEVEL_DEBUG
/* Deprecated. */
#ifndef MA_LOG_LEVEL
#define MA_LOG_LEVEL MA_LOG_LEVEL_ERROR
#define MA_LOG_LEVEL MA_LOG_LEVEL_ERROR
#endif
/*
...
...
@@ -298,7 +303,7 @@ typedef int ma_result;
#define MA_NOT_DIRECTORY -14
#define MA_IS_DIRECTORY -15
#define MA_DIRECTORY_NOT_EMPTY -16
#define MA_END_OF_FILE -17
#define MA_AT_END -17
#define MA_NO_SPACE -18
#define MA_BUSY -19
#define MA_IO_ERROR -20
...
...
@@ -334,7 +339,6 @@ typedef int ma_result;
#define MA_IN_PROGRESS -50
#define MA_CANCELLED -51
#define MA_MEMORY_ALREADY_MAPPED -52
#define MA_AT_END -53
/* General miniaudio-specific errors. */
#define MA_FORMAT_NOT_SUPPORTED -100
...
...
@@ -440,7 +444,7 @@ typedef enum
ma_channel_mix_mode_simple,/* Drop excess channels; zeroed out extra channels. */
ma_channel_mix_mode_custom_weights,/* Use custom weights specified in ma_channel_router_config. */
ma_log_proclogCallback;/* Legacy logging callback. Will be removed in version 0.11. */
ma_log*pLog;
ma_thread_prioritythreadPriority;
size_tthreadStackSize;
void*pUserData;
...
...
@@ -2129,7 +2182,9 @@ struct ma_context
{
ma_backend_callbackscallbacks;
ma_backendbackend;/* DirectSound, ALSA, etc. */
ma_log_proclogCallback;
ma_log*pLog;
ma_loglog;/* Only used if the log is owned by the context. The pLog member will be set to &log in this case. */
ma_log_proclogCallback;/* Legacy callback. Will be removed in version 0.11. */
ma_thread_prioritythreadPriority;
size_tthreadStackSize;
void*pUserData;
...
...
@@ -2875,8 +2930,9 @@ When `backends` is NULL, the default priority order will be used. Below is a lis
The context can be configured via the `pConfig` argument. The config object is initialized with `ma_context_config_init()`. Individual configuration settings
can then be set directly on the structure. Below are the members of the `ma_context_config` object.
logCallback
Callback for handling log messages from miniaudio.
pLog
A pointer to the `ma_log` to post log messages to. Can be NULL if the application does not
require logging. See the `ma_log` API for details on how to use the logging system.
threadPriority
The desired priority to use for the audio thread. Allowable values include the following:
...
...
@@ -3045,6 +3101,23 @@ This is mainly for the purpose of bindings to know how much memory to allocate.
*/
MA_APIsize_tma_context_sizeof(void);
/*
Retrieves a pointer to the log object associated with this context.
Remarks
-------
Pass the returned pointer to `ma_log_post()`, `ma_log_postv()` or `ma_log_postf()` to post a log
message.
Return Value
------------
A pointer to the `ma_log` object that the context uses to post log messages. If some error occurs,
/* Variables below are placeholder and not yet used. */
constma_data_source_vtable*vtable;
ma_uint64rangeBegInFrames;
ma_uint64rangeEndInFrames;/* Set to -1 for unranged (default). */
ma_uint64loopBegInFrames;/* Relative to rangeBegInFrames. */
ma_uint64loopEndInFrames;/* Relative to rangeBegInFrames. Set to -1 for the end of the range. */
ma_data_source*pCurrent;/* When non-NULL, the data source being initialized will act as a proxy and will route all operations to pCurrent. Used in conjunction with pNext/onGetNext for seamless chaining. */
ma_data_source*pNext;/* When set to NULL, onGetNext will be used. */
ma_data_source_get_next_proconGetNext;/* Will be used when pNext is NULL. If both are NULL, no next will be used. */
MA_APIma_resultma_data_source_read_pcm_frames(ma_data_source*pDataSource,void*pFramesOut,ma_uint64frameCount,ma_uint64*pFramesRead,ma_bool32loop);/* Must support pFramesOut = NULL in which case a forward seek should be performed. */
MA_APIma_resultma_data_source_seek_pcm_frames(ma_data_source*pDataSource,ma_uint64frameCount,ma_uint64*pFramesSeeked,ma_bool32loop);/* Can only seek forward. Equivalent to ma_data_source_read_pcm_frames(pDataSource, NULL, frameCount); */
MA_APIma_resultma_data_source_unmap(ma_data_source*pDataSource,ma_uint64frameCount);/* Returns MA_AT_END if the end has been reached. This should be considered successful. */
MA_APIma_resultma_data_source_map(ma_data_source*pDataSource,void**ppFramesOut,ma_uint64*pFrameCount);/* Returns MA_NOT_IMPLEMENTED if mapping is not supported. */
MA_APIma_resultma_data_source_unmap(ma_data_source*pDataSource,ma_uint64frameCount);/* Returns MA_AT_END if the end has been reached. */
MA_APIma_resultma_data_source_get_length_in_pcm_frames(ma_data_source*pDataSource,ma_uint64*pLength);/* Returns MA_NOT_IMPLEMENTED if the length is unknown or cannot be determined. Decoders can return this. */
MA_APIma_resultma_audio_buffer_ref_unmap(ma_audio_buffer_ref*pAudioBufferRef,ma_uint64frameCount);/* Returns MA_AT_END if the end has been reached. This should be considered successful. */
MA_APIma_resultma_audio_buffer_unmap(ma_audio_buffer*pAudioBuffer,ma_uint64frameCount);/* Returns MA_AT_END if the end has been reached. This should be considered successful. */
@@ -4552,12 +4693,30 @@ you do your own synchronization.
#ifndef MA_NO_DECODING
typedefstructma_decoderma_decoder;
typedefsize_t(*ma_decoder_read_proc)(ma_decoder*pDecoder,void*pBufferOut,size_tbytesToRead);/* Returns the number of bytes read. */
typedefma_bool32(*ma_decoder_seek_proc)(ma_decoder*pDecoder,intbyteOffset,ma_seek_originorigin);/* Origin will never be ma_seek_origin_end. */
typedefma_uint64(*ma_decoder_read_pcm_frames_proc)(ma_decoder*pDecoder,void*pFramesOut,ma_uint64frameCount);/* Returns the number of frames read. Output data is in internal format. */
ma_data_source*pBackend;/* The decoding backend we'll be pulling data from. */
constma_decoding_backend_vtable*pBackendVTable;/* The vtable for the decoding backend. This needs to be stored so we can access the onUninit() callback. */
void*pBackendUserData;
ma_decoder_read_proconRead;
ma_decoder_seek_proconSeek;
ma_decoder_tell_proconTell;
void*pUserData;
ma_uint64readPointerInBytes;/* In internal encoded data. */
ma_uint64readPointerInPCMFrames;/* In output sample rate. Used for keeping track of how many frames are available for decoding. */
ma_formatinternalFormat;
ma_uint32internalChannels;
ma_uint32internalSampleRate;
ma_channelinternalChannelMap[MA_MAX_CHANNELS];
ma_formatoutputFormat;
ma_uint32outputChannels;
ma_uint32outputSampleRate;
ma_uint64readPointerInPCMFrames;/* In output sample rate. Used for keeping track of how many frames are available for decoding. */
ma_formatoutputFormat;
ma_uint32outputChannels;
ma_uint32outputSampleRate;
ma_channeloutputChannelMap[MA_MAX_CHANNELS];
ma_data_converterconverter;/* <-- Data conversion is achieved by running frames through this. */
/* TODO: Remove these when internal decoders are transferred over to the new backend system. */
typedef ma_uint64 (* ma_decoder_read_pcm_frames_proc) (ma_decoder* pDecoder, void* pFramesOut, ma_uint64 frameCount); /* Returns the number of frames read. Output data is in internal format. */