-sound buffer can stay in mem1

This commit is contained in:
fix94.1 2012-06-08 19:00:02 +00:00
parent 0272e193ad
commit 00419301c8
2 changed files with 62 additions and 62 deletions

View File

@ -29,113 +29,113 @@
BufferCircle::BufferCircle()
{
which = 0;
BufferBlockSize = 0;
which = 0;
BufferBlockSize = 0;
}
BufferCircle::~BufferCircle()
{
FreeBuffer();
SoundBuffer.clear();
BufferSize.clear();
BufferReady.clear();
FreeBuffer();
SoundBuffer.clear();
BufferSize.clear();
BufferReady.clear();
}
void BufferCircle::SetBufferBlockSize(int size)
{
if(size < 0)
return;
if(size < 0)
return;
BufferBlockSize = size;
BufferBlockSize = size;
for(int i = 0; i < Size(); i++)
{
for(int i = 0; i < Size(); i++)
{
if(SoundBuffer[i] != NULL)
MEM2_free(SoundBuffer[i]);
MEM1_free(SoundBuffer[i]);
SoundBuffer[i] = (u8 *)MEM2_memalign(32, BufferBlockSize);
BufferSize[i] = 0;
BufferReady[i] = false;
}
SoundBuffer[i] = (u8 *)MEM1_memalign(32, BufferBlockSize);
BufferSize[i] = 0;
BufferReady[i] = false;
}
}
void BufferCircle::Resize(int size)
{
while(size < Size())
RemoveBuffer(Size()-1);
while(size < Size())
RemoveBuffer(Size()-1);
int oldSize = Size();
int oldSize = Size();
SoundBuffer.resize(size);
BufferSize.resize(size);
BufferReady.resize(size);
SoundBuffer.resize(size);
BufferSize.resize(size);
BufferReady.resize(size);
for(int i = oldSize; i < Size(); i++)
{
if(BufferBlockSize > 0)
SoundBuffer[i] = (u8 *)MEM2_memalign(32, BufferBlockSize);
else
SoundBuffer[i] = NULL;
BufferSize[i] = 0;
BufferReady[i] = false;
}
for(int i = oldSize; i < Size(); i++)
{
if(BufferBlockSize > 0)
SoundBuffer[i] = (u8 *)MEM1_memalign(32, BufferBlockSize);
else
SoundBuffer[i] = NULL;
BufferSize[i] = 0;
BufferReady[i] = false;
}
}
void BufferCircle::RemoveBuffer(int pos)
{
if(!Valid(pos))
return;
if(!Valid(pos))
return;
if(SoundBuffer[pos] != NULL)
MEM2_free(SoundBuffer[pos]);
MEM1_free(SoundBuffer[pos]);
SoundBuffer.erase(SoundBuffer.begin()+pos);
BufferSize.erase(BufferSize.begin()+pos);
BufferReady.erase(BufferReady.begin()+pos);
SoundBuffer.erase(SoundBuffer.begin()+pos);
BufferSize.erase(BufferSize.begin()+pos);
BufferReady.erase(BufferReady.begin()+pos);
}
void BufferCircle::ClearBuffer()
{
for(int i = 0; i < Size(); i++)
{
BufferSize[i] = 0;
BufferReady[i] = false;
}
which = 0;
for(int i = 0; i < Size(); i++)
{
BufferSize[i] = 0;
BufferReady[i] = false;
}
which = 0;
}
void BufferCircle::FreeBuffer()
{
for(int i = 0; i < Size(); i++)
{
for(int i = 0; i < Size(); i++)
{
if(SoundBuffer[i] != NULL)
MEM2_free(SoundBuffer[i]);
BufferSize[i] = 0;
BufferReady[i] = false;
}
MEM1_free(SoundBuffer[i]);
BufferSize[i] = 0;
BufferReady[i] = false;
}
}
void BufferCircle::LoadNext()
{
int pos = (which+Size()-1) % Size();
BufferReady[pos] = false;
BufferSize[pos] = 0;
int pos = (which+Size()-1) % Size();
BufferReady[pos] = false;
BufferSize[pos] = 0;
which = (which+1) % Size();
which = (which+1) % Size();
}
void BufferCircle::SetBufferReady(int pos, bool state)
{
if(!Valid(pos))
return;
if(!Valid(pos))
return;
BufferReady[pos] = state;
BufferReady[pos] = state;
}
void BufferCircle::SetBufferSize(int pos, int size)
{
if(!Valid(pos))
return;
if(!Valid(pos))
return;
BufferSize[pos] = size;
BufferSize[pos] = size;
}

View File

@ -43,7 +43,7 @@ SoundHandler::SoundHandler()
for(u32 i = 0; i < MAX_DECODERS; ++i)
DecoderList[i] = NULL;
ThreadStack = (u8 *)MEM2_memalign(32, 32768);
ThreadStack = (u8 *)MEM1_memalign(32, 32768);
if(!ThreadStack)
return;
@ -61,7 +61,7 @@ SoundHandler::~SoundHandler()
SoundThread = LWP_THREAD_NULL;
if(ThreadStack != NULL)
{
MEM2_free(ThreadStack);
MEM1_free(ThreadStack);
ThreadStack = NULL;
}