First of all, I'm from Germany so please be patient about my bad english, I hope it's enough. Maybe you can say me how my text was
Now to my problem, I'm writing on a Netstream Player, I use FMOD for playing the stream, and now I wanted to use Irrlicht for the Interface, but when I now start my programm, I've 99% CPU usage on both cores. That can't be normal. And without the Irrlicht Interface I've 10% at maximum.
I think the best would be when I show you my code, there is many German text, but I hope you can understand it anyway
Here's the main.cpp:
Code: Select all
/*===============================================================================================
Technobase.FM Player - Spielt den Technobase.FM MP3 Stream ab und bietet eine Community Platform
TO-DO:
-Interface
-ACC Stream abspielen können
-Sämtliche Features
===============================================================================================*/
#include "main.h"
///Mainwindow erstellen
int WINAPI WinMain( HINSTANCE, HINSTANCE, PSTR, int )
{
///Irrlicht Device + Irrlicht System erstellen
device = createDevice(EDT_OPENGL, dimension2d<s32>(320, 240), 16, false, false, false, 0);
device->setWindowCaption(L"TechnoBase.FM Player - 2008 by Christian Sauthoff");
driver = device->getVideoDriver();
smgr = device->getSceneManager();
guienv = device->getGUIEnvironment();
//filesys = device->getFileSystem();
///Interface erstellen
Prozentanzeige = guienv->addStaticText(L"We aRe oNe!",rect<s32>(10, 10, 10+100, 10+20));
///FMOD Initialiesieren
FSOUND_Init(32000, 64, 0);
FSOUND_Stream_SetBufferSize(100);
FSOUND_Stream_Net_SetBufferProperties(64000, 60, 80);
TechnobaseFM_Stream = FSOUND_Stream_Open("http://dsl.tb-stream.net:80", FSOUND_NORMAL | FSOUND_NONBLOCKING, 0, 0);
///Hauptschleife
while(device->run())
{
driver->beginScene(true, true, SColor(255,255,255,255)); ///Irrlicht Szene Beginnen
//UpdateKeys();
UpdateStream();
Prozentanzeige->setText(L"");
ProzentanzeigeStr=L"";
ProzentanzeigeStr.append(stringw(GetStreamPercent()));
Prozentanzeige->setText(ProzentanzeigeStr.c_str());
smgr->drawAll();
guienv->drawAll();
driver->endScene(); ///Irrlicht Szene beenden
}
///Programm beenden
device->drop();
FSOUND_Stream_Close(TechnobaseFM_Stream);
FSOUND_Close();
}
///========================================================================================================================
///==================================================FUNKTIONEN============================================================
///========================================================================================================================
int GetStreamStatus()
{
FSOUND_Stream_Net_GetStatus(TechnobaseFM_Stream, &StreamStatus, &Prozent_Geladen, &StreamBitrate, &Stream_Flags);
return 5;
}
int GetStreamPercent()
{
FSOUND_Stream_Net_GetStatus(TechnobaseFM_Stream, &StreamStatus, &Prozent_Geladen, &StreamBitrate, &Stream_Flags);
return Prozent_Geladen;
}
void UpdateKeys()
{
///Tastenabfragen
if (kbhit())
{
LetzteTaste = getch();
if (LetzteTaste == ' ')
{
if(PauseAktiv) {
FSOUND_SetPaused(TechnobaseFM_Channel, false);
PauseAktiv=false;
}
else if(!PauseAktiv) {
FSOUND_SetPaused(TechnobaseFM_Channel, true);
PauseAktiv=true;
}
}
}
}
void UpdateStream()
{
if (TechnobaseFM_Channel < 0 && Prozent_Geladen>90) ///Wenn Noch nicht abgespielt, und genug vorgebuffert abspielen
{
TechnobaseFM_Channel = FSOUND_Stream_PlayEx(FSOUND_FREE, TechnobaseFM_Stream, NULL, TRUE);
FSOUND_SetPaused(TechnobaseFM_Channel, FALSE);
}
}
Code: Select all
#ifndef MAIN_H_INCLUDED
#define MAIN_H_INCLUDED
//=========================================================================================================================
//==================================ANFANG INCLUDIEREN DER HEADER DATEIEN==================================================
//=========================================================================================================================
#include <irrlicht.h>
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <conio.h>
#include <fmod.h>
#include <fmod_errors.h>
#include <iostream>
//=========================================================================================================================
//=====================================ENDE INCLUDIEREN DER HEADER DATEIEN=================================================
//=========================================================================================================================
//=========================================================================================================================
//===========================================ANFANG SETZEN DER NAMESPACES==================================================
//=========================================================================================================================
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
using namespace std;
//=========================================================================================================================
//==========================================ENDE SETZEN DER NAMESPACES=====================================================
//=========================================================================================================================
//=========================================================================================================================
//===========================================ANFANG FUNKTIONSDEKLARIERUNG==================================================
//=========================================================================================================================
int GetStreamStatus();
int GetStreamPercent();
void UpdateKeys();
void UpdateStream();
//=========================================================================================================================
//============================================ENDE FUNKTIONSDEKLARIERUNG===================================================
//=========================================================================================================================
//=========================================================================================================================
//===========================================ANFANG VARIABLENDEKLARIERUNG==================================================
//=========================================================================================================================
//FMOD Variablen
int Prozent_Geladen = 0, StreamStatus = 0, StreamZustand, StreamBitrate;
unsigned int Stream_Flags;
int TechnobaseFM_Channel = -1;
//Interface Variablen
char LetzteTaste=0;
bool PauseAktiv=false;
stringw ProzentanzeigeStr;
//=========================================================================================================================
//============================================ENDE VARIABLENDEKLARIERUNG===================================================
//=========================================================================================================================
//=========================================================================================================================
//===========================================ANFANG ERSTELLEN DER POINTER==================================================
//=========================================================================================================================
//Irrlicht / Interface Pointer
IrrlichtDevice *device = 0;
IVideoDriver* driver = 0;
ISceneManager* smgr = 0;
IGUIEnvironment* guienv = 0;
IFileSystem* filesys = 0;
IGUIStaticText* Prozentanzeige = 0;
//FMOD/NetStream Pointer
FMUSIC_MODULE *mod = NULL;
FSOUND_STREAM *TechnobaseFM_Stream;
//=========================================================================================================================
//============================================ENDE ERSTELLEN DER POINTER===================================================
//=========================================================================================================================
#endif // MAIN_H_INCLUDED
Why is the CPU Usage so high?
I hope you can help me,
Thanks,
Christian