]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
Merge topic branch t/afs-cleanups into master
authorAndre Noll <maan@tuebingen.mpg.de>
Sun, 20 Nov 2022 18:21:35 +0000 (19:21 +0100)
committerAndre Noll <maan@tuebingen.mpg.de>
Sun, 20 Nov 2022 18:23:40 +0000 (19:23 +0100)
A fair number of patches which clean up all parts of the audio file
selector. The most visible change is probably that error messages from
afs callbacks are sent with a proper sideband designator so that they
are written to stderr on the client side.

* refs/heads/t/afs-cleanups: (30 commits)
  Introduce afs_error().
  afs.c: Move com_select() and its callback down.
  Rename mood_switch(), mood_close(), playlist_{open/close}.
  Assume that score_open() and score_clear() always succeed.
  playlist.c: Rename playlist_info -> playlist_instance.
  mood.c: Rename struct mood to mood_instance.
  afs.c: Rename ->handler of struct callback_query to ->cb.
  Simplify and improve activate_mood_or_playlist().
  afs: Replace ->init of afs tables by table operations.
  Merge load_playlist() into playlist_open() and simplify.
  Simplify row_belongs_to_score_table().
  Remove mood.h.
  Clean up and rename change_current_mood().
  mood.c: Simplify and rename load_mood().
  mood.c: Move struct statistics into struct mood.
  afs.c: Improve activate_mood_or_playlist().
  Improve playlist_open().
  blob.c: Don't initialize table pointer in table->init().
  blob: Constify name argument of blob_get_def_by_name().
  Rename admissible_file_loop() -> score_loop().
  ...

1  2 
NEWS.md
error.h
mood.c

diff --cc NEWS.md
index 539f75768c6b99ef6bbbff4074e8fd309692b5c4,5a00175c3255702b03ec86e0af1938863f53ba4d..009982a3b85a3ad2421aab8ef4684b3dc30a8587
+++ b/NEWS.md
@@@ -1,18 -1,6 +1,21 @@@
  NEWS
  ====
  
 +------------------------------------------
 +0.7.2 (to be announced) "optical friction"
 +------------------------------------------
 +
++- A major cleanup of the audio file selector.
++- The client no longer prints error messages from afs commands to
++  stdout but to stderr.
 +- The sleep subcommand of para_mixer gained two options to control
 +  the startup mood and the time period before fade-out starts. A bunch
 +  of further improvements for this subcommand went in as well.
 +- Minor cleanup of the net subsystem.
 +
 +Downloads:
 +[tarball](./releases/paraslash-git.tar.xz)
 +
  --------------------------------------
  0.7.1 (2022-10-03) "digital spindrift"
  --------------------------------------
diff --cc error.h
Simple merge
diff --cc mood.c
index d47c54efa360b856c63b660fd4cdb5b81d442b68,15da76f2b20e630e87fca05e674166b59027ac41..9cdfd011a6ef4f2ab9fb180892f6412247eb68fe
--- 1/mood.c
--- 2/mood.c
+++ b/mood.c
@@@ -249,25 -252,25 +252,27 @@@ int mood_check_callback(struct afs_call
   * overflows and rounding errors we store the common divisor of the
   * correction factors separately.
   */
- static long compute_score(struct afs_info *afsi)
 -static int64_t normalized_value(int64_t x, int64_t n, int64_t sum, int64_t qd)
 -{
 -      if (!n || !qd)
 -              return 0;
 -      return 100 * (n * x - sum) / (int64_t)int_sqrt(n) / (int64_t)int_sqrt(qd);
 -}
 -
+ static long compute_score(struct afs_info *afsi,
+               const struct afs_statistics *stats)
  {
 -      long score = -normalized_value(afsi->num_played, stats->num,
 -              stats->num_played_sum, stats->num_played_qd);
 -      score -= normalized_value(afsi->last_played, stats->num,
 -              stats->last_played_sum, stats->last_played_qd);
 -      return score / 2;
 +      int64_t mean_n, mean_l,score_n, score_l;
 +
-       assert(statistics.normalization_divisor > 0);
-       assert(statistics.num > 0);
-       mean_n = statistics.num_played_sum / statistics.num;
-       mean_l = statistics.last_played_sum / statistics.num;
++      assert(stats->normalization_divisor > 0);
++      assert(stats->num > 0);
++      mean_n = stats->num_played_sum / stats->num;
++      mean_l = stats->last_played_sum / stats->num;
 +
 +      score_n = -((int64_t)afsi->num_played - mean_n)
-               * statistics.num_played_correction
-               / statistics.normalization_divisor;
++              * stats->num_played_correction
++              / stats->normalization_divisor;
 +      score_l = -((int64_t)afsi->last_played - mean_l)
-               * statistics.last_played_correction
-               / statistics.normalization_divisor;
++              * stats->last_played_correction
++              / stats->normalization_divisor;
 +      return (score_n + score_l) / 2;
  }
  
- static int add_afs_statistics(const struct osl_row *row)
+ static int add_afs_statistics(const struct osl_row *row,
+               struct afs_statistics *stats)
  {
        uint64_t n, x, s, q;
        struct afs_info afsi;