mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-18 02:12:00 +00:00
Implement GetStats for OpenAL streams
This commit is contained in:
parent
68988ab93c
commit
665d685a44
3 changed files with 73 additions and 2 deletions
|
@ -345,6 +345,41 @@ void *OpenALSoundStream::GetData(size_t bytes)
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FString OpenALSoundStream::GetStats()
|
||||||
|
{
|
||||||
|
FString stats;
|
||||||
|
ALfloat volume;
|
||||||
|
ALint processed;
|
||||||
|
ALint queued;
|
||||||
|
ALint state;
|
||||||
|
ALenum err;
|
||||||
|
|
||||||
|
alGetSourcef(Source, AL_GAIN, &volume);
|
||||||
|
alGetSourcei(Source, AL_SOURCE_STATE, &state);
|
||||||
|
alGetSourcei(Source, AL_BUFFERS_QUEUED, &queued);
|
||||||
|
alGetSourcei(Source, AL_BUFFERS_PROCESSED, &processed);
|
||||||
|
if((err=alGetError()) != AL_NO_ERROR)
|
||||||
|
{
|
||||||
|
stats = "Error getting stats: ";
|
||||||
|
stats += alGetString(err);
|
||||||
|
return stats;
|
||||||
|
}
|
||||||
|
|
||||||
|
stats = (state == AL_INITIAL) ? "Buffering" : (state == AL_STOPPED) ? "Underrun" :
|
||||||
|
(state == AL_PLAYING || state == AL_PAUSED) ? "Ready" : "Unknown state";
|
||||||
|
stats.AppendFormat(",%3d%% buffered", (queued ? 100-(processed*100/queued) : 0));
|
||||||
|
stats.AppendFormat(", %d%%", int(volume * 100));
|
||||||
|
if(state == AL_PAUSED)
|
||||||
|
stats += ", paused";
|
||||||
|
if(state == AL_PLAYING)
|
||||||
|
stats += ", playing";
|
||||||
|
stats.AppendFormat(", %uHz", SampleRate);
|
||||||
|
if(!Playing)
|
||||||
|
stats += " XX";
|
||||||
|
return stats;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool OpenALSoundStream::InitSample()
|
bool OpenALSoundStream::InitSample()
|
||||||
{
|
{
|
||||||
UInt32 smpsize = 0;
|
UInt32 smpsize = 0;
|
||||||
|
|
|
@ -47,6 +47,8 @@ public:
|
||||||
|
|
||||||
virtual bool IsEnded();
|
virtual bool IsEnded();
|
||||||
|
|
||||||
|
virtual FString GetStats();
|
||||||
|
|
||||||
bool Init(const char *filename, int offset, int length);
|
bool Init(const char *filename, int offset, int length);
|
||||||
bool Init(const BYTE *data, unsigned int datalen);
|
bool Init(const BYTE *data, unsigned int datalen);
|
||||||
};
|
};
|
||||||
|
|
|
@ -400,6 +400,40 @@ public:
|
||||||
return !Playing;
|
return !Playing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FString GetStats()
|
||||||
|
{
|
||||||
|
FString stats;
|
||||||
|
ALfloat volume;
|
||||||
|
ALint processed;
|
||||||
|
ALint queued;
|
||||||
|
ALint state;
|
||||||
|
ALenum err;
|
||||||
|
|
||||||
|
alGetSourcef(Source, AL_GAIN, &volume);
|
||||||
|
alGetSourcei(Source, AL_SOURCE_STATE, &state);
|
||||||
|
alGetSourcei(Source, AL_BUFFERS_QUEUED, &queued);
|
||||||
|
alGetSourcei(Source, AL_BUFFERS_PROCESSED, &processed);
|
||||||
|
if((err=alGetError()) != AL_NO_ERROR)
|
||||||
|
{
|
||||||
|
stats = "Error getting stats: ";
|
||||||
|
stats += alGetString(err);
|
||||||
|
return stats;
|
||||||
|
}
|
||||||
|
|
||||||
|
stats = (state == AL_INITIAL) ? "Buffering" : (state == AL_STOPPED) ? "Underrun" :
|
||||||
|
(state == AL_PLAYING || state == AL_PAUSED) ? "Ready" : "Unknown state";
|
||||||
|
stats.AppendFormat(",%3d%% buffered", (queued ? 100-(processed*100/queued) : 0));
|
||||||
|
stats.AppendFormat(", %d%%", int(volume * 100));
|
||||||
|
if(state == AL_PAUSED)
|
||||||
|
stats += ", paused";
|
||||||
|
if(state == AL_PLAYING)
|
||||||
|
stats += ", playing";
|
||||||
|
stats.AppendFormat(", %uHz", SampleRate);
|
||||||
|
if(!Playing)
|
||||||
|
stats += " XX";
|
||||||
|
return stats;
|
||||||
|
}
|
||||||
|
|
||||||
bool Init(SoundStreamCallback callback, int buffbytes, int flags, int samplerate, void *userdata)
|
bool Init(SoundStreamCallback callback, int buffbytes, int flags, int samplerate, void *userdata)
|
||||||
{
|
{
|
||||||
if(!SetupSource())
|
if(!SetupSource())
|
||||||
|
|
Loading…
Reference in a new issue