@@ -95,10 +95,10 @@ MA_ENABLE_ONLY_SPECIFIC_BACKENDS) and it's supported at compile time (MA_SUPPORT
95
95
96
96
typedef int (* MA_PFN_SDL_InitSubSystem )(ma_uint32 flags );
97
97
typedef void (* MA_PFN_SDL_QuitSubSystem )(ma_uint32 flags );
98
- typedef int (* MA_PFN_SDL_GetDefaultAudioInfo )(char * * name , MA_SDL_AudioSpec * spec , int iscapture );
99
98
typedef int (* MA_PFN_SDL_GetNumAudioDevices )(int iscapture );
100
- typedef const char * (* MA_PFN_SDL_GetAudioDeviceName )( int index , int iscapture );
99
+ typedef int (* MA_PFN_SDL_GetDefaultAudioInfo )( char * * name , MA_SDL_AudioSpec * spec , int iscapture );
101
100
typedef int (* MA_PFN_SDL_GetAudioDeviceSpec )(int index , int iscapture , MA_SDL_AudioSpec * spec );
101
+ typedef const char * (* MA_PFN_SDL_GetAudioDeviceName )(int index , int iscapture );
102
102
typedef void (* MA_PFN_SDL_CloseAudioDevice )(MA_SDL_AudioDeviceID dev );
103
103
typedef MA_SDL_AudioDeviceID (* MA_PFN_SDL_OpenAudioDevice )(const char * device , int iscapture , const MA_SDL_AudioSpec * desired , MA_SDL_AudioSpec * obtained , int allowed_changes );
104
104
typedef void (* MA_PFN_SDL_PauseAudioDevice )(MA_SDL_AudioDeviceID dev , int pause_on );
@@ -108,10 +108,10 @@ typedef struct
108
108
ma_handle hSDL ; /* A handle to the SDL2 shared object. We dynamically load function pointers at runtime so we can avoid linking. */
109
109
MA_PFN_SDL_InitSubSystem SDL_InitSubSystem ;
110
110
MA_PFN_SDL_QuitSubSystem SDL_QuitSubSystem ;
111
- MA_PFN_SDL_GetDefaultAudioInfo SDL_GetDefaultAudioInfo ;
112
111
MA_PFN_SDL_GetNumAudioDevices SDL_GetNumAudioDevices ;
113
- MA_PFN_SDL_GetAudioDeviceName SDL_GetAudioDeviceName ;
112
+ MA_PFN_SDL_GetDefaultAudioInfo SDL_GetDefaultAudioInfo ;
114
113
MA_PFN_SDL_GetAudioDeviceSpec SDL_GetAudioDeviceSpec ;
114
+ MA_PFN_SDL_GetAudioDeviceName SDL_GetAudioDeviceName ;
115
115
MA_PFN_SDL_CloseAudioDevice SDL_CloseAudioDevice ;
116
116
MA_PFN_SDL_OpenAudioDevice SDL_OpenAudioDevice ;
117
117
MA_PFN_SDL_PauseAudioDevice SDL_PauseAudioDevice ;
@@ -225,10 +225,10 @@ static ma_result ma_context_init__sdl(ma_context* pContext, const void* pContext
225
225
/* Now that we have the handle to the shared object we can go ahead and load some function pointers. */
226
226
pContextStateSDL -> SDL_InitSubSystem = (MA_PFN_SDL_InitSubSystem )ma_dlsym (pLog , pContextStateSDL -> hSDL , "SDL_InitSubSystem" );
227
227
pContextStateSDL -> SDL_QuitSubSystem = (MA_PFN_SDL_QuitSubSystem )ma_dlsym (pLog , pContextStateSDL -> hSDL , "SDL_QuitSubSystem" );
228
- pContextStateSDL -> SDL_GetDefaultAudioInfo = (MA_PFN_SDL_GetDefaultAudioInfo )ma_dlsym (pLog , pContextStateSDL -> hSDL , "SDL_GetDefaultAudioInfo" );
229
228
pContextStateSDL -> SDL_GetNumAudioDevices = (MA_PFN_SDL_GetNumAudioDevices )ma_dlsym (pLog , pContextStateSDL -> hSDL , "SDL_GetNumAudioDevices" );
230
- pContextStateSDL -> SDL_GetAudioDeviceName = (MA_PFN_SDL_GetAudioDeviceName )ma_dlsym (pLog , pContextStateSDL -> hSDL , "SDL_GetAudioDeviceName " );
229
+ pContextStateSDL -> SDL_GetDefaultAudioInfo = (MA_PFN_SDL_GetDefaultAudioInfo )ma_dlsym (pLog , pContextStateSDL -> hSDL , "SDL_GetDefaultAudioInfo " );
231
230
pContextStateSDL -> SDL_GetAudioDeviceSpec = (MA_PFN_SDL_GetAudioDeviceSpec )ma_dlsym (pLog , pContextStateSDL -> hSDL , "SDL_GetAudioDeviceSpec" );
231
+ pContextStateSDL -> SDL_GetAudioDeviceName = (MA_PFN_SDL_GetAudioDeviceName )ma_dlsym (pLog , pContextStateSDL -> hSDL , "SDL_GetAudioDeviceName" );
232
232
pContextStateSDL -> SDL_CloseAudioDevice = (MA_PFN_SDL_CloseAudioDevice )ma_dlsym (pLog , pContextStateSDL -> hSDL , "SDL_CloseAudioDevice" );
233
233
pContextStateSDL -> SDL_OpenAudioDevice = (MA_PFN_SDL_OpenAudioDevice )ma_dlsym (pLog , pContextStateSDL -> hSDL , "SDL_OpenAudioDevice" );
234
234
pContextStateSDL -> SDL_PauseAudioDevice = (MA_PFN_SDL_PauseAudioDevice )ma_dlsym (pLog , pContextStateSDL -> hSDL , "SDL_PauseAudioDevice" );
@@ -237,10 +237,15 @@ static ma_result ma_context_init__sdl(ma_context* pContext, const void* pContext
237
237
{
238
238
pContextStateSDL -> SDL_InitSubSystem = SDL_InitSubSystem ;
239
239
pContextStateSDL -> SDL_QuitSubSystem = SDL_QuitSubSystem ;
240
- pContextStateSDL -> SDL_GetDefaultAudioInfo = SDL_GetDefaultAudioInfo ;
241
240
pContextStateSDL -> SDL_GetNumAudioDevices = SDL_GetNumAudioDevices ;
242
- pContextStateSDL -> SDL_GetAudioDeviceName = SDL_GetAudioDeviceName ;
241
+ #ifndef __EMSCRIPTEN__
242
+ pContextStateSDL -> SDL_GetDefaultAudioInfo = SDL_GetDefaultAudioInfo ;
243
243
pContextStateSDL -> SDL_GetAudioDeviceSpec = SDL_GetAudioDeviceSpec ;
244
+ #else
245
+ pContextStateSDL -> SDL_GetDefaultAudioInfo = NULL ;
246
+ pContextStateSDL -> SDL_GetAudioDeviceSpec = NULL ;
247
+ #endif
248
+ pContextStateSDL -> SDL_GetAudioDeviceName = SDL_GetAudioDeviceName ;
244
249
pContextStateSDL -> SDL_CloseAudioDevice = SDL_CloseAudioDevice ;
245
250
pContextStateSDL -> SDL_OpenAudioDevice = SDL_OpenAudioDevice ;
246
251
pContextStateSDL -> SDL_PauseAudioDevice = SDL_PauseAudioDevice ;
@@ -318,8 +323,13 @@ static ma_result ma_context_enumerate_devices__sdl(ma_context* pContext, ma_enum
318
323
ma_strncpy_s (deviceInfo .name , sizeof (deviceInfo .name ), pContextStateSDL -> SDL_GetAudioDeviceName (iDevice , 0 ), (size_t )-1 );
319
324
320
325
/* Data Format. */
321
- if (pContextStateSDL -> SDL_GetAudioDeviceSpec (iDevice , 0 , & audioSpec ) == 0 ) {
322
- ma_add_native_format_from_AudioSpec__sdl (& deviceInfo , & audioSpec );
326
+ if (pContextStateSDL -> SDL_GetAudioDeviceSpec != NULL ) {
327
+ if (pContextStateSDL -> SDL_GetAudioDeviceSpec (iDevice , 0 , & audioSpec ) == 0 ) {
328
+ ma_add_native_format_from_AudioSpec__sdl (& deviceInfo , & audioSpec );
329
+ }
330
+ } else {
331
+ /* No way to retrieve the data format. Just report support for everything. */
332
+ deviceInfo .nativeDataFormatCount = 1 ;
323
333
}
324
334
325
335
cbResult = callback (ma_device_type_playback , & deviceInfo , pCallbackUserData );
@@ -350,8 +360,13 @@ static ma_result ma_context_enumerate_devices__sdl(ma_context* pContext, ma_enum
350
360
ma_strncpy_s (deviceInfo .name , sizeof (deviceInfo .name ), pContextStateSDL -> SDL_GetAudioDeviceName (iDevice , 1 ), (size_t )-1 );
351
361
352
362
/* Data Format. */
353
- if (pContextStateSDL -> SDL_GetAudioDeviceSpec (iDevice , 1 , & audioSpec ) == 0 ) {
354
- ma_add_native_format_from_AudioSpec__sdl (& deviceInfo , & audioSpec );
363
+ if (pContextStateSDL -> SDL_GetAudioDeviceSpec != NULL ) {
364
+ if (pContextStateSDL -> SDL_GetAudioDeviceSpec (iDevice , 1 , & audioSpec ) == 0 ) {
365
+ ma_add_native_format_from_AudioSpec__sdl (& deviceInfo , & audioSpec );
366
+ }
367
+ } else {
368
+ /* No way to retrieve the data format. Just report support for everything. */
369
+ deviceInfo .nativeDataFormatCount = 1 ;
355
370
}
356
371
357
372
cbResult = callback (ma_device_type_capture , & deviceInfo , pCallbackUserData );
0 commit comments