]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
Merge branch 'refs/heads/t/afh'
authorAndre Noll <maan@tuebingen.mpg.de>
Sun, 1 Sep 2019 11:18:41 +0000 (13:18 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Sun, 1 Sep 2019 11:19:29 +0000 (13:19 +0200)
A couple of patches which remove ->init of struct audio_format_handler
and struct receiver.

Cooking for 9 months.

* refs/heads/t/afh:
  Remove ->init() of struct receiver.
  afh: Constify definition of audio format handlers.
  afh: Introduce audio_format_names[].
  afh: Get rid of dummy entry at the end of afl[].
  afh: Minor simplification for afh_get_chunk().
  afh: Move audio_format_name() up.

1  2 
NEWS.md
afh.c
mp3_afh.c

diff --combined NEWS.md
index 50ec0a3a51e156b704cf6979ec595f83a300192e,55ef3be947ee76d6b0937b33988b0cd960c0e985..7ed78027fc29cf5f681e0d4b00464397ff4e995b
+++ b/NEWS.md
@@@ -1,21 -1,6 +1,22 @@@
  NEWS
  ====
  
 +----------------------------------------------
 +0.6.3 (to be announced) "generalized activity"
 +----------------------------------------------
 +
 +- The ff command now accepts a negative argument to instruct the
 +  virtual streaming system to jump backwards in the current audio
 +  stream. The old syntax (e.g., "ff 30-") is still supported but it
 +  is deprecated and no longer documented. The compatibility code is
 +  sheduled for removal after 0.7.0.
 +- para_afh: New option: --preserve to reset the modification time to
 +  the value of the original file after meta data modification.
 +- Overhaul of the compress filter code. The refined algorithm should
 +  reduce clipping. The meaning of --aggressiveness has changed, see the
 +  updated and extended documentation of the compress filter for details.
++- Cleanup of the audio format handler code.
 +
  --------------------------------------
  0.6.2 (2018-06-30) "elastic diversity"
  --------------------------------------
diff --combined afh.c
index ffb4315b0d41e7087aa03ee7b353e7f690989126,69b834d2c507fa5944dc3871838d555b4317115b..567b560a038f0923a663005b447a0fc688c57b2a
--- 1/afh.c
--- 2/afh.c
+++ b/afh.c
@@@ -113,24 -113,6 +113,24 @@@ static int rewrite_tags(const char *nam
                        goto out;
        }
        ret = xrename(tmp_name, name);
 +      if (ret < 0)
 +              goto out;
 +      if (OPT_GIVEN(PRESERVE)) {
 +              struct timespec times[2]; /* [0]: atime, [1]: mtime */
 +              times[0].tv_nsec = UTIME_OMIT;
 +              times[1] = sb.st_mtim;
 +              /*
 +               * We might well have written a file of identical size. If we
 +               * keep the mtime as well, we might fool backup applications
 +               * like rsync which skip files whose size and mtime haven't
 +               * changed. So we change the mtime slightly.
 +               */
 +              times[1].tv_sec++;
 +              if (futimens(output_fd, times) < 0) {
 +                      ret = -ERRNO_TO_PARA_ERROR(errno);
 +                      goto out;
 +              }
 +      }
  out:
        if (ret < 0 && output_fd >= 0)
                unlink(tmp_name); /* ignore errors */
@@@ -221,7 -203,6 +221,6 @@@ int main(int argc, char **argv
        loglevel = OPT_UINT32_VAL(LOGLEVEL);
        version_handle_flag("afh", OPT_GIVEN(VERSION));
        handle_help_flags();
-       afh_init();
        for (i = 0; i < lls_num_inputs(lpr); i++) {
                int ret2;
                const char *path = lls_input(i, lpr);
diff --combined mp3_afh.c
index 471efd99db36634e1db33763be94ef70c4ae6de4,e5027a0b051a346c560b61d1141bc4da952aa7af..6ed73c2aaa2e068ee404dea1d16fec8183ee5237
+++ b/mp3_afh.c
@@@ -63,6 -63,8 +63,6 @@@ static const int mp3info_bitrate[2][3][
  };
  
  static const int frame_size_index[] = {24000, 72000, 72000};
 -static const char *mode_text[] = {"stereo", "joint stereo", "dual channel", "mono", "invalid"};
 -
  #ifdef HAVE_ID3TAG
  
  #include <id3tag.h>
@@@ -431,13 -433,10 +431,13 @@@ static int header_frequency(struct mp3h
        return frequencies[h->version][h->freq];
  }
  
 -static const char *header_mode(struct mp3header *h)
 +static const char *header_mode(const struct mp3header *h)
  {
 -      if (h->mode > 4)
 -              h->mode = 4; /* invalid */
 +      const char * const mode_text[] = {"stereo", "joint stereo",
 +              "dual channel", "mono"};
 +
 +      if (h->mode >= ARRAY_SIZE(mode_text))
 +              return "invalid";
        return mode_text[h->mode];
  }
  
@@@ -683,15 -682,14 +683,14 @@@ static int mp3_get_file_info(char *map
  static const char * const mp3_suffixes[] = {"mp3", NULL};
  
  /**
-  * the init function of the mp3 audio format handler
+  * The mp3 audio format handler.
   *
-  * \param afh pointer to the struct to initialize
+  * It does not depend on any libraries and is hence always compiled in.
   */
- void mp3_afh_init(struct audio_format_handler *afh)
- {
-       afh->get_file_info = mp3_get_file_info;
-       afh->suffixes = mp3_suffixes;
+ const struct audio_format_handler mp3_afh = {
+       .get_file_info = mp3_get_file_info,
+       .suffixes = mp3_suffixes,
  #ifdef HAVE_LIBID3TAG
-       afh->rewrite_tags = mp3_rewrite_tags;
+       .rewrite_tags = mp3_rewrite_tags,
  #endif /* HAVE_LIBID3TAG */
- }
+ };