Skip to content

Commit

Permalink
Reformat: xrSound
Browse files Browse the repository at this point in the history
  • Loading branch information
invokr committed Jan 15, 2017
1 parent e65a4bb commit 6852d9d
Show file tree
Hide file tree
Showing 41 changed files with 3,943 additions and 3,698 deletions.
82 changes: 43 additions & 39 deletions src/xrSound/MusicStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,82 +2,86 @@
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "MusicStream.h"
#include "stdafx.h"
#include "xr_streamsnd.h"

#include "x_ray.h"
#include "GameFont.h"
#include "x_ray.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CMusicStream::CMusicStream()
{

}

CMusicStream::~CMusicStream()
{

}

int CMusicStream::FindEmptySlot()
{
for (u32 i=0; i<streams.size(); i++) {
if (streams[i]==0) return i;
}
return -1;
for (u32 i = 0; i < streams.size(); i++)
{
if (streams[i] == 0) return i;
}
return -1;
}

CSoundStream* CMusicStream::CreateSound (LPCSTR name )
CSoundStream* CMusicStream::CreateSound(LPCSTR name)
{
int slot;
CSoundStream *pSnd = xr_new<CSoundStream> ();
pSnd->Load(name);
int slot;
CSoundStream* pSnd = xr_new<CSoundStream>();
pSnd->Load(name);

if ((slot=FindEmptySlot())>=0){
streams[slot] = pSnd;
return pSnd;
}
if ((slot = FindEmptySlot()) >= 0) {
streams[slot] = pSnd;
return pSnd;
}

streams.push_back(pSnd);
return pSnd;
streams.push_back(pSnd);
return pSnd;
}

void CMusicStream::DeleteSound (CSoundStream* pSnd)
void CMusicStream::DeleteSound(CSoundStream* pSnd)
{
int slot=-1;
for (u32 i=0; i<streams.size(); i++){
if (streams[i]==pSnd) { slot = i; break; }
}

if (slot>=0){
xr_delete(streams[slot]);
pSnd = NULL;
}
int slot = -1;
for (u32 i = 0; i < streams.size(); i++)
{
if (streams[i] == pSnd) {
slot = i;
break;
}
}

if (slot >= 0) {
xr_delete(streams[slot]);
pSnd = NULL;
}
}

void CMusicStream::OnMove()
{
for(u32 i=0; i<streams.size(); i++) streams[i]->OnMove();
/* if (psDeviceFlags&rsStatistic)
{
int cnt = 0;
for(int i=0; i<streams.size(); i++) cnt+=streams[i]->isPlaying()?1:0;
pApp->pFont->Out(0,0.5f,"%d / %d",cnt,streams.size());
}
*/
for (u32 i = 0; i < streams.size(); i++)
streams[i]->OnMove();
/* if (psDeviceFlags&rsStatistic)
{
int cnt = 0;
for(int i=0; i<streams.size(); i++) cnt+=streams[i]->isPlaying()?1:0;
pApp->pFont->Out(0,0.5f,"%d / %d",cnt,streams.size());
}
*/
}

void CMusicStream::Reload()
{
// ...
// ...
}

void CMusicStream::Update()
{
for (u32 i=0; i<streams.size(); i++)
if (streams[i]) streams[i]->bNeedUpdate=true;
for (u32 i = 0; i < streams.size(); i++)
if (streams[i]) streams[i]->bNeedUpdate = true;
}
24 changes: 13 additions & 11 deletions src/xrSound/MusicStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,21 @@
class ENGINE_API CSoundStream;
class ENGINE_API CInifile;

class CMusicStream {
xr_vector<CSoundStream*> streams;
int FindEmptySlot();
class CMusicStream
{
xr_vector<CSoundStream*> streams;
int FindEmptySlot();

public:
CMusicStream ();
~CMusicStream ();
CMusicStream();
~CMusicStream();

CSoundStream* CreateSound (LPCSTR name );
void DeleteSound (CSoundStream* pSnd);
CSoundStream* CreateSound(LPCSTR name);
void DeleteSound(CSoundStream* pSnd);

void OnMove ();
void Reload ();
void Update ();
void OnMove();
void Reload();
void Update();
};

#endif // !defined(AFX_MUSICSTREAM_H__7DAD65D5_8E32_4262_89C8_67A135405BAF__INCLUDED_)
#endif // !defined(AFX_MUSICSTREAM_H__7DAD65D5_8E32_4262_89C8_67A135405BAF__INCLUDED_)
Loading

0 comments on commit 6852d9d

Please sign in to comment.