Skip to content

Commit

Permalink
Improve logging
Browse files Browse the repository at this point in the history
  • Loading branch information
mdias committed Jan 12, 2020
1 parent d9ce598 commit 4c12f75
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 3 deletions.
5 changes: 5 additions & 0 deletions RS_ASIO/AsioSharedHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,11 @@ const ASIOChannelInfo* AsioSharedHost::GetInputChannelInfo(unsigned channel) con
return &m_AsioInChannelInfo[channel];
}

void AsioSharedHost::ResetDebugLogAsioBufferSwitches()
{
m_dbgNumBufferSwitches = 0;
}

void AsioSharedHost::DisplayCurrentError() const
{
if (!m_Driver)
Expand Down
2 changes: 2 additions & 0 deletions RS_ASIO/AsioSharedHost.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class AsioSharedHost : public ComBaseUnknown<IUnknown>
unsigned GetNumInputChannels() const { return m_AsioInChannelInfo.size(); }
unsigned GetNumOutputChannels() const { return m_AsioOutChannelInfo.size(); }

void ResetDebugLogAsioBufferSwitches();

private:
void DisplayCurrentError() const;

Expand Down
2 changes: 1 addition & 1 deletion RS_ASIO/DebugWrapperCaptureClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ HRESULT STDMETHODCALLTYPE DebugWrapperCaptureClient::GetBuffer(BYTE **ppData, UI

if (m_GetCount < 3)
{
++m_GetCount;
rslog::info_ts() << m_DeviceId << " " __FUNCTION__ << std::endl;

hr = m_RealClient.GetBuffer(ppData, pNumFramesToRead, pdwFlags, pu64DevicePosition, pu64QPCPosition);
Expand All @@ -45,6 +44,7 @@ HRESULT STDMETHODCALLTYPE DebugWrapperCaptureClient::ReleaseBuffer(UINT32 NumFra

if (m_GetCount < 3)
{
++m_GetCount;
rslog::info_ts() << m_DeviceId << " " __FUNCTION__ " NumFramesRead: " << NumFramesRead << std::endl;
hr = m_RealClient.ReleaseBuffer(NumFramesRead);
}
Expand Down
2 changes: 1 addition & 1 deletion RS_ASIO/DebugWrapperRenderClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ HRESULT STDMETHODCALLTYPE DebugWrapperRenderClient::GetBuffer(UINT32 NumFramesRe

if (m_GetCount < 3)
{
++m_GetCount;
rslog::info_ts() << m_DeviceId << " " __FUNCTION__ " NumFramesRequested: " << NumFramesRequested << std::endl;

hr = m_RealClient.GetBuffer(NumFramesRequested, ppData);
Expand All @@ -45,6 +44,7 @@ HRESULT STDMETHODCALLTYPE DebugWrapperRenderClient::ReleaseBuffer(UINT32 NumFram

if (m_GetCount < 3)
{
++m_GetCount;
rslog::info_ts() << m_DeviceId << " " __FUNCTION__ " NumFramesWritten: " << NumFramesWritten << std::endl;
hr = m_RealClient.ReleaseBuffer(NumFramesWritten, dwFlags);
}
Expand Down
16 changes: 15 additions & 1 deletion RS_ASIO/RSAsioAudioClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ HRESULT RSAsioAudioClient::Start()
return AUDCLNT_E_NOT_STOPPED;

m_IsStarted = true;
m_dbgNumBufferSwitches = 0;

return S_OK;
}
Expand Down Expand Up @@ -435,6 +436,9 @@ void RSAsioAudioClient::SwapBuffers()
std::lock_guard<std::mutex> g(m_bufferMutex);
std::swap(m_frontBuffer, m_backBuffer);
m_bufferHasUpdatedData = true;

if (m_dbgNumBufferSwitches < 3)
rslog::info_ts() << m_AsioDevice.GetIdRef() << " " __FUNCTION__ << std::endl;
}

void RSAsioAudioClient::OnAsioBufferSwitch(unsigned buffIdx)
Expand All @@ -452,6 +456,8 @@ void RSAsioAudioClient::OnAsioBufferSwitch(unsigned buffIdx)
else if (!m_bufferHasUpdatedData)
{
rslog::info_ts() << m_AsioDevice.GetIdRef() << " " __FUNCTION__ " - buffer underrun detected" << std::endl;
m_AsioDevice.GetAsioHost().ResetDebugLogAsioBufferSwitches();
m_dbgNumBufferSwitches = 0;
}

// sanity check
Expand Down Expand Up @@ -553,11 +559,19 @@ void RSAsioAudioClient::OnAsioBufferSwitch(unsigned buffIdx)
}
}

if (m_UsingEventHandle && m_EventHandle && m_bufferHasUpdatedData)
const bool signalEvent = (m_UsingEventHandle && m_EventHandle && m_bufferHasUpdatedData);
if (signalEvent)
{
SetEvent(m_EventHandle);
}
m_bufferHasUpdatedData = false;

if (m_IsStarted && m_dbgNumBufferSwitches < 3)
{
++m_dbgNumBufferSwitches;
if (m_dbgNumBufferSwitches < 3)
rslog::info_ts() << m_AsioDevice.GetIdRef() << " " __FUNCTION__ " - signalled event: " << signalEvent << std::endl;
}
}

void RSAsioAudioClient::UpdateChannelMap()
Expand Down
2 changes: 2 additions & 0 deletions RS_ASIO/RSAsioAudioClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ class RSAsioAudioClient : public ComBaseUnknown<IAudioClient3>, protected IAsioB
std::vector<BYTE> m_backBuffer;
bool m_bufferHasUpdatedData = false;

unsigned m_dbgNumBufferSwitches;

std::mutex m_bufferMutex;
DWORD m_bufferNumFrames;
std::vector<int> m_ChannelMap;
Expand Down

0 comments on commit 4c12f75

Please sign in to comment.