LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-13-2012, 04:28 PM   #16
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374

Glad it's working more or less like you were hoping.

On the scripting front, let me say this:

I stopped looking into the scripting option when 273 made the post about IDJC. The meager amount of info I gathered was that you have two scripting language options with ices: Perl and Python. So, when you compiled ices originally, you must have the dev packages installed for one of those two.

Furthermore, the Perl/Python script must have certain predefined hooks/functions that ices expects... callbacks if you're familiar with the term.

The thing is, I know Python allows for outside system calls to another program. So if you can get all the functionality you want in language XYZ, you'll just have to struggle with setting up a Python script to act an an intermediary between ices and your language of choice.
 
1 members found this post helpful.
Old 01-13-2012, 05:09 PM   #17
lucmove
Senior Member
 
Registered: Aug 2005
Location: Brazil
Distribution: Debian
Posts: 1,432

Original Poster
Rep: Reputation: 110Reputation: 110
Meh, I seriously dislike Perl and Python. Maybe I could find Perl tolerable if I tried it again, but the last time I tried was 10 years ago, I forgot almost everything. Python about 8 years and I didn't like it at all. The only languages I am fully willing to accept are Tcl and shell.

But that's fine, I will have to investigate the details on Ices again, then see what I can do. Still haven't gotten around to do it, I will later on, in the after hours.
 
Old 01-13-2012, 05:19 PM   #18
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680

Rep: Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373
I'm glad IDJC was of some help and I would actually like to ask my own question here:
When you install IDJC does it install Jack also and, if so, does that mean that when you run IDJC it locks the sound server so no other programs have sound?
I ask because it is a while (a couple of years I think) since I used IDJC last and there were sound problems in Ubuntu relating to Pulse Audio at the time so I never did get it working with ALSA and still have other applications using sound.
I'm sounding like the newby I am here but I'm loath to install it in case ALSA is modified and I lose sound for my other applications.
 
Old 01-13-2012, 05:31 PM   #19
lucmove
Senior Member
 
Registered: Aug 2005
Location: Brazil
Distribution: Debian
Posts: 1,432

Original Poster
Rep: Reputation: 110Reputation: 110
Quote:
Originally Posted by 273 View Post
I'm glad IDJC was of some help and I would actually like to ask my own question here:
When you install IDJC does it install Jack also and, if so, does that mean that when you run IDJC it locks the sound server so no other programs have sound?
I ask because it is a while (a couple of years I think) since I used IDJC last and there were sound problems in Ubuntu relating to Pulse Audio at the time so I never did get it working with ALSA and still have other applications using sound.
I'm sounding like the newby I am here but I'm loath to install it in case ALSA is modified and I lose sound for my other applications.
I may have good news for you:

1) Yes, Ubuntu installed jackd as a dependency. I hesitated a lot before accepting it because I also have had my share of problems with Jack. But I went ahead with it and it works this time! No problems at all.

2) I just launched Audacious then Mplayer with some other random song while streaming with icecast2/IDJC. I didn't have any problem. The computer across the room kept playing the stream while my notebook played the other (unrelated) song on Audacious or Mplayer. I hope that means there is no locking.

Gotta go now, should be back in a few hours.
 
Old 01-13-2012, 05:33 PM   #20
lucmove
Senior Member
 
Registered: Aug 2005
Location: Brazil
Distribution: Debian
Posts: 1,432

Original Poster
Rep: Reputation: 110Reputation: 110
NOTE: I am running Lubuntu 11.10 (Oneiric).
 
Old 01-13-2012, 05:38 PM   #21
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680

Rep: Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373
Thank you, much appreciated. I thought it would be fine or I would not have mentioned it -- I've a couple of sound cards on this PC so have to be more careful.
 
Old 01-15-2012, 02:35 PM   #22
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
Quote:
Originally Posted by lucmove
Meh, I seriously dislike Perl and Python.
Understandable. As it turns out, it's not necessary for you to mess with either anymore. Later today, I'll post a patch file for ices-0.4. The patch creates a new "Type" and supporting "ExternalData" element in the config file.

In short, with the patch appied (and ices re-compiled), your config file can include these lines:
Code:
<Type>external</Type>
<ExternalData>somestring</ExternalData>
<File>/path/to/some/executable</File>
It's simple: the value of element "File" is the executable file. The value of "Type" is the flag that says ices should run an external program. The value of "ExternalData" can be anything you want. The idea is that your script/executable uses the ExternalData as a way to keep track of what songs to serve. In other words, you could write one script to serve multiple streams (e.g. alternative stream, jazz stream, classical stream, etc.), and the value of ExternalData is given to the program on the command line so that the program knows which stream it needs to work on.

There are three ways the executable will be called: (1) initialization, (2) get next song, and (3) shutdown. Each way will be distinguished by different command line arguments.

As an example, I just tested it with the following config file settings:
Code:
<File>/home/user/temp/playlist_script.bash</File>
<Type>external</Type>
<ExternalData>--script_id testing</ExternalData>
For the initialization, the command would be:
Code:
/home/user/temp/playlist_script.bash --script_id testing --ices_action init
For getting the next song, the command would be:
Code:
/home/user/temp/playlist_script.bash --script_id testing --ices_action getnext
For shutdown, the command would be:
Code:
/home/user/temp/playlist_script.bash --script_id testing --ices_action shutdown
The script/executable can ignore all of the arguments; ices doesn't care. The only requirement is that the script/executable output the full path and filename for the next song. Bear in mind that ices will only read the first line of that output. Any output beyond the first line will be ignored.

Like I said, I'll post the patch later today along with instructions on how to apply it and any usage warnings (it's still a little rough).
 
1 members found this post helpful.
Old 01-15-2012, 06:58 PM   #23
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
As promised... the patch.

My goal was simply to get support for an external executable. So, I have not done much testing. In other words, deviate from the examples at your own risk.

The patch (also attached):
Code:
diff -Naur ices-0.4.original/src/ices_config.c ices-0.4/src/ices_config.c
--- ices-0.4.original/src/ices_config.c	2004-07-28 20:17:27.000000000 -0500
+++ ices-0.4/src/ices_config.c	2012-01-15 13:35:03.442779309 -0600
@@ -268,12 +268,18 @@
 	ices_config->pm.playlist_type = ices_playlist_python_e;
       else if (str && (strcmp (str, "perl") == 0))
 	ices_config->pm.playlist_type = ices_playlist_perl_e;
+      if (str && (strcmp (str, "external") == 0))
+	ices_config->pm.playlist_type = ices_playlist_external_e;
       else
 	ices_config->pm.playlist_type = ices_playlist_builtin_e;
     } else if (strcmp (cur->name, "File") == 0) {
       ices_util_free (ices_config->pm.playlist_file);
       ices_config->pm.playlist_file =
 	ices_util_strdup (ices_xml_read_node (doc, cur));
+    } else if (strcmp (cur->name, "ExternalData") == 0) {
+      ices_util_free (ices_config->pm.external_data);
+      ices_config->pm.external_data =
+	ices_util_strdup (ices_xml_read_node (doc, cur));
     } else if (strcmp (cur->name, "Module") == 0) {
       ices_util_free (ices_config->pm.module);
       ices_config->pm.module =
diff -Naur ices-0.4.original/src/icestypes.h ices-0.4/src/icestypes.h
--- ices-0.4.original/src/icestypes.h	2004-07-30 21:47:08.000000000 -0500
+++ ices-0.4/src/icestypes.h	2012-01-15 15:03:18.572777815 -0600
@@ -31,7 +31,8 @@
 typedef enum {
   ices_playlist_builtin_e,
   ices_playlist_python_e,
-  ices_playlist_perl_e
+  ices_playlist_perl_e,
+  ices_playlist_external_e
 } playlist_type_t;
 
 typedef struct ices_stream_St {
@@ -67,6 +68,7 @@
   int randomize;
   char* playlist_file;
   char* module;
+  char* external_data;
 
   char* (*get_next) (void);     /* caller frees result */
   char* (*get_metadata) (void); /* caller frees result */
diff -Naur ices-0.4.original/src/playlist/playlist.c ices-0.4/src/playlist/playlist.c
--- ices-0.4.original/src/playlist/playlist.c	2004-03-21 21:13:12.000000000 -0600
+++ ices-0.4/src/playlist/playlist.c	2012-01-15 13:57:34.802760707 -0600
@@ -73,6 +73,9 @@
     case ices_playlist_builtin_e:
       rc = ices_playlist_builtin_initialize (&ices_config.pm);
       break;
+    case ices_playlist_external_e:
+      rc = ices_playlist_external_initialize (&ices_config.pm);
+      break;
     case ices_playlist_python_e:
 #ifdef HAVE_LIBPYTHON
       rc = ices_playlist_python_initialize (&ices_config.pm);
diff -Naur ices-0.4.original/src/playlist/pm_builtin.c ices-0.4/src/playlist/pm_builtin.c
--- ices-0.4.original/src/playlist/pm_builtin.c	2004-03-21 21:13:12.000000000 -0600
+++ ices-0.4/src/playlist/pm_builtin.c	2012-01-15 15:02:56.562778274 -0600
@@ -38,6 +38,11 @@
 static void playlist_builtin_shuffle_playlist (void);
 static int playlist_builtin_line_skip (int lineno, FILE* fp);
 
+static char* playlist_external_get_next (void);
+static void playlist_external_shutdown (void);
+
+static int playlist_external_open_playlist (playlist_module_t* pm);
+
 /* Global function definitions */
 
 /* Initialize the builting playlist handler */
@@ -228,3 +233,115 @@
 
   return 1;
 }
+
+/* Initialize the builting playlist handler */
+int
+ices_playlist_external_initialize (playlist_module_t* pm)
+{
+  FILE *external_pipe;
+  char command_line[1024];
+
+  ices_log_debug ("Initializing external playlist program...");
+
+  pm->get_next = playlist_external_get_next;
+  pm->get_metadata = NULL;
+  pm->get_lineno = NULL;
+  pm->shutdown = playlist_external_shutdown;
+
+  if (!playlist_external_open_playlist (pm)) {
+    ices_log ("Could not find a valid external playlist program.");
+    ices_setup_shutdown ();
+    return -1;
+  }
+
+  ices_log_debug ("Calling external file with '--ices_action init' ...");
+  snprintf( command_line, 1023, "%s %s --ices_action init", pm->playlist_file, pm->external_data );
+  external_pipe = popen( command_line, "r" );
+  if( !external_pipe ) {
+    ices_log_error ( "Unable to execute: %s", command_line );
+    return -1;
+  }
+  pclose( external_pipe );
+
+  return 1;
+}
+
+static char *
+playlist_external_get_next (void)
+{
+  char command_line[1024];
+  char *out;
+  static int level = 0;
+  FILE *external_pipe;
+
+  ices_log_debug ("Calling external file with '--ices_action getnext' ...");
+  snprintf( command_line, 1023, "%s %s --ices_action getnext", ices_config.pm.playlist_file, ices_config.pm.external_data );
+  external_pipe = popen( command_line, "r" );
+  if( !external_pipe ) {
+    ices_log_error ( "Unable to execute: %s", command_line );
+    return NULL;
+  }
+
+  if (! (out = ices_util_read_line (external_pipe)))
+    return NULL;
+
+  pclose( external_pipe );
+
+  if (out[0])
+    out[strlen (out) - 1] = '\0';
+
+  if (! out[0]) {
+    if (level++) {
+      level = 0;
+      ices_log_error ("Unreadable or empty result");
+      return NULL;
+    }
+    return playlist_external_get_next ();
+  }
+
+  level = 0;
+
+  ices_log_debug ("External playlist handler serving: %s", ices_util_nullcheck (out));
+
+  return out;
+}
+
+/* Shutdown the builtin playlist handler */
+static void
+playlist_external_shutdown (void)
+{
+  char command_line[1024];
+  FILE *external_pipe;
+
+  ices_log_debug ("Calling external file with '--ices_action shutdown' ...");
+  snprintf( command_line, 1023, "%s %s --ices_action shutdown", ices_config.pm.playlist_file, ices_config.pm.external_data );
+  external_pipe = popen( command_line, "r" );
+  if( !external_pipe ) {
+    ices_log_error ( "Unable to execute: %s", command_line );
+    return;
+  }
+  pclose( external_pipe );
+}
+	
+/* Private function definitions */
+
+/* Verify that the user specified playlist actually exists */
+static int
+playlist_external_open_playlist (playlist_module_t* pm)
+{
+  if (!pm->playlist_file || !pm->playlist_file[0]) {
+    ices_log_error ("External playlist source filename is not set!");
+    return 0;
+  }
+
+  fp = ices_util_fopen_for_reading (pm->playlist_file);
+
+  if (fp) {
+    ices_util_fclose (fp);
+
+    return 1;
+  } else {
+    ices_log_error ("Could not open external playlist source: %s", pm->playlist_file);
+    return 0;
+  }
+}
diff -Naur ices-0.4.original/src/playlist/pm_builtin.h ices-0.4/src/playlist/pm_builtin.h
--- ices-0.4.original/src/playlist/pm_builtin.h	2004-03-21 21:13:12.000000000 -0600
+++ ices-0.4/src/playlist/pm_builtin.h	2012-01-15 13:32:05.252795007 -0600
@@ -20,3 +20,4 @@
 
 /* Public function declarations */
 int ices_playlist_builtin_initialize (playlist_module_t* pm);
+int ices_playlist_external_initialize (playlist_module_t* pm);
diff -Naur ices-0.4.original/src/setup.c ices-0.4/src/setup.c
--- ices-0.4.original/src/setup.c	2004-07-31 04:13:35.000000000 -0500
+++ ices-0.4/src/setup.c	2012-01-15 15:03:07.182780067 -0600
@@ -19,6 +19,7 @@
  *
  */
 
+#include <time.h>
 #include "definitions.h"
 #include "metadata.h"
 
@@ -166,6 +167,12 @@
 static void
 ices_setup_parse_defaults (ices_config_t *ices_config)
 {
+  time_t current_time;
+  char default_external_data[50];
+
+  time( &current_time );
+  snprintf( default_external_data, 50, "--ices_id %u", current_time );
+
   ices_config->configfile = ices_util_strdup (ICES_DEFAULT_CONFIGFILE);
   ices_config->daemon = ICES_DEFAULT_DAEMON;
   ices_config->base_directory = ices_util_strdup (ICES_DEFAULT_BASE_DIRECTORY);
@@ -176,6 +183,7 @@
     ices_util_strdup (ICES_DEFAULT_PLAYLIST_FILE);
   ices_config->pm.module = ices_util_strdup (ICES_DEFAULT_MODULE);
   ices_config->pm.randomize = ICES_DEFAULT_RANDOMIZE_PLAYLIST;
+  ices_config->pm.external_data = ices_util_strdup (default_external_data);
   ices_config->pm.playlist_type = ICES_DEFAULT_PLAYLIST_TYPE;
 
   ices_config->streams = (ices_stream_t*) malloc (sizeof (ices_stream_t));
(1) Download the attachment or paste the above code into a file and save it (e.g. "ices_external.patch").
(2) Extract the ices-0.4 tar file and cd into the created source tree:
Code:
tar xvzf ices-0.4.tar.gz
cd ices-0.4
(3) Apply the patch:
Code:
patch -p1 < ../ices_external.patch
(4) Compile/install like normal:
Code:
./configure && make && make install
As mentioned in my earlier reply, the ices config file used should:
(5) Use the <File> element to provide the full path to your executable file
(6) Change the <Type> element to a value of "external"
(7) Add an <ExternalData> element with a value of whatever your executable wants/need to distinguish the stream. If you do not include an <ExternalData> element, ices will default to "--ices_id <seconds_since_epoch>"

Also, as stated earlier, there will be three types of calls: initialization, get-next, and shutdown.

Your executable does not need to respond to the initialization ("--ices_action init") or shutdown ("--ices_action shutdown") calls. In fact, any response will be ignored. So, your executable should not supply a filename for the "--ices_action init" argument or it will be ignored. The initialization and shutdown actions are provided as an aid to the executable for preparation/cleanup if necessary.

On get-next calls ("--ices_action getnext"), the executable should supply the full path to a song for streaming on one line. The ices program will read the first line only. Subsequent lines will be ignored.

I hope it's useful.

Note to moderators: I included the text of the patch in the reply itself on the off chance this thread goes to "archive" status some day and the attachment is no longer available. If including it both ways is a no-no, you have my apologies.
Attached Files
File Type: txt ices_external.patch.txt (7.5 KB, 11 views)

Last edited by Dark_Helmet; 01-15-2012 at 08:34 PM.
 
1 members found this post helpful.
Old 01-17-2012, 10:29 PM   #24
lucmove
Senior Member
 
Registered: Aug 2005
Location: Brazil
Distribution: Debian
Posts: 1,432

Original Poster
Rep: Reputation: 110Reputation: 110
Hello. I'm back. Sorry for taking so long to reply. I have been super busy. But tonight I have the free time for that.

Wow, you have been busy. You wrote a patch. I am going to try it now, but first I tried to do without it. Yes, because I thought none of this would be necessary. Can anyone blame me? Look at this:

Quote:
... 'Script' playlist input module

<module>playlist</module>
<param name='type'>script</param>
Select 'script' playlist module.

<param name='program'></param>
Name of a program or script to call. All this script should do is output a single line containing the filename to play, however the script itself can be arbitrarily complex. With a little ingenuity you could implement play frequencies, music genre depending on time of day and regularly placed trailers.

If you send ices a HUP signal, it will move to the next track in a playlist.
Doesn't it absolutely make it all sound like no patching is necessary, because all the functionality is already built in?

But alas, I can't make it work so I am finally going to try your patch. I will be back in a few minutes...
 
Old 01-17-2012, 10:38 PM   #25
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
Yeah. I saw that documentation and immediately thought, "it's already been done." Then I looked a little closer at the source code when things didn't work. I'll just say that documentation is "out of date"--which is saying something because the tarball of ices-0.4 shows the last modification of contained files as being around 2004.

Anyway, it seems all of that <param name='blah'> was either ripped out or never implemented for 0.4. All that the stock 0.4 version can do is hook into Python/Perl.

That's why patches were invented I guess...
 
1 members found this post helpful.
Old 01-17-2012, 10:49 PM   #26
lucmove
Senior Member
 
Registered: Aug 2005
Location: Brazil
Distribution: Debian
Posts: 1,432

Original Poster
Rep: Reputation: 110Reputation: 110
Hum, the patch was applied and ices built without any errors (I think). But I can't make it work. I am reading your instructions again and again and the whole thing is a little bit confusing. First off, there are configuration "sections", to wit:

<Playlist></Playlist>
<Execution></Execution>
<Stream></Stream>

You told me write something like this:

<Type>external</Type>
<ExternalData>--test</ExternalData>
<File>/home/luc/ices/stream.sh</File>

Where exactly do those lines go? I put them inside the <Playlist> tags, then outside, in both cases got many errors, so I decided to come here and get some more help...
 
Old 01-17-2012, 10:57 PM   #27
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
No problem, I'll post a sample config. Those elements in my earlier post should be located in the <Playlist> group.

The following is only the <Playlist> portion of the config. I can post the whole thing if necessary.
Code:
  <Playlist>
    <!-- This is the filename used as a playlist when using the builtin 
         playlist handler. -->
    <File>/home/username/temp/playlist_script.bash</File>
    <!-- Set this to 0 if you don't want to randomize your playlist, and to
         1 if you do. -->
    <Randomize>1</Randomize>
    <!-- One of builtin, perl, or python. -->
    <Type>external</Type>
    <ExternalData>--id testing</ExternalData>
    <!-- Module name to pass to the playlist handler if using  perl or python.
         If you use the builtin playlist handler then this is ignored -->
    <Module>ices</Module>
    <!-- Set this to the number of seconds to crossfade between tracks.
         Leave out or set to zero to disable crossfading (the default).
    <Crossfade>5</Crossfade>
    -->
  </Playlist>
I'm not sure if the elements are case sensitive or not. I'd have to go back and check, but try them in mixed case on the off chance that you may have typed the element names in all lowercase.

If that still doesn't work, post the errors and I'll look into it more closely.
 
1 members found this post helpful.
Old 01-18-2012, 12:59 AM   #28
lucmove
Senior Member
 
Registered: Aug 2005
Location: Brazil
Distribution: Debian
Posts: 1,432

Original Poster
Rep: Reputation: 110Reputation: 110
OK. Lots of progress here. Just one damn glitch I can't resolve. Not sure you will be able to help.

Here is the script I'm using. Even if you are not familiar with Tcl, you should be able to read it:

Code:
#!/usr/bin/env tclsh

# SET FILES - OPTIONS - CONFIG
set queuefile "/home/luc/ices/queue.txt"
set historyfile "/home/luc/ices/history.txt"

# Note about Tcl: 
# [open $file r] = open for reading
# [open $file w] = open for writing
# [open $file a] = open for appending

# READ QUEUE FILE AND MAKE QUEUE LIST
set _fp [open $queuefile r]
set queuelist [string trim [read $_fp]]
set queuelist [split $queuelist "\n"]
close $_fp

# PICK FIRST SONG IN THE LIST AND ADD IT TO HISTORY
set playnow [lindex $queuelist 0]
set _fp [open $historyfile a]
puts $_fp $playnow
close $_fp

# BUILD NEW LIST WITH FIRST SONG REMOVED
# REWRITE/UPDATE QUEUE FILE
set queuelist [lrange $queuelist 1 end]
set _fp [open $queuefile w]
foreach i $queuelist 	{
	puts $_fp $i
}
close $_fp

puts $playnow

exit
And here is a queue.txt file I made for testing:

Quote:
/media/music/TV themes/Get Smart.mp3
/media/music/P/Pixies/Surfer Rosa/01 - Bone Machine.mp3
/media/music/P/Pixies/Surfer Rosa/02 - Break My Body.mp3
/media/music/P/Pixies/Surfer Rosa/03 - Something Against You.mp3

So first I test it on the command line:
Code:
$ ./enqueue.tcl
Every time I run it, it prints the path to one song in the list, in the expected order. The queue.txt file ends up empty, as expected. The history file effectively becomes a list of songs that have already been played. So it works, right? Right?

Well, almost. I always get this output:

Quote:
luc[1205-1]/progs/ices/ices-0.4/src> ./ices -c /home/luc/ices/config.txt
Logfile opened
error writing "stdout": broken pipe
while executing
"puts $playnow"
(file "/home/luc/ices/enqueue.tcl" line 33)
Playing /media/music/P/Pixies/Surfer Rosa/01 - Bone Machine.mp3
Mounted on http://localhost:9000/ices
And thus the first song always gets skipped. If the queue file has only one song, the whole thing fails.

There is nothing wrong with that first, "Get Smart" MP3 file. It will play fine if moved to the end of the queue, or 2nd place etc. I have also tested with other files. It's always the first one that fails.

Apart from that glitch, the little machine works fine. It will play all the songs (except the first one) till the end of the list. I just have to find out why it always craps out on the first song.

Any ideas?
 
Old 01-18-2012, 01:20 AM   #29
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
Quote:
Originally Posted by lucmove
And thus the first song always gets skipped. If the queue file has only one song, the whole thing fails
Quote:
Originally Posted by Dark_Helmet
Your executable does not need to respond to the initialization ("--ices_action init") or shutdown ("--ices_action shutdown") calls. In fact, any response will be ignored. So, your executable should not supply a filename for the "--ices_action init" argument or it will be ignored. The initialization and shutdown actions are provided as an aid to the executable for preparation/cleanup if necessary.


Ok, when ices runs, it first calls your script with an "--ices_action init" command line, subsequent calls use "--ices_action getnext", and a final call (when ices is killed) with "--ices_action shutdown".

The reason for this is in case the external executable needs to do any preparation. For instance, submit a SQL query to a database to get a list of songs, open a network connection to some other machine, etc. The ices program does not expect a response when it issues the "--ices_action init" nor the "--ices_action shutdown".

All you need to do is modify your TCL script to check if the "--ices_action init" arguments are present. If so, then exit without doing anything--likewise for the shutdown.

If it makes more sense to reverse it, then have the TCL script look for "--ices_action getnext" on the command line, and only then print the next song.

EDIT2:
A quick Google search told me that TCL accesses command line options with names similar to C. The number of arguments is stored in $argc and the individual command line arguments are stored in an array named $argv (and accessible with something like "[lindex $argv 0]" etc.)

EDIT:
To be honest, I don't know if TCL has a mechanism for examine the command line arguments, but I would be surprised if it doesn't. If TCL does not have such a mechanism, you can wrap your TCL script with something like this:
Code:
#!/bin/bash
while [ $# -gt 1 ] ; do
  if [ \( "${1}" = "--ices_action" \) -a \( "${2}" = "getnext" \) ] ; then
    /path/to/tcl/script.tcl
  fi
  shift
done
Then have ices call this wrapper script. The wrapper script will only invoke the TCL script when "--ices_action getnext" is present on the command line. Keep in mind though, this simple wrapper discards any extra information you would pass with the ExternalData.

Last edited by Dark_Helmet; 01-18-2012 at 01:36 AM.
 
Old 01-18-2012, 01:47 AM   #30
lucmove
Senior Member
 
Registered: Aug 2005
Location: Brazil
Distribution: Debian
Posts: 1,432

Original Poster
Rep: Reputation: 110Reputation: 110
OK. I just added this line to the very top of the script:

Code:
if $argv != {--ices_action getnext}  	{exit}
Result:

Quote:
luc[1258-1]/p/i/i/src> ./ices -c /home/luc/ices/config.txt
Logfile opened
Playlist file name is empty, shutting down.
Ices Exiting...
So I replaced that line with these two:

Code:
if 	{ $argv == "--ices_action init" }  	{exit}
if 	{ $argv == "--ices_action shutdown" }  	{exit}
...and now the first song is skipped again, with that same "broken pipe" error...

:-(
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
VLC and /dev/dsp: Stream Audio Over Internal Home Network GraysonPeddie Linux - Software 0 07-10-2010 05:08 AM
Stream movies and music from home server to other computers on the network. bowbalitic Linux - Software 3 03-27-2010 03:37 PM
How to stream the sound / music on another linux box on network ? frenchn00b Linux - General 4 11-09-2007 01:09 AM
Stream music and video accross a network jem522 Linux - Software 4 08-29-2006 03:29 AM
App to stream music? linux-addict Linux - Software 2 09-28-2003 09:10 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:44 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration