Commit 2c1a83a3 authored by Simon Morlat's avatar Simon Morlat
Browse files

Attempt to workaround wasapi failures, when the device is open/close

within a short timeframe.
parent 1dcb06b1
......@@ -51,24 +51,23 @@ static void ms_wasapi_read_init(MSFilter *f) {
static void ms_wasapi_read_preprocess(MSFilter *f) {
MSWASAPIReaderType r = MSWASAPI_READER(f->data);
r->activate();
r->start();
}
static void ms_wasapi_read_process(MSFilter *f) {
MSWASAPIReaderType r = MSWASAPI_READER(f->data);
if (!r->isStarted()) {
r->start();
}
r->feed(f);
}
static void ms_wasapi_read_postprocess(MSFilter *f) {
MSWASAPIReaderType r = MSWASAPI_READER(f->data);
r->stop();
r->deactivate();
}
static void ms_wasapi_read_uninit(MSFilter *f) {
MSWASAPIReaderType r = MSWASAPI_READER(f->data);
r->deactivate();
MSWASAPIReaderDelete(static_cast<MSWASAPIReaderPtr>(f->data));
}
......@@ -194,24 +193,22 @@ static void ms_wasapi_write_init(MSFilter *f) {
static void ms_wasapi_write_preprocess(MSFilter *f) {
MSWASAPIWriterType w = MSWASAPI_WRITER(f->data);
w->activate();
w->start();
}
static void ms_wasapi_write_process(MSFilter *f) {
MSWASAPIWriterType w = MSWASAPI_WRITER(f->data);
if (!w->isStarted()) {
w->start();
}
w->feed(f);
}
static void ms_wasapi_write_postprocess(MSFilter *f) {
MSWASAPIWriterType w = MSWASAPI_WRITER(f->data);
w->stop();
w->deactivate();
}
static void ms_wasapi_write_uninit(MSFilter *f) {
MSWASAPIWriterType w = MSWASAPI_WRITER(f->data);
w->deactivate();
MSWASAPIWriterDelete(static_cast<MSWASAPIWriterPtr>(f->data));
}
......
......@@ -146,6 +146,7 @@ void MSWASAPIReader::init(LPCWSTR id)
FREE_PTR(pWfx);
mIsInitialized = true;
smInstantiated = true;
activate();
return;
error:
......@@ -166,8 +167,6 @@ int MSWASAPIReader::activate()
if (!mIsInitialized) goto error;
ms_ticker_set_synchronizer(mFilter->ticker, mTickerSynchronizer);
#ifdef MS2_WINDOWS_PHONE
flags = AUDCLNT_SESSIONFLAGS_EXPIREWHENUNOWNED | AUDCLNT_SESSIONFLAGS_DISPLAY_HIDE | AUDCLNT_SESSIONFLAGS_DISPLAY_HIDEWHENEXPIRED;
#endif
......@@ -217,7 +216,7 @@ int MSWASAPIReader::deactivate()
{
RELEASE_CLIENT(mAudioCaptureClient);
RELEASE_CLIENT(mVolumeControler);
ms_ticker_set_synchronizer(mFilter->ticker, nullptr);
mIsActivated = false;
return 0;
}
......@@ -233,6 +232,7 @@ void MSWASAPIReader::start()
ms_error("Could not start playback on the MSWASAPI audio input interface [%x]", result);
}
}
ms_ticker_set_synchronizer(mFilter->ticker, mTickerSynchronizer);
}
void MSWASAPIReader::stop()
......@@ -245,6 +245,7 @@ void MSWASAPIReader::stop()
if (result != S_OK) {
ms_error("Could not stop playback on the MSWASAPI audio input interface [%x]", result);
}
ms_ticker_set_synchronizer(mFilter->ticker, nullptr);
}
}
......
......@@ -146,6 +146,7 @@ void MSWASAPIWriter::init(LPCWSTR id, MSFilter *f) {
FREE_PTR(pWfx);
mIsInitialized = true;
smInstantiated = true;
activate();
return;
error:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment