From 38f544857eb04eaead29b4cd6371e540d91ce5e6 Mon Sep 17 00:00:00 2001 From: relnev Date: Wed, 5 Jun 2002 08:05:29 +0000 Subject: [PATCH] stub/warning removal. reworked the sound code. --- Makefile | 2 - include/fxos.h | 51 --- include/unix.h | 14 +- src/cfile/cfile.cpp | 13 +- src/freespace2/freespace.cpp | 14 +- src/graphics/bitblt.cpp | 11 +- src/graphics/font.cpp | 9 +- src/graphics/grsoft.cpp | 12 +- src/graphics/scaler.cpp | 14 +- src/io/timer.cpp | 28 +- src/math/floating.cpp | 11 +- src/menuui/optionsmenumulti.cpp | 15 +- src/network/multiutil.cpp | 10 +- src/object/objectsnd.cpp | 16 +- src/platform/unix.cpp | 5 +- src/sound/ds.cpp | 760 ++++++++++++++++++++++++-------- src/sound/ds3d-unix.cpp | 42 -- src/sound/dscap-unix.cpp | 54 --- src/sound/sound.cpp | 14 +- src/weapon/weapons.cpp | 11 +- 20 files changed, 687 insertions(+), 419 deletions(-) delete mode 100644 include/fxos.h delete mode 100644 src/sound/ds3d-unix.cpp delete mode 100644 src/sound/dscap-unix.cpp diff --git a/Makefile b/Makefile index 1556886..d825dab 100644 --- a/Makefile +++ b/Makefile @@ -149,8 +149,6 @@ CODE_SOURCES =./src/anim/animplay.cpp \ ./src/sound/acm-unix.cpp \ ./src/sound/audiostr.cpp \ ./src/sound/ds.cpp \ - ./src/sound/ds3d-unix.cpp \ - ./src/sound/dscap-unix.cpp \ ./src/vcodec/codec1.cpp \ ./src/particle/particle.cpp \ ./src/pcxutils/pcxutils.cpp \ diff --git a/include/fxos.h b/include/fxos.h deleted file mode 100644 index 727aa64..0000000 --- a/include/fxos.h +++ /dev/null @@ -1,51 +0,0 @@ -/* -** Copyright (c) 1995, 3Dfx Interactive, Inc. -** All Rights Reserved. -** -** This is UNPUBLISHED PROPRIETARY SOURCE CODE of 3Dfx Interactive, Inc.; -** the contents of this file may not be disclosed to third parties, copied or -** duplicated in any form, in whole or in part, without the prior written -** permission of 3Dfx Interactive, Inc. -** -** RESTRICTED RIGHTS LEGEND: -** Use, duplication or disclosure by the Government is subject to restrictions -** as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data -** and Computer Software clause at DFARS 252.227-7013, and/or in similar or -** successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished - -** rights reserved under the Copyright Laws of the United States. -** -** $ Revision: $ -** $ Date: $ -** -*/ - - -#ifndef _FXOS_H_ -#define _FXOS_H_ - -#include - -# ifdef __cplusplus -extern "C" { -# endif - -# ifdef WIN32 -void sleep(int secs); -#define gethostname fxGethostname - -int gethostname(char *name, int namelen); - -# endif - -float fxTime(void); -float timer(int flag); - -FILE *fxFopenPath(const char *filename, const char *mode, - const char *path, const char **pprefix); - -# ifdef __cplusplus -} -# endif - -#endif - diff --git a/include/unix.h b/include/unix.h index d3599a3..3f47c31 100644 --- a/include/unix.h +++ b/include/unix.h @@ -116,18 +116,6 @@ extern int MulDiv (int, int, int); #define WSAECONNRESET ECONNRESET #define WSAECONNABORTED ECONNABORTED #define WSAESHUTDOWN ESHUTDOWN - -typedef struct channel -{ - int sig; // uniquely - int snd_id; // identifies which - int pdsb; // pointer to the secondary buffer t - int pds3db; // 3D interface, only used if sound buffer created w - int looping; // flag to i - int vol; // in Direct - int priority; // implementation de - bool is_voice_msg; - int last_position; -} channel; +#define WSAENOTSOCK ENOTSOCK #endif diff --git a/src/cfile/cfile.cpp b/src/cfile/cfile.cpp index e7797d7..5b11c8e 100644 --- a/src/cfile/cfile.cpp +++ b/src/cfile/cfile.cpp @@ -7,6 +7,11 @@ * Utilities for operating on files * * $Log$ + * Revision 1.4 2002/06/05 08:05:28 relnev + * stub/warning removal. + * + * reworked the sound code. + * * Revision 1.3 2002/05/28 08:52:03 relnev * implemented two assembly stubs. * @@ -455,7 +460,7 @@ int cfile_push_chdir(int type) int e; char dir[128]; char OriginalDirectory[128]; - char *Drive, *Path; + char *Path; char NoDir[] = "\\."; _getcwd(OriginalDirectory, 127); @@ -465,7 +470,7 @@ int cfile_push_chdir(int type) cf_create_default_path_string( dir, type, NULL ); _strlwr(dir); #ifndef PLAT_UNIX - Drive = strchr(dir, ':'); + char *Drive = strchr(dir, ':'); if (Drive) { if (!cfile_chdrive( *(Drive - 1) - 'a' + 1, 1)) @@ -498,14 +503,14 @@ int cfile_chdir(char *dir) { int e; char OriginalDirectory[128]; - char *Drive, *Path; + char *Path; char NoDir[] = "\\."; _getcwd(OriginalDirectory, 127); _strlwr(dir); #ifndef PLAT_UNIX - Drive = strchr(dir, ':'); + char *Drive = strchr(dir, ':'); if (Drive) { if (!cfile_chdrive( *(Drive - 1) - 'a' + 1, 1)) return 1; diff --git a/src/freespace2/freespace.cpp b/src/freespace2/freespace.cpp index 50f0e44..ab2378b 100644 --- a/src/freespace2/freespace.cpp +++ b/src/freespace2/freespace.cpp @@ -7,6 +7,11 @@ * Freespace main body * * $Log$ + * Revision 1.15 2002/06/05 08:05:28 relnev + * stub/warning removal. + * + * reworked the sound code. + * * Revision 1.14 2002/06/05 04:03:32 relnev * finished cfilesystem. * @@ -2556,8 +2561,6 @@ void game_show_framerate() sy += dy; gr_printf( sx, sy, NOX("EXP VRAM: %dKB\n"), (Glide_explosion_vram)/1024 ); sy += dy; -#else - STUB_FUNCTION; #endif } // gr_printf( sx, sy, "BPP: %d", gr_screen.bits_per_pixel ); @@ -2640,8 +2643,6 @@ void game_show_framerate() sy += dy; gr_printf( sx, sy, NOX("EXP VRAM: %dKB\n"), (Glide_explosion_vram)/1024 ); sy += dy; -#else - STUB_FUNCTION; #endif } } @@ -6731,8 +6732,6 @@ int PASCAL WinMainSub(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int nCm free(tmp_mem); tmp_mem = NULL; -#else - STUB_FUNCTION; #endif /* this code doesn't work, and we will hit an error about being unable to load the direct draw @@ -6941,9 +6940,8 @@ int PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int nCmdSh } return result; #else - STUB_FUNCTION; + nprintf(("WinMain", "exceptions shall fall through")); - fprintf(stderr, "WinMain: exceptions shall fall through\n"); result = WinMainSub(hInst, hPrev, szCmdLine, nCmdShow); return result; diff --git a/src/graphics/bitblt.cpp b/src/graphics/bitblt.cpp index fe7a826..34f5cde 100644 --- a/src/graphics/bitblt.cpp +++ b/src/graphics/bitblt.cpp @@ -7,6 +7,11 @@ * Code to do software bitblt type stuff * * $Log$ + * Revision 1.3 2002/06/05 08:05:29 relnev + * stub/warning removal. + * + * reworked the sound code. + * * Revision 1.2 2002/05/28 21:36:10 relnev * some more timer junk. * @@ -314,7 +319,7 @@ void grx_aabitmap_ex(int x,int y,int w,int h,int sx,int sy) void gr8_bitmap_ex(int x,int y,int w,int h,int sx,int sy) { -#if 1 +#if 0 MONITOR_INC( Num2dBitmaps, 1 ); gr_lock(); @@ -329,8 +334,8 @@ void gr8_bitmap_ex(int x,int y,int w,int h,int sx,int sy) //mprintf(( "x=%d, y=%d, w=%d, h=%d\n", x, y, w, h )); //mprintf(( "sx=%d, sy=%d, bw=%d, bh=%d\n", sx, sy, bmp->w, bmp->h )); -#warning BMP_XPARENT == BMP_TEX_XPARENT ?? - if ( bmp->flags & BMP_TEX_XPARENT ) { + + if ( bmp->flags & BMP_XPARENT ) { for (i=0; irowsize*(v>>16)]; dbits = GR_SCREEN_PTR(ubyte,dx0,y); + +#ifdef USE_COMPILED_CODE // uint lookup = (uint)&Current_alphacolor->table.lookup[0][0]; uint lookup = (uint)&old_alphac.table.lookup[0][0]; -#ifdef USE_COMPILED_CODE // Call the compiled code to draw one scanline if ( Gr_scaler_zbuffering && gr_zbuffering ) { int x, tmp_u; diff --git a/src/io/timer.cpp b/src/io/timer.cpp index ff96f2e..f812324 100644 --- a/src/io/timer.cpp +++ b/src/io/timer.cpp @@ -7,6 +7,11 @@ * Include file for timer stuff * * $Log$ + * Revision 1.6 2002/06/05 08:05:29 relnev + * stub/warning removal. + * + * reworked the sound code. + * * Revision 1.5 2002/05/29 21:38:20 relnev * fixed? * @@ -88,19 +93,20 @@ #define USE_TIMING #endif +#ifndef PLAT_UNIX static longlong Timer_last_value, Timer_base; static uint Timer_freq=0; +static CRITICAL_SECTION Timer_lock; +#endif static int Timer_inited = 0; -static CRITICAL_SECTION Timer_lock; - void timer_close() { if ( Timer_inited ) { Timer_inited = 0; #ifdef PLAT_UNIX - STUB_FUNCTION; +// STUB_FUNCTION; #else DeleteCriticalSection( &Timer_lock ); #endif @@ -111,7 +117,7 @@ void timer_init() { if ( !Timer_inited ) { #ifdef PLAT_UNIX - SDL_InitSubSystem(SDL_INIT_TIMER); +// SDL_InitSubSystem(SDL_INIT_TIMER); #else LARGE_INTEGER tmp; QueryPerformanceFrequency(&tmp); @@ -130,12 +136,10 @@ void timer_init() } } +#ifndef PLAT_UNIX // Fills Time_now with the ticks since program start static void timer_get(LARGE_INTEGER * out) { -#ifdef PLAT_UNIX - STUB_FUNCTION; -#else EnterCriticalSection(&Timer_lock); longlong time_tmp; @@ -156,16 +160,12 @@ static void timer_get(LARGE_INTEGER * out) out->QuadPart = Time_now; LeaveCriticalSection(&Timer_lock); -#endif } +#endif fix timer_get_fixed_seconds() { #ifdef PLAT_UNIX -// STUB_FUNCTION; -// return 0; - -// return (SDL_GetTicks() << 16) / 1000; __extension__ long long a = SDL_GetTicks(); a *= 65536; @@ -258,9 +258,6 @@ sub_again: int timer_get_microseconds() { #ifdef PLAT_UNIX -// STUB_FUNCTION; -// return 0; - return SDL_GetTicks() * 1000; #else int tmp; @@ -602,4 +599,3 @@ void timing_display(int x, int y) } #endif } - diff --git a/src/math/floating.cpp b/src/math/floating.cpp index b9bccb3..8170735 100644 --- a/src/math/floating.cpp +++ b/src/math/floating.cpp @@ -7,6 +7,11 @@ * Low-level floating point math routines * * $Log$ + * Revision 1.4 2002/06/05 08:05:29 relnev + * stub/warning removal. + * + * reworked the sound code. + * * Revision 1.3 2002/05/31 00:29:32 theoddone33 * Fix frand() * @@ -74,9 +79,6 @@ typedef float FLOAT; #define GET_EMANT(a) (((a) >> LOOKUP_POS) & LOOKUP_MASK ) #define SET_MANTSEED(a) (((unsigned long)(a)) << SEED_POS ) -static unsigned char iSqrt[TABLE_SIZE]; -static int iSqrt_inited = 0; - int fl_magic = 0x59C00000; //representation of 2^51 + 2^52 const float *p_fl_magic = (const float *)&fl_magic; @@ -86,6 +88,9 @@ union _flint { } fi, fo; /* +static unsigned char iSqrt[TABLE_SIZE]; +static int iSqrt_inited = 0; + static void MakeInverseSqrtLookupTable() { long f; diff --git a/src/menuui/optionsmenumulti.cpp b/src/menuui/optionsmenumulti.cpp index 0607203..91e1f9e 100644 --- a/src/menuui/optionsmenumulti.cpp +++ b/src/menuui/optionsmenumulti.cpp @@ -5,6 +5,11 @@ * $Author$ * * $Log$ + * Revision 1.4 2002/06/05 08:05:29 relnev + * stub/warning removal. + * + * reworked the sound code. + * * Revision 1.3 2002/06/02 06:02:59 relnev * tcp.cfg namefix * @@ -198,9 +203,7 @@ #include "bmpman.h" #include "cfile.h" #include "key.h" -#ifndef PLAT_UNIX #include "ds.h" -#endif #include "font.h" #include "gamesnd.h" #include "freespace.h" @@ -2043,9 +2046,6 @@ void options_multi_vox_do() case OM_VOX_TEST_PLAYBACK: // if we were playing a sound back, but now the sound is done -#ifdef PLAT_UNIX - STUB_FUNCTION; -#else if((Om_vox_playback_handle != -1) && (ds_get_play_position(ds_get_channel(Om_vox_playback_handle)) >= (DWORD)Om_vox_voice_comp_size)){ // flush all playing sounds safely rtvoice_stop_playback_all(); @@ -2060,7 +2060,6 @@ void options_multi_vox_do() // free the status up Om_vox_test_status = OM_VOX_TEST_NONE; } -#endif break; } } @@ -2212,9 +2211,6 @@ void options_multi_vox_process_waveform() case OM_VOX_TEST_PLAYBACK: // get the offset into the playing direct sound buffer -#ifdef PLAT_UNIX - STUB_FUNCTION; -#else buf_offset = ds_get_play_position(ds_get_channel(Om_vox_playback_handle)); // get the # of samples we'll average for one line @@ -2237,7 +2233,6 @@ void options_multi_vox_process_waveform() running_avg /= avg_len; gr_line((gr_screen.max_w - OM_VOX_WAVE_WIDTH)/2 + idx, OM_VOX_WAVE_Y, (gr_screen.max_w - OM_VOX_WAVE_WIDTH)/2 + idx, OM_VOX_WAVE_Y + running_avg); } -#endif break; } } diff --git a/src/network/multiutil.cpp b/src/network/multiutil.cpp index 0d04a25..b6df8f6 100644 --- a/src/network/multiutil.cpp +++ b/src/network/multiutil.cpp @@ -7,6 +7,11 @@ * C file that contains misc. functions to support multiplayer * * $Log$ + * Revision 1.6 2002/06/05 08:05:29 relnev + * stub/warning removal. + * + * reworked the sound code. + * * Revision 1.5 2002/06/02 04:26:34 relnev * warning cleanup * @@ -209,6 +214,7 @@ #include #include #include +#include #endif #include #include "multiutil.h" @@ -1680,9 +1686,6 @@ int multi_netplayer_flag_check(int flags,int ignore_standalone) // is no longer there. void multi_eval_socket_error(PSNET_SOCKET sock, int error) { -#ifdef PLAT_UNIX - STUB_FUNCTION; -#else if ( error == WSAENOTSOCK ){ nprintf(("Network","Socket connection terminated and/or nonexistent, bailing..\n")); @@ -1722,7 +1725,6 @@ void multi_eval_socket_error(PSNET_SOCKET sock, int error) nprintf(("Network", "Communications to server lost -- quitting game\n")); multi_quit_game(PROMPT_NONE, MULTI_END_NOTIFY_NONE, MULTI_END_ERROR_CONTACT_LOST); } -#endif } // send a repair info packet with code == code to a player if his object is the one being acted upon diff --git a/src/object/objectsnd.cpp b/src/object/objectsnd.cpp index 7ef5e2e..9988a22 100644 --- a/src/object/objectsnd.cpp +++ b/src/object/objectsnd.cpp @@ -7,6 +7,11 @@ * C module for managing object-linked persistant sounds * * $Log$ + * Revision 1.3 2002/06/05 08:05:29 relnev + * stub/warning removal. + * + * reworked the sound code. + * * Revision 1.2 2002/05/07 03:16:48 theoddone33 * The Great Newline Fix * @@ -239,9 +244,7 @@ #include "linklist.h" #include "ship.h" #include "gamesnd.h" -#ifndef PLAT_UNIX #include "ds.h" -#endif #include "ds3d.h" #include "timer.h" #include "3d.h" @@ -770,9 +773,6 @@ void obj_snd_do_frame() } // end switch if ( go_ahead_flag ) { -#ifdef PLAT_UNIX - STUB_FUNCTION; -#else if ( ds_using_ds3d() ) { osp->instance = snd_play_3d(gs, &source_pos, &View_position, add_distance, &objp->phys_info.vel, 1, 1.0f, SND_PRIORITY_TRIPLE_INSTANCE); if ( osp->instance != -1 ) { @@ -787,7 +787,6 @@ void obj_snd_do_frame() Num_obj_sounds_playing++; } } -#endif } Assert(Num_obj_sounds_playing <= MAX_OBJ_SOUNDS_PLAYING); @@ -818,10 +817,6 @@ void obj_snd_do_frame() if ( objp->type == OBJ_SHIP ) sp = &Ships[objp->instance]; - -#ifdef PLAT_UNIX - STUB_FUNCTION; -#else if (ds_using_ds3d()) { channel = ds_get_channel(osp->instance); // for DirectSound3D sounds, re-establish the maximum speed based on the @@ -867,7 +862,6 @@ void obj_snd_do_frame() else snd_set_volume( osp->instance, 0.0f ); } -#endif } // end for // see if we want to play a flyby sound diff --git a/src/platform/unix.cpp b/src/platform/unix.cpp index b93b0ee..26815e7 100644 --- a/src/platform/unix.cpp +++ b/src/platform/unix.cpp @@ -186,7 +186,7 @@ int Log_debug_output_to_file = 0; void load_filter_info(void) { - STUB_FUNCTION; +// STUB_FUNCTION; } void outwnd_printf(char* id, char* format, ...) @@ -213,7 +213,7 @@ void outwnd_printf2(char* format, ...) void outwnd_close() { - STUB_FUNCTION; +// STUB_FUNCTION; } void Warning( char * filename, int line, char * format, ... ) @@ -242,4 +242,5 @@ void Error( char * filename, int line, char * format, ... ) void WinAssert(char * text,char *filename, int line) { fprintf (stderr, "Assertion: (%s:%d) %s\n", filename, line, text); +// exit(1); } diff --git a/src/sound/ds.cpp b/src/sound/ds.cpp index 32ddfc9..cb001d2 100644 --- a/src/sound/ds.cpp +++ b/src/sound/ds.cpp @@ -7,6 +7,11 @@ * C file for interface to DirectSound * * $Log$ + * Revision 1.9 2002/06/05 08:05:29 relnev + * stub/warning removal. + * + * reworked the sound code. + * * Revision 1.8 2002/06/05 04:03:33 relnev * finished cfilesystem. * @@ -477,6 +482,39 @@ GUID DSPROPSETID_EAXBUFFER_ReverbProperties_Def = {0x4a4e6fc0, 0xc341, 0x11d1, { // prototypes void ds_get_soundcard_caps(DSCAPS *dscaps); #else // !PLAT_UNIX + +typedef struct channel +{ + int sig; // uniquely identifies the sound playing on the channel + int snd_id; // identifies which kind of sound is playing + ALuint source_id; // OpenAL source id + int buf_id; // currently bound buffer index (-1 if none) + int looping; // flag to indicate that the sound is looping + int vol; + int priority; // implementation dependant priority + bool is_voice_msg; + int last_position; +} channel; + +typedef struct sound_buffer +{ + ALuint buf_id; // OpenAL buffer id + int source_id; // source index this buffer is currently bound to + + int frequency; + int bits_per_sample; + int nchannels; + int nseconds; +} sound_buffer; + +#define MAX_DS_SOFTWARE_BUFFERS 256 + +static int MAX_CHANNELS = 1000; // initialized properly in ds_init_channels() +channel *Channels; +static int channel_next_sig = 1; + +sound_buffer sound_buffers[MAX_DS_SOFTWARE_BUFFERS]; + static int Ds_use_ds3d = 0; static int Ds_use_a3d = 0; static int Ds_use_eax = 0; @@ -484,8 +522,20 @@ static int Ds_use_eax = 0; ALCdevice *ds_sound_device; void *ds_sound_context = (void *)0; -static int MAX_CHANNELS = 1000; // initialized properly in ds_init_channels() -channel Channels[100]; +#ifndef NDEBUG +#define OpenAL_ErrorCheck() do { \ + int i = alGetError(); \ + if (i != AL_NO_ERROR) { \ + while(i != AL_NO_ERROR) { \ + nprintf(("Warning", "%s/%s:%d - OpenAL error %s\n", __FUNCTION__, __FILE__, __LINE__, alGetString(i))); \ + i = alGetError(); \ + } \ + return -1; \ + } \ +} while (0); +#else +#define OpenAL_ErrorCheck() +#endif #endif // PLAT_UNIX @@ -527,8 +577,7 @@ int ds_is_3d_buffer(int sid) return ds_is_3d_buffer(ds_software_buffers[sid].pdsb); } #else -// STUB_FUNCTION; - return 1; + return 0; #endif } @@ -665,7 +714,6 @@ int ds_parse_wave(char *filename, ubyte **dest, uint *dest_size, WAVEFORMATEX ** return 0; } - // --------------------------------------------------------------------------------------- // ds_get_sid() // @@ -673,9 +721,18 @@ int ds_parse_wave(char *filename, ubyte **dest, uint *dest_size, WAVEFORMATEX ** int ds_get_sid() { #ifdef PLAT_UNIX - // this function is unused in linux. - STUB_FUNCTION; - return -1; + int i; + + for ( i = 0; i < MAX_DS_SOFTWARE_BUFFERS; i++ ) { + if ( sound_buffers[i].buf_id == 0 ) + break; + } + + if ( i == MAX_DS_SOFTWARE_BUFFERS ) { + return -1; + } + + return i; #else int i; @@ -699,8 +756,6 @@ int ds_get_sid() int ds_get_hid() { #ifdef PLAT_UNIX - STUB_FUNCTION; - return -1; #else int i; @@ -739,13 +794,10 @@ int ds_get_hid() // NOTE: this function is slow, especially when sounds are loaded into hardware. Don't call this // function from within gameplay. // -int ds_get_free_channel(int new_volume, int snd_id, int priority); int ds_load_buffer(int *sid, int *hid, int *final_size, void *header, sound_info *si, int flags) { #ifdef PLAT_UNIX - int channel = ds_get_free_channel(0,0,0); - Assert( final_size != NULL ); Assert( header != NULL ); Assert( si != NULL ); @@ -753,10 +805,17 @@ int ds_load_buffer(int *sid, int *hid, int *final_size, void *header, sound_info // All sounds are required to have a software buffer + *sid = ds_get_sid(); + if ( *sid == -1 ) { + nprintf(("Sound","SOUND ==> No more sound buffers available\n")); + return -1; + } ALuint pi; alGenBuffers (1, &pi); + OpenAL_ErrorCheck(); + ALenum format; ALsizei size; ALuint frequency; @@ -768,6 +827,7 @@ int ds_load_buffer(int *sid, int *hid, int *final_size, void *header, sound_info data = si->data; break; default: + STUB_FUNCTION; return -1; } @@ -798,32 +858,17 @@ int ds_load_buffer(int *sid, int *hid, int *final_size, void *header, sound_info alBufferData (pi, format, data, size, frequency); - (*sid) = Channels[channel].pds3db = (int)pi; - - if ( *sid == -1 ) { - nprintf(("Sound","SOUND ==> Weird!\n")); - return -1; - } - - ALfloat pos[] = { 0, 0, 0 }; - ALfloat vel[] = { 0, 0, 0 }; - - alGenSources (1, (ALuint*)hid); - Channels[channel].pdsb = (int)*hid; - (*sid) = channel; - - alSourcef(*((ALuint*)hid), AL_PITCH, 1.0f); - alSourcef(*((ALuint*)hid), AL_GAIN, 1.0f); - alSourcefv(*((ALuint*)hid), AL_POSITION, pos); - alSourcefv(*((ALuint*)hid), AL_VELOCITY, vel); - - int i = alGetError(); - if(i != AL_NO_ERROR) { - printf("%s|||errorC!\n", alGetString(i)); - return -1; - } + sound_buffers[*sid].buf_id = pi; + sound_buffers[*sid].source_id = -1; + sound_buffers[*sid].frequency = frequency; + sound_buffers[*sid].bits_per_sample = si->bits; + sound_buffers[*sid].nchannels = si->n_channels; + sound_buffers[*sid].nseconds = si->size / si->avg_bytes_per_sec; + + OpenAL_ErrorCheck(); return 0; + #else Assert( final_size != NULL ); Assert( header != NULL ); @@ -976,13 +1021,21 @@ int ds_load_buffer(int *sid, int *hid, int *final_size, void *header, sound_info void ds_init_channels() { #ifdef PLAT_UNIX - // STUB_FUNCTION; // not needed with openal (CM) - for(int i = 0; i < MAX_CHANNELS; i++) { - Channels[i].pdsb = 0; // source - Channels[i].pds3db = 0; // buffer - Channels[i].vol = 0; // volume; + int i; + + MAX_CHANNELS = 32; + + Channels = (channel*) malloc(sizeof(channel) * MAX_CHANNELS); + if (Channels == NULL) { + Error(LOCATION, "Unable to allocate %d bytes for %d audio channels.", sizeof(channel) * MAX_CHANNELS, MAX_CHANNELS); + } + + // init the channels + for ( i = 0; i < MAX_CHANNELS; i++ ) { + alGenSources(1, &Channels[i].source_id); + Channels[i].buf_id = -1; + Channels[i].vol = 0; } - return; #else int i; @@ -1025,8 +1078,12 @@ void ds_init_channels() void ds_init_software_buffers() { #ifdef PLAT_UNIX - // STUB_FUNCTION; // not needed with openal (CM) - return; + int i; + + for ( i = 0; i < MAX_DS_SOFTWARE_BUFFERS; i++ ) { + sound_buffers[i].buf_id = 0; + sound_buffers[i].source_id = -1; + } #else int i; @@ -1117,13 +1174,10 @@ void ds_show_caps(DSCAPS *dscaps) } #endif +#ifndef PLAT_UNIX // Fill in the waveformat struct with the primary buffer characteristics. void ds_get_primary_format(WAVEFORMATEX *wfx) { -#ifdef PLAT_UNIX - STUB_FUNCTION; - // unused in linux -#else // Set 16 bit / 22KHz / mono wfx->wFormatTag = WAVE_FORMAT_PCM; wfx->nChannels = 2; @@ -1132,6 +1186,7 @@ void ds_get_primary_format(WAVEFORMATEX *wfx) wfx->cbSize = 0; wfx->nBlockAlign = (unsigned short)(wfx->nChannels * (wfx->wBitsPerSample / 8)); wfx->nAvgBytesPerSec = wfx->nBlockAlign * wfx->nSamplesPerSec; + } //XSTR:OFF // obtain the function pointers from the dsound.dll @@ -1139,8 +1194,8 @@ void ds_dll_get_functions() { pfn_DirectSoundCreate = (HRESULT(__stdcall *)(LPGUID lpGuid, LPDIRECTSOUND *ppDS, IUnknown FAR *pUnkOuter))GetProcAddress(Ds_dll_handle,"DirectSoundCreate"); pfn_DirectSoundCaptureCreate = (HRESULT(__stdcall *)(LPGUID lpGuid, LPDIRECTSOUNDCAPTURE *lplpDSC, IUnknown FAR *pUnkOuter))GetProcAddress(Ds_dll_handle,"DirectSoundCaptureCreate"); -#endif } +#endif // Load the dsound.dll, and get funtion pointers // exit: 0 -> dll loaded successfully @@ -1148,8 +1203,7 @@ void ds_dll_get_functions() int ds_dll_load() { #ifdef PLAT_UNIX - STUB_FUNCTION; - // usused + // unused #else if ( !Ds_dll_loaded ) { Ds_dll_handle = LoadLibrary("dsound.dll"); @@ -1167,7 +1221,6 @@ int ds_dll_load() int ds_init_a3d() { #ifdef PLAT_UNIX - STUB_FUNCTION; //unused #else HINSTANCE a3d_handle; @@ -1245,7 +1298,6 @@ int ds_init_a3d() int ds_init_property_set() { #ifdef PLAT_UNIX - STUB_FUNCTION; //unused #else HRESULT hr; @@ -1307,23 +1359,22 @@ int ds_init(int use_a3d, int use_eax) Ds_use_eax = 0; Ds_use_ds3d = 0; - nprintf(( "Sound", "SOUND ==> Initializing DirectSound...\n" )); + nprintf(( "Sound", "SOUND ==> Initializing OpenAL...\n" )); - // load OpenAl + // load OpenAL ds_sound_device = alcOpenDevice (initStr); // Create Sound Device ds_sound_context = alcCreateContext (ds_sound_device, attr); alcMakeContextCurrent (ds_sound_context); - if (alGetError() != AL_NO_ERROR) { - nprintf(("Sound", "SOUND ==> Cannot initiate OpenAL\n")); + if (alcGetError(ds_sound_device) != ALC_NO_ERROR) { + nprintf(("Sound", "SOUND ==> Couldn't initialize OpenAL\n")); return -1; } - // Get the primary buffer format - //ds_get_primary_format(&wave_format); - + OpenAL_ErrorCheck(); + // Initialize DirectSound3D. Since software performance of DirectSound3D is unacceptably // slow, we require the voice manger (a DirectSound extension) to be present. The // exception is when A3D is being used, since A3D has a resource manager built in. @@ -1575,11 +1626,13 @@ char *get_DSERR_text(int DSResult) void ds_close_channel(int i) { #ifdef PLAT_UNIX -// STUB_FUNCTION; - if(Channels[i].pdsb != 0 && alIsSource (Channels[i].pdsb)) { - alSourceStop (Channels[i].pdsb); - Channels[i].pdsb = 0; + if(Channels[i].source_id != 0 && alIsSource (Channels[i].source_id)) { + alSourceStop (Channels[i].source_id); + alDeleteSources(1, &Channels[i].source_id); + + Channels[i].source_id = 0; } + return; #else HRESULT hr; @@ -1646,15 +1699,18 @@ void ds_close_all_channels() void ds_unload_buffer(int sid, int hid) { #ifdef PLAT_UNIX -// STUB_FUNCTION; - - if(alIsSource (hid)) { - alSourceStop ((ALuint)hid); - alDeleteSources(1, (ALuint*)&hid); - } - if(alIsBuffer (sid)) { - alDeleteBuffers(1, (ALuint*)&sid); + if (sid != -1) { + ALuint buf_id = sound_buffers[sid].buf_id; + + if (buf_id != 0 && alIsBuffer(buf_id)) { + alDeleteBuffers(1, &buf_id); + } + + sound_buffers[sid].buf_id = 0; } + + /* hid unused */ + return; #else HRESULT hr; @@ -1690,7 +1746,17 @@ void ds_unload_buffer(int sid, int hid) void ds_close_software_buffers() { #ifdef PLAT_UNIX - STUB_FUNCTION; + int i; + + for (i = 0; i < MAX_DS_SOFTWARE_BUFFERS; i++) { + ALuint buf_id = sound_buffers[i].buf_id; + + if (buf_id != 0 && alIsBuffer(buf_id)) { + alDeleteBuffers(1, &buf_id); + } + + sound_buffers[i].buf_id = 0; + } #else int i; HRESULT hr; @@ -1715,7 +1781,7 @@ void ds_close_software_buffers() void ds_close_hardware_buffers() { #ifdef PLAT_UNIX - STUB_FUNCTION; + // unused #else int i; HRESULT hr; @@ -1754,9 +1820,7 @@ void ds_close() ds_close_all_channels(); ds_close_buffers(); -#ifdef PLAT_UNIX - STUB_FUNCTION; -#else +#ifndef PLAT_UNIX if (pPropertySet != NULL) { pPropertySet->Release(); pPropertySet = NULL; @@ -1795,11 +1859,11 @@ void ds_close() if (Ds_must_call_couninitialize == 1) { CoUninitialize(); } +#endif // free the Channels[] array, since it was dynamically allocated free(Channels); Channels = NULL; -#endif } // --------------------------------------------------------------------------------------- @@ -1847,20 +1911,100 @@ void ds_get_3d_interface(LPDIRECTSOUNDBUFFER pdsb, LPDIRECTSOUND3DBUFFER *ppds3d // NOTE: snd_id is needed since we limit the number of concurrent samples // // -#define DS_MAX_SOUND_INSTANCES 2 int ds_get_free_channel(int new_volume, int snd_id, int priority) { #ifdef PLAT_UNIX -// STUB_FUNCTION; - for(int i = 0; i < MAX_CHANNELS; i++) { - if(Channels[i].pdsb == 0) { - Channels[i].snd_id = snd_id; - Channels[i].vol = new_volume; - return i; + int i, first_free_channel, limit; + int lowest_vol = 0, lowest_vol_index = -1; + int instance_count; // number of instances of sound already playing + int lowest_instance_vol, lowest_instance_vol_index; + channel *chp; + int status; + + instance_count = 0; + lowest_instance_vol = 99; + lowest_instance_vol_index = -1; + first_free_channel = -1; + + // Look for a channel to use to play this sample + for ( i = 0; i < MAX_CHANNELS; i++ ) { + chp = &Channels[i]; + if ( chp->source_id == 0 ) { + if ( first_free_channel == -1 ) + first_free_channel = i; + continue; + } + + alGetSourceiv(chp->source_id, AL_SOURCE_STATE, &status); + + OpenAL_ErrorCheck(); + + if ( status != AL_PLAYING ) { + if ( first_free_channel == -1 ) + first_free_channel = i; + continue; + } + else { + if ( chp->snd_id == snd_id ) { + instance_count++; + if ( chp->vol < lowest_instance_vol && chp->looping == FALSE ) { + lowest_instance_vol = chp->vol; + lowest_instance_vol_index = i; + } + } + + if ( chp->vol < lowest_vol && chp->looping == FALSE ) { + lowest_vol_index = i; + lowest_vol = chp->vol; + } } } - return -1; + + // determine the limit of concurrent instances of this sound + switch(priority) { + case DS_MUST_PLAY: + limit = 100; + break; + case DS_LIMIT_ONE: + limit = 1; + break; + case DS_LIMIT_TWO: + limit = 2; + break; + case DS_LIMIT_THREE: + limit = 3; + break; + default: + Int3(); // get Alan + limit = 100; + break; + } + + + // If we've exceeded the limit, then maybe stop the duplicate if it is lower volume + if ( instance_count >= limit ) { + // If there is a lower volume duplicate, stop it.... otherwise, don't play the sound + if ( lowest_instance_vol_index >= 0 && (Channels[lowest_instance_vol_index].vol <= new_volume) ) { + first_free_channel = lowest_instance_vol_index; + } else { + first_free_channel = -1; + } + } else { + // there is no limit barrier to play the sound, so see if we've ran out of channels + if ( first_free_channel == -1 ) { + // stop the lowest volume instance to play our sound if priority demands it + if ( lowest_vol_index != -1 && priority == DS_MUST_PLAY ) { + // Check if the lowest volume playing is less than the volume of the requested sound. + // If so, then we are going to trash the lowest volume sound. + if ( Channels[lowest_vol_index].vol <= new_volume ) { + first_free_channel = lowest_vol_index; + } + } + } + } + + return first_free_channel; #else int i, first_free_channel, limit; int lowest_vol = 0, lowest_vol_index = -1; @@ -2014,10 +2158,29 @@ void ds_restore_buffer(LPDIRECTSOUNDBUFFER pdsb) int ds_create_buffer(int frequency, int bits_per_sample, int nchannels, int nseconds) { #ifdef PLAT_UNIX -// STUB_FUNCTION; ALuint i; + int sid; + + if (!ds_initialized) { + return -1; + } + + sid = ds_get_sid(); + if ( sid == -1 ) { + nprintf(("Sound","SOUND ==> No more OpenAL buffers available\n")); + return -1; + } + alGenBuffers (1, &i); - return (int)i; + + sound_buffers[sid].buf_id = i; + sound_buffers[sid].source_id = -1; + sound_buffers[sid].frequency = frequency; + sound_buffers[sid].bits_per_sample = bits_per_sample; + sound_buffers[sid].nchannels = nchannels; + sound_buffers[sid].nseconds = nseconds; + + return sid; #else HRESULT dsrval; DSBUFFERDESC dsbd; @@ -2063,7 +2226,36 @@ int ds_create_buffer(int frequency, int bits_per_sample, int nchannels, int nsec int ds_lock_data(int sid, unsigned char *data, int size) { #ifdef PLAT_UNIX - STUB_FUNCTION; + Assert(sid >= 0); + + ALuint buf_id = sound_buffers[sid].buf_id; + ALenum format; + + if (sound_buffers[sid].bits_per_sample == 16) { + if (sound_buffers[sid].nchannels == 2) { + format = AL_FORMAT_STEREO16; + } else if (sound_buffers[sid].nchannels == 1) { + format = AL_FORMAT_MONO16; + } else { + return -1; + } + } else if (sound_buffers[sid].bits_per_sample == 8) { + if (sound_buffers[sid].nchannels == 2) { + format = AL_FORMAT_STEREO8; + } else if (sound_buffers[sid].nchannels == 1) { + format = AL_FORMAT_MONO8; + } else { + return -1; + } + } else { + return -1; + } + + alBufferData(buf_id, format, data, size, sound_buffers[sid].frequency); + + OpenAL_ErrorCheck(); + + return 0; #else HRESULT dsrval; LPDIRECTSOUNDBUFFER pdsb; @@ -2097,16 +2289,24 @@ int ds_lock_data(int sid, unsigned char *data, int size) if ( dsrval != DS_OK ) { return -1; } -#endif return 0; +#endif } // Stop a buffer from playing directly void ds_stop_easy(int sid) { #ifdef PLAT_UNIX - STUB_FUNCTION; + Assert(sid >= 0); + + int cid = sound_buffers[sid].source_id; + + if (cid != -1) { + ALuint source_id = Channels[cid].source_id; + + alSourceStop(source_id); + } #else HRESULT dsrval; LPDIRECTSOUNDBUFFER pdsb; @@ -2125,7 +2325,37 @@ void ds_stop_easy(int sid) int ds_play_easy(int sid, int volume) { #ifdef PLAT_UNIX - STUB_FUNCTION; + if (!ds_initialized) + return -1; + + int channel = ds_get_free_channel(volume, -1, DS_MUST_PLAY); + + if (channel > -1) { + ALuint source_id = Channels[channel].source_id; + + alSourceStop(source_id); + + if (Channels[channel].buf_id != sid) { + ALuint buffer_id = sound_buffers[sid].buf_id; + + alSourcei(source_id, AL_BUFFER, buffer_id); + + OpenAL_ErrorCheck(); + } + + Channels[channel].buf_id = sid; + + /* TODO: volume */ + + alSourcei(source_id, AL_LOOPING, AL_FALSE); + alSourcePlay(source_id); + + OpenAL_ErrorCheck(); + + return 0; + } + + return -1; #else HRESULT dsrval; LPDIRECTSOUNDBUFFER pdsb; @@ -2138,14 +2368,11 @@ int ds_play_easy(int sid, int volume) if ( dsrval != DS_OK ) { return -1; } -#endif return 0; +#endif } -//extern void HUD_add_to_scrollback(char *text, int source); -//extern void HUD_printf(char *format, ...); - // --------------------------------------------------------------------------------------- // Play a DirectSound secondary buffer. // @@ -2168,48 +2395,94 @@ int ds_play_easy(int sid, int volume) int ds_play(int sid, int hid, int snd_id, int priority, int volume, int pan, int looping, bool is_voice_msg) { #ifdef PLAT_UNIX - - if(sid < 0) + int channel; + + if (!ds_initialized) return -1; - printf("hid = %d | sid = %d | looping = %d\n", Channels[sid].pdsb, - Channels[sid].pds3db, looping); + channel = ds_get_free_channel(volume, snd_id, priority); - int value; - hid = Channels[sid].pdsb; - Channels[sid].is_voice_msg = is_voice_msg; - Channels[sid].snd_id = snd_id; - Channels[sid].priority = priority; - Channels[sid].last_position = 1; + if (channel > -1) { + if ( Channels[channel].source_id == 0 ) { + return -1; + } - alGetSourceiv(hid, AL_SOURCE_STATE, &value); - if(value & AL_PLAYING) - alSourceStop (hid); + if ( ds_using_ds3d() ) { + } + + // Actually play it + Channels[channel].vol = volume; + Channels[channel].looping = looping; + Channels[channel].priority = priority; - sid = Channels[sid].pds3db; - if (!alIsBuffer (sid)) { - nprintf (("Error", "SOUND ==> %d is not a buffer!\n", sid)); + /* TODO: pan */ + // Channels[channel].pdsb->SetPan(pan); + + /* TODO: volume */ + // Channels[channel].pdsb->SetVolume(volume); + + Channels[channel].is_voice_msg = is_voice_msg; + + OpenAL_ErrorCheck(); + + ALint status; + alGetSourceiv(Channels[channel].source_id, AL_SOURCE_STATE, &status); + + OpenAL_ErrorCheck(); + + if (status == AL_PLAYING) + alSourceStop(Channels[channel].source_id); + + OpenAL_ErrorCheck(); + + alSourcei (Channels[channel].source_id, AL_BUFFER, sound_buffers[sid].buf_id); + + OpenAL_ErrorCheck(); + + alSourcei (Channels[channel].source_id, AL_LOOPING, (looping) ? AL_TRUE : AL_FALSE); + + OpenAL_ErrorCheck(); + + alSourcePlay(Channels[channel].source_id); + + OpenAL_ErrorCheck(); + + sound_buffers[sid].source_id = channel; + Channels[channel].buf_id = sid; + } + else { +// nprintf(( "Sound", "SOUND ==> Not playing sound requested at volume %.2f\n", ds_get_percentage_vol(volume) )); return -1; } - alSourcei (hid, AL_BUFFER, sid); - alSourcei (hid, AL_LOOPING, (looping) ? AL_TRUE : AL_FALSE); - alSourcei (hid, AL_SOURCE_RELATIVE, AL_TRUE); + Channels[channel].snd_id = snd_id; + Channels[channel].sig = channel_next_sig++; + if (channel_next_sig < 0 ) { + channel_next_sig = 1; + } - // set pan, volume, etc - alSourcePlay (hid); + Channels[channel].last_position = 0; - if(looping) { - nprintf(("Sound","SOUND ==> Playing sound %d looping\n", sid)); - } else nprintf(("Sound", "SOUND ==> Playing sound %d not looping\n", sid)); + // make sure there aren't any looping voice messages + for (int i=0; i %s!\n", alGetString(i)); - return -1; + // TODO: this thing + // DWORD current_position = ds_get_play_position(i); + // if (current_position != 0) { + // if (current_position < Channels[i].last_position) { + // ds_close_channel(i); + // } else { + // Channels[i].last_position = current_position; + // } + // } + } } - return 0; + return Channels[channel].sig; #else int channel; HRESULT DSResult; @@ -2341,7 +2614,17 @@ int ds_play(int sid, int hid, int snd_id, int priority, int volume, int pan, int int ds_get_channel(int sig) { #ifdef PLAT_UNIX - STUB_FUNCTION; + int i; + + for ( i = 0; i < MAX_CHANNELS; i++ ) { + if ( Channels[i].source_id && Channels[i].sig == sig ) { + if ( ds_is_channel_playing(i) == TRUE ) { + return i; + } + } + } + + return -1; #else int i; @@ -2352,8 +2635,8 @@ int ds_get_channel(int sig) } } } -#endif return -1; +#endif } // --------------------------------------------------------------------------------------- @@ -2363,7 +2646,15 @@ int ds_get_channel(int sig) int ds_is_channel_playing(int channel) { #ifdef PLAT_UNIX - STUB_FUNCTION; + if ( Channels[channel].source_id != 0 ) { + ALint status; + + alGetSourceiv(Channels[channel].source_id, AL_SOURCE_STATE, &status); + OpenAL_ErrorCheck(); + + return (status == AL_PLAYING); + } + return 0; #else HRESULT hr; @@ -2392,7 +2683,13 @@ int ds_is_channel_playing(int channel) // void ds_stop_channel(int channel) { +#ifdef PLAT_UNIX + if ( Channels[channel].source_id != 0 ) { + alSourceStop(Channels[channel].source_id); + } +#else ds_close_channel(channel); +#endif } // --------------------------------------------------------------------------------------- @@ -2401,17 +2698,23 @@ void ds_stop_channel(int channel) // void ds_stop_channel_all() { -//#ifdef PLAT_UNIX -// STUB_FUNCTION; -//#else +#ifdef PLAT_UNIX + int i; + + for ( i=0; i= 0); + STUB_FUNCTION; + + return -1; #else HRESULT dsrval; LPDIRECTSOUNDBUFFER pdsb; @@ -2906,7 +3221,6 @@ int ds_get_size(int sid, int *size) *size = caps.dwBufferBytes; #endif - return 0; } int ds_using_ds3d() @@ -2920,7 +3234,7 @@ int ds_using_ds3d() uint ds_get_primary_buffer_interface() { #ifdef PLAT_UNIX - STUB_FUNCTION; + // unused return 0; #else return (uint)pPrimaryBuffer; @@ -2932,7 +3246,7 @@ uint ds_get_primary_buffer_interface() uint ds_get_dsound_interface() { #ifdef PLAT_UNIX - STUB_FUNCTION; + // unused return 0; #else return (uint)pDirectSound; @@ -2942,7 +3256,6 @@ uint ds_get_dsound_interface() uint ds_get_property_set_interface() { #ifdef PLAT_UNIX - STUB_FUNCTION; return 0; #else return (uint)pPropertySet; @@ -2964,8 +3277,7 @@ uint ds_get_property_set_interface() int ds_eax_set_volume(float volume) { #ifdef PLAT_UNIX - STUB_FUNCTION; - return 0; + return -1; #else HRESULT hr; @@ -2995,8 +3307,7 @@ int ds_eax_set_volume(float volume) int ds_eax_set_decay_time(float seconds) { #ifdef PLAT_UNIX - STUB_FUNCTION; - return 0; + return -1; #else HRESULT hr; @@ -3026,8 +3337,7 @@ int ds_eax_set_decay_time(float seconds) int ds_eax_set_damping(float damp) { #ifdef PLAT_UNIX - STUB_FUNCTION; - return 0; + return -1; #else HRESULT hr; @@ -3057,8 +3367,7 @@ int ds_eax_set_damping(float damp) int ds_eax_set_environment(unsigned long envid) { #ifdef PLAT_UNIX - STUB_FUNCTION; - return 0; + return -1; #else HRESULT hr; @@ -3086,7 +3395,6 @@ int ds_eax_set_environment(unsigned long envid) int ds_eax_set_preset(unsigned long envid) { #ifdef PLAT_UNIX - STUB_FUNCTION; return -1; #else HRESULT hr; @@ -3120,8 +3428,7 @@ int ds_eax_set_preset(unsigned long envid) int ds_eax_set_all(unsigned long id, float vol, float damping, float decay) { #ifdef PLAT_UNIX - STUB_FUNCTION; - return 0; + return -1; #else HRESULT hr; @@ -3157,8 +3464,7 @@ int ds_eax_set_all(unsigned long id, float vol, float damping, float decay) int ds_eax_get_all(EAX_REVERBPROPERTIES *er) { #ifdef PLAT_UNIX - STUB_FUNCTION; - return 0; + return -1; #else HRESULT hr; unsigned long outsize; @@ -3182,9 +3488,7 @@ int ds_eax_get_all(EAX_REVERBPROPERTIES *er) // void ds_eax_close() { -#ifdef PLAT_UNIX - STUB_FUNCTION; -#else +#ifndef PLAT_UNIX if (Ds_eax_inited == 0) { return; } @@ -3199,9 +3503,7 @@ void ds_eax_close() // int ds_eax_init() { -#ifdef PLAT_UNIX - STUB_FUNCTION; -#else +#ifndef PLAT_UNIX HRESULT hr; unsigned long driver_support = 0; @@ -3247,7 +3549,6 @@ ds_eax_init_failed: int ds_eax_is_inited() { #ifdef PLAT_UNIX - STUB_FUNCTION; return 0; #else return Ds_eax_inited; @@ -3257,7 +3558,6 @@ int ds_eax_is_inited() bool ds_using_a3d() { #ifdef PLAT_UNIX - STUB_FUNCTION; return false; #else if (Ds_use_a3d == 0) { @@ -3277,7 +3577,7 @@ void ds_do_frame() for (int i=0; iis_voice_msg) { - if (cp->pdsb == 0) { + if (cp->source_id == 0) { continue; } @@ -3293,3 +3593,109 @@ void ds_do_frame() } } +#ifdef PLAT_UNIX +void ds3d_close() +{ + STUB_FUNCTION; +} + +int ds3d_update_buffer(int channel, float min, float max, vector *pos, vector *vel) +{ + STUB_FUNCTION; + + return -1; +} + +int ds3d_update_listener(vector *pos, vector *vel, matrix *orient) +{ + STUB_FUNCTION; + +#if 0 + ALfloat posv[] = { pos->x, pos->y, pos->z }; + ALfloat velv[] = { vel->x, vel->y, vel->z }; + ALfloat oriv[] = { orient->a1d[0], + orient->a1d[1], orient->a1d[2], + orient->a1d[3], orient->a1d[4], + orient->a1d[5] }; + alListenerfv(AL_POSITION, posv); + alListenerfv(AL_VELOCITY, velv); + alListenerfv(AL_ORIENTATION, oriv); +#endif + + return -1; +} + +int ds3d_init (int unused) +{ + STUB_FUNCTION; + +#if 0 + ALfloat pos[] = { 0.0, 0.0, 0.0 }, + vel[] = { 0.0, 0.0, 0.0 }, + ori[] = { 0.0, 0.0, 1.0, 0.0, -1.0, 0.0 }; + + alListenerfv (AL_POSITION, pos); + alListenerfv (AL_VELOCITY, vel); + alListenerfv (AL_ORIENTATION, ori); + + if(alGetError() != AL_NO_ERROR) + return -1; + + return 0; +#endif + + return -1; +} + +void dscap_close() +{ + STUB_FUNCTION; +} + +int dscap_create_buffer(int freq, int bits_per_sample, int nchannels, int nseconds) +{ + STUB_FUNCTION; + + return -1; +} + +int dscap_get_raw_data(unsigned char *outbuf, unsigned int max_size) +{ + STUB_FUNCTION; + + return -1; +} + +int dscap_max_buffersize() +{ + STUB_FUNCTION; + + return -1; +} + +void dscap_release_buffer() +{ + STUB_FUNCTION; +} + +int dscap_start_record() +{ + STUB_FUNCTION; + + return -1; +} + +int dscap_stop_record() +{ + STUB_FUNCTION; + + return -1; +} + +int dscap_supported() +{ + STUB_FUNCTION; + + return 0; +} +#endif diff --git a/src/sound/ds3d-unix.cpp b/src/sound/ds3d-unix.cpp deleted file mode 100644 index f431ab5..0000000 --- a/src/sound/ds3d-unix.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include -#include -#include - -#include "pstypes.h" - -void ds3d_close() -{ - STUB_FUNCTION; -} - -int ds3d_update_listener(vector *pos, vector *vel, matrix *orient) -{ - //STUB_FUNCTION; - ALfloat posv[] = { pos->x, pos->y, pos->z }; - ALfloat velv[] = { vel->x, vel->y, vel->z }; - ALfloat oriv[] = { orient->a1d[0], - orient->a1d[1], orient->a1d[2], - orient->a1d[3], orient->a1d[4], - orient->a1d[5] }; - alListenerfv(AL_POSITION, posv); - alListenerfv(AL_VELOCITY, velv); - alListenerfv(AL_ORIENTATION, oriv); - - return -1; -} - -int ds3d_init (int unused) -{ - ALfloat pos[] = { 0.0, 0.0, 0.0 }, - vel[] = { 0.0, 0.0, 0.0 }, - ori[] = { 0.0, 0.0, 1.0, 0.0, -1.0, 0.0 }; - - alListenerfv (AL_POSITION, pos); - alListenerfv (AL_VELOCITY, vel); - alListenerfv (AL_ORIENTATION, ori); - - if(alGetError() != AL_NO_ERROR) - return -1; - - return 0; -} diff --git a/src/sound/dscap-unix.cpp b/src/sound/dscap-unix.cpp deleted file mode 100644 index fb7c85d..0000000 --- a/src/sound/dscap-unix.cpp +++ /dev/null @@ -1,54 +0,0 @@ -#include "pstypes.h" - -void dscap_close() -{ - STUB_FUNCTION; -} - -int dscap_create_buffer(int freq, int bits_per_sample, int nchannels, int nseconds) -{ - STUB_FUNCTION; - - return -1; -} - -int dscap_get_raw_data(unsigned char *outbuf, unsigned int max_size) -{ - STUB_FUNCTION; - - return -1; -} - -int dscap_max_buffersize() -{ - STUB_FUNCTION; - - return -1; -} - -void dscap_release_buffer() -{ - STUB_FUNCTION; -} - -int dscap_start_record() -{ - STUB_FUNCTION; - - return -1; -} - -int dscap_stop_record() -{ - STUB_FUNCTION; - - return -1; -} - -int dscap_supported() -{ - STUB_FUNCTION; - - return 0; -} - diff --git a/src/sound/sound.cpp b/src/sound/sound.cpp index 6ffda21..c6bb30b 100644 --- a/src/sound/sound.cpp +++ b/src/sound/sound.cpp @@ -7,6 +7,11 @@ * Low-level sound code * * $Log$ + * Revision 1.6 2002/06/05 08:05:29 relnev + * stub/warning removal. + * + * reworked the sound code. + * * Revision 1.5 2002/06/02 21:11:12 cemason * Few changes * @@ -352,10 +357,6 @@ static int snd_next_sig = 1; // convert the game level sound priorities to the DirectSound priority descriptions int ds_priority(int priority) { -#ifdef PLAT_UNIX - STUB_FUNCTION; - return 1; -#else switch(priority){ case SND_PRIORITY_MUST_PLAY: return DS_MUST_PLAY; @@ -368,8 +369,7 @@ int ds_priority(int priority) default: Int3(); return DS_MUST_PLAY; - }; -#endif + } } void snd_clear() @@ -1282,7 +1282,7 @@ void snd_stop_all() uint sound_get_ds() { #ifdef PLAT_UNIX - STUB_FUNCTION; + // unused return 0; #else return (uint)pDirectSound; diff --git a/src/weapon/weapons.cpp b/src/weapon/weapons.cpp index 2040060..2beeab7 100644 --- a/src/weapon/weapons.cpp +++ b/src/weapon/weapons.cpp @@ -7,6 +7,11 @@ * Code to handle the weapon systems * * $Log$ + * Revision 1.5 2002/06/05 08:05:29 relnev + * stub/warning removal. + * + * reworked the sound code. + * * Revision 1.4 2002/06/01 03:32:00 relnev * fix texture loading mistake. * @@ -1441,11 +1446,11 @@ void weapon_init() int rval; if ( !Weapons_inited ) { -#ifndef FS2_DEMO - STUB_FUNCTION; -#warning FS2_DEMO HACK! commented out a function call +#ifndef FS2_DEMO // TODO - this seems to work? unless it's breaking that multiplayer mission... // parse weapon_exp.tbl parse_weapon_expl_tbl(); +#else + STUB_FUNCTION; #endif // parse weapons.tbl if ((rval = setjmp(parse_abort)) != 0) { -- 2.39.2