Can an application use the microphone for two different tasks at the same time?


Question

I'm currently exploring the PortSIP app( link is here) to make calls. I want to be able to record what I speak. I am successfully able to record using the microphone, when there is no call in progress. But once the call is initialized, the reciever can't hear my voice.



Is there any way to make this work??


Answer

Can two apps use the microphone at the same time?



As far as I know: By default, the same way two different apps can't use the camera at the same time, the same principle applies to microphone too. Since these hardwares' drivers respond to only one call from one user at a time. Of course you can make an app that gets the input from microphone and then acts as a broadcaster to share the input with other apps. But the microphone itself doesn't provide for two users at the same time. Since the Phone app is also a user, microphone provides only for it. That being told, my information can be outdated. Or there can be ways to cheat in this case. User Micheal from this Stack Overflow question says:




I don't remember exactly where the limitation comes from, but on one of
the platforms I've worked with we had a workaround in the form of a
stream splitter. This class was written by the platform provider (so
it was proprietary), and was part of libaudioflinger IIRC. It would
manage the audio hw input stream, and hand out audio data to all
clients (apps) that wanted to record audio. So it can be done if you
have the ability to build your own Android ROM, but it's not trivial.




So is it possible? Yeah. But seems unnecessarily painful to me. Still as I said, take my words as a grain of salt, since my Android knowledge is not very up to date.



Can an app use microphone for two different things?
An app is made of different components. User of the phone uses user interfaces (activities) to start processes that happen in the background (services) and all services have their own thing to do. Yet, they all belong to the same process that has a specific UID given by the Android. Once the given UID gets the input info from camera, microphone etc. it can use it for different services at the same time. That's up to app to decide.


Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes