mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2024-11-23 19:59:16 +01:00
-sound buffer can stay in mem1
This commit is contained in:
parent
0272e193ad
commit
00419301c8
@ -29,113 +29,113 @@
|
|||||||
|
|
||||||
BufferCircle::BufferCircle()
|
BufferCircle::BufferCircle()
|
||||||
{
|
{
|
||||||
which = 0;
|
which = 0;
|
||||||
BufferBlockSize = 0;
|
BufferBlockSize = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
BufferCircle::~BufferCircle()
|
BufferCircle::~BufferCircle()
|
||||||
{
|
{
|
||||||
FreeBuffer();
|
FreeBuffer();
|
||||||
SoundBuffer.clear();
|
SoundBuffer.clear();
|
||||||
BufferSize.clear();
|
BufferSize.clear();
|
||||||
BufferReady.clear();
|
BufferReady.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BufferCircle::SetBufferBlockSize(int size)
|
void BufferCircle::SetBufferBlockSize(int size)
|
||||||
{
|
{
|
||||||
if(size < 0)
|
if(size < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BufferBlockSize = size;
|
BufferBlockSize = size;
|
||||||
|
|
||||||
for(int i = 0; i < Size(); i++)
|
for(int i = 0; i < Size(); i++)
|
||||||
{
|
{
|
||||||
if(SoundBuffer[i] != NULL)
|
if(SoundBuffer[i] != NULL)
|
||||||
MEM2_free(SoundBuffer[i]);
|
MEM1_free(SoundBuffer[i]);
|
||||||
|
|
||||||
SoundBuffer[i] = (u8 *)MEM2_memalign(32, BufferBlockSize);
|
SoundBuffer[i] = (u8 *)MEM1_memalign(32, BufferBlockSize);
|
||||||
BufferSize[i] = 0;
|
BufferSize[i] = 0;
|
||||||
BufferReady[i] = false;
|
BufferReady[i] = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BufferCircle::Resize(int size)
|
void BufferCircle::Resize(int size)
|
||||||
{
|
{
|
||||||
while(size < Size())
|
while(size < Size())
|
||||||
RemoveBuffer(Size()-1);
|
RemoveBuffer(Size()-1);
|
||||||
|
|
||||||
int oldSize = Size();
|
int oldSize = Size();
|
||||||
|
|
||||||
SoundBuffer.resize(size);
|
SoundBuffer.resize(size);
|
||||||
BufferSize.resize(size);
|
BufferSize.resize(size);
|
||||||
BufferReady.resize(size);
|
BufferReady.resize(size);
|
||||||
|
|
||||||
for(int i = oldSize; i < Size(); i++)
|
for(int i = oldSize; i < Size(); i++)
|
||||||
{
|
{
|
||||||
if(BufferBlockSize > 0)
|
if(BufferBlockSize > 0)
|
||||||
SoundBuffer[i] = (u8 *)MEM2_memalign(32, BufferBlockSize);
|
SoundBuffer[i] = (u8 *)MEM1_memalign(32, BufferBlockSize);
|
||||||
else
|
else
|
||||||
SoundBuffer[i] = NULL;
|
SoundBuffer[i] = NULL;
|
||||||
BufferSize[i] = 0;
|
BufferSize[i] = 0;
|
||||||
BufferReady[i] = false;
|
BufferReady[i] = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BufferCircle::RemoveBuffer(int pos)
|
void BufferCircle::RemoveBuffer(int pos)
|
||||||
{
|
{
|
||||||
if(!Valid(pos))
|
if(!Valid(pos))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(SoundBuffer[pos] != NULL)
|
if(SoundBuffer[pos] != NULL)
|
||||||
MEM2_free(SoundBuffer[pos]);
|
MEM1_free(SoundBuffer[pos]);
|
||||||
|
|
||||||
SoundBuffer.erase(SoundBuffer.begin()+pos);
|
SoundBuffer.erase(SoundBuffer.begin()+pos);
|
||||||
BufferSize.erase(BufferSize.begin()+pos);
|
BufferSize.erase(BufferSize.begin()+pos);
|
||||||
BufferReady.erase(BufferReady.begin()+pos);
|
BufferReady.erase(BufferReady.begin()+pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BufferCircle::ClearBuffer()
|
void BufferCircle::ClearBuffer()
|
||||||
{
|
{
|
||||||
for(int i = 0; i < Size(); i++)
|
for(int i = 0; i < Size(); i++)
|
||||||
{
|
{
|
||||||
BufferSize[i] = 0;
|
BufferSize[i] = 0;
|
||||||
BufferReady[i] = false;
|
BufferReady[i] = false;
|
||||||
}
|
}
|
||||||
which = 0;
|
which = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BufferCircle::FreeBuffer()
|
void BufferCircle::FreeBuffer()
|
||||||
{
|
{
|
||||||
for(int i = 0; i < Size(); i++)
|
for(int i = 0; i < Size(); i++)
|
||||||
{
|
{
|
||||||
if(SoundBuffer[i] != NULL)
|
if(SoundBuffer[i] != NULL)
|
||||||
MEM2_free(SoundBuffer[i]);
|
MEM1_free(SoundBuffer[i]);
|
||||||
BufferSize[i] = 0;
|
BufferSize[i] = 0;
|
||||||
BufferReady[i] = false;
|
BufferReady[i] = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BufferCircle::LoadNext()
|
void BufferCircle::LoadNext()
|
||||||
{
|
{
|
||||||
int pos = (which+Size()-1) % Size();
|
int pos = (which+Size()-1) % Size();
|
||||||
BufferReady[pos] = false;
|
BufferReady[pos] = false;
|
||||||
BufferSize[pos] = 0;
|
BufferSize[pos] = 0;
|
||||||
|
|
||||||
which = (which+1) % Size();
|
which = (which+1) % Size();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BufferCircle::SetBufferReady(int pos, bool state)
|
void BufferCircle::SetBufferReady(int pos, bool state)
|
||||||
{
|
{
|
||||||
if(!Valid(pos))
|
if(!Valid(pos))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BufferReady[pos] = state;
|
BufferReady[pos] = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BufferCircle::SetBufferSize(int pos, int size)
|
void BufferCircle::SetBufferSize(int pos, int size)
|
||||||
{
|
{
|
||||||
if(!Valid(pos))
|
if(!Valid(pos))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BufferSize[pos] = size;
|
BufferSize[pos] = size;
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ SoundHandler::SoundHandler()
|
|||||||
for(u32 i = 0; i < MAX_DECODERS; ++i)
|
for(u32 i = 0; i < MAX_DECODERS; ++i)
|
||||||
DecoderList[i] = NULL;
|
DecoderList[i] = NULL;
|
||||||
|
|
||||||
ThreadStack = (u8 *)MEM2_memalign(32, 32768);
|
ThreadStack = (u8 *)MEM1_memalign(32, 32768);
|
||||||
if(!ThreadStack)
|
if(!ThreadStack)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ SoundHandler::~SoundHandler()
|
|||||||
SoundThread = LWP_THREAD_NULL;
|
SoundThread = LWP_THREAD_NULL;
|
||||||
if(ThreadStack != NULL)
|
if(ThreadStack != NULL)
|
||||||
{
|
{
|
||||||
MEM2_free(ThreadStack);
|
MEM1_free(ThreadStack);
|
||||||
ThreadStack = NULL;
|
ThreadStack = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user