*** empty log message ***

This commit is contained in:
Cary Sandvig 2000-10-13 21:41:07 +00:00
parent 8fd084e497
commit 8495b019f5
5 changed files with 92 additions and 38 deletions

View File

@ -408,11 +408,12 @@ WinSample* WinSample::load_raw(unsigned char* data, unsigned long size) {
wavInfo.nBlockAlign = wavInfo.wBitsPerSample / 8 * wavInfo.nChannels; wavInfo.nBlockAlign = wavInfo.wBitsPerSample / 8 * wavInfo.nChannels;
wavInfo.nAvgBytesPerSec = wavInfo.nSamplesPerSec * wavInfo.nBlockAlign; wavInfo.nAvgBytesPerSec = wavInfo.nSamplesPerSec * wavInfo.nBlockAlign;
if (data = (unsigned char*)0L) if (data == (unsigned char*)0L)
return ret; return ret;
// create a direct sound channel for this data // create a direct sound channel for this data
ret = new WinSample(); ret = new WinSample();
DSBUFFERDESC dsbdDesc; DSBUFFERDESC dsbdDesc;
ZeroMemory(&dsbdDesc, sizeof(DSBUFFERDESC)); ZeroMemory(&dsbdDesc, sizeof(DSBUFFERDESC));
dsbdDesc.dwSize = 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); dsbdDesc.lpwfxFormat->cbSize = sizeof(wavInfo);
HRESULT result = soundDirectSound->CreateSoundBuffer(&dsbdDesc, HRESULT result = soundDirectSound->CreateSoundBuffer(&dsbdDesc,
&(ret->_channel), NULL); &(ret->_channel), NULL);
if (FAILED(result)) { if (FAILED(result)) {
delete ret; delete ret;
ret = (WinSample*)0L; ret = (WinSample*)0L;

View File

@ -11,13 +11,13 @@
NotifyCategoryDecl(audio, EXPCL_PANDA, EXPTP_PANDA); NotifyCategoryDecl(audio, EXPCL_PANDA, EXPTP_PANDA);
extern int audio_sample_voices; extern EXPCL_PANDA int audio_sample_voices;
extern int audio_mix_freq; extern EXPCL_PANDA int audio_mix_freq;
extern string* audio_mode_flags; extern EXPCL_PANDA string* audio_mode_flags;
extern int audio_driver_select; extern EXPCL_PANDA int audio_driver_select;
extern string* audio_driver_params; extern EXPCL_PANDA string* audio_driver_params;
extern int audio_buffer_size; extern EXPCL_PANDA int audio_buffer_size;
extern string* audio_device; extern EXPCL_PANDA string* audio_device;
extern int audio_auto_update_delay; extern EXPCL_PANDA int audio_auto_update_delay;
#endif /* __CONFIG_AUDIO_H__ */ #endif /* __CONFIG_AUDIO_H__ */

View File

@ -36,14 +36,14 @@
#end lib_target #end lib_target
//#begin lib_target #begin lib_target
// #define TARGET audio_load_mp3 #define TARGET audio_load_mp3
// #define BUILDING_DLL BUILDING_MISC #define BUILDING_DLL BUILDING_MISC
// #define LOCAL_LIBS \ #define LOCAL_LIBS \
// audio mpg123 express audio mpg123 express
// #define CFLAGS -DGENERIC -DNOXFERMEM #define C++FLAGS -DGENERIC -DNOXFERMEM
//
// #define SOURCES \ #define SOURCES \
// audio_load_mp3.cxx audio_load_mp3.cxx
//
//#end lib_target #end lib_target

View File

@ -128,7 +128,43 @@ static void initialize(void) {
initialized = true; 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" { extern "C" {
int audio_open(struct audio_info_struct* ai) { 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 audio_play_samples(struct audio_info_struct* ai, unsigned char* buf,
int len) { int len) {
for (int i=0; i<len; ++i) if (my_buf_head == (BufferPart*)0L) {
(*my_outstream) << buf[i]; my_buf_head = my_buf_curr = new BufferPart(buf, len);
} else {
my_buf_curr = my_buf_curr->add(buf, len);
}
return len; return len;
} }
@ -331,10 +370,9 @@ static void read_file(Filename filename, unsigned char** buf,
unsigned long& slen) { unsigned long& slen) {
int init; int init;
unsigned long frameNum = 0; unsigned long frameNum = 0;
ostringstream out;
initialize(); initialize();
my_outstream = &out; my_buf_head = my_buf_curr = (BufferPart*)0L;
if (open_stream((char*)(filename.c_str()), -1)) { if (open_stream((char*)(filename.c_str()), -1)) {
long leftFrames, newFrame; long leftFrames, newFrame;
@ -343,6 +381,9 @@ static void read_file(Filename filename, unsigned char** buf,
newFrame = param.startFrame; newFrame = param.startFrame;
leftFrames = numframes; leftFrames = numframes;
for (frameNum=0; read_frame(&fr) && leftFrames && !intflag; ++frameNum) { 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 && if (frameNum < param.startFrame || (param.doublespeed &&
(frameNum % param.doublespeed))) { (frameNum % param.doublespeed))) {
if (fr.lay == 3) if (fr.lay == 3)
@ -362,6 +403,8 @@ static void read_file(Filename filename, unsigned char** buf,
intflag = FALSE; intflag = FALSE;
} }
} }
if (audio_cat->is_debug())
audio_cat->debug(false) << endl;
audio_flush(param.outmode, &ai); audio_flush(param.outmode, &ai);
free(pcm_sample); free(pcm_sample);
switch (param.outmode) { switch (param.outmode) {
@ -379,11 +422,10 @@ static void read_file(Filename filename, unsigned char** buf,
break; break;
} }
// generate output // generate output
string s = out.str(); slen = my_buf_head->length();
slen = s.length();
*buf = new byte[slen]; *buf = new byte[slen];
memcpy(*buf, s.data(), slen); my_buf_head->output(*buf);
my_outstream = (ostream*)0L; delete my_buf_head;
} }
#ifdef AUDIO_USE_MIKMOD #ifdef AUDIO_USE_MIKMOD
@ -410,19 +452,26 @@ void AudioLoadMp3(AudioTraits::SampleClass** sample,
#include "audio_win_traits.h" #include "audio_win_traits.h"
void AudioDestroyMp3(AudioTraits::SampleClass* sample) { void EXPCL_MISC AudioDestroyMp3(AudioTraits::SampleClass* sample) {
delete sample; delete sample;
} }
void AudioLoadMp3(AudioTraits::SampleClass** sample, void AudioLoadMp3(AudioTraits::SampleClass** sample,
AudioTraits::PlayingClass** state, AudioTraits::PlayingClass** state,
AudioTraits::PlayerClass** player, AudioTraits::PlayerClass** player,
AudioTraits::DeleteSampleFunc** destroy, Filename) { AudioTraits::DeleteSampleFunc** destroy, Filename filename) {
audio_cat->warning() << "win32 doesn't support reading mp3 data yet" unsigned char* buf;
<< endl; unsigned long len;
*sample = (AudioTraits::SampleClass*)0L; read_file(filename, &buf, len);
*state = (AudioTraits::PlayingClass*)0L; if (buf != (unsigned char*)0L) {
*player = (AudioTraits::PlayerClass*)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; *destroy = AudioDestroyMp3;
} }
@ -445,13 +494,12 @@ void AudioLoadMp3(AudioTraits::SampleClass** sample,
*sample = LinuxSample::load_raw(buf, len); *sample = LinuxSample::load_raw(buf, len);
*state = ((LinuxSample*)(*sample))->get_state(); *state = ((LinuxSample*)(*sample))->get_state();
*player = LinuxPlayer::get_instance(); *player = LinuxPlayer::get_instance();
*destroy = AudioDestroyMp3;
} else { } else {
*sample = (AudioTraits::SampleClass*)0L; *sample = (AudioTraits::SampleClass*)0L;
*state = (AudioTraits::PlayingClass*)0L; *state = (AudioTraits::PlayingClass*)0L;
*player = (AudioTraits::PlayerClass*)0L; *player = (AudioTraits::PlayerClass*)0L;
*destroy = AudioDestroyMp3;
} }
*destroy = AudioDestroyMp3;
} }
#elif defined(AUDIO_USE_NULL) #elif defined(AUDIO_USE_NULL)

View File

@ -63,9 +63,13 @@ typedef unsigned char byte;
#endif #endif
#ifdef __GNUC__ #ifdef __GNUC__
#ifndef INLINE
#define INLINE inline #define INLINE inline
#endif /* INLINE */
#else #else
#ifndef INLINE
#define INLINE #define INLINE
#endif /* INLINE */
#endif #endif
#include "mpgaudio.h" #include "mpgaudio.h"