]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
Merge /home/maan/scm/paraslash_fml/paraslash
authorAndre Noll <maan@systemlinux.org>
Sat, 24 Mar 2007 17:25:08 +0000 (18:25 +0100)
committerAndre Noll <maan@systemlinux.org>
Sat, 24 Mar 2007 17:25:08 +0000 (18:25 +0100)
NEWS
aac_afh.c
afh.h
mysql_selector.c

diff --git a/NEWS b/NEWS
index 58c3722530f76cc67bfe07505e239d8a6c77b87f..9277d1cfd0701e497a84c188710c51848b7314dd 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -10,8 +10,9 @@ cleanup which removes some similar/duplicate code and makes it easier
 to implement plugins for other audio formats. Of course, the usual mix
 of other improvements/changes/bugfixes also made it into the release.
 
-       - simplified audio format handlers (some of the handling functions
+       - simplified audio format handlers (most of the handling functions
          were moved one layer up to the virtual streaming system).
+       - para_server uses mmap to read audio files
        - repositioning of mp3 streams is much faster, in particular for
          jumping near the end of large mp3 files.
        - permission flags DB_READ,DB_WRITE have been renamed to AFS_READ
index bf402f091968254a0c120eec5f762f1180aaf2c0..13e9c5d5ad4bc1c96f24ae8353e8fafbc0e52494 100644 (file)
--- a/aac_afh.c
+++ b/aac_afh.c
@@ -91,7 +91,7 @@ static long unsigned aac_set_chunk_tv(struct audio_format_info *afi,
        PARA_INFO_LOG("%luHz, %fs (%lu x %lums)\n",
                mp4ASC->samplingFrequency, ms / 1000,
                afi->chunks_total, tv2ms(&afi->chunk_tv));
-       return ms / 1000;
+       return ms < 1000? -E_MP4ASC : ms / 1000;
 }
 
 /*
@@ -116,10 +116,14 @@ static int aac_get_file_info(char *map, off_t numbytes,
        ret = -E_AACDEC_INIT;
        if (NeAACDecInit(handle, map + skip, decoder_len, &rate, &channels))
                goto out;
+       if (!channels)
+               goto out;
        PARA_INFO_LOG("rate: %lu, channels: %d\n", rate, channels);
        ret = -E_MP4ASC;
        if (NeAACDecAudioSpecificConfig(map + skip, numbytes - skip, &mp4ASC))
                goto out;
+       if (!mp4ASC.samplingFrequency)
+               goto out;
        ret = aac_compute_chunk_table(afi, map, numbytes);
        if (ret < 0)
                goto out;
@@ -131,11 +135,18 @@ static int aac_get_file_info(char *map, off_t numbytes,
        afi->chunk_table[0] = ret;
        for (i = 1; i<= afi->chunks_total; i++)
                afi->chunk_table[i] += ret;
-       sprintf(afi->info_string, "audio_file_info1:%lu x %lums\n"
+       afi->channels = channels;
+       afi->frequency = rate;
+       ret = (afi->chunk_table[afi->chunks_total] - afi->chunk_table[0]) * 8; /* bits */
+       ret += (channels * afi->seconds_total * 500); /* avoid rounding error */
+       afi->bitrate = ret / (channels * afi->seconds_total * 1000);
+       sprintf(afi->info_string, "audio_file_info1:%lu x %lums, "
+               "%uHz, %d channel%s, %ukb/s\n"
                "audio_file_info2:\n"
                "audio_file_info3:\n",
-               afi->chunks_total,
-               tv2ms(&afi->chunk_tv));
+               afi->chunks_total, tv2ms(&afi->chunk_tv),
+               afi->frequency, channels, channels == 1? "" : "s", afi->bitrate
+       );
        tv_scale(20, &afi->chunk_tv, &afi->eof_tv);
        ret = 1;
 out:
diff --git a/afh.h b/afh.h
index 246cb9200fefc8a601a333ad7f3e82b490beb346..e365df86569337ba767cfe9601f81c3ba39c939c 100644 (file)
--- a/afh.h
+++ b/afh.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005-2006 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 2005-2007 Andre Noll <maan@systemlinux.org>
  *
  *     This program is free software; you can redistribute it and/or modify
  *     it under the terms of the GNU General Public License as published by
@@ -72,6 +72,9 @@ struct audio_format_info {
        char *header;
        /** the length of the header, ignored if \a header is \p NULL */
        unsigned header_len;
+       uint8_t channels;
+       uint16_t frequency;
+       uint16_t bitrate;
 };
 
 /**
index d7d4ee104f80e6fd6d419ecd2a068073d594cbfe..b2a925e09311a6cc71bf45c488c73eca8a163e99 100644 (file)
@@ -900,7 +900,6 @@ write:
        return info;
 }
 
-
 /* might return NULL */
 static char *get_current_audio_file(void)
 {
@@ -911,6 +910,29 @@ static char *get_current_audio_file(void)
        return name;
 }
 
+/* If called as child, mmd_lock must be held */
+static void update_mmd(char *info)
+{
+       PARA_DEBUG_LOG("%s", "updating shared memory area\n");
+       strncpy(mmd->selector_info, info, MMD_INFO_SIZE - 1);
+       mmd->selector_info[MMD_INFO_SIZE - 1] = '\0';
+}
+
+static void refresh_selector_info(void)
+{
+       char *name = get_current_audio_file();
+       char *info;
+
+       if (!name)
+               return;
+       info = get_selector_info(name);
+       free(name);
+       mmd_lock();
+       update_mmd(info);
+       mmd_unlock();
+       free(info);
+}
+
 /* list attributes / print database info */
 static int com_la_info(int fd, int argc, char *argv[])
 {
@@ -1186,7 +1208,10 @@ int com_picass(int fd, int argc, char *argv[])
  */
 int com_snp(int fd, int argc, char *argv[])
 {
-       return com_set(fd, argc, argv);
+       int ret = com_set(fd, argc, argv);
+       if (ret >= 0)
+               refresh_selector_info();
+       return ret;
 }
 
 /*
@@ -1463,14 +1488,6 @@ out:
        return ret;
 }
 
-/* If called as child, mmd_lock must be held */
-static void update_mmd(char *info)
-{
-       PARA_DEBUG_LOG("%s", "updating shared memory area\n");
-       strncpy(mmd->selector_info, info, MMD_INFO_SIZE - 1);
-       mmd->selector_info[MMD_INFO_SIZE - 1] = '\0';
-}
-
 static void update_audio_file_server_handler(char *name)
 {
        char *info;
@@ -1492,24 +1509,11 @@ int com_us(__a_unused int fd, int argc, char *argv[])
                return -E_ESCAPE;
        ret = update_audio_file(argv[1]);
        free(tmp);
+       if (ret >= 0)
+               refresh_selector_info();
        return ret;
 }
 
-static void refresh_selector_info(void)
-{
-       char *name = get_current_audio_file();
-       char *info;
-
-       if (!name)
-               return;
-       info = get_selector_info(name);
-       free(name);
-       mmd_lock();
-       update_mmd(info);
-       mmd_unlock();
-       free(info);
-}
-
 /* select previous / next stream */
 static int com_ps_ns(__a_unused int fd, int argc, char *argv[])
 {