Process -nomusic argument again

This commit is contained in:
zicodxx 2010-06-14 17:55:25 +00:00
parent 63966cab5c
commit 4678e1e815
4 changed files with 74 additions and 78 deletions

View file

@ -8,6 +8,7 @@ arch/sdl/jukebox.c: Small fix and improvement for Jukebox path detection
arch/sdl/digi_mixer_music.c, main/songs.c: Use strrchr instead of strchr for music filename extension in case there are dots in the filename
main/collide.c: Made reactor damage with persistent weapons FPS-independent but still a bit stronger than normal
arch/sdl/jukebox.c: rev1112 contd: Killed juggling around with adding Jukebox paths - must always be removed correctly if Jukebox loading fails
arch/linux/hmiplay.c, arch/sdl/digi.c, main/songs.c: Process -nomusic argument again
20100503
--------

View file

@ -92,7 +92,7 @@ void seqbuf_dump()
}
_seqbufptr = 0;
}
void my_quit()
{
}
@ -100,34 +100,34 @@ void my_quit()
int seq_init()
{
int nrmidis,nrsynths,i;
if ((seqfd = open(SEQ_DEV, O_WRONLY, 0)) < 0)
{
perror ("Error opening sequencer device");
return (-1);
}
if (ioctl(seqfd, SNDCTL_SEQ_NRSYNTHS, &nrsynths) == -1)
{
perror ("There is no soundcard");
return (-1);
}
if (ioctl(seqfd, SNDCTL_SEQ_NRMIDIS, &nrmidis) == -1)
{
perror ("There is no soundcard");
return (-1);
}
if(nrsynths < 1 && nrmidis < 1)
{
con_printf(CON_URGENT,"No synth or midi device!\n");
return -1;
}
synth_dev = 0;
//Check if we have wavetable synth device
for (i=0; i < nrsynths; i++)
{
@ -137,14 +137,14 @@ int seq_init()
perror("cannot get info on soundcard");
return (-1);
}
if (card_info.synth_type == SYNTH_TYPE_SAMPLE)
{
synth_dev = i;
break;
}
}
#ifdef WANT_AWE32
for (i=0; i < nrsynths; i++)
{
@ -154,7 +154,7 @@ int seq_init()
perror("cannot get info on soundcard");
return (-1);
}
if (card_info.synth_type==SYNTH_TYPE_SAMPLE
&&card_info.synth_subtype==SAMPLE_TYPE_AWE32) {
synth_dev = i;
@ -162,7 +162,7 @@ int seq_init()
}
}
#endif
#ifdef WANT_MPU401
for (i=0; i < nrmidis; i++)
{
@ -173,33 +173,33 @@ int seq_init()
perror("cannot get info on soundcard");
return (-1);
}
// Just take first available for now.
card_info.synth_type=SYNTH_TYPE_MIDI;
card_info.device=i;
synth_dev=i;
break;
}
if (card_info.synth_type!=SYNTH_TYPE_MIDI) {
#endif
card_info.device = synth_dev;
if (ioctl(seqfd, SNDCTL_SYNTH_INFO, &card_info) == -1)
{
perror("cannot get info on soundcard");
return (-1);
}
#ifdef WANT_MPU401
}
if (card_info.synth_type==SYNTH_TYPE_MIDI) {
MIDI_RESET;
SEQ_DUMPBUF();
} else
#endif
#ifdef WANT_AWE32
#ifdef WANT_AWE32
if (card_info.synth_type == SYNTH_TYPE_SAMPLE
&& card_info.synth_subtype == SAMPLE_TYPE_AWE32)
{
@ -216,7 +216,7 @@ int seq_init()
voices[i].channel = -1;
}
}
return(0);
}
@ -244,7 +244,7 @@ void set_program(int channel, int pgm)
void start_note(int channel, int note, int vel)
{
int i;
#ifdef WANT_AWE32
if (card_info.synth_type == SYNTH_TYPE_SAMPLE
&& card_info.synth_subtype == SAMPLE_TYPE_AWE32)
@ -262,7 +262,7 @@ void start_note(int channel, int note, int vel)
voices[i].note = note;
voices[i].channel = channel;
if (((1<<channel) & drumflag)) /* drum note */
{
{
SEQ_SET_PATCH(synth_dev, i, note + 128);
}
else
@ -277,7 +277,7 @@ void start_note(int channel, int note, int vel)
void stop_note(int channel, int note, int vel)
{
int i;
#ifdef WANT_AWE32
if (card_info.synth_type == SYNTH_TYPE_SAMPLE
&& card_info.synth_subtype == SAMPLE_TYPE_AWE32)
@ -302,7 +302,7 @@ void stop_note(int channel, int note, int vel)
void set_control(int channel,int ctrl,int value)
{
int i;
#ifdef WANT_AWE32
if (card_info.synth_type == SYNTH_TYPE_SAMPLE
&& card_info.synth_subtype == SAMPLE_TYPE_AWE32)
@ -322,7 +322,7 @@ void set_control(int channel,int ctrl,int value)
void set_pitchbend(int channel, int bend)
{
int i;
#ifdef WANT_AWE32
if (card_info.synth_type == SYNTH_TYPE_SAMPLE
&& card_info.synth_subtype == SAMPLE_TYPE_AWE32)
@ -336,14 +336,14 @@ void set_pitchbend(int channel, int bend)
if (voices[i].channel == channel)
{
SEQ_BENDER(synth_dev, i, bend);
}
}
}
}
void set_key_pressure(int channel, int note, int vel)
{
int i;
#ifdef WANT_AWE32
if (card_info.synth_type == SYNTH_TYPE_SAMPLE
&& card_info.synth_subtype == SAMPLE_TYPE_AWE32)
@ -360,12 +360,12 @@ void set_key_pressure(int channel, int note, int vel)
}
void set_chn_pressure(int channel, int vel)
{
{
int i;
#ifdef WANT_AWE32
if (card_info.synth_type == SYNTH_TYPE_SAMPLE
&& card_info.synth_subtype == SAMPLE_TYPE_AWE32)
&& card_info.synth_subtype == SAMPLE_TYPE_AWE32)
{
AWE_CHN_PRESSURE(synth_dev,channel,vel);
}
@ -381,11 +381,11 @@ void set_chn_pressure(int channel, int vel)
void stop_all()
{
int i;
#ifdef WANT_AWE32
int j;
if (card_info.synth_type == SYNTH_TYPE_SAMPLE
&& card_info.synth_subtype == SAMPLE_TYPE_AWE32)
&& card_info.synth_subtype == SAMPLE_TYPE_AWE32)
{
for (i=0; i<16;i++)
for (j=0;j<128;j++)
@ -402,7 +402,7 @@ void stop_all()
{
for (i=0; i<card_info.nr_voices;i++)
SEQ_STOP_NOTE(synth_dev,i,voices[i].note,0);
}
}
}
// ZICO - clears some unused notes to improve song switching
@ -412,7 +412,7 @@ void cut_trough()
int i;
int j;
if (card_info.synth_type == SYNTH_TYPE_SAMPLE
&& card_info.synth_subtype == SAMPLE_TYPE_AWE32)
&& card_info.synth_subtype == SAMPLE_TYPE_AWE32)
{
for (i=4; i<16;i++)
for (j=4;j<32;j++)
@ -431,11 +431,11 @@ int get_dtime(unsigned char *data, int *pos)
char buf;
int result;
result =0;
buf = data[*pos];
*pos +=1;
result = (0x7f & buf);
if (!(buf & 0x80))
{
buf = data[*pos];
@ -454,7 +454,7 @@ int get_dtime(unsigned char *data, int *pos)
}
}
}
return result;
}
@ -462,7 +462,7 @@ int do_track_event(unsigned char *data, int *pos)
{
char channel;
unsigned char buf[5];
buf[0]=data[*pos];
*pos +=1;
channel = buf[0] & 0xf;
@ -492,7 +492,7 @@ int do_track_event(unsigned char *data, int *pos)
return 0;
}
#endif
switch((buf[0] & 0xf0))
{
case 0x80:
@ -561,7 +561,7 @@ void send_ipc(char *message)
con_printf(CON_DEBUG,"sendipc %s\n", message);
if (ipc_queue_id<0)
{
ipc_queue_id=msgget ((key_t) ('l'<<24) | ('d'<<16) | ('e'<<8) | 's',
ipc_queue_id=msgget ((key_t) ('l'<<24) | ('d'<<16) | ('e'<<8) | 's',
IPC_CREAT | 0660);
snd=d_malloc(sizeof(long) + 32);
snd->mtype=1;
@ -587,9 +587,9 @@ int do_ipc(int qid, struct msgbuf *buf, int flags)
CFILE *fptr = NULL;
float last_volume = volume;
int l=0;
ipc_read = msgrcv(qid,buf,16,0,flags | MSG_NOERROR);
switch (ipc_read)
{
case -1:
@ -664,45 +664,45 @@ void play_hmi (void * arg)
int qid;
int ipc_read = 0;
int k=0;
struct msgbuf *rcv;
Track_info *t_info;
con_printf(CON_DEBUG,"play_hmi\n");
stop = 0;
ipc_read=0;
rcv=d_malloc(sizeof(long) + 16);
rcv->mtype=1;
rcv->mtext[0]='0';
qid=msgget ((key_t) ('l'<<24) | ('d'<<16) | ('e'<<8) | 's', 0660);
if(qid == -1)
{
{
return;
}
do
{
ipc_read=do_ipc(qid,rcv,0);
}
while(rcv->mtext[0] != 'p');
stop=0;
rcv->mtext[0] = '0';
seq_init();
n_chunks=data[0x30];
t_info = d_malloc(sizeof(Track_info)*n_chunks);
while(1)
{
for(i=0;i<n_chunks;i++)
{
t_info[i].position = pos + 12;
@ -726,27 +726,27 @@ void play_hmi (void * arg)
i++;
}
while((low_chunk <=0) && (i<n_chunks));
if (low_chunk == -1)
break;
low_dtime = t_info[low_chunk].time;
for(i=1;i<n_chunks;i++)
{
if ((t_info[i].time < low_dtime) &&
if ((t_info[i].time < low_dtime) &&
(t_info[i].status == PLAYING))
{
low_dtime = t_info[i].time;
low_chunk = i;
}
}
if (low_dtime < 0)
con_printf(CON_URGENT,"Serious warning: d_time negative!!!!!!\n");
csec = 0.86 * low_dtime;
//flush sequencer buffer after 20 events
if (k == 20)
{
@ -759,20 +759,20 @@ void play_hmi (void * arg)
if (csec != lcsec) {
SEQ_WAIT_TIME(csec);
}
lcsec = csec;
t_info[low_chunk].status = do_track_event(data,&t_info[low_chunk].position);
if (t_info[low_chunk].status == 3)
{
con_printf(CON_URGENT,"Error playing data in chunk %d\n",low_chunk);
t_info[low_chunk].status = STOPPED;
}
if (t_info[low_chunk].status == PLAYING)
t_info[low_chunk].time += get_dtime(data,&t_info[low_chunk].position);
//Check if the song has reached the end
stop = t_info[0].status;
for(i=1;i<n_chunks;i++)
@ -782,13 +782,13 @@ void play_hmi (void * arg)
// endlevel song does change rephmi to 0 while endlevel. endlevel song takes about 1950 csec till it's finished
if (!rephmi && csec > 1950)
send_ipc("s");
if((do_ipc(qid,rcv,IPC_NOWAIT) > 0) && (rcv->mtext[0]=='p'))
{
n_chunks=data[0x30];
t_info = d_realloc(t_info,sizeof(Track_info)*n_chunks);
stop = 1;
rcv->mtext[0] = '0';
rcv->mtext[0] = '0';
stop_all();
}
}
@ -812,14 +812,11 @@ void play_hmi (void * arg)
d_free(data);
d_free(t_info);
d_free(rcv);
}
int digi_play_midi_song(char *filename, char *melodic_bank, char *drum_bank, int loop)
{
if (GameArg.SndNoMusic)
return 0;
if (!filename)
send_ipc("p");
else
@ -829,14 +826,12 @@ int digi_play_midi_song(char *filename, char *melodic_bank, char *drum_bank, int
send_ipc(buf);
}
rephmi=loop;
return 1; // FIXME: assume everything is OK
}
void digi_set_midi_volume( int mvolume ) {
void digi_set_midi_volume( int mvolume ) {
char buf[128];
if (GameArg.SndNoMusic)
return;
sprintf(buf,"v%i",mvolume);
send_ipc(buf);

View file

@ -164,9 +164,6 @@ void digi_win32_set_midi_volume( int mvolume )
int digi_win32_play_midi_song( char * filename, char * melodic_bank, char * drum_bank, int loop )
{
if (GameArg.SndNoMusic)
return 0;
digi_stop_current_song();
if (filename == NULL)

View file

@ -178,6 +178,9 @@ void songs_init()
}
}
if (GameArg.SndNoMusic)
GameCfg.MusicType = MUSIC_TYPE_NONE;
// If SDL_Mixer is not supported (or deactivated), switch to no-music type if SDL_mixer-related music type was selected
#ifdef USE_SDLMIXER
if (GameArg.SndDisableSdlMixer)