repo: music
action: commit
revision: 
path_from: 
revision_from: e3a2263b0723547cb2c3a53122fee1cc2d1823ad:
path_to: 
revision_to: 
git.thebackupbox.net
music
git clone git://git.thebackupbox.net/music
commit e3a2263b0723547cb2c3a53122fee1cc2d1823ad
Author: epoch 
Date:   Tue Dec 17 00:04:08 2019 -0600

    added pad to the Makefile, using pad to finish out the 16 byte chunks in icy-metadata which now works... more correctly I guess.

diff --git a/Makefile b/Makefile
index 364525e3432441a065f89994980c4044a9ce3aab..
index ..3667858cc1bfb735956a343de05af9adbdb9ac23 100644
--- a/Makefile
+++ b/Makefile
@@ -1,10 +1,18 @@
 PREFIX:=/usr/local

-.PHONY: install
+.PHONY: install clean
+
+all: qargs pad

 qargs: qargs.c

-install: qargs
+pad: pad.c
+
+clean:
+	rm qargs
+	rm pad
+
+install: all
 	install qargs $(PREFIX)/bin/
 	install music-player $(PREFIX)/bin/
 	install music-playpause $(PREFIX)/bin/
@@ -23,3 +31,5 @@ install: qargs
 	install icy-metadata $(PREFIX)/bin/
 	install music-radio $(PREFIX)/bin/
 	install music-stream $(PREFIX)/bin/
+	install music-stream-mp3 $(PREFIX)/bin/
+	install pad $(PREFIX)/bin/
diff --git a/icy-metadata b/icy-metadata
index a9496bf44a549e6d2f3b43d0fa8ec64cf7393dff..
index ..a3304088f9699a1509ca07e5019777499a3b6ece 100755
--- a/icy-metadata
+++ b/icy-metadata
@@ -1,8 +1,10 @@
 #!/bin/bash
 while true;do
-  head -c 1024
-  NP="$(music-nowplaying 2>/dev/null)"
-  #LEN=$(printf "%64s" "${NP}" | wc -c | tr -cd '0-9')
-  #HEXLEN=$(printf "%02x\n" $[$LEN / 16 + 1])
-  printf "\x05StreamTitle='%64s';\n" "${NP}"
+  dd count="$1" bs=1 2>/dev/null
+  NP="$(music-nowplaying 2>/dev/null)" # | cut -b1-255 | pad 255 2>/dev/null)"
+  LEN=$(printf "%s" "${NP}" | wc -c | tr -cd '0-9')
+  CHUNKS=$[$LEN / 16 + 2]
+  HEXLEN=$(printf "%02x\n" $CHUNKS)
+  PADDING=$[16 * $CHUNKS]
+  printf "\x${HEXLEN}StreamTitle='%s';\n" "${NP}" | pad $PADDING _
 done
diff --git a/pad.c b/pad.c
new file mode 100644
index 0000000000000000000000000000000000000000..f520de3ad45bc6a0462480ddd31ea859d2a672b2
--- /dev/null
+++ b/pad.c
@@ -0,0 +1,33 @@
+#include 
+#include 
+#include 
+
+int main(int argc,char *argv[]) {
+ short in;
+ int i=0;
+ int width=argc>1?atoi(argv[1]):80;
+ char with=argc>2?argv[2][0]:' ';
+ char *line=argc>3?argv[3]:0;
+ if(width <= 0) width=80;
+ if(!line) {
+  while((in=fgetc(stdin)) != -1) {
+   if(in == '\n') {
+    for(;i%width || i == 0;i++) {
+     putchar(with);
+    }
+    i=-1;
+   }
+   i++;
+   putchar(in);
+  }
+ } else {
+  i=strlen(line);
+ }
+ if(i != 0 || line) {
+  if(line) fputs(line,stdout);
+  for(;i%width || i == 0;i++) {
+   putchar(with);
+  }
+ }
+ return 0;
+}

-----END OF PAGE-----