2 "$Id: sound.c 9719 2008-08-04 18:57:47Z ryo_saeba $";
71 LOG(
LOG_ERROR,
"init_sounds:",
"sound-server variable not set to anything");
82 if (access(sound_path, X_OK)<0) {
83 fprintf(stderr,
"Unable to access %s sound server process\n", sound_path);
90 if (fcntl(sound_process->
tube[0], F_SETFL, O_NONBLOCK)<0) {
94 perror(
"init_sounds: Warning - unable to set non blocking on sound pipe\n");
112 static void play_sound(
int soundnum,
int soundtype,
int x,
int y)
117 if ( (fprintf(
sound_pipe,
"%4x %4x %4x %4x\n",soundnum,soundtype,x,y)<=0) ||
119 LOG(
LOG_ERROR,
"gtk::play_sound",
"couldn't write to sound pipe: %d",errno);
135 LOG(
LOG_WARNING,
"gtk::SoundCmd",
"Got invalid length on sound command: %d", len);
144 fprintf(stderr,
"Playing sound %d (type %d), offset %d, %x\n",
153 uint8 x, y, dir, volume, type, len_action;
160 LOG(
LOG_WARNING,
"gtk::Sound2Cmd",
"Got too short length on sound2 command: %d\n", len);
168 len_action = data[5];
170 if (len_action >= (len-8)) {
171 LOG(
LOG_WARNING,
"gtk::Sound2Cmd",
"Bad length of \"len of action\" in sound2 command: %d\n", len);
174 if (len_action != 0) {
175 action = (
char*)data+6;
176 data[6+len_action]=
'\0';
179 len_name = data[6+len_action+1];
180 if (len_name >= (len-8-len_action)) {
181 LOG(
LOG_WARNING,
"gtk::Sound2Cmd",
"Bad length of \"len of name\" in sound2 command: %d\n", len);
185 name = (
char*)data+6+len_action+1;
186 data[6+len_action+1+len_name]=
'\0';
188 LOG(
LOG_WARNING,
"gtk::Sound2Cmd",
"Playing sound2 x=%hhd y=%hhd dir=%hhd volume=%hhd type=%hhd\n",
189 x, y, dir, volume, type);
190 LOG(
LOG_WARNING,
"gtk::Sound2Cmd",
" len_action=%hhd action=%s\n", len_action, action);
191 LOG(
LOG_WARNING,
"gtk::Sound2Cmd",
" len_name=%hhd name=%s\n", len_name, name);
200 if (!strncmp(data,
"NONE", len)) {
203 LOG(
LOG_WARNING,
"gtk::MusicCmd",
"music command: %s (Implement me!)\n", data);
static ChildProcess * sound_process
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]
static void play_sound(int soundnum, int soundtype, int x, int y)
void LOG(LogLevel level, const char *origin, const char *format,...)
sint16 use_config[CONFIG_NUMS]
const char *const rcsid_gtk_sound_c
static void signal_pipe(int i)
ChildProcess * raiseChild(char *name, int flag)
void MusicCmd(const char *data, int len)
void SoundCmd(unsigned char *data, int len)