mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Minor cleanups in CaptureDevice
This commit is contained in:
parent
6c9b9b54b7
commit
a24e2e6946
2 changed files with 23 additions and 30 deletions
|
@ -111,13 +111,15 @@ MediaParam defaultAudioParam = { 44100, 2, 16, MFAudioFormat_PCM };
|
||||||
|
|
||||||
HRESULT GetDefaultStride(IMFMediaType *pType, LONG *plStride);
|
HRESULT GetDefaultStride(IMFMediaType *pType, LONG *plStride);
|
||||||
|
|
||||||
ReaderCallback::ReaderCallback(WindowsCaptureDevice *device): img_convert_ctx(nullptr), resample_ctx(nullptr){
|
ReaderCallback::ReaderCallback(WindowsCaptureDevice *_device) : device(_device) {}
|
||||||
this->device = device;
|
|
||||||
}
|
|
||||||
|
|
||||||
ReaderCallback::~ReaderCallback() {
|
ReaderCallback::~ReaderCallback() {
|
||||||
sws_freeContext(img_convert_ctx);
|
if (img_convert_ctx) {
|
||||||
swr_free(&resample_ctx);
|
sws_freeContext(img_convert_ctx);
|
||||||
|
}
|
||||||
|
if (resample_ctx) {
|
||||||
|
swr_free(&resample_ctx);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT ReaderCallback::QueryInterface(REFIID riid, void** ppv)
|
HRESULT ReaderCallback::QueryInterface(REFIID riid, void** ppv)
|
||||||
|
@ -439,20 +441,10 @@ u32 ReaderCallback::doResample(u8 **dst, u32 &dstSampleRate, u32 &dstChannels, u
|
||||||
return av_samples_get_buffer_size(nullptr, dstChannels, outSamplesCount, AV_SAMPLE_FMT_S16, 0);
|
return av_samples_get_buffer_size(nullptr, dstChannels, outSamplesCount, AV_SAMPLE_FMT_S16, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
WindowsCaptureDevice::WindowsCaptureDevice(CAPTUREDEVIDE_TYPE type) :
|
WindowsCaptureDevice::WindowsCaptureDevice(CAPTUREDEVIDE_TYPE _type) :
|
||||||
type(type),
|
type(_type),
|
||||||
m_pCallback(nullptr),
|
|
||||||
m_pSource(nullptr),
|
|
||||||
m_pReader(nullptr),
|
|
||||||
imageRGB(nullptr),
|
|
||||||
imageJpeg(nullptr),
|
|
||||||
imgJpegSize(0),
|
|
||||||
resampleBuf(nullptr),
|
|
||||||
resampleBufSize(0),
|
|
||||||
rawAudioBuf(nullptr),
|
|
||||||
error(CAPTUREDEVIDE_ERROR_NO_ERROR),
|
error(CAPTUREDEVIDE_ERROR_NO_ERROR),
|
||||||
errorMessage(""),
|
errorMessage(""),
|
||||||
isDeviceChanged(false),
|
|
||||||
state(CAPTUREDEVIDE_STATE::UNINITIALIZED) {
|
state(CAPTUREDEVIDE_STATE::UNINITIALIZED) {
|
||||||
param = { 0 };
|
param = { 0 };
|
||||||
deviceParam = { 0 };
|
deviceParam = { 0 };
|
||||||
|
@ -482,6 +474,7 @@ WindowsCaptureDevice::~WindowsCaptureDevice() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowsCaptureDevice::CheckDevices() {
|
void WindowsCaptureDevice::CheckDevices() {
|
||||||
isDeviceChanged = true;
|
isDeviceChanged = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,8 +171,8 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
WindowsCaptureDevice *device;
|
WindowsCaptureDevice *device;
|
||||||
SwsContext *img_convert_ctx;
|
SwsContext *img_convert_ctx = nullptr;
|
||||||
SwrContext *resample_ctx;
|
SwrContext *resample_ctx = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
class WindowsCaptureDevice {
|
class WindowsCaptureDevice {
|
||||||
|
@ -222,12 +222,12 @@ protected:
|
||||||
CAPTUREDEVIDE_ERROR error;
|
CAPTUREDEVIDE_ERROR error;
|
||||||
std::string errorMessage;
|
std::string errorMessage;
|
||||||
|
|
||||||
bool isDeviceChanged;
|
bool isDeviceChanged = false;
|
||||||
|
|
||||||
// MF interface.
|
// MF interface.
|
||||||
ReaderCallback *m_pCallback;
|
ReaderCallback *m_pCallback = nullptr;
|
||||||
IMFSourceReader *m_pReader;
|
IMFSourceReader *m_pReader = nullptr;
|
||||||
IMFMediaSource *m_pSource;
|
IMFMediaSource *m_pSource = nullptr;
|
||||||
|
|
||||||
// Message loop.
|
// Message loop.
|
||||||
std::mutex mutex;
|
std::mutex mutex;
|
||||||
|
@ -241,15 +241,15 @@ protected:
|
||||||
std::mutex paramMutex;
|
std::mutex paramMutex;
|
||||||
|
|
||||||
// Camera only
|
// Camera only
|
||||||
unsigned char *imageRGB;
|
unsigned char *imageRGB = nullptr;
|
||||||
int imgRGBLineSizes[4];
|
int imgRGBLineSizes[4]{};
|
||||||
unsigned char *imageJpeg;
|
unsigned char *imageJpeg = nullptr;
|
||||||
int imgJpegSize;
|
int imgJpegSize = 0;
|
||||||
|
|
||||||
//Microphone only
|
//Microphone only
|
||||||
u8 *resampleBuf;
|
u8 *resampleBuf = nullptr;
|
||||||
u32 resampleBufSize;
|
u32 resampleBufSize = 0;
|
||||||
QueueBuf *rawAudioBuf;
|
QueueBuf *rawAudioBuf = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern WindowsCaptureDevice *winCamera;
|
extern WindowsCaptureDevice *winCamera;
|
||||||
|
|
Loading…
Add table
Reference in a new issue