-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Fix "out of buffers" crash #3783
Changes from 8 commits
b6421d4
6b557d2
c11d12f
9c91079
73728d7
aebbe22
70ac7db
d1aa39b
93e4bd7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,18 +22,23 @@ | |
* | ||
*/ | ||
|
||
#include "PlayHandle.h" | ||
#include "BufferManager.h" | ||
#include "Engine.h" | ||
#include "Mixer.h" | ||
#include "PlayHandle.h" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why this line have been moved from above? It should stay above There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No reason, probably an unintentional change. |
||
|
||
#include <QtCore/QThread> | ||
#include <QDebug> | ||
|
||
#include <iterator> | ||
|
||
PlayHandle::PlayHandle( const Type type, f_cnt_t offset ) : | ||
m_type( type ), | ||
m_offset( offset ), | ||
m_affinity( QThread::currentThread() ), | ||
m_playHandleBuffer( NULL ), | ||
m_usesBuffer( true ) | ||
PlayHandle::PlayHandle(const Type type, f_cnt_t offset) : | ||
m_type(type), | ||
m_offset(offset), | ||
m_affinity(QThread::currentThread()), | ||
m_playHandleBuffer(BufferManager::acquire()), | ||
m_bufferReleased(true), | ||
m_usesBuffer(true) | ||
{ | ||
} | ||
|
||
|
@@ -48,8 +53,8 @@ void PlayHandle::doProcessing() | |
{ | ||
if( m_usesBuffer ) | ||
{ | ||
if( ! m_playHandleBuffer ) m_playHandleBuffer = BufferManager::acquire(); | ||
play( m_playHandleBuffer ); | ||
m_bufferReleased = false; | ||
play( buffer() ); | ||
} | ||
else | ||
{ | ||
|
@@ -60,6 +65,10 @@ void PlayHandle::doProcessing() | |
|
||
void PlayHandle::releaseBuffer() | ||
{ | ||
BufferManager::release( m_playHandleBuffer ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @lukas-w Why did you move this to destructor? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @PhysSong Because I moved buffer allocation to the constructor. The buffer's lifetime matches the |
||
m_playHandleBuffer = NULL; | ||
m_bufferReleased = true; | ||
} | ||
|
||
sampleFrame* PlayHandle::buffer() | ||
{ | ||
return m_bufferReleased ? nullptr : reinterpret_cast<sampleFrame*>(m_playHandleBuffer); | ||
}; |
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.
These parts aren't used. Are there some reasons you leave them in our codebase?
Some more inconsistencies: you mixed
< foo >
and<foo>
, it makes the code look inconsistent.One more thing(minor): if you are going to use this later, I think
vector
is not very good name. If you want to keep the name, of course you may do.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.
I plan on using them at a later point in time. Using an Allocator class is the standard C++ way of having custom allocators, and should be preferred over using the macros
MM_ALLOC
andMM_FREE
.This has already been discussed by @Umcaruje and me in the comments here. C++03 doesn't allow
>>
for nested template arguments (it always interprets it as thestreamright shift operator>>
). We can't use>>
here, because the headers is included by plugins that are compiled without C++11 support. See d1aa39b.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.
Well it's a vector, so why not call it
vector
? What would you call it?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.
You're right, but you used both
template<typename T>
andtemplate< class U >
above. Is that intentional?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.
Ah, no that's not intentional.