本文整理汇总了C++中fmod::Sound::getOpenState方法的典型用法代码示例。如果您正苦于以下问题:C++ Sound::getOpenState方法的具体用法?C++ Sound::getOpenState怎么用?C++ Sound::getOpenState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fmod::Sound
的用法示例。
在下文中一共展示了Sound::getOpenState方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
FMOD::System *system;
FMOD::Sound *sound;
FMOD::Channel *channel = 0;
FMOD_RESULT result;
int key;
unsigned int version;
HANDLE threadhandle;
InitializeCriticalSection(&gCrit);
threadhandle = (HANDLE)_beginthreadex(NULL, 0, ProcessQueue, 0, 0, 0);
if (!threadhandle)
{
printf("Failed to create file thread.\n");
return 0;
}
/*
Create a System object and initialize.
*/
result = FMOD::System_Create(&system);
ERRCHECK(result);
result = system->getVersion(&version);
ERRCHECK(result);
if (version < FMOD_VERSION)
{
printf("Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION);
return 0;
}
result = system->init(1, FMOD_INIT_NORMAL, 0);
ERRCHECK(result);
result = system->setStreamBufferSize(32768, FMOD_TIMEUNIT_RAWBYTES);
ERRCHECK(result);
result = system->setFileSystem(myopen, myclose, myread, myseek, myasyncread, myasynccancel, 2048);
ERRCHECK(result);
printf("====================================================================\n");
printf("Stream IO Example. Copyright (c) Firelight Technologies 2004-2014.\n");
printf("====================================================================\n");
printf("\n");
printf("\n");
printf("====================== CALLING CREATESOUND ON MP3 =======================\n");
result = system->createStream("../media/wave.mp3", FMOD_SOFTWARE | FMOD_LOOP_NORMAL | FMOD_2D | FMOD_IGNORETAGS, 0, &sound);
ERRCHECK(result);
printf("====================== CALLING PLAYSOUND ON MP3 =======================\n");
result = system->playSound(FMOD_CHANNEL_FREE, sound, false, &channel);
ERRCHECK(result);
/*
Main loop.
*/
do
{
if (sound)
{
FMOD_OPENSTATE openstate;
bool starving;
sound->getOpenState(&openstate, 0, &starving, 0);
if (starving)
{
printf("Starving\n");
result = channel->setMute(true);
}
else
{
result = channel->setMute(false);
ERRCHECK(result);
}
}
if (_kbhit())
{
key = _getch();
switch (key)
{
case ' ' :
{
result = sound->release();
if (result == FMOD_OK)
{
sound = 0;
printf("Released sound.\n");
}
break;
}
}
//.........这里部分代码省略.........
示例2: FMOD_Main
int FMOD_Main()
{
FMOD::System *system = 0;
FMOD::Sound *sound = 0;
FMOD::Channel *channel = 0;
FMOD_RESULT result = FMOD_OK;
FMOD_OPENSTATE openstate = FMOD_OPENSTATE_READY;
unsigned int version = 0;
void *extradriverdata = 0;
const int tagcount = 4;
int tagindex = 0;
char tagstring[tagcount][128] = { 0 };
Common_Init(&extradriverdata);
/*
Create a System object and initialize.
*/
result = FMOD::System_Create(&system);
ERRCHECK(result);
result = system->getVersion(&version);
ERRCHECK(result);
if (version < FMOD_VERSION)
{
Common_Fatal("FMOD lib version %08x doesn't match header version %08x", version, FMOD_VERSION);
}
result = system->init(1, FMOD_INIT_NORMAL, extradriverdata);
ERRCHECK(result);
/* Increase the file buffer size a little bit to account for Internet lag. */
result = system->setStreamBufferSize(64*1024, FMOD_TIMEUNIT_RAWBYTES);
ERRCHECK(result);
result = system->createSound("http://shoutmedia.abc.net.au:10426", FMOD_CREATESTREAM | FMOD_NONBLOCKING, 0, &sound);
ERRCHECK(result);
/*
Main loop
*/
do
{
unsigned int pos = 0;
unsigned int percent = 0;
bool playing = false;
bool paused = false;
bool starving = false;
const char *state = "Stopped";
Common_Update();
if (Common_BtnPress(BTN_ACTION1))
{
if (channel)
{
bool paused = false;
result = channel->getPaused(&paused);
ERRCHECK(result);
result = channel->setPaused(!paused);
ERRCHECK(result);
}
}
result = system->update();
ERRCHECK(result);
result = sound->getOpenState(&openstate, &percent, &starving, 0);
ERRCHECK(result);
if (channel)
{
FMOD_TAG tag;
/*
Read any tags that have arrived, this could happen if a radio station switches
to a new song.
*/
while (sound->getTag(0, -1, &tag) == FMOD_OK)
{
if (tag.datatype == FMOD_TAGDATATYPE_STRING)
{
sprintf(tagstring[tagindex], "%s = '%s' (%d bytes)", tag.name, (char *)tag.data, tag.datalen);
tagindex = (tagindex + 1) % tagcount;
}
else if (tag.type == FMOD_TAGTYPE_FMOD)
{
/* When a song changes, the sample rate may also change, so compensate here. */
if (!strcmp(tag.name, "Sample Rate Change"))
{
float frequency = *((float *)tag.data);
result = channel->setFrequency(frequency);
ERRCHECK(result);
}
}
}
//.........这里部分代码省略.........