Commit 35af204e authored by David Reid's avatar David Reid

Clean up whitespace.

parent 5d0705b3
...@@ -73,7 +73,7 @@ mal_uint32 on_send_frames_to_device(mal_device* pDevice, mal_uint32 frameCount, ...@@ -73,7 +73,7 @@ mal_uint32 on_send_frames_to_device(mal_device* pDevice, mal_uint32 frameCount,
if (pWav == NULL) { if (pWav == NULL) {
return 0; return 0;
} }
return (mal_uint32)drwav_read_s16(pWav, frameCount * pDevice->channels, (mal_int16*)pSamples) / pDevice->channels; return (mal_uint32)drwav_read_s16(pWav, frameCount * pDevice->channels, (mal_int16*)pSamples) / pDevice->channels;
} }
...@@ -93,12 +93,12 @@ int main(int argc, char** argv) ...@@ -93,12 +93,12 @@ int main(int argc, char** argv)
mal_context context; mal_context context;
if (mal_context_init(NULL, 0, NULL, &context) != MAL_SUCCESS) { if (mal_context_init(NULL, 0, NULL, &context) != MAL_SUCCESS) {
printf("Failed to initialize context.\n"); printf("Failed to initialize context.\n");
drwav_uninit(&wav); drwav_uninit(&wav);
return -3; return -3;
} }
mal_device_config config = mal_device_config_init_playback(mal_format_s16, wav.channels, wav.sampleRate, on_send_frames_to_device); mal_device_config config = mal_device_config_init_playback(mal_format_s16, wav.channels, wav.sampleRate, on_send_frames_to_device);
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.\n"); printf("Failed to open playback device.\n");
...@@ -114,14 +114,14 @@ int main(int argc, char** argv) ...@@ -114,14 +114,14 @@ int main(int argc, char** argv)
drwav_uninit(&wav); drwav_uninit(&wav);
return -5; return -5;
} }
printf("Press Enter to quit..."); printf("Press Enter to quit...");
getchar(); getchar();
mal_device_uninit(&device); mal_device_uninit(&device);
mal_context_uninit(&context); mal_context_uninit(&context);
drwav_uninit(&wav); drwav_uninit(&wav);
return 0; return 0;
} }
``` ```
......
...@@ -81,9 +81,9 @@ int main(int argc, char** argv) ...@@ -81,9 +81,9 @@ int main(int argc, char** argv)
} }
printf("Playback Devices (%d)\n", playbackDeviceCount); printf("Playback Devices (%d)\n", playbackDeviceCount);
for (mal_uint32 iDevice = 0; iDevice < playbackDeviceCount; ++iDevice) { for (mal_uint32 iDevice = 0; iDevice < playbackDeviceCount; ++iDevice) {
printf(" %u: %s\n", iDevice, pPlaybackDeviceInfos[iDevice].name); printf(" %u: %s\n", iDevice, pPlaybackDeviceInfos[iDevice].name);
} }
printf("\n"); printf("\n");
...@@ -103,9 +103,9 @@ int main(int argc, char** argv) ...@@ -103,9 +103,9 @@ int main(int argc, char** argv)
} }
printf("Capture Devices (%d)\n", captureDeviceCount); printf("Capture Devices (%d)\n", captureDeviceCount);
for (mal_uint32 iDevice = 0; iDevice < captureDeviceCount; ++iDevice) { for (mal_uint32 iDevice = 0; iDevice < captureDeviceCount; ++iDevice) {
printf(" %u: %s\n", iDevice, pCaptureDeviceInfos[iDevice].name); printf(" %u: %s\n", iDevice, pCaptureDeviceInfos[iDevice].name);
} }
// Open the device. // Open the device.
...@@ -169,10 +169,10 @@ int main(int argc, char** argv) ...@@ -169,10 +169,10 @@ int main(int argc, char** argv)
printf("Press Enter to quit..."); printf("Press Enter to quit...");
getchar(); getchar();
mal_device_uninit(&playbackDevice); mal_device_uninit(&playbackDevice);
mal_context_uninit(&context); mal_context_uninit(&context);
return 0; return 0;
} }
...@@ -22,96 +22,96 @@ ...@@ -22,96 +22,96 @@
mal_uint32 on_send_flac_frames_to_device(mal_device* pDevice, mal_uint32 frameCount, void* pSamples) mal_uint32 on_send_flac_frames_to_device(mal_device* pDevice, mal_uint32 frameCount, void* pSamples)
{ {
drflac* pFlac = (drflac*)pDevice->pUserData; drflac* pFlac = (drflac*)pDevice->pUserData;
if (pFlac == NULL) { if (pFlac == NULL) {
return 0; return 0;
} }
return (mal_uint32)drflac_read_s16(pFlac, frameCount * pDevice->channels, (mal_int16*)pSamples) / pDevice->channels; return (mal_uint32)drflac_read_s16(pFlac, frameCount * pDevice->channels, (mal_int16*)pSamples) / pDevice->channels;
} }
mal_uint32 on_send_wav_frames_to_device(mal_device* pDevice, mal_uint32 frameCount, void* pSamples) mal_uint32 on_send_wav_frames_to_device(mal_device* pDevice, mal_uint32 frameCount, void* pSamples)
{ {
drwav* pWav = (drwav*)pDevice->pUserData; drwav* pWav = (drwav*)pDevice->pUserData;
if (pWav == NULL) { if (pWav == NULL) {
return 0; return 0;
} }
return (mal_uint32)drwav_read_s16(pWav, frameCount * pDevice->channels, (mal_int16*)pSamples) / pDevice->channels; return (mal_uint32)drwav_read_s16(pWav, frameCount * pDevice->channels, (mal_int16*)pSamples) / pDevice->channels;
} }
mal_uint32 on_send_vorbis_frames_to_device(mal_device* pDevice, mal_uint32 frameCount, void* pSamples) mal_uint32 on_send_vorbis_frames_to_device(mal_device* pDevice, mal_uint32 frameCount, void* pSamples)
{ {
stb_vorbis* pVorbis = (stb_vorbis*)pDevice->pUserData; stb_vorbis* pVorbis = (stb_vorbis*)pDevice->pUserData;
if (pVorbis == NULL) { if (pVorbis == NULL) {
return 0; return 0;
} }
return (mal_uint32)stb_vorbis_get_samples_short_interleaved(pVorbis, pDevice->channels, (short*)pSamples, frameCount * pDevice->channels) / pDevice->channels; return (mal_uint32)stb_vorbis_get_samples_short_interleaved(pVorbis, pDevice->channels, (short*)pSamples, frameCount * pDevice->channels) / pDevice->channels;
} }
mal_uint32 on_send_mod_frames_to_device(mal_device* pDevice, mal_uint32 frameCount, void* pSamples) mal_uint32 on_send_mod_frames_to_device(mal_device* pDevice, mal_uint32 frameCount, void* pSamples)
{ {
jar_mod_context_t* pMod = (jar_mod_context_t*)pDevice->pUserData; jar_mod_context_t* pMod = (jar_mod_context_t*)pDevice->pUserData;
if (pMod == NULL) { if (pMod == NULL) {
return 0; return 0;
} }
jar_mod_fillbuffer(pMod, (mal_int16*)pSamples, frameCount, 0); jar_mod_fillbuffer(pMod, (mal_int16*)pSamples, frameCount, 0);
return frameCount; return frameCount;
} }
mal_uint32 on_send_xm_frames_to_device(mal_device* pDevice, mal_uint32 frameCount, void* pSamples) mal_uint32 on_send_xm_frames_to_device(mal_device* pDevice, mal_uint32 frameCount, void* pSamples)
{ {
jar_xm_context_t* pXM = (jar_xm_context_t*)pDevice->pUserData; jar_xm_context_t* pXM = (jar_xm_context_t*)pDevice->pUserData;
if (pXM == NULL) { if (pXM == NULL) {
return 0; return 0;
} }
jar_xm_generate_samples_16bit(pXM, (short*)pSamples, frameCount); jar_xm_generate_samples_16bit(pXM, (short*)pSamples, frameCount);
return frameCount; return frameCount;
} }
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
int exitcode = 0; int exitcode = 0;
if (argc < 2) { if (argc < 2) {
printf("No input file."); printf("No input file.");
return -1; return -1;
} }
enum { UNK, FLAC, WAV, VORBIS, MOD, XM } type = UNK; enum { UNK, FLAC, WAV, VORBIS, MOD, XM } type = UNK;
jar_mod_context_t mod; jar_mod_context_t mod;
jar_mod_init(&mod); jar_mod_init(&mod);
jar_xm_context_t *xm = 0; jar_xm_context_t *xm = 0;
drflac* flac = NULL; drflac* flac = NULL;
drwav* wav = NULL; drwav* wav = NULL;
stb_vorbis* vorbis = NULL; stb_vorbis* vorbis = NULL;
if ( type == UNK && (flac = drflac_open_file(argv[1])) != NULL) type = FLAC; if ( type == UNK && (flac = drflac_open_file(argv[1])) != NULL) type = FLAC;
if ( type == UNK && (wav = drwav_open_file(argv[1])) != NULL) type = WAV; if ( type == UNK && (wav = drwav_open_file(argv[1])) != NULL) type = WAV;
if ( type == UNK && (vorbis = stb_vorbis_open_filename(argv[1], NULL, NULL)) != NULL) type = VORBIS; if ( type == UNK && (vorbis = stb_vorbis_open_filename(argv[1], NULL, NULL)) != NULL) type = VORBIS;
if ( type == UNK && (jar_xm_create_context_from_file(&xm, 48000, argv[1]) == 0)) type = XM; if ( type == UNK && (jar_xm_create_context_from_file(&xm, 48000, argv[1]) == 0)) type = XM;
if ( type == UNK && (jar_mod_load_file(&mod, argv[1]) != 0) ) type = MOD; if ( type == UNK && (jar_mod_load_file(&mod, argv[1]) != 0) ) type = MOD;
if( type == UNK ) { if( type == UNK ) {
printf("Not a valid input file."); printf("Not a valid input file.");
exitcode = -2; exitcode = -2;
goto end; goto end;
} }
mal_context context; mal_context context;
if (mal_context_init(NULL, 0, NULL, &context) != MAL_SUCCESS) { if (mal_context_init(NULL, 0, NULL, &context) != MAL_SUCCESS) {
printf("Failed to initialize context."); printf("Failed to initialize context.");
exitcode = -3; exitcode = -3;
goto end; goto end;
} }
void* pUserData = NULL; void* pUserData = NULL;
mal_device_config config; mal_device_config config;
switch (type) switch (type)
{ {
case FLAC: case FLAC:
...@@ -140,34 +140,34 @@ int main(int argc, char** argv) ...@@ -140,34 +140,34 @@ int main(int argc, char** argv)
break; break;
} }
mal_device device; mal_device device;
if (mal_device_init(&context, mal_device_type_playback, NULL, &config, pUserData, &device) != MAL_SUCCESS) { if (mal_device_init(&context, mal_device_type_playback, NULL, &config, pUserData, &device) != MAL_SUCCESS) {
printf("Failed to open playback device."); printf("Failed to open playback device.");
mal_context_uninit(&context); mal_context_uninit(&context);
exitcode = -4; exitcode = -4;
goto end; goto end;
} }
if (mal_device_start(&device) != MAL_SUCCESS) { if (mal_device_start(&device) != MAL_SUCCESS) {
printf("Failed to start playback device.\n"); printf("Failed to start playback device.\n");
mal_device_uninit(&device); mal_device_uninit(&device);
mal_context_uninit(&context); mal_context_uninit(&context);
exitcode = -4; exitcode = -4;
goto end; goto end;
} }
printf("Press Enter to quit..."); printf("Press Enter to quit...");
getchar(); getchar();
mal_device_uninit(&device); mal_device_uninit(&device);
mal_context_uninit(&context); mal_context_uninit(&context);
end:; end:;
drflac_close(flac); drflac_close(flac);
drwav_close(wav); drwav_close(wav);
stb_vorbis_close(vorbis); stb_vorbis_close(vorbis);
jar_mod_unload(&mod); jar_mod_unload(&mod);
if(xm) jar_xm_free_context(xm); if(xm) jar_xm_free_context(xm);
return exitcode; return exitcode;
} }
...@@ -15,7 +15,7 @@ mal_uint32 playbackSample = 0; ...@@ -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) {
...@@ -74,8 +74,8 @@ int main() ...@@ -74,8 +74,8 @@ int main()
getchar(); getchar();
mal_device_uninit(&captureDevice); mal_device_uninit(&captureDevice);
printf("Playing...\n"); printf("Playing...\n");
mal_device playbackDevice; mal_device playbackDevice;
......
...@@ -14,40 +14,40 @@ int main(int argc, char** argv) ...@@ -14,40 +14,40 @@ int main(int argc, char** argv)
return -2; return -2;
} }
mal_device_info infos[32]; mal_device_info infos[32];
mal_uint32 infoCount = sizeof(infos) / sizeof(infos[0]); mal_uint32 infoCount = sizeof(infos) / sizeof(infos[0]);
// Playback devices. // Playback devices.
mal_result result = mal_enumerate_devices(&context, mal_device_type_playback, &infoCount, infos); mal_result result = mal_enumerate_devices(&context, mal_device_type_playback, &infoCount, infos);
if (result != MAL_SUCCESS) { if (result != MAL_SUCCESS) {
printf("Failed to enumerate playback devices."); printf("Failed to enumerate playback devices.");
mal_context_uninit(&context); mal_context_uninit(&context);
return -3; return -3;
} }
printf("Playback Devices\n"); printf("Playback Devices\n");
for (mal_uint32 iDevice = 0; iDevice < infoCount; ++iDevice) { for (mal_uint32 iDevice = 0; iDevice < infoCount; ++iDevice) {
printf(" %u: %s\n", iDevice, infos[iDevice].name); printf(" %u: %s\n", iDevice, infos[iDevice].name);
} }
printf("\n"); printf("\n");
// Capture devices. // Capture devices.
result = mal_enumerate_devices(&context, mal_device_type_capture, &infoCount, infos); result = mal_enumerate_devices(&context, mal_device_type_capture, &infoCount, infos);
if (result != MAL_SUCCESS) { if (result != MAL_SUCCESS) {
printf("Failed to enumerate capture devices."); printf("Failed to enumerate capture devices.");
mal_context_uninit(&context); mal_context_uninit(&context);
return -4; return -4;
} }
printf("Capture Devices\n"); printf("Capture Devices\n");
for (mal_uint32 iDevice = 0; iDevice < infoCount; ++iDevice) { for (mal_uint32 iDevice = 0; iDevice < infoCount; ++iDevice) {
printf(" %u: %s\n", iDevice, infos[iDevice].name); printf(" %u: %s\n", iDevice, infos[iDevice].name);
} }
mal_context_uninit(&context); mal_context_uninit(&context);
return 0; return 0;
} }
...@@ -13,7 +13,7 @@ mal_uint32 on_send_frames_to_device(mal_device* pDevice, mal_uint32 frameCount, ...@@ -13,7 +13,7 @@ mal_uint32 on_send_frames_to_device(mal_device* pDevice, mal_uint32 frameCount,
if (pWav == NULL) { if (pWav == NULL) {
return 0; return 0;
} }
return (mal_uint32)drwav_read_s16(pWav, frameCount * pDevice->channels, (mal_int16*)pSamples) / pDevice->channels; return (mal_uint32)drwav_read_s16(pWav, frameCount * pDevice->channels, (mal_int16*)pSamples) / pDevice->channels;
} }
...@@ -33,12 +33,12 @@ int main(int argc, char** argv) ...@@ -33,12 +33,12 @@ int main(int argc, char** argv)
mal_context context; mal_context context;
if (mal_context_init(NULL, 0, NULL, &context) != MAL_SUCCESS) { if (mal_context_init(NULL, 0, NULL, &context) != MAL_SUCCESS) {
printf("Failed to initialize context.\n"); printf("Failed to initialize context.\n");
drwav_uninit(&wav); drwav_uninit(&wav);
return -3; return -3;
} }
mal_device_config config = mal_device_config_init_playback(mal_format_s16, wav.channels, wav.sampleRate, on_send_frames_to_device); mal_device_config config = mal_device_config_init_playback(mal_format_s16, wav.channels, wav.sampleRate, on_send_frames_to_device);
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.\n"); printf("Failed to open playback device.\n");
...@@ -54,13 +54,13 @@ int main(int argc, char** argv) ...@@ -54,13 +54,13 @@ int main(int argc, char** argv)
drwav_uninit(&wav); drwav_uninit(&wav);
return -5; return -5;
} }
printf("Press Enter to quit..."); printf("Press Enter to quit...");
getchar(); getchar();
mal_device_uninit(&device); mal_device_uninit(&device);
mal_context_uninit(&context); mal_context_uninit(&context);
drwav_uninit(&wav); drwav_uninit(&wav);
return 0; return 0;
} }
This diff is collapsed.
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