mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-22 00:06:59 +02:00
Clean up whitespace.
This commit is contained in:
@@ -93,7 +93,7 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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)
|
|||||||
}
|
}
|
||||||
|
|
||||||
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.
|
||||||
|
|||||||
+69
-69
@@ -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)
|
|||||||
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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,38 +14,38 @@ 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);
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user