General discussion

Here you can discuss everything related to MOC which doesn't fit other subforum.

Internet Streaming

Hi!
I have some problems with internet streaming. When I want to listen to some music(no matter what format), moc keeps "Connecting...", but he never get connected ;/ I have curl (7.16.2) and moc from svn.
I hope somebody will help me...

ungetc

Is it possible to an implement ungetc analog in the io library? I'm trying to write a wrapper for wavpack decoder and it requires ungetc function.

Playing m3u from comandline

Short question:

Is there some 'official' way to start playing a playlist from a command line?

Long question (actually the same):

I think I am not very familiar with whole moc functionalities, so I am not sure if this message is a question-on-usage, a feature request or a patch. So, please let me take a little of your time to explain my needs.

My needs are somehow specific. I need the following command-line player features:
1. start playing a file;
2. start playing files from an m3u;
3. next/prev/stop/pause/resume (when playing m3u);
4. tell what is playing now.

The player must not require X, and desirably should play as a background server. Also, player should not be limited to playing mp3 only.

This is required to provide IR-controlled music, somewhat like a radio-station with feedback. I use LIRC and my own perl script.

So, after some searches, I recognized that MOC fits my purposes best. I took moc, it was 2.3.3.

To play file, I used `mocp -l filename.mp3`. But I couldn't find how can I start an m3u file. So, I applies a little patch to moc:

--- begin ---

--- moc-2.3.3/interface.c 2005-12-29 17:06:55.000000000 +0300
+++ moc-2.3.3.my/interface.c 2006-02-05 03:58:53.000000000 +0300
@@ -4295,9 +4295,16 @@

plist_init (&plist);

- for (i = 0; i < arg_num; i++)
+ for (i = 0; i < arg_num; i++) {
if (is_url(args) || is_sound_file(args))
plist_add (&plist, args);
+ if (is_plist_file(args)) {
+ struct plist tmp;
+ plist_init(&tmp);
+ plist_load(&tmp, args, NULL);
+ plist_cat(&plist, &tmp);
+ }
+ }

if (plist_count(&plist)) {
int serial;

--- end ---

After that, I could start m3u's with `moc -l playlist.m3u`

Thank you for reading so much :) My questions are:

1. Is there some 'official' way to start playing a playlist?
2. If no, would that feature fit well with mainstream MOC ideas?

SID Plugin

I made a SID-Tune plugin for MOC (2.5.0-alpha1).
This was a bit tricky but I think it works quite well...

Depends on libsidplay2 and libsidutils (and on the existence of the ReSID-Builder from that libraries).

Features :
ReSID-Builder for SID-Playback
HVSC-Database support for songlengths
...some more

I hope this opens MOC to an even wider public... :-)

There might be some bugs although I tried to catch most of them - feedback appreciated...

Patch : http://www.tzi.de/~hiben/darcsrep/linux/gentoo/portage/media-sound/moc/files/2.5.0-sidplay2.patch

More info : http://www.tzi.de/~hiben/moc/

Bug? .pls loads only 9 entries

When loading .pls playlist, having more than 9 entries, mocp displays only first nine.
Debian etch, moc 2.4.1 Build: Oct 21 2006 22:43:12

Use keymap file.

Hi. I'm sorry for my idiotic question, but I don't understand how to use subj.
I have this string in my keymap file (for example):

go_to_fast_dir1 = "/mnt" !
exec_command1 = "rm %f" F1

I run the mocp. Press "Shift 1". And that mocp write: FastDir is not defined.
Press "F1". And that mocp write: ExecCommand1 is not set.
Well, I don't understand a file syntax. Explain it please.

True remove patch (broken link)

Hi All. I need a true delete patch (from file system), but link is broken. Fix link please.

menu_items_swap bug [PATCH]

I was attempting to implement a queue feature this afternoon when I came across a bug in menu.c. The interface menu is represented by a doubly-linked list, and swapping two items is pretty tricky. In current usage, the two items are almost always adjacent, and the swap works fine in this case. In case the two items are not adjacent, though, the current code swaps the prev and next pointers in such a way that some data gets clobbered.

In fixing this bug, I introduced a generic swap function in common.h (see below), and I cleaned up the menu_items_swap function a little (to use the new swap function where appropriate).

I've tested the function as thoroughly as I can, and I've tried to stick to the style of the files I changed. Hope this makes it easy for you to apply the patch.

Index: menu.c
===================================================================
--- menu.c	(revision 1986)
+++ menu.c	(working copy)
@@ -776,8 +776,6 @@
 static void menu_items_swap (struct menu *menu, struct menu_item *mi1,
 		struct menu_item *mi2)
 {
-	int t;
-	
 	assert (menu != NULL);
 	assert (mi1 != NULL);
 	assert (mi2 != NULL);
@@ -785,43 +783,28 @@
 
 	/* if they are next to each other, change the pointers so that mi2
 	 * is the second one */
-	if (mi2->next == mi1) {
-		struct menu_item *i = mi1;
+	if (mi2->next == mi1)
+		swap(&mi1, &mi2, sizeof(mi1));
 
-		mi1 = mi2;
-		mi2 = i;
-	}
+	// safe even if mi1->next == mi2
+	if (mi2->next) mi2->next->prev = mi1;
+	if (mi1->prev) mi1->prev->next = mi2;
 
 	if (mi1->next == mi2) {
-		if (mi2->next)
-			mi2->next->prev = mi1;
-		if (mi1->prev)
-			mi1->prev->next = mi2;
-		
 		mi1->next = mi2->next;
 		mi2->prev = mi1->prev;
 		mi1->prev = mi2;
 		mi2->next = mi1;
+	} else {
+		// not safe if mi1->next == mi2
+		if (mi2->prev) mi2->prev->next = mi1;
+		if (mi1->next) mi1->next->prev = mi2;
+
+		swap(&mi1->prev, &mi2->prev, sizeof(mi1->prev));
+		swap(&mi1->next, &mi2->next, sizeof(mi1->next));
 	}
-	else {
-		if (mi2->next)
-			mi2->next->prev = mi1;
-		if (mi2->prev)
-			mi2->prev->next = mi1;
-		mi2->next = mi1->next;
-		mi2->prev = mi1->prev;
-		
-		if (mi1->next)
-			mi1->next->prev = mi2;
-		if (mi1->prev)
-			mi1->prev->next = mi2;
-		mi1->next = mi2->next;
-		mi1->prev = mi2->prev;
-	}
 
-	t = mi1->num;
-	mi1->num = mi2->num;
-	mi2->num = t;
+	swap(&mi1->num, &mi2->num, sizeof(mi1->num));
 
 	if (menu->top == mi1)
 		menu->top = mi2;
Index: common.c
===================================================================
--- common.c	(revision 1986)
+++ common.c	(working copy)
@@ -124,4 +124,16 @@
 	return fname;
 }
 
+static void swap_bytes(char *b1, char *b2) {
+	if (*b1 != *b2) {
+		*b1 ^= *b2;
+		*b2 ^= *b1;
+		*b1 ^= *b2;
+	}
+}
 
+void swap(void *a, void *b, size_t n) {
+	int i = 0;
+	for ( ; i < n; ++i)
+		swap_bytes((char*)a + i, (char*)b + i);
+}
Index: common.h
===================================================================
--- common.h	(revision 1986)
+++ common.h	(working copy)
@@ -55,4 +55,6 @@
 void set_me_server ();
 char *create_file_name (const char *file);
 
+void swap(void *a, void *b, size_t n);
+
 #endif

Pages

Subscribe to RSS - General discussion