mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-28 07:48:37 -04:00
*** empty log message ***
This commit is contained in:
parent
8fd084e497
commit
8495b019f5
@ -408,11 +408,12 @@ WinSample* WinSample::load_raw(unsigned char* data, unsigned long size) {
|
||||
wavInfo.nBlockAlign = wavInfo.wBitsPerSample / 8 * wavInfo.nChannels;
|
||||
wavInfo.nAvgBytesPerSec = wavInfo.nSamplesPerSec * wavInfo.nBlockAlign;
|
||||
|
||||
if (data = (unsigned char*)0L)
|
||||
if (data == (unsigned char*)0L)
|
||||
return ret;
|
||||
|
||||
// create a direct sound channel for this data
|
||||
ret = new WinSample();
|
||||
|
||||
DSBUFFERDESC dsbdDesc;
|
||||
ZeroMemory(&dsbdDesc, sizeof(DSBUFFERDESC));
|
||||
dsbdDesc.dwSize = sizeof(DSBUFFERDESC);
|
||||
@ -422,6 +423,7 @@ WinSample* WinSample::load_raw(unsigned char* data, unsigned long size) {
|
||||
dsbdDesc.lpwfxFormat->cbSize = sizeof(wavInfo);
|
||||
HRESULT result = soundDirectSound->CreateSoundBuffer(&dsbdDesc,
|
||||
&(ret->_channel), NULL);
|
||||
|
||||
if (FAILED(result)) {
|
||||
delete ret;
|
||||
ret = (WinSample*)0L;
|
||||
|
@ -11,13 +11,13 @@
|
||||
|
||||
NotifyCategoryDecl(audio, EXPCL_PANDA, EXPTP_PANDA);
|
||||
|
||||
extern int audio_sample_voices;
|
||||
extern int audio_mix_freq;
|
||||
extern string* audio_mode_flags;
|
||||
extern int audio_driver_select;
|
||||
extern string* audio_driver_params;
|
||||
extern int audio_buffer_size;
|
||||
extern string* audio_device;
|
||||
extern int audio_auto_update_delay;
|
||||
extern EXPCL_PANDA int audio_sample_voices;
|
||||
extern EXPCL_PANDA int audio_mix_freq;
|
||||
extern EXPCL_PANDA string* audio_mode_flags;
|
||||
extern EXPCL_PANDA int audio_driver_select;
|
||||
extern EXPCL_PANDA string* audio_driver_params;
|
||||
extern EXPCL_PANDA int audio_buffer_size;
|
||||
extern EXPCL_PANDA string* audio_device;
|
||||
extern EXPCL_PANDA int audio_auto_update_delay;
|
||||
|
||||
#endif /* __CONFIG_AUDIO_H__ */
|
||||
|
@ -36,14 +36,14 @@
|
||||
|
||||
#end lib_target
|
||||
|
||||
//#begin lib_target
|
||||
// #define TARGET audio_load_mp3
|
||||
// #define BUILDING_DLL BUILDING_MISC
|
||||
// #define LOCAL_LIBS \
|
||||
// audio mpg123 express
|
||||
// #define CFLAGS -DGENERIC -DNOXFERMEM
|
||||
//
|
||||
// #define SOURCES \
|
||||
// audio_load_mp3.cxx
|
||||
//
|
||||
//#end lib_target
|
||||
#begin lib_target
|
||||
#define TARGET audio_load_mp3
|
||||
#define BUILDING_DLL BUILDING_MISC
|
||||
#define LOCAL_LIBS \
|
||||
audio mpg123 express
|
||||
#define C++FLAGS -DGENERIC -DNOXFERMEM
|
||||
|
||||
#define SOURCES \
|
||||
audio_load_mp3.cxx
|
||||
|
||||
#end lib_target
|
||||
|
@ -128,7 +128,43 @@ static void initialize(void) {
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
ostream* my_outstream;
|
||||
class BufferPart {
|
||||
private:
|
||||
unsigned char* _ptr;
|
||||
unsigned long _len;
|
||||
BufferPart* _next;
|
||||
|
||||
BufferPart(void) : _ptr((unsigned char*)0L), _len(0), _next((BufferPart*)0L)
|
||||
{}
|
||||
public:
|
||||
BufferPart(unsigned char* b, unsigned long l) : _next((BufferPart*)0L),
|
||||
_len(l) {
|
||||
_ptr = new unsigned char[l];
|
||||
memcpy(_ptr, b, l);
|
||||
}
|
||||
~BufferPart(void) {
|
||||
delete _next;
|
||||
delete [] _ptr;
|
||||
}
|
||||
BufferPart* add(unsigned char* b, unsigned long l) {
|
||||
_next = new BufferPart(b, l);
|
||||
return _next;
|
||||
}
|
||||
unsigned long length(void) const {
|
||||
unsigned long ret = _len;
|
||||
if (_next != (BufferPart*)0L)
|
||||
ret += _next->length();
|
||||
return ret;
|
||||
}
|
||||
void output(unsigned char* b) {
|
||||
memcpy(b, _ptr, _len);
|
||||
if (_next != (BufferPart*)0L)
|
||||
_next->output(b+_len);
|
||||
}
|
||||
};
|
||||
|
||||
static BufferPart* my_buf_head;
|
||||
static BufferPart* my_buf_curr;
|
||||
|
||||
extern "C" {
|
||||
int audio_open(struct audio_info_struct* ai) {
|
||||
@ -177,8 +213,11 @@ int audio_get_formats(struct audio_info_struct* ai) {
|
||||
|
||||
int audio_play_samples(struct audio_info_struct* ai, unsigned char* buf,
|
||||
int len) {
|
||||
for (int i=0; i<len; ++i)
|
||||
(*my_outstream) << buf[i];
|
||||
if (my_buf_head == (BufferPart*)0L) {
|
||||
my_buf_head = my_buf_curr = new BufferPart(buf, len);
|
||||
} else {
|
||||
my_buf_curr = my_buf_curr->add(buf, len);
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
@ -331,10 +370,9 @@ static void read_file(Filename filename, unsigned char** buf,
|
||||
unsigned long& slen) {
|
||||
int init;
|
||||
unsigned long frameNum = 0;
|
||||
ostringstream out;
|
||||
|
||||
initialize();
|
||||
my_outstream = &out;
|
||||
my_buf_head = my_buf_curr = (BufferPart*)0L;
|
||||
if (open_stream((char*)(filename.c_str()), -1)) {
|
||||
long leftFrames, newFrame;
|
||||
|
||||
@ -343,6 +381,9 @@ static void read_file(Filename filename, unsigned char** buf,
|
||||
newFrame = param.startFrame;
|
||||
leftFrames = numframes;
|
||||
for (frameNum=0; read_frame(&fr) && leftFrames && !intflag; ++frameNum) {
|
||||
if ((frameNum % 100) == 0)
|
||||
if (audio_cat->is_debug())
|
||||
audio_cat->debug(false) << ".";
|
||||
if (frameNum < param.startFrame || (param.doublespeed &&
|
||||
(frameNum % param.doublespeed))) {
|
||||
if (fr.lay == 3)
|
||||
@ -362,6 +403,8 @@ static void read_file(Filename filename, unsigned char** buf,
|
||||
intflag = FALSE;
|
||||
}
|
||||
}
|
||||
if (audio_cat->is_debug())
|
||||
audio_cat->debug(false) << endl;
|
||||
audio_flush(param.outmode, &ai);
|
||||
free(pcm_sample);
|
||||
switch (param.outmode) {
|
||||
@ -379,11 +422,10 @@ static void read_file(Filename filename, unsigned char** buf,
|
||||
break;
|
||||
}
|
||||
// generate output
|
||||
string s = out.str();
|
||||
slen = s.length();
|
||||
slen = my_buf_head->length();
|
||||
*buf = new byte[slen];
|
||||
memcpy(*buf, s.data(), slen);
|
||||
my_outstream = (ostream*)0L;
|
||||
my_buf_head->output(*buf);
|
||||
delete my_buf_head;
|
||||
}
|
||||
|
||||
#ifdef AUDIO_USE_MIKMOD
|
||||
@ -410,19 +452,26 @@ void AudioLoadMp3(AudioTraits::SampleClass** sample,
|
||||
|
||||
#include "audio_win_traits.h"
|
||||
|
||||
void AudioDestroyMp3(AudioTraits::SampleClass* sample) {
|
||||
void EXPCL_MISC AudioDestroyMp3(AudioTraits::SampleClass* sample) {
|
||||
delete sample;
|
||||
}
|
||||
|
||||
void AudioLoadMp3(AudioTraits::SampleClass** sample,
|
||||
AudioTraits::PlayingClass** state,
|
||||
AudioTraits::PlayerClass** player,
|
||||
AudioTraits::DeleteSampleFunc** destroy, Filename) {
|
||||
audio_cat->warning() << "win32 doesn't support reading mp3 data yet"
|
||||
<< endl;
|
||||
AudioTraits::DeleteSampleFunc** destroy, Filename filename) {
|
||||
unsigned char* buf;
|
||||
unsigned long len;
|
||||
read_file(filename, &buf, len);
|
||||
if (buf != (unsigned char*)0L) {
|
||||
*sample = WinSample::load_raw(buf, len);
|
||||
*state = ((WinSample*)(*sample))->get_state();
|
||||
*player = WinPlayer::get_instance();
|
||||
} else {
|
||||
*sample = (AudioTraits::SampleClass*)0L;
|
||||
*state = (AudioTraits::PlayingClass*)0L;
|
||||
*player = (AudioTraits::PlayerClass*)0L;
|
||||
}
|
||||
*destroy = AudioDestroyMp3;
|
||||
}
|
||||
|
||||
@ -445,13 +494,12 @@ void AudioLoadMp3(AudioTraits::SampleClass** sample,
|
||||
*sample = LinuxSample::load_raw(buf, len);
|
||||
*state = ((LinuxSample*)(*sample))->get_state();
|
||||
*player = LinuxPlayer::get_instance();
|
||||
*destroy = AudioDestroyMp3;
|
||||
} else {
|
||||
*sample = (AudioTraits::SampleClass*)0L;
|
||||
*state = (AudioTraits::PlayingClass*)0L;
|
||||
*player = (AudioTraits::PlayerClass*)0L;
|
||||
*destroy = AudioDestroyMp3;
|
||||
}
|
||||
*destroy = AudioDestroyMp3;
|
||||
}
|
||||
|
||||
#elif defined(AUDIO_USE_NULL)
|
||||
|
@ -63,9 +63,13 @@ typedef unsigned char byte;
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#ifndef INLINE
|
||||
#define INLINE inline
|
||||
#endif /* INLINE */
|
||||
#else
|
||||
#ifndef INLINE
|
||||
#define INLINE
|
||||
#endif /* INLINE */
|
||||
#endif
|
||||
|
||||
#include "mpgaudio.h"
|
||||
|
Loading…
x
Reference in New Issue
Block a user