Fixed compiler warnings and added wrapping for ndx
This commit is contained in:
parent
df23dfb874
commit
30266e702b
|
@ -31,7 +31,7 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
printf("send: '%s'\n", buffer);
|
printf("send: '%s'\n", buffer);
|
||||||
|
|
||||||
EXPECT(sendto(sock_fd, buffer, strlen(buffer), 0, (struct sockaddr *)&sa_server, sizeof(sa_server)), == strlen(buffer));
|
EXPECT(sendto(sock_fd, buffer, strlen(buffer), 0, (struct sockaddr *)&sa_server, sizeof(sa_server)), == (ssize_t)strlen(buffer));
|
||||||
int data_len;
|
int data_len;
|
||||||
while ((data_len = recv(sock_fd, buffer, BUFFER_SIZE, 0)) > 0) {
|
while ((data_len = recv(sock_fd, buffer, BUFFER_SIZE, 0)) > 0) {
|
||||||
printf("%.*s", data_len, buffer);
|
printf("%.*s", data_len, buffer);
|
||||||
|
|
26
src/sfxd.c
26
src/sfxd.c
|
@ -46,7 +46,7 @@ struct sfx_pool {
|
||||||
int cap, use;
|
int cap, use;
|
||||||
};
|
};
|
||||||
|
|
||||||
ssize_t send_data(struct msg_target tgt, const void *data, size_t len);
|
ssize_t send_data(struct msg_target tgt, const void *data, ssize_t len);
|
||||||
ssize_t send_txt(struct msg_target tgt, const char *fmt, ...);
|
ssize_t send_txt(struct msg_target tgt, const char *fmt, ...);
|
||||||
void execute_command(struct msg_target tgt, const char *command, const char *params);
|
void execute_command(struct msg_target tgt, const char *command, const char *params);
|
||||||
bool execute_file(struct msg_target tgt, const char *path, int depth);
|
bool execute_file(struct msg_target tgt, const char *path, int depth);
|
||||||
|
@ -77,6 +77,8 @@ struct global_counters {
|
||||||
|
|
||||||
void usage(int argc, char **argv) {
|
void usage(int argc, char **argv) {
|
||||||
// TODO
|
// TODO
|
||||||
|
(void)argc;
|
||||||
|
(void)argv;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
|
@ -131,16 +133,16 @@ void ipc_loop(void) {
|
||||||
socklen_t sl_client = sizeof(ipc.sa_client);
|
socklen_t sl_client = sizeof(ipc.sa_client);
|
||||||
while ((data_len = recvfrom(ipc.sock_fd, buffer_ipc_loop, sizeof(buffer_ipc_loop) - 1, 0, (struct sockaddr *)&ipc.sa_client, &sl_client)) != -1) {
|
while ((data_len = recvfrom(ipc.sock_fd, buffer_ipc_loop, sizeof(buffer_ipc_loop) - 1, 0, (struct sockaddr *)&ipc.sa_client, &sl_client)) != -1) {
|
||||||
buffer_ipc_loop[data_len] = '\0';
|
buffer_ipc_loop[data_len] = '\0';
|
||||||
struct sockaddr_un *sau_client = &ipc.sa_client;
|
struct sockaddr *sa_client = (struct sockaddr *)&ipc.sa_client;
|
||||||
char *command = buffer_ipc_loop;
|
char *command = buffer_ipc_loop;
|
||||||
char *params = strchr(command, ' ');
|
char *params = strchr(command, ' ');
|
||||||
if (params != NULL) {
|
if (params != NULL) {
|
||||||
*params = '\0';
|
*params = '\0';
|
||||||
params++;
|
params++;
|
||||||
}
|
}
|
||||||
execute_command((struct msg_target) { 0, ipc.sock_fd, (struct sockaddr *)&ipc.sa_client, sl_client }, command, params);
|
execute_command((struct msg_target) { 0, ipc.sock_fd, sa_client, sl_client }, command, params);
|
||||||
SOFT_EXPECT(sendto(ipc.sock_fd, "OK\n", 4, 0, (struct sockaddr *)&ipc.sa_client, sl_client), == 4,);
|
SOFT_EXPECT(sendto(ipc.sock_fd, "OK\n", 4, 0, sa_client, sl_client), == 4,);
|
||||||
SOFT_EXPECT(sendto(ipc.sock_fd, "", 0, 0, (struct sockaddr *)&ipc.sa_client, sl_client), == 0,);
|
SOFT_EXPECT(sendto(ipc.sock_fd, "", 0, 0, sa_client, sl_client), == 0,);
|
||||||
sl_client = sizeof(ipc.sa_client);
|
sl_client = sizeof(ipc.sa_client);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -151,7 +153,7 @@ bool audio_init(void) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t send_data(struct msg_target tgt, const void *data, size_t len) {
|
ssize_t send_data(struct msg_target tgt, const void *data, ssize_t len) {
|
||||||
ssize_t written;
|
ssize_t written;
|
||||||
if (tgt.file_handle) {
|
if (tgt.file_handle) {
|
||||||
if ((written = fwrite(data, 1, len, tgt.file_handle)) != len) {
|
if ((written = fwrite(data, 1, len, tgt.file_handle)) != len) {
|
||||||
|
@ -208,7 +210,9 @@ void execute_command(struct msg_target tgt, const char *command, const char *par
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ma_sound *sfx = &sound->sounds[(sound->last_index++) % MAX_SOUNDS_PER_KEY];
|
sound->last_index = (sound->last_index + 1) % MAX_SOUNDS_PER_KEY;
|
||||||
|
ma_sound *sfx = &sound->sounds[sound->last_index];
|
||||||
|
|
||||||
ma_sound_set_pitch(sfx, sound->pitch_min);
|
ma_sound_set_pitch(sfx, sound->pitch_min);
|
||||||
ma_sound_set_volume(sfx, sound->volume);
|
ma_sound_set_volume(sfx, sound->volume);
|
||||||
ma_sound_start(sfx);
|
ma_sound_start(sfx);
|
||||||
|
@ -219,7 +223,9 @@ void execute_command(struct msg_target tgt, const char *command, const char *par
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ma_sound *sfx = &sound->sounds[(sound->last_index++) % MAX_SOUNDS_PER_KEY];
|
sound->last_index = (sound->last_index + 1) % MAX_SOUNDS_PER_KEY;
|
||||||
|
ma_sound *sfx = &sound->sounds[sound->last_index];
|
||||||
|
|
||||||
float pitch = sound->pitch_min + (rand() / (float)RAND_MAX) * (sound->pitch_max - sound->pitch_min);
|
float pitch = sound->pitch_min + (rand() / (float)RAND_MAX) * (sound->pitch_max - sound->pitch_min);
|
||||||
ma_sound_set_pitch(sfx, pitch);
|
ma_sound_set_pitch(sfx, pitch);
|
||||||
ma_sound_set_volume(sfx, sound->volume);
|
ma_sound_set_volume(sfx, sound->volume);
|
||||||
|
@ -272,8 +278,8 @@ void execute_command(struct msg_target tgt, const char *command, const char *par
|
||||||
if (item.key[0] == '\0') {
|
if (item.key[0] == '\0') {
|
||||||
send_txt(tgt, "%3d (unused)\n", i);
|
send_txt(tgt, "%3d (unused)\n", i);
|
||||||
} else {
|
} else {
|
||||||
send_txt(tgt, "%3d vol=%7.5f pitch=%7.5f..%7.5f @%2d (0x%08x) \"%s\"\n",
|
send_txt(tgt, "%3d vol=%7.5f pitch=%7.5f..%7.5f (0x%08x) \"%s\" from %s\n",
|
||||||
i, item.volume, item.pitch_min, item.pitch_max, item.last_index, adler32(item.key, strlen(item.key)), item.key);
|
i, item.volume, item.pitch_min, item.pitch_max, adler32(item.key, strlen(item.key)), item.key, item.path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (0 == strcmp(command, "source")) {
|
} else if (0 == strcmp(command, "source")) {
|
||||||
|
|
Loading…
Reference in New Issue