]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - afs.c
client.m4: Adjust coding style of ggo options.
[paraslash.git] / afs.c
diff --git a/afs.c b/afs.c
index c5e2c93ee51363a69f3178b77c4d79982b427f73..ea0a9f9f310d55f3e4fc56377a3583937e1bd92d 100644 (file)
--- a/afs.c
+++ b/afs.c
@@ -195,7 +195,7 @@ static int dispatch_result(int result_shmid, callback_result_handler *handler,
  * copied.  It then notifies the afs process that the callback function \a f
  * should be executed by sending the shared memory identifier (shmid) to the
  * socket.
-
+ *
  * If the callback produces a result, it sends any number of shared memory
  * identifiers back via the socket. For each such identifier received, \a
  * result_handler is called. The contents of the sma identified by the received
@@ -236,8 +236,8 @@ int send_callback_request(callback_function *f, struct osl_object *query,
        if (ret < 0)
                goto out;
 
-       *(uint32_t *) buf = afs_socket_cookie;
-       *(int *) (buf + sizeof(afs_socket_cookie)) = query_shmid;
+       *(uint32_t *)buf = afs_socket_cookie;
+       *(int *)(buf + sizeof(afs_socket_cookie)) = query_shmid;
 
        ret = connect_local_socket(conf.afs_socket_arg);
        if (ret < 0)
@@ -455,7 +455,7 @@ static int pass_afd(int fd, char *buf, size_t size)
 }
 
 /**
- * Open the audio file with highest score.
+ * Pass the fd of the next audio file to the server process.
  *
  * This stores all information for streaming the "best" audio file in a shared
  * memory area. The id of that area and an open file descriptor for the next
@@ -467,27 +467,15 @@ static int pass_afd(int fd, char *buf, size_t size)
  */
 static int open_next_audio_file(void)
 {
-       struct osl_row *aft_row;
        struct audio_file_data afd;
        int ret, shmid;
        char buf[8];
-       long score;
-again:
-       PARA_NOTICE_LOG("getting next audio file\n");
-       ret = score_get_best(&aft_row, &score);
+
+       ret = open_and_update_audio_file(&afd);
        if (ret < 0) {
                PARA_ERROR_LOG("%s\n", para_strerror(-ret));
                goto no_admissible_files;
        }
-       ret = open_and_update_audio_file(aft_row, score, &afd);
-       if (ret < 0) {
-               ret = score_delete(aft_row);
-               if (ret < 0) {
-                       PARA_ERROR_LOG("%s\n", para_strerror(-ret));
-                       goto no_admissible_files;
-               }
-               goto again;
-       }
        shmid = ret;
        if (!write_ok(server_socket)) {
                ret = -E_AFS_SOCKET;
@@ -607,8 +595,9 @@ static void com_select_callback(int fd, const struct osl_object *query)
                        activate_mood_or_playlist(NULL, &num_admissible);
                }
        } else
-               ret2 = para_printf(&pb, "activated %s (%d admissible files)\n", current_mop?
-                       current_mop : "dummy mood", num_admissible);
+               ret2 = para_printf(&pb, "activated %s (%d admissible files)\n",
+                       current_mop?  current_mop : "dummy mood",
+                       num_admissible);
 out:
        if (ret2 >= 0 && pb.offset)
                pass_buffer_as_shm(fd, SBD_OUTPUT, pb.buf, pb.offset);
@@ -1010,7 +999,13 @@ static void create_tables_callback(int fd, const struct osl_object *query)
 {
        uint32_t table_mask = *(uint32_t *)query->data;
        int i, ret;
-       struct para_buffer pb = {.buf = NULL};
+       struct para_buffer pb = {
+               .max_size = shm_get_shmmax(),
+               .private_data = &(struct afs_max_size_handler_data) {
+                       .fd = fd,
+                       .band = SBD_OUTPUT
+               }
+       };
 
        close_afs_tables();
        for (i = 0; i < NUM_AFS_TABLES; i++) {