]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - afs.c
typo
[paraslash.git] / afs.c
diff --git a/afs.c b/afs.c
index e3b0db55894dfb4705ed5c052594d6469fb6332d..2d4184d239e6d1f54ef6fb41bdbe1591e89c0195 100644 (file)
--- a/afs.c
+++ b/afs.c
@@ -26,6 +26,7 @@
 #include <sys/time.h> /* gettimeofday */
 #include "server.cmdline.h"
 #include "db.h"
+#include "afh.h"
 #include "afs.h"
 #include "send.h"
 #include "error.h"
@@ -36,11 +37,11 @@ extern const char *status_item_list[];
 static struct timeval announce_tv;
 static struct timeval data_send_barrier;
 static struct timeval eof_barrier;
+static struct timeval autoplay_barrier;
 
 extern struct misc_meta_data *mmd;
 extern struct audio_file_selector selectors[];
 extern struct sender senders[];
-extern struct gengetopt_args_info conf;
 
 static FILE *audio_file = NULL;
 
@@ -166,6 +167,14 @@ void afs_init(void)
        }
        free(hn);
        free(home);
+       if (conf.autoplay_given) {
+               struct timeval now, tmp;
+               mmd->afs_status_flags |= AFS_PLAYING;
+               mmd->new_afs_status_flags |= AFS_PLAYING;
+               gettimeofday(&now, NULL);
+               ms2tv(conf.autoplay_delay_arg, &tmp);
+               tv_add(&now, &tmp, &autoplay_barrier);
+       }
 }
 
 static int get_file_info(int i)
@@ -197,7 +206,7 @@ int guess_audio_format(const char *name)
                                continue;
                        if (strcasecmp(name + len - plen, p))
                                continue;
-                       PARA_DEBUG_LOG("might be %s\n", audio_format_name(i));
+//                     PARA_DEBUG_LOG("might be %s\n", audio_format_name(i));
                        return i;
                }
        }
@@ -288,14 +297,15 @@ free:
 }
 
 static int chk_barrier(const char *bname, const struct timeval *now,
-               const struct timeval *barrier, struct timeval *diff, int log)
+               const struct timeval *barrier, struct timeval *diff,
+               int print_log)
 {
        long ms;
 
        if (tv_diff(now, barrier, diff) > 0)
                return 1;
        ms = tv2ms(diff);
-       if (log && ms)
+       if (print_log && ms)
                PARA_DEBUG_LOG("%s barrier: %lims left\n", bname, ms);
        return -1;
 }
@@ -324,6 +334,9 @@ static struct timeval *afs_compute_timeout(void)
                return &the_timeout;
        }
        gettimeofday(&now, NULL);
+       if (chk_barrier("autoplay_delay", &now, &autoplay_barrier,
+                       &the_timeout, 1) < 0)
+               return &the_timeout;
        if (chk_barrier("eof", &now, &eof_barrier, &the_timeout, 1) < 0)
                return &the_timeout;
        if (chk_barrier("data send", &now, &data_send_barrier,
@@ -393,6 +406,10 @@ char *afs_get_header(int *header_len)
                return NULL;
        return afl[mmd->audio_format].get_header_info(header_len);
 }
+const char *supported_audio_formats(void)
+{
+       return SUPPORTED_AUDIO_FORMATS;
+}
 
 /**
  * get the chunk time of the current audio file
@@ -417,9 +434,9 @@ struct timeval *afs_chunk_time(void)
  * and acted upon by calling appropriate functions from the lower layers.
  * Possible actions include
  *
- *     - request a new file list from the current dabase tool (audio file change)
+ *     - request a new file list from the current audio file selector
  *     - shutdown of all senders (stop/pause command)
- *     - repositioning of the stream (ff/jmp command)
+ *     - reposition the stream (ff/jmp command)
  *
  * \return A pointer to a struct timeval containing the timeout for the next
  * chunk of data to be sent, or NULL if we're not sending right now.