Skip to content

Commit

Permalink
Switch from bool to HRESULT for myDMSegment::m_isPlaying
Browse files Browse the repository at this point in the history
  • Loading branch information
Solanacean committed Mar 1, 2019
1 parent 12b6e2e commit c1e1760
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
16 changes: 7 additions & 9 deletions GrimoireDigiMusic/myDMPerformance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ inline double ConvertRange(double value, double oldStart, double oldEnd, double

void CALLBACK MySyncProc(HSYNC handle, DWORD channel, DWORD data, myDMSegment *pSeg)
{
pSeg->m_isPlaying.store(false, std::memory_order_relaxed);
pSeg->m_isPlaying.store(S_FALSE, std::memory_order_relaxed);
}

/*
Expand Down Expand Up @@ -114,18 +114,16 @@ HRESULT __stdcall myDMPerformance::PlaySegment(IDirectMusicSegment *pSegment, DW
return ~S_OK;
}

pSeg->m_isPlaying.store(S_OK, std::memory_order_relaxed);

if (!BASS_ChannelPlay(pSeg->m_hStream, TRUE))
{
pSeg->m_isPlaying.store(S_FALSE, std::memory_order_relaxed);

LOG_ERROR("BASS_ChannelPlay failed with error code: ", BASS_ErrorGetCode());
return ~S_OK;
}

DWORD channelState = BASS_ChannelIsActive(pSeg->m_hStream);
pSeg->m_isPlaying.store((channelState == BASS_ACTIVE_PLAYING || channelState == BASS_ACTIVE_STALLED),
std::memory_order_relaxed);

//pMySegment->m_isPlaying.store(true, std::memory_order_relaxed);

return S_OK;
}

Expand All @@ -143,7 +141,7 @@ HRESULT __stdcall myDMPerformance::Stop(IDirectMusicSegment *pSegment, IDirectMu
}
else
{
pSeg->m_isPlaying.store(false, std::memory_order_relaxed);
pSeg->m_isPlaying.store(S_FALSE, std::memory_order_relaxed);
}

return S_OK;
Expand All @@ -155,7 +153,7 @@ HRESULT __stdcall myDMPerformance::IsPlaying(IDirectMusicSegment* pSegment, IDir
{
auto *pSeg = static_cast<myDMSegment*>(pSegment);

return pSeg->m_isPlaying.load(std::memory_order_relaxed) ? S_OK : S_FALSE;
return pSeg->m_isPlaying.load(std::memory_order_relaxed);
}

// CDXMidi::Init
Expand Down
2 changes: 1 addition & 1 deletion GrimoireDigiMusic/myDMSegment.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class myDMSegment : public IDirectMusicSegment

public:
HSTREAM m_hStream;
std::atomic_bool m_isPlaying {false};
std::atomic<HRESULT> m_isPlaying {S_FALSE};

myDMSegment(HSTREAM hStream) : m_hStream(hStream) {}

Expand Down

0 comments on commit c1e1760

Please sign in to comment.