-
Notifications
You must be signed in to change notification settings - Fork 77
DS Sound Streaming #302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DS Sound Streaming #302
Conversation
| #include <stdexcept> | ||
| #include <vector> | ||
|
|
||
| #ifdef _MSC_VER |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this, we don't need it.
| #include "client/sound/SoundSystem.hpp" | ||
| #include "client/sound/SoundData.hpp" | ||
|
|
||
| #define SOUND_SYSTEM SoundSystemDS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put this back on top
|
|
||
| class SoundSystemDS : public SoundSystem | ||
| { | ||
| private: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this back to the top
| @@ -0,0 +1,312 @@ | |||
| #define WIN32_LEAN_AND_MEAN | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be here, it should be right before the windows header
| #define WIN32_LEAN_AND_MEAN | ||
| #include "SoundStreamDS.hpp" | ||
| #include "client/app/AppPlatform.hpp" | ||
| #include <cassert> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Standard stuff should go above our local headers
|
|
||
| void SoundStreamDS::_deleteBuffers() | ||
| { | ||
| for (auto buffer : m_buffers) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't use foreach loops in C++98
| // Verify buffers were created | ||
| if (m_buffers.size() != 2 || !m_source) | ||
| { | ||
| LOG_I("Failed to create DirectSound buffers or source"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use LOG_E
| @@ -0,0 +1,52 @@ | |||
| #pragma once | |||
| #include <windows.h> | |||
| #pragma comment(lib, "dsound.lib") | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't need these
| SPDX-License-Identifier: BSD-1-Clause | ||
| ********************************************************************/ | ||
|
|
||
| #define WIN32_LEAN_AND_MEAN |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't need this here
| m_directsound->Release(); | ||
| } | ||
|
|
||
| WAVEFORMATEX SoundSystemDS::_getWaveFormat(const PCMSoundHeader& header, float pitch) const |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should go up here, since it's private.
BrentDaMage
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple minor things, but overall great.
| // Re-fill buffers after restoration | ||
| for (size_t i = 0; i < m_buffers.size(); ++i) | ||
| { | ||
| if (!_stream(i)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cleanup this deep if statement. ex: have it call continue if _stream is true
| (lastWritePos >= m_bufferSize && writeCursor < m_bufferSize)) | ||
| { | ||
| int bufferId = (currentSegment + 1) % 2; | ||
| if (!_stream(bufferId)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably cleanup this if as well
| } | ||
|
|
||
| result = m_directsound->SetCooperativeLevel(m_hWnd, DSSCL_NORMAL); | ||
| result = m_directsound->SetCooperativeLevel(m_hWnd, DSSCL_PRIORITY); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why? What does this do? Please put it in a comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The normal cooperative level doesn't have enough control over the buffer, basically causing the sound streaming to not work at all
No description provided.