mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-22 00:06:59 +02:00
Update website.
This commit is contained in:
@@ -245,7 +245,7 @@ a.doc-navigation-l4 {
|
||||
<div style="background-color:#fff; padding-bottom:0em; border-top:solid 1px #003800; background-color:#eee;">
|
||||
<table border="0" style="margin:0 auto; width:100%; border-collapse:collapse; border:solid 0px #000; table-layout:fixed;"><tr>
|
||||
<td valign="top" style="width:20em; padding:0; margin:0; border-right:solid 0px #000;"><div style="position:relative; height:100%; width:100%; border:solid 0px #000; padding:0; margin:0;">
|
||||
<a href="../index.html" class="doc-navigation">Documentation Home</a><a href="../manual/index.html" class="doc-navigation">Programming Manual</a><a href="index.html" class="doc-navigation ">Examples</a><a href="custom_backend.html" class="doc-navigation doc-navigation-l1 doc-navigation-active">Custom Backend</a><a href="fixed_size_callback.html" class="doc-navigation doc-navigation-l1 ">Fixed Size Callback</a><a href="simple_capture.html" class="doc-navigation doc-navigation-l1 ">Simple Capture</a><a href="simple_duplex.html" class="doc-navigation doc-navigation-l1 ">Simple Duplex</a><a href="simple_enumeration.html" class="doc-navigation doc-navigation-l1 ">Simple Enumeration</a><a href="simple_loopback.html" class="doc-navigation doc-navigation-l1 ">Simple Loopback</a><a href="simple_looping.html" class="doc-navigation doc-navigation-l1 ">Simple Looping</a><a href="simple_mixing.html" class="doc-navigation doc-navigation-l1 ">Simple Mixing</a><a href="simple_playback.html" class="doc-navigation doc-navigation-l1 ">Simple Playback</a><a href="simple_playback_sine.html" class="doc-navigation doc-navigation-l1 ">Simple Playback Sine</a><a href="../api/index.html" class="doc-navigation" style="border-bottom:none;">API Reference</a></div></td><td valign="top" style="padding:1em; border-left:solid 1px #bbb;">
|
||||
<a href="../index.html" class="doc-navigation">Documentation Home</a><a href="../manual/index.html" class="doc-navigation">Programming Manual</a><a href="index.html" class="doc-navigation ">Examples</a><a href="custom_backend.html" class="doc-navigation doc-navigation-l1 doc-navigation-active">Custom Backend</a><a href="custom_decoder.html" class="doc-navigation doc-navigation-l1 ">Custom Decoder</a><a href="data_source_chaining.html" class="doc-navigation doc-navigation-l1 ">Data Source Chaining</a><a href="fixed_size_callback.html" class="doc-navigation doc-navigation-l1 ">Fixed Size Callback</a><a href="simple_capture.html" class="doc-navigation doc-navigation-l1 ">Simple Capture</a><a href="simple_duplex.html" class="doc-navigation doc-navigation-l1 ">Simple Duplex</a><a href="simple_enumeration.html" class="doc-navigation doc-navigation-l1 ">Simple Enumeration</a><a href="simple_loopback.html" class="doc-navigation doc-navigation-l1 ">Simple Loopback</a><a href="simple_looping.html" class="doc-navigation doc-navigation-l1 ">Simple Looping</a><a href="simple_mixing.html" class="doc-navigation doc-navigation-l1 ">Simple Mixing</a><a href="simple_playback.html" class="doc-navigation doc-navigation-l1 ">Simple Playback</a><a href="simple_playback_sine.html" class="doc-navigation doc-navigation-l1 ">Simple Playback Sine</a><a href="../api/index.html" class="doc-navigation" style="border-bottom:none;">API Reference</a></div></td><td valign="top" style="padding:1em; border-left:solid 1px #bbb;">
|
||||
<h1>Custom Backend</h1><p>
|
||||
This example show how a custom backend can be implemented.
|
||||
</p>
|
||||
@@ -293,9 +293,12 @@ backends would actually get hit. By default, the <span style="font-family:monosp
|
||||
<span style="color:#009900">/* Support SDL on everything. */</span>
|
||||
<span style="color:#666666">#define</span> MA_SUPPORT_SDL
|
||||
|
||||
<span style="color:#009900">/* Only enable SDL if it's hasn't been explicitly disabled (MA_NO_SDL) and it's supported at compile time (MA_SUPPORT_SDL). */</span>
|
||||
<span style="color:#666666">#if</span> !defined(MA_NO_SDL) && defined(MA_SUPPORT_SDL)
|
||||
<span style="color:#666666">#define</span> MA_ENABLE_SDL
|
||||
<span style="color:#009900">/*
|
||||
Only enable SDL if it's hasn't been explicitly disabled (MA_NO_SDL) or enabled (MA_ENABLE_SDL with
|
||||
MA_ENABLE_ONLY_SPECIFIC_BACKENDS) and it's supported at compile time (MA_SUPPORT_SDL).
|
||||
*/</span>
|
||||
<span style="color:#666666">#if</span> defined(MA_SUPPORT_SDL) && !defined(MA_NO_SDL) && (!defined(MA_ENABLE_ONLY_SPECIFIC_BACKENDS) || defined(MA_ENABLE_SDL))
|
||||
<span style="color:#666666">#define</span> MA_HAS_SDL
|
||||
<span style="color:#666666">#endif</span>
|
||||
|
||||
|
||||
@@ -331,9 +334,7 @@ backends would actually get hit. By default, the <span style="font-family:monosp
|
||||
|
||||
|
||||
|
||||
<span style="color:#666666">#if</span> defined(MA_ENABLE_SDL)
|
||||
<span style="color:#666666">#define</span> MA_HAS_SDL
|
||||
|
||||
<span style="color:#666666">#if</span> defined(MA_HAS_SDL)
|
||||
<span style="color:#009900">/* SDL headers are necessary if using compile-time linking. */</span>
|
||||
<span style="color:#666666">#ifdef</span> MA_NO_RUNTIME_LINKING
|
||||
<span style="color:#666666">#ifdef</span> __has_include
|
||||
@@ -587,7 +588,7 @@ ma_format ma_format_from_sdl(MA_SDL_AudioFormat format)
|
||||
|
||||
MA_ASSERT(pDeviceEx != NULL);
|
||||
|
||||
ma_device_handle_backend_data_callback((<span style="color:#0099cc">ma_device</span>*)pDeviceEx, pBuffer, NULL, (<span style="color:#0099cc">ma_uint32</span>)bufferSizeInBytes / ma_get_bytes_per_frame(pDeviceEx->device.capture.internalFormat, pDeviceEx->device.capture.internalChannels));
|
||||
ma_device_handle_backend_data_callback((<span style="color:#0099cc">ma_device</span>*)pDeviceEx, pBuffer, NULL, (<span style="color:#0099cc">ma_uint32</span>)bufferSizeInBytes / ma_get_bytes_per_frame(pDeviceEx->device.playback.internalFormat, pDeviceEx->device.playback.internalChannels));
|
||||
}
|
||||
|
||||
<span style="color:#0033ff">static</span> <span style="color:#0099cc">ma_result</span> ma_device_init_internal__sdl(ma_device_ex* pDeviceEx, <span style="color:#0033ff">const</span> <span style="color:#0099cc">ma_device_config</span>* pConfig, ma_device_descriptor* pDescriptor)
|
||||
@@ -622,22 +623,11 @@ ma_format ma_format_from_sdl(MA_SDL_AudioFormat format)
|
||||
|
||||
Note that options 2 and 3 require knowledge of the sample rate in order to convert it to a frame count. You should try to keep the
|
||||
calculation of the period size as accurate as possible, but sometimes it's just not practical so just use whatever you can.
|
||||
|
||||
A helper function called ma_calculate_buffer_size_in_frames_from_descriptor() is available to do all of this for you which is what
|
||||
we'll be using here.
|
||||
*/</span>
|
||||
<span style="color:#0033ff">if</span> (pDescriptor->periodSizeInFrames == 0) {
|
||||
<span style="color:#0033ff">if</span> (pDescriptor->periodSizeInMilliseconds == 0) {
|
||||
<span style="color:#009900">/* The default period size has been requested. I don't think SDL has an API to retrieve this, so just using defaults defined by miniaudio. */</span>
|
||||
<span style="color:#0033ff">if</span> (pConfig->performanceProfile == ma_performance_profile_low_latency) {
|
||||
pDescriptor->periodSizeInFrames = ma_calculate_buffer_size_in_frames_from_milliseconds(MA_DEFAULT_PERIOD_SIZE_IN_MILLISECONDS_LOW_LATENCY, pDescriptor->sampleRate);
|
||||
} <span style="color:#0033ff">else</span> {
|
||||
pDescriptor->periodSizeInFrames = ma_calculate_buffer_size_in_frames_from_milliseconds(MA_DEFAULT_PERIOD_SIZE_IN_MILLISECONDS_CONSERVATIVE, pDescriptor->sampleRate);
|
||||
}
|
||||
} <span style="color:#0033ff">else</span> {
|
||||
<span style="color:#009900">/* An explicit period size in milliseconds was specified. */</span>
|
||||
pDescriptor->periodSizeInFrames = ma_calculate_buffer_size_in_frames_from_milliseconds(pDescriptor->periodSizeInMilliseconds, pDescriptor->sampleRate);
|
||||
}
|
||||
} <span style="color:#0033ff">else</span> {
|
||||
<span style="color:#009900">/* Nothing to do here. An explicit period size in frames was specified. */</span>
|
||||
}
|
||||
pDescriptor->periodSizeInFrames = ma_calculate_buffer_size_in_frames_from_descriptor(pDescriptor, pDescriptor->sampleRate, pConfig->performanceProfile);
|
||||
|
||||
<span style="color:#009900">/* SDL wants the buffer size to be a power of 2 for some reason. */</span>
|
||||
<span style="color:#0033ff">if</span> (pDescriptor->periodSizeInFrames > 32768) {
|
||||
|
||||
Reference in New Issue
Block a user