From d9978e9a01b5b93fc807c670e2944da15c20ba88 Mon Sep 17 00:00:00 2001 From: Kaido Kert Date: Fri, 29 Mar 2024 16:34:36 -0700 Subject: [PATCH] Clean up compile conditionals for microphone (#2771) Microphone is universally enabled on all platforms, the #ifdefs are a no-op. b/150410605 --- cobalt/media_capture/media_devices.cc | 6 ------ cobalt/media_stream/microphone_audio_source.cc | 9 --------- cobalt/speech/cobalt_speech_recognizer.cc | 12 +----------- cobalt/speech/google_speech_service.cc | 3 --- cobalt/speech/microphone_starboard.cc | 4 ---- cobalt/speech/microphone_starboard.h | 6 +----- cobalt/speech/speech_configuration.h | 2 -- .../evergreen/arm/softfp/configuration_public.h | 3 --- starboard/evergreen/arm64/configuration_public.h | 3 --- 9 files changed, 2 insertions(+), 46 deletions(-) diff --git a/cobalt/media_capture/media_devices.cc b/cobalt/media_capture/media_devices.cc index 3c671f3609f2..c2cdef79293c 100644 --- a/cobalt/media_capture/media_devices.cc +++ b/cobalt/media_capture/media_devices.cc @@ -36,10 +36,6 @@ namespace cobalt { namespace media_capture { -#if SB_USE_SB_MICROPHONE && !defined(DISABLE_MICROPHONE_IDL) -#define ENABLE_MICROPHONE_IDL -#endif - namespace { using speech::Microphone; @@ -56,13 +52,11 @@ std::unique_ptr CreateMicrophone( std::unique_ptr mic; -#if defined(ENABLE_MICROPHONE_IDL) mic.reset(new speech::MicrophoneStarboard( speech::MicrophoneStarboard::kDefaultSampleRate, /* Buffer for one second. */ speech::MicrophoneStarboard::kDefaultSampleRate * speech::MicrophoneStarboard::kSbMicrophoneSampleSizeInBytes)); -#endif // defined(ENABLE_MICROPHONE_IDL) return mic; } diff --git a/cobalt/media_stream/microphone_audio_source.cc b/cobalt/media_stream/microphone_audio_source.cc index 3ed0be94ba91..06e69c0f5b6a 100644 --- a/cobalt/media_stream/microphone_audio_source.cc +++ b/cobalt/media_stream/microphone_audio_source.cc @@ -23,10 +23,6 @@ #include "cobalt/speech/microphone_fake.h" #include "cobalt/speech/microphone_starboard.h" -#if SB_USE_SB_MICROPHONE && !defined(DISABLE_MICROPHONE_IDL) -#define ENABLE_MICROPHONE_IDL -#endif - namespace cobalt { namespace media_stream { @@ -43,16 +39,12 @@ void MicrophoneAudioSource::EnsureSourceIsStopped() { std::unique_ptr MicrophoneAudioSource::CreateMicrophone( const cobalt::speech::Microphone::Options& options, int buffer_size_bytes) { -#if !defined(ENABLE_MICROPHONE_IDL) - return std::unique_ptr(); -#else std::unique_ptr mic; #if defined(ENABLE_FAKE_MICROPHONE) if (options.enable_fake_microphone) { mic.reset(new speech::MicrophoneFake(options)); } -#else #endif // defined(ENABLE_FAKE_MICROPHONE) if (!mic) { @@ -68,7 +60,6 @@ MicrophoneAudioSource::CreateMicrophone( } return mic; -#endif // defined(ENABLE_MICROPHONE_IDL) } MicrophoneAudioSource::MicrophoneAudioSource( diff --git a/cobalt/speech/cobalt_speech_recognizer.cc b/cobalt/speech/cobalt_speech_recognizer.cc index d7527af19d62..20111f7a1d20 100644 --- a/cobalt/speech/cobalt_speech_recognizer.cc +++ b/cobalt/speech/cobalt_speech_recognizer.cc @@ -24,10 +24,8 @@ #include "cobalt/speech/url_fetcher_fake.h" #endif // defined(ENABLE_FAKE_MICROPHONE) #include "cobalt/speech/microphone_manager.h" -#include "cobalt/speech/speech_recognition_error.h" -#if defined(SB_USE_SB_MICROPHONE) #include "cobalt/speech/microphone_starboard.h" -#endif // defined(SB_USE_SB_MICROPHONE) +#include "cobalt/speech/speech_recognition_error.h" #include "net/url_request/url_fetcher.h" namespace cobalt { @@ -45,15 +43,10 @@ std::unique_ptr CreateURLFetcher( } std::unique_ptr CreateMicrophone(int buffer_size_bytes) { -#if defined(SB_USE_SB_MICROPHONE) return std::unique_ptr( new MicrophoneStarboard(kSampleRate, buffer_size_bytes)); -#else - return std::unique_ptr(); -#endif // defined(SB_USE_SB_MICROPHONE) } -#if defined(SB_USE_SB_MICROPHONE) #if defined(ENABLE_FAKE_MICROPHONE) std::unique_ptr CreateFakeURLFetcher( const GURL& url, net::URLFetcher::RequestType request_type, @@ -67,7 +60,6 @@ std::unique_ptr CreateFakeMicrophone( return std::unique_ptr(new MicrophoneFake(options)); } #endif // defined(ENABLE_FAKE_MICROPHONE) -#endif // defined(SB_USE_SB_MICROPHONE) } // namespace CobaltSpeechRecognizer::CobaltSpeechRecognizer( @@ -80,7 +72,6 @@ CobaltSpeechRecognizer::CobaltSpeechRecognizer( MicrophoneManager::MicrophoneCreator microphone_creator = base::Bind(&CreateMicrophone); -#if defined(SB_USE_SB_MICROPHONE) #if defined(ENABLE_FAKE_MICROPHONE) if (microphone_options.enable_fake_microphone) { // If fake microphone is enabled, fake URL fetchers should be enabled as @@ -89,7 +80,6 @@ CobaltSpeechRecognizer::CobaltSpeechRecognizer( microphone_creator = base::Bind(&CreateFakeMicrophone, microphone_options); } #endif // defined(ENABLE_FAKE_MICROPHONE) -#endif // defined(SB_USE_SB_MICROPHONE) service_.reset(new GoogleSpeechService( network_module, diff --git a/cobalt/speech/google_speech_service.cc b/cobalt/speech/google_speech_service.cc index 1ee9e4b4c871..71fdd6d1591f 100644 --- a/cobalt/speech/google_speech_service.cc +++ b/cobalt/speech/google_speech_service.cc @@ -41,10 +41,7 @@ #include "cobalt/speech/speech_recognition_error.h" #include "net/base/escape.h" #include "net/url_request/url_fetcher.h" - -#if defined(SB_USE_SB_MICROPHONE) #include "starboard/system.h" -#endif // defined(SB_USE_SB_MICROPHONE) namespace cobalt { namespace speech { diff --git a/cobalt/speech/microphone_starboard.cc b/cobalt/speech/microphone_starboard.cc index cf74ab4b8ed6..0f7350637f26 100644 --- a/cobalt/speech/microphone_starboard.cc +++ b/cobalt/speech/microphone_starboard.cc @@ -14,8 +14,6 @@ #include "cobalt/speech/microphone_starboard.h" -#if defined(SB_USE_SB_MICROPHONE) - #include "starboard/common/log.h" namespace cobalt { @@ -89,5 +87,3 @@ bool MicrophoneStarboard::Close() { } // namespace speech } // namespace cobalt - -#endif // defined(SB_USE_SB_MICROPHONE) diff --git a/cobalt/speech/microphone_starboard.h b/cobalt/speech/microphone_starboard.h index a9c7e01605e3..04f371997f2b 100644 --- a/cobalt/speech/microphone_starboard.h +++ b/cobalt/speech/microphone_starboard.h @@ -15,13 +15,10 @@ #ifndef COBALT_SPEECH_MICROPHONE_STARBOARD_H_ #define COBALT_SPEECH_MICROPHONE_STARBOARD_H_ -#include "cobalt/speech/speech_configuration.h" - -#if defined(SB_USE_SB_MICROPHONE) - #include #include "cobalt/speech/microphone.h" +#include "cobalt/speech/speech_configuration.h" #include "starboard/microphone.h" namespace cobalt { @@ -55,5 +52,4 @@ class MicrophoneStarboard : public Microphone { } // namespace speech } // namespace cobalt -#endif // defined(SB_USE_SB_MICROPHONE) #endif // COBALT_SPEECH_MICROPHONE_STARBOARD_H_ diff --git a/cobalt/speech/speech_configuration.h b/cobalt/speech/speech_configuration.h index a7a1b49eec17..f083844b3ae0 100644 --- a/cobalt/speech/speech_configuration.h +++ b/cobalt/speech/speech_configuration.h @@ -18,6 +18,4 @@ #include "build/build_config.h" #include "starboard/configuration.h" -#define SB_USE_SB_MICROPHONE 1 - #endif // COBALT_SPEECH_SPEECH_CONFIGURATION_H_ diff --git a/starboard/evergreen/arm/softfp/configuration_public.h b/starboard/evergreen/arm/softfp/configuration_public.h index 31b629de472f..661e61cb694d 100644 --- a/starboard/evergreen/arm/softfp/configuration_public.h +++ b/starboard/evergreen/arm/softfp/configuration_public.h @@ -72,9 +72,6 @@ // --- I/O Configuration ----------------------------------------------------- -// Whether the current platform has microphone supported. -#define SB_HAS_MICROPHONE 0 - // Whether the current platform implements the on screen keyboard interface. #define SB_HAS_ON_SCREEN_KEYBOARD 0 diff --git a/starboard/evergreen/arm64/configuration_public.h b/starboard/evergreen/arm64/configuration_public.h index 4fcaacbda8f9..628af7dfa124 100644 --- a/starboard/evergreen/arm64/configuration_public.h +++ b/starboard/evergreen/arm64/configuration_public.h @@ -72,9 +72,6 @@ // --- I/O Configuration ----------------------------------------------------- -// Whether the current platform has microphone supported. -#define SB_HAS_MICROPHONE 1 - // Whether the current platform implements the on screen keyboard interface. #define SB_HAS_ON_SCREEN_KEYBOARD 0