2 "$Id: sound.c 9215 2008-06-02 18:31:04Z anmaster $";
64 LOG(
LOG_ERROR,
"init_sounds:",
"sound-server variable not set to anything");
74 snprintf(sound_path,
sizeof(sound_path),
"%s/%s", BINDIR,
sound_server);
76 if (access(sound_path, X_OK)<0) {
77 fprintf(stderr,
"Unable to access %s sound server process\n", sound_path);
84 if (fcntl(sound_process->
tube[0], F_SETFL, O_NONBLOCK)<0) {
89 perror(
"init_sounds: Warning - unable to set non blocking on sound pipe\n");
114 static void play_sound(
int soundnum,
int soundtype,
int x,
int y)
119 if ( (fprintf(
sound_pipe,
"%4x %4x %4x %4x\n",soundnum,soundtype,x,y)<=0) ||
121 LOG(
LOG_ERROR,
"gtk::play_sound",
"couldn't write to sound pipe: %d",errno);
142 LOG(
LOG_WARNING,
"gtk::SoundCmd",
"Got invalid length on sound command: %d", len);
151 fprintf(stderr,
"Playing sound %d (type %d), offset %d, %x\n",
161 uint8 x, y, dir, volume, type, len_action;
168 LOG(
LOG_WARNING,
"gtk::Sound2Cmd",
"Got too short length on sound2 command: %d\n", len);
176 len_action = data[5];
178 if (len_action >= (len-8)) {
179 LOG(
LOG_WARNING,
"gtk::Sound2Cmd",
"Bad length of \"len of action\" in sound2 command: %d\n", len);
182 if (len_action != 0) {
183 action = (
char*)data+6;
184 data[6+len_action]=
'\0';
187 len_name = data[6+len_action+1];
188 if (len_name >= (len-8-len_action)) {
189 LOG(
LOG_WARNING,
"gtk::Sound2Cmd",
"Bad length of \"len of name\" in sound2 command: %d\n", len);
193 name = (
char*)data+6+len_action+1;
194 data[6+len_action+1+len_name]=
'\0';
196 LOG(
LOG_WARNING,
"gtk::Sound2Cmd",
"Playing sound2 x=%hhd y=%hhd dir=%hhd volume=%hhd type=%hhd\n",
197 x, y, dir, volume, type);
198 LOG(
LOG_WARNING,
"gtk::Sound2Cmd",
" len_action=%hhd action=%s\n", len_action, action);
199 LOG(
LOG_WARNING,
"gtk::Sound2Cmd",
" len_name=%hhd name=%s\n", len_name, name);
210 if (!strncmp(data,
"NONE", len)) {
213 LOG(
LOG_WARNING,
"gtk::MusicCmd",
"music command: %s (Implement me!)\n", data);
short GetShort_String(const unsigned char *data)
void Sound2Cmd(unsigned char *data, int len)
void logChildPipe(ChildProcess *child, LogLevel level, int flag)
sint16 want_config[CONFIG_NUMS]
const char *const rcsid_gtk2_sound_c
void LOG(LogLevel level, const char *origin, const char *format,...)
ChildProcess * sound_process
sint16 use_config[CONFIG_NUMS]
ChildProcess * raiseChild(char *name, int flag)
static void play_sound(int soundnum, int soundtype, int x, int y)
void MusicCmd(const char *data, int len)
void SoundCmd(unsigned char *data, int len)