Skip to content

Commit

Permalink
apple: don't allow opening sdl2 microphone if not using sdl2 audio (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
warmenhoven committed Sep 11, 2024
1 parent 14b1af9 commit 6e2f0a4
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 0 deletions.
10 changes: 10 additions & 0 deletions audio/drivers_microphone/sdl_microphone.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,16 @@ static void *sdl_microphone_open_mic(void *driver_context,
SDL_AudioSpec desired_spec = {0};
void *tmp = NULL;

#if __APPLE__
if (!string_is_equal(audio_driver_get_ident(), "sdl2"))
{
runloop_msg_queue_push(
msg_hash_to_str(MSG_SDL2_MIC_NEEDS_SDL2_AUDIO), 1, 100, true, NULL,
MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_WARNING);
return NULL;
}
#endif

/* If the audio driver wasn't initialized yet... */
if (!SDL_WasInit(SDL_INIT_AUDIO))
{
Expand Down
5 changes: 5 additions & 0 deletions configuration.c
Original file line number Diff line number Diff line change
Expand Up @@ -521,10 +521,15 @@ static const enum audio_driver_enum AUDIO_DEFAULT_DRIVER = AUDIO_AUDIOIO;
static const enum audio_driver_enum AUDIO_DEFAULT_DRIVER = AUDIO_OSS;
#elif defined(HAVE_JACK)
static const enum audio_driver_enum AUDIO_DEFAULT_DRIVER = AUDIO_JACK;
#elif defined(HAVE_COREAUDIO3) || defined(HAVE_COREAUDIO)
/* SDL microphone does not play well with coreaudio audio driver */
#if defined(HAVE_SDL2) && defined(HAVE_MICROPHONE)
static const enum audio_driver_enum AUDIO_DEFAULT_DRIVER = AUDIO_SDL2;
#elif defined(HAVE_COREAUDIO3)
static const enum audio_driver_enum AUDIO_DEFAULT_DRIVER = AUDIO_COREAUDIO3;
#elif defined(HAVE_COREAUDIO)
static const enum audio_driver_enum AUDIO_DEFAULT_DRIVER = AUDIO_COREAUDIO;
#endif
#elif defined(HAVE_WASAPI)
static const enum audio_driver_enum AUDIO_DEFAULT_DRIVER = AUDIO_WASAPI;
#elif defined(HAVE_XAUDIO)
Expand Down
4 changes: 4 additions & 0 deletions intl/msg_hash_us.h
Original file line number Diff line number Diff line change
Expand Up @@ -16558,6 +16558,10 @@ MSG_HASH(
MSG_IOS_TOUCH_MOUSE_DISABLED,
"Touch mouse is disabled"
)
MSG_HASH(
MSG_SDL2_MIC_NEEDS_SDL2_AUDIO,
"sdl2 microphone requires sdl2 audio driver"
)
MSG_HASH(
MSG_ACCESSIBILITY_STARTUP,
"RetroArch accessibility on. Main Menu Load Core."
Expand Down
1 change: 1 addition & 0 deletions msg_hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,7 @@ enum msg_hash_enums

MSG_IOS_TOUCH_MOUSE_ENABLED,
MSG_IOS_TOUCH_MOUSE_DISABLED,
MSG_SDL2_MIC_NEEDS_SDL2_AUDIO,

/* Add To Playlist*/
MSG_ADDED_TO_PLAYLIST,
Expand Down
8 changes: 8 additions & 0 deletions ui/drivers/ui_cocoatouch.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@
#import <GameController/GCMouse.h>
#endif

#ifdef HAVE_SDL2
#define SDL_MAIN_HANDLED
#include "SDL.h"
#endif

#if defined(HAVE_COCOA_METAL) || defined(HAVE_COCOATOUCH)
#import "JITSupport.h"
id<ApplePlatform> apple_platform;
Expand Down Expand Up @@ -963,6 +968,9 @@ int main(int argc, char *argv[])
RARCH_LOG("Ptrace hack complete, JIT support is enabled.\n");
else
RARCH_WARN("Ptrace hack NOT available; Please use an app like Jitterbug.\n");
#endif
#ifdef HAVE_SDL2
SDL_SetMainReady();
#endif
@autoreleasepool {
return UIApplicationMain(argc, argv, NSStringFromClass([RApplication class]), NSStringFromClass([RetroArch_iOS class]));
Expand Down

0 comments on commit 6e2f0a4

Please sign in to comment.