moved sound callback into AV member function
git-svn-id: svn://anubis/anaglym/trunk@277 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
parent
a072c49b0e
commit
6e502367bc
23
AV.cc
23
AV.cc
@ -8,16 +8,9 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
static void AV_sound_callback(void * userdata, Uint8 * stream, int len)
|
void AV_sound_callback(void * userdata, Uint8 * stream, int len)
|
||||||
{
|
{
|
||||||
static int pos = 0;
|
((AV *)userdata)->playCallback(stream, len);
|
||||||
Sint16 * str = (Sint16 *) stream;
|
|
||||||
for (int i = 0; i < len / 4; i++)
|
|
||||||
{
|
|
||||||
str[i*2] = (Sint16) (32000.0 * sin(pos * 263.0 / AV_SOUND_RATE * 2.0 * M_PI));
|
|
||||||
str[i*2+1] = 0;
|
|
||||||
pos++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AV::AV()
|
AV::AV()
|
||||||
@ -121,6 +114,18 @@ void AV::stop()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AV::playCallback(Uint8 * stream, int len)
|
||||||
|
{
|
||||||
|
static int pos = 0;
|
||||||
|
Sint16 * str = (Sint16 *) stream;
|
||||||
|
for (int i = 0; i < len / 4; i++)
|
||||||
|
{
|
||||||
|
str[i*2] = (Sint16) (32000.0 * sin(pos * 440.0 / AV_SOUND_RATE * 2.0 * M_PI));
|
||||||
|
str[i*2+1] = 0;
|
||||||
|
pos++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
AV::Sound::Sound(AV & av)
|
AV::Sound::Sound(AV & av)
|
||||||
: m_av(av)
|
: m_av(av)
|
||||||
{
|
{
|
||||||
|
4
AV.h
4
AV.h
@ -55,7 +55,11 @@ class AV
|
|||||||
}
|
}
|
||||||
refptr<Sound> createSound() { return new Sound(*this); }
|
refptr<Sound> createSound() { return new Sound(*this); }
|
||||||
|
|
||||||
|
friend void AV_sound_callback(void * userdata, Uint8 * stream, int len);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void playCallback(Uint8 * stream, int len);
|
||||||
|
|
||||||
int m_defaultWidth;
|
int m_defaultWidth;
|
||||||
int m_defaultHeight;
|
int m_defaultHeight;
|
||||||
int m_width;
|
int m_width;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user