]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
Rename struct audio format to audio_format_handler
authorAndre <maan@p133.(none)>
Sat, 13 May 2006 20:46:34 +0000 (22:46 +0200)
committerAndre <maan@p133.(none)>
Sat, 13 May 2006 20:46:34 +0000 (22:46 +0200)
aac_afh.c
afs.c
afs.h
command.c
dccp_send.c
http_send.c
mp3.c
ogg.c
ortp_send.c
send.h
server.c

index 5ace47e5762749a6f0efff37398932ec168a92d7..d6f37fcb59887403cbaf85454d703844032ee823 100644 (file)
--- a/aac_afh.c
+++ b/aac_afh.c
@@ -37,7 +37,7 @@ static FILE *infile;
 static int inbuf_size;
 static unsigned char *inbuf;
 static size_t inbuf_len;
-struct audio_format *af;
+struct audio_format_handler *af;
 static size_t num_chunks;
 static size_t entry;
 
diff --git a/afs.c b/afs.c
index 29bae161682bc00f6fd133e3c29ca7e5df06994d..8e0a50aa90fd5547c80bf168236f76221f36e7bf 100644 (file)
--- a/afs.c
+++ b/afs.c
@@ -58,7 +58,7 @@ static FILE *audio_file = NULL;
 /**
  * the list of supported  audio formats
  */
-struct audio_format afl[] = {
+struct audio_format_handler afl[] = {
 #if 1
        {
                .name = "mp3",
@@ -336,7 +336,7 @@ static struct timeval *afs_compute_timeout(void)
        return &the_timeout;
 }
 
-static void afs_eof(struct audio_format *af)
+static void afs_eof(struct audio_format_handler *af)
 {
        struct timeval now;
        int i;
@@ -388,7 +388,7 @@ static void afs_eof(struct audio_format *af)
  */
 struct timeval *afs_preselect(void)
 {
-       struct audio_format *af = NULL;
+       struct audio_format_handler *af = NULL;
        int i, format;
        struct timeval *ret;
 again:
@@ -449,7 +449,7 @@ again:
 void afs_send_chunk(void)
 {
        int i;
-       struct audio_format *af;
+       struct audio_format_handler *af;
        char *buf;
        ssize_t ret;
        struct timeval now, due;
diff --git a/afs.h b/afs.h
index cc96dbbbf31793426ac5f5334be15d06f6d0576e..19d5b685e927811f3ab74d6e771824f274c368c8 100644 (file)
--- a/afs.h
+++ b/afs.h
  * para_server calls the \a init function of each audio format handler which is
  * expected to fill in all the other function pointers.
  */
-struct audio_format {
-/**
- *
- *
- * name of the audio format
- */
-const char *name;
-/**
- *
- *
- * pointer to the audio format handler's init function
- *
- * Must initialize all function pointers and is assumed to succeed.
- */
-void (*init)(void*);
-/**
- *
- *
- * period of time between sending data chunks
-*/
-struct timeval chunk_tv; /* length of one chunk of data */
-/**
- *
- *
- * end of file timeout - do not load new audio file until this time
- *
-*/
-struct timeval eof_tv; /* timeout on eof */
-/**
- *
- *
- * Pointer to the optional get-header function.
- *
- * This is called from a sender in case a new client connects in the middle of
- * the stream.  The audio format handler may set this to NULL to indicate that
- * this audio format does not need any special header treatment.  If non-NULL,
- * the function it points to must return a pointer to a buffer holding the
- * current audio file header, together with the header length.
-*/
-char *(*get_header_info)(int *header_len);
-/**
- *
- *
- * check if this audio format handler can handle the file
- *
- * This is a  pointer to a function returning whether a given file is valid for
- * this audio format. A negative return value indicates that this audio format
- * handler did not recognize the given file. On success, the function is
- * expected to return a positive value and to fill in \arg info_str, \arg
- * chunks and \arg seconds appropriately.
-*/
-int (*get_file_info)(FILE *audio_file, char *info_str,
-       long unsigned *chunks, int *seconds);
-/**
- *
- *
- * cleanup function of this audio format handler
- *
- * This close function should deallocate any resources
- * associated with the current audio file. In particular, it is responsible
- * for closing the file handle. It is assumed to succeed.
-*/
-void (*close_audio_file)(void);
-/**
- *
- *
- * jump to another position in the current audio file
- *
- * This is called if a client issued the ff or jmp command with \a request
- * being the number of the next chunk that should be sent out. Must return a
- * positive value on success and a negative value on errors.
-*/
-int (*reposition_stream)(long unsigned request);
-/**
- *
- *
- * function responsible for reading one data chunk.
- *
- * \a read_chunk() must return a pointer to the next chunk of data that should
- * be sent out, or \p NULL on errors or if the end of the file was encountered.
- *
- * If it returns non-NULL, \a len must contain the length of the returned
- * buffer (which may be zero if nothing has to be sent for some reason).
- * Otherwise, \a len is used to distinguish between the eof and the error case:
- * It must be zero in the eof case, or negative if an error occcured.
-*/
-char * (*read_chunk)(long unsigned chunk_num, ssize_t *len);
+struct audio_format_handler {
+       /**
+        * name of the audio format
+        */
+       const char *name;
+       /**
+        * typical file endings for files that can be handled by this afh.
+        */
+       const char **suffixes;
+       /**
+        * pointer to the audio format handler's init function
+        *
+        * Must initialize all function pointers and is assumed to succeed.
+        */
+       void (*init)(void*);
+       /**
+        * period of time between sending data chunks
+       */
+       struct timeval chunk_tv; /* length of one chunk of data */
+       /**
+        * end of file timeout - do not load new audio file until this time
+        *
+       */
+       struct timeval eof_tv; /* timeout on eof */
+       /**
+        * Pointer to the optional get-header function.
+        *
+        * This is called from a sender in case a new client connects in the middle of
+        * the stream.  The audio format handler may set this to NULL to indicate that
+        * this audio format does not need any special header treatment.  If non-NULL,
+        * the function it points to must return a pointer to a buffer holding the
+        * current audio file header, together with the header length.
+       */
+       char *(*get_header_info)(int *header_len);
+       /**
+        * check if this audio format handler can handle the file
+        *
+        * This is a  pointer to a function returning whether a given file is valid for
+        * this audio format. A negative return value indicates that this audio format
+        * handler did not recognize the given file. On success, the function is
+        * expected to return a positive value and to fill in \arg info_str, \arg
+        * chunks and \arg seconds appropriately.
+       */
+       int (*get_file_info)(FILE *audio_file, char *info_str,
+               long unsigned *chunks, int *seconds);
+       /**
+        * cleanup function of this audio format handler
+        *
+        * This close function should deallocate any resources
+        * associated with the current audio file. In particular, it is responsible
+        * for closing the file handle. It is assumed to succeed.
+       */
+       void (*close_audio_file)(void);
+       /**
+        * jump to another position in the current audio file
+        *
+        * This is called if a client issued the ff or jmp command with \a request
+        * being the number of the next chunk that should be sent out. Must return a
+        * positive value on success and a negative value on errors.
+       */
+       int (*reposition_stream)(long unsigned request);
+       /**
+        * function responsible for reading one data chunk.
+        *
+        * \a read_chunk() must return a pointer to the next chunk of data that should
+        * be sent out, or \p NULL on errors or if the end of the file was encountered.
+        *
+        * If it returns non-NULL, \a len must contain the length of the returned
+        * buffer (which may be zero if nothing has to be sent for some reason).
+        * Otherwise, \a len is used to distinguish between the eof and the error case:
+        * It must be zero in the eof case, or negative if an error occcured.
+       */
+       char * (*read_chunk)(long unsigned chunk_num, ssize_t *len);
 };
 
 void afs_init(void);
index f5b39731f94224f81c954949e7fbf41d8aa1e066..5d785f5ce92f66618dafc877beb454bb2c0062e9 100644 (file)
--- a/command.c
+++ b/command.c
@@ -44,7 +44,7 @@ extern const char *status_item_list[NUM_STAT_ITEMS];
 extern struct misc_meta_data *mmd;
 extern struct gengetopt_args_info conf;
 extern struct audio_file_selector selectors[];
-extern struct audio_format afl[];
+extern struct audio_format_handler afl[];
 extern struct sender senders[];
 extern char *user_list;
 struct sockaddr_in *in_addr;
index e838b3d87f23a64faa7eb4829f38c2dbcac7cf1c..855780e6cd6a691be9dbaf1200e2c40f8fda3872 100644 (file)
@@ -50,8 +50,8 @@ struct dccp_client {
        int header_sent;
 };
 
-static void dccp_pre_select(__a_unused struct audio_format *af, int *max_fileno, fd_set *rfds,
-               __a_unused fd_set *wfds)
+static void dccp_pre_select(__a_unused struct audio_format_handler *af,
+               int *max_fileno, fd_set *rfds, __a_unused fd_set *wfds)
 {
        if (listen_fd < 0)
                return;
@@ -59,8 +59,8 @@ static void dccp_pre_select(__a_unused struct audio_format *af, int *max_fileno,
        *max_fileno = PARA_MAX(*max_fileno, listen_fd);
 }
 
-static void dccp_post_select(__a_unused struct audio_format *af, fd_set *rfds,
-               __a_unused fd_set *wfds)
+static void dccp_post_select(__a_unused struct audio_format_handler *af,
+               fd_set *rfds, __a_unused fd_set *wfds)
 {
        struct dccp_client *dc;
        int ret;
@@ -133,7 +133,7 @@ err_out:
        return -E_DCCP_WRITE;
 }
 
-static void dccp_send(__a_unused struct audio_format *af,
+static void dccp_send(__a_unused struct audio_format_handler *af,
                long unsigned current_chunk,
                __a_unused long unsigned chunks_sent, const char *buf, size_t len)
 {
index ea88bd4a8cdfbcdad902d36d7717702318279e73..f9345acedb0e76ef8ef0487cd24ec411a35ea53f 100644 (file)
@@ -206,7 +206,7 @@ static int send_queued_packets(struct http_client *hc)
        return 1;
 }
 
-static void http_send(__a_unused struct audio_format *af,
+static void http_send(__a_unused struct audio_format_handler *af,
                long unsigned current_chunk,
                __a_unused long unsigned chunks_sent, const char *buf, size_t len)
 {
@@ -267,7 +267,7 @@ static int host_in_access_perm_list(struct http_client *hc)
        return 0;
 }
 
-static void http_post_select(__a_unused struct audio_format *af, fd_set *rfds,
+static void http_post_select(__a_unused struct audio_format_handler *af, fd_set *rfds,
                fd_set *wfds)
 {
        int i = -1, match;
@@ -347,8 +347,8 @@ err_out:
        free(hc);
 }
 
-static void http_pre_select(struct audio_format *af, int *max_fileno, fd_set *rfds,
-               fd_set *wfds)
+static void http_pre_select(struct audio_format_handler *af, int *max_fileno,
+       fd_set *rfds, fd_set *wfds)
 {
        struct http_client *hc, *tmp;
 
diff --git a/mp3.c b/mp3.c
index bc253aa5aeaa7a787550f9619d55d2c263ce25c7..b9b21a94de7db52f680bb90e788778fa8e74d1e6 100644 (file)
--- a/mp3.c
+++ b/mp3.c
@@ -107,7 +107,7 @@ static const char *mode_text[] = {"stereo", "joint stereo", "dual channel", "mon
 static struct mp3info mp3;
 static char mp3buf[8192];
 static int chunk_size;
-static struct audio_format *af;
+static struct audio_format_handler *af;
 
 static int header_frequency(struct mp3header *h)
 {
diff --git a/ogg.c b/ogg.c
index 2d584e5be5a84f8d5ce9e4f1a2f0eb7ca928f7d1..e5647b26eca11e8ce975d69034944174fb973164 100644 (file)
--- a/ogg.c
+++ b/ogg.c
@@ -36,7 +36,7 @@ static FILE *infile;
 static int header_len, oggbuf_len, vi_channels;
 static char *header, *oggbuf;
 static ssize_t *chunk_table, max_chunk_len;
-struct audio_format *af;
+struct audio_format_handler *af;
 static long vi_sampling_rate, vi_bitrate, vi_bitrate_nominal,
        num_chunks;
 
index 9dcde7fc376a0c526c4902641bf495b4650f55fc..46b3ece763aaed16f8de964a40d5c5c91d10eaf2 100644 (file)
@@ -133,7 +133,8 @@ static void ortp_shutdown_targets(void)
        }
 }
 
-static int need_extra_header(struct audio_format *af, long unsigned chunks_sent)
+static int need_extra_header(struct audio_format_handler *af,
+               long unsigned chunks_sent)
 {
        /* FIXME: No need to compute this on every run */
        int mod = conf.ortp_header_interval_arg / (tv2ms(&af->chunk_tv) + 1);
@@ -142,7 +143,7 @@ static int need_extra_header(struct audio_format *af, long unsigned chunks_sent)
        return 1;
 }
 
-static void ortp_send(struct audio_format *af, long unsigned current_chunk,
+static void ortp_send(struct audio_format_handler *af, long unsigned current_chunk,
                long unsigned chunks_sent, const char *buf, size_t len)
 {
        struct ortp_target *ot, *tmp;
@@ -289,7 +290,7 @@ success:
        }
 }
 
-static void ortp_pre_select(__a_unused struct audio_format *af,
+static void ortp_pre_select(__a_unused struct audio_format_handler *af,
        __a_unused  int *max_fileno, __a_unused fd_set *rfds,
        __a_unused fd_set *wfds)
 {
diff --git a/send.h b/send.h
index 3aebb1600ebfdee0450c0100ae8c99921c7c0cd0..f7198ed7df94f5b3c4491f15656a6f4649fea5b4 100644 (file)
--- a/send.h
+++ b/send.h
@@ -45,7 +45,7 @@ struct sender {
  * command. Of course, \a buf is a pointer to the chunk of data which
  * should be sent, and \a len is the length of this buffer.
 */
-       void (*send)(struct audio_format *af, long unsigned current_chunk,
+       void (*send)(struct audio_format_handler *af, long unsigned current_chunk,
                long unsigned chunks_sent, const char *buf, size_t len);
 /** add file descriptors to fd_sets
  *
@@ -58,7 +58,7 @@ struct sender {
  *
  * \sa select(2)
 */
-       void (*pre_select)(struct audio_format *af, int *max_fileno, fd_set *rfds,
+       void (*pre_select)(struct audio_format_handler *af, int *max_fileno, fd_set *rfds,
                fd_set *wfds);
 /**
  * handle the file descriptors which are ready for I/O
@@ -67,7 +67,7 @@ struct sender {
  * set, this is the hook to check the result and do any I/O on those descriptors
  * which are ready for reading/writing.
  */
-       void (*post_select)(struct audio_format *af, fd_set *rfds, fd_set *wfds);
+       void (*post_select)(struct audio_format_handler *af, fd_set *rfds, fd_set *wfds);
 /**
  * terminate all connected clients
  *
index caa32d8ef3f77e94d68aa57cdc7283c41725cb07..62427717eab054950f8e26a02f3ecd3ff60d9e24 100644 (file)
--- a/server.c
+++ b/server.c
@@ -61,7 +61,7 @@ char *user_list = NULL;
 extern void dccp_send_init(struct sender *);
 extern void http_send_init(struct sender *);
 extern void ortp_send_init(struct sender *);
-extern struct audio_format afl[];
+extern struct audio_format_handler afl[];
 
 /* TODO: This is better handled by autoconf */
 /** the list of supported audio file selectors */