1 // Copyright (c) 2019- PPSSPP Project. 2 3 // This program is free software: you can redistribute it and/or modify 4 // it under the terms of the GNU General Public License as published by 5 // the Free Software Foundation, version 2.0 or later versions. 6 7 // This program is distributed in the hope that it will be useful, 8 // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 // GNU General Public License 2.0 for more details. 11 12 // A copy of the GPL 2.0 should have been included with the program. 13 // If not, see http://www.gnu.org/licenses/ 14 15 // Official git repository and contact information can be found at 16 // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. 17 18 #pragma once 19 20 #include "sceKernel.h" 21 #include <mutex> 22 23 void Register_sceUsbMic(); 24 25 void __UsbMicInit(); 26 void __UsbMicShutdown(); 27 void __UsbMicDoState(PointerWrap &p); 28 29 enum MICTYPE { 30 AUDIOINPUT, 31 USBMIC, 32 CAMERAMIC 33 }; 34 35 struct MicWaitInfo { 36 SceUID threadID; 37 u32 addr; 38 u32 needSize; 39 u32 sampleRate; 40 }; 41 42 class QueueBuf { 43 public: 44 QueueBuf(u32 size); 45 ~QueueBuf(); 46 47 QueueBuf(const QueueBuf &buf); 48 QueueBuf& operator=(const QueueBuf &buf); 49 50 u32 push(u8 *buf, u32 size); 51 u32 pop(u8 *buf, u32 size); 52 void resize(u32 newSize); 53 void flush(); 54 u32 getAvailableSize(); 55 u32 getRemainingSize(); 56 u32 getStartPos(); getCapacity()57 u32 getCapacity() const { 58 return capacity; 59 } 60 61 private: 62 u32 available; 63 u32 end; 64 u32 capacity; 65 u8 *buf_; 66 std::mutex mutex; 67 }; 68 69 namespace Microphone { 70 int startMic(void *param); 71 int stopMic(); 72 bool isHaveDevice(); 73 bool isMicStarted(); 74 u32 numNeedSamples(); 75 u32 availableAudioBufSize(); 76 u32 getReadMicDataLength(); 77 78 79 int addAudioData(u8 *buf, u32 size); 80 u32 getAudioData(u8 *buf, u32 size); 81 void flushAudioData(); 82 83 std::vector<std::string> getDeviceList(); 84 void onMicDeviceChange(); 85 86 // Deprecated. 87 bool isNeedInput(); 88 } 89 90 u32 __MicInput(u32 maxSamples, u32 sampleRate, u32 bufAddr, MICTYPE type, bool block = true); 91