mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-23 08:44:04 +02:00
Tabs to spaces.
This commit is contained in:
+14
-12
@@ -15,7 +15,7 @@ mal_uint32 playbackSample = 0;
|
|||||||
void on_recv_frames(mal_device* pDevice, mal_uint32 frameCount, const void* pSamples)
|
void on_recv_frames(mal_device* pDevice, mal_uint32 frameCount, const void* pSamples)
|
||||||
{
|
{
|
||||||
mal_uint32 sampleCount = frameCount * pDevice->channels;
|
mal_uint32 sampleCount = frameCount * pDevice->channels;
|
||||||
|
|
||||||
mal_uint32 newCapturedSampleCount = capturedSampleCount + sampleCount;
|
mal_uint32 newCapturedSampleCount = capturedSampleCount + sampleCount;
|
||||||
mal_int16* pNewCapturedSamples = (mal_int16*)realloc(pCapturedSamples, newCapturedSampleCount * sizeof(mal_int16));
|
mal_int16* pNewCapturedSamples = (mal_int16*)realloc(pCapturedSamples, newCapturedSampleCount * sizeof(mal_int16));
|
||||||
if (pNewCapturedSamples == NULL) {
|
if (pNewCapturedSamples == NULL) {
|
||||||
@@ -53,15 +53,17 @@ int main()
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
mal_device_config config;
|
mal_device_config config;
|
||||||
config.format = mal_format_s16;
|
config.format = mal_format_s16;
|
||||||
config.channels = 2;
|
config.channels = 2;
|
||||||
config.sampleRate = 48000;
|
config.sampleRate = 48000;
|
||||||
config.bufferSizeInFrames = 0; // Use default.
|
config.channelMap[0] = MAL_CHANNEL_FRONT_LEFT;
|
||||||
config.periods = 0; // Use default.
|
config.channelMap[1] = MAL_CHANNEL_FRONT_RIGHT;
|
||||||
config.onRecvCallback = on_recv_frames;
|
config.bufferSizeInFrames = 0; // Use default.
|
||||||
config.onSendCallback = on_send_frames;
|
config.periods = 0; // Use default.
|
||||||
config.onStopCallback = NULL;
|
config.onRecvCallback = on_recv_frames;
|
||||||
|
config.onSendCallback = on_send_frames;
|
||||||
|
config.onStopCallback = NULL;
|
||||||
config.onLogCallback = NULL;
|
config.onLogCallback = NULL;
|
||||||
|
|
||||||
printf("Recording...\n");
|
printf("Recording...\n");
|
||||||
@@ -89,9 +91,9 @@ int main()
|
|||||||
mal_device_start(&playbackDevice);
|
mal_device_start(&playbackDevice);
|
||||||
|
|
||||||
printf("Press Enter to quit...\n");
|
printf("Press Enter to quit...\n");
|
||||||
getchar();
|
getchar();
|
||||||
mal_device_uninit(&playbackDevice);
|
mal_device_uninit(&playbackDevice);
|
||||||
|
|
||||||
mal_context_uninit(&context);
|
mal_context_uninit(&context);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
+12
-10
@@ -37,17 +37,19 @@ int main(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// In this example we use the default playback device with a default buffer size and period count.
|
// In this example we use the default playback device with a default buffer size and period count.
|
||||||
mal_device_config config;
|
mal_device_config config;
|
||||||
config.format = mal_format_s16;
|
config.format = mal_format_s16;
|
||||||
config.channels = wav.channels;
|
config.channels = wav.channels;
|
||||||
config.sampleRate = wav.sampleRate;
|
config.sampleRate = wav.sampleRate;
|
||||||
config.bufferSizeInFrames = 0; // Use default.
|
config.channelMap[0] = MAL_CHANNEL_FRONT_LEFT;
|
||||||
config.periods = 0; // Use default.
|
config.channelMap[1] = MAL_CHANNEL_FRONT_RIGHT;
|
||||||
config.onRecvCallback = NULL; // Not used for playback.
|
config.bufferSizeInFrames = 0; // Use default.
|
||||||
config.onSendCallback = on_send_frames_to_device;
|
config.periods = 0; // Use default.
|
||||||
config.onStopCallback = NULL;
|
config.onRecvCallback = NULL; // Not used for playback.
|
||||||
|
config.onSendCallback = on_send_frames_to_device;
|
||||||
|
config.onStopCallback = NULL;
|
||||||
config.onLogCallback = NULL;
|
config.onLogCallback = NULL;
|
||||||
|
|
||||||
mal_device device;
|
mal_device device;
|
||||||
if (mal_device_init(&context, mal_device_type_playback, NULL, &config, &wav, &device) != MAL_SUCCESS) {
|
if (mal_device_init(&context, mal_device_type_playback, NULL, &config, &wav, &device) != MAL_SUCCESS) {
|
||||||
printf("Failed to open playback device.");
|
printf("Failed to open playback device.");
|
||||||
|
|||||||
Reference in New Issue
Block a user