mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-22 00:06:59 +02:00
Add syntax highlighting to documentation.
This commit is contained in:
@@ -250,44 +250,44 @@ This example uses a decoder as the data source. Decoders can be used with the <s
|
||||
supports looping via the <span style="font-family:monospace;">ma_data_source_read_pcm_frames()</span> API. To use it, all you need to do is pass a pointer to the
|
||||
decoder straight into <span style="font-family:monospace;">ma_data_source_read_pcm_frames()</span> and it will just work.</p>
|
||||
<div style="font-family:monospace; border:solid 1px #003800; border-left:solid 0.5em #003800; margin:1em 0em;"><pre style="margin:0.5em 1em; padding:0; line-height:125%">
|
||||
#define MINIAUDIO_IMPLEMENTATION
|
||||
#include "../miniaudio.h"
|
||||
<span style="color:#666666">#define</span> MINIAUDIO_IMPLEMENTATION
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300">"../miniaudio.h"</span>
|
||||
|
||||
#include <stdio.h>
|
||||
<span style="color:#666666">#include</span> <span style="color:#cc3300"><stdio.h></span>
|
||||
|
||||
void data_callback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount)
|
||||
<span style="color:#0033ff">void</span> data_callback(<span style="color:#0099cc">ma_device</span>* pDevice, <span style="color:#0033ff">void</span>* pOutput, <span style="color:#0033ff">const</span> <span style="color:#0033ff">void</span>* pInput, <span style="color:#0099cc">ma_uint32</span> frameCount)
|
||||
{
|
||||
ma_bool32 isLooping = MA_TRUE;
|
||||
<span style="color:#0099cc">ma_bool32</span> isLooping = MA_TRUE;
|
||||
|
||||
ma_decoder* pDecoder = (ma_decoder*)pDevice->pUserData;
|
||||
if (pDecoder == NULL) {
|
||||
return;
|
||||
<span style="color:#0099cc">ma_decoder</span>* pDecoder = (<span style="color:#0099cc">ma_decoder</span>*)pDevice->pUserData;
|
||||
<span style="color:#0033ff">if</span> (pDecoder == NULL) {
|
||||
<span style="color:#0033ff">return</span>;
|
||||
}
|
||||
|
||||
/*
|
||||
<span style="color:#009900">/*
|
||||
A decoder is a data source which means you can seemlessly plug it into the ma_data_source API. We can therefore take advantage
|
||||
of the "loop" parameter of ma_data_source_read_pcm_frames() to handle looping for us.
|
||||
*/
|
||||
*/</span>
|
||||
ma_data_source_read_pcm_frames(pDecoder, pOutput, frameCount, NULL, isLooping);
|
||||
|
||||
(void)pInput;
|
||||
(<span style="color:#0033ff">void</span>)pInput;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
<span style="color:#0033ff">int</span> main(<span style="color:#0033ff">int</span> argc, <span style="color:#0033ff">char</span>** argv)
|
||||
{
|
||||
ma_result result;
|
||||
ma_decoder decoder;
|
||||
ma_device_config deviceConfig;
|
||||
ma_device device;
|
||||
<span style="color:#0099cc">ma_result</span> result;
|
||||
<span style="color:#0099cc">ma_decoder</span> decoder;
|
||||
<span style="color:#0099cc">ma_device_config</span> deviceConfig;
|
||||
<span style="color:#0099cc">ma_device</span> device;
|
||||
|
||||
if (argc < 2) {
|
||||
printf("No input file.\n");
|
||||
return -1;
|
||||
<span style="color:#0033ff">if</span> (argc < 2) {
|
||||
printf(<span style="color:#cc3300">"No input file.\n"</span>);
|
||||
<span style="color:#0033ff">return</span> -1;
|
||||
}
|
||||
|
||||
result = ma_decoder_init_file(argv[1], NULL, &decoder);
|
||||
if (result != MA_SUCCESS) {
|
||||
return -2;
|
||||
<span style="color:#0033ff">if</span> (result != MA_SUCCESS) {
|
||||
<span style="color:#0033ff">return</span> -2;
|
||||
}
|
||||
|
||||
deviceConfig = ma_device_config_init(ma_device_type_playback);
|
||||
@@ -297,26 +297,26 @@ int main(int argc, char** argv)
|
||||
deviceConfig.dataCallback = data_callback;
|
||||
deviceConfig.pUserData = &decoder;
|
||||
|
||||
if (ma_device_init(NULL, &deviceConfig, &device) != MA_SUCCESS) {
|
||||
printf("Failed to open playback device.\n");
|
||||
<span style="color:#0033ff">if</span> (ma_device_init(NULL, &deviceConfig, &device) != MA_SUCCESS) {
|
||||
printf(<span style="color:#cc3300">"Failed to open playback device.\n"</span>);
|
||||
ma_decoder_uninit(&decoder);
|
||||
return -3;
|
||||
<span style="color:#0033ff">return</span> -3;
|
||||
}
|
||||
|
||||
if (ma_device_start(&device) != MA_SUCCESS) {
|
||||
printf("Failed to start playback device.\n");
|
||||
<span style="color:#0033ff">if</span> (ma_device_start(&device) != MA_SUCCESS) {
|
||||
printf(<span style="color:#cc3300">"Failed to start playback device.\n"</span>);
|
||||
ma_device_uninit(&device);
|
||||
ma_decoder_uninit(&decoder);
|
||||
return -4;
|
||||
<span style="color:#0033ff">return</span> -4;
|
||||
}
|
||||
|
||||
printf("Press Enter to quit...");
|
||||
printf(<span style="color:#cc3300">"Press Enter to quit..."</span>);
|
||||
getchar();
|
||||
|
||||
ma_device_uninit(&device);
|
||||
ma_decoder_uninit(&decoder);
|
||||
|
||||
return 0;
|
||||
<span style="color:#0033ff">return</span> 0;
|
||||
}
|
||||
</pre></div></td>
|
||||
</tr></table>
|
||||
|
||||
Reference in New Issue
Block a user