Package: xine-lib
Severity: wishlist

Hi,

please find attached a patch which adds support for remote esound
server. Until now, only `localhost' is used, since the `NULL' parameter
is specified when calling esd_* functions. With this patch, one can
specify a `audio.device.esd_server' parameter, which will be used to
determine the esound server to use.

By default, when one has selected the `esd' output with the following
line in the configuration file, localhost is used automatically, as
before, so that the default behaviour isn't changed.

audio.driver:esd


The new configuration item can be used as follows, either by specifying
`localhost' (or leaving it blank, which has the same effect), or by
specifying a remote server.

audio.device.esd_server:my_remote_server


I didn't get really how configuration item types are determined, so
instead of querying the `str_value' of the configuration item, I query
`unknown_value'. But I guess that upstream will know how to handle this
tiny imperfection.


Of course, I checked all the above-mentioned behaviours.

Cheers,

-- 
Cyril Brulebois

PS: Looks like a call to a xine_config_register_string() should do the
    job, but that would be in xine-ui, I guess. However, documenting
        this new feature could be sufficient at the moment, e.g. in a
        README.Debian file.
--- xine-lib-1.1.2+dfsg~/src/audio_out/audio_esd_out.c	2006-11-24 06:40:40.000000000 +0100
+++ xine-lib-1.1.2+dfsg/src/audio_out/audio_esd_out.c	2006-11-24 06:44:41.000000000 +0100
@@ -92,6 +92,8 @@
   int		   reblock_rem;
 #endif
 
+  char            *server_name; /* ESD server, NULL for localhost */
+
 } esd_driver_t;
 
 typedef struct {
@@ -160,7 +162,7 @@
 #endif
   this->output_sample_k_rate = this->output_sample_rate / 1000;
 
-  this->audio_fd = esd_play_stream(format, this->output_sample_rate, NULL, this->pname);
+  this->audio_fd = esd_play_stream(format, this->output_sample_rate, this->server_name, this->pname);
   if (this->audio_fd < 0) {
     char *server = getenv("ESPEAKER");
     xprintf(this->xine, XINE_VERBOSITY_LOG,
@@ -343,6 +345,7 @@
   if (this->audio_fd != -1)
     esd_close(this->audio_fd);
 
+  free(this->server_name);
   free(this->pname);
 
   free (this);
@@ -357,7 +360,7 @@
   switch(property) {
   case AO_PROP_MIXER_VOL:
     
-    if((mixer_fd = esd_open_sound(NULL)) >= 0) {
+    if((mixer_fd = esd_open_sound(this->server_name)) >= 0) {
       if((esd_i = esd_get_all_info(mixer_fd)) != NULL) {
 	for(esd_pi = esd_i->player_list; esd_pi != NULL; esd_pi = esd_pi->next) {
 	  if(!strcmp(this->pname, esd_pi->name)) {
@@ -398,7 +401,7 @@
       /* need this to get source_id */
       (void) ao_esd_get_property(&this->ao_driver, AO_PROP_MIXER_VOL);
 
-      if((mixer_fd = esd_open_sound(NULL)) >= 0) {
+      if((mixer_fd = esd_open_sound(this->server_name)) >= 0) {
 	int v = (value * 256) / 100;
 	
 	esd_set_stream_pan(mixer_fd, this->mixer.source_id, v, v);
@@ -422,7 +425,7 @@
     (void) ao_esd_get_property(&this->ao_driver, AO_PROP_MIXER_VOL);
     
     if(mute) {
-      if((mixer_fd = esd_open_sound(NULL)) >= 0) {
+      if((mixer_fd = esd_open_sound(this->server_name)) >= 0) {
 	int v = 0;
 	
 	esd_set_stream_pan(mixer_fd, this->mixer.source_id, v, v);
@@ -430,7 +433,7 @@
       }
     }
     else {
-      if((mixer_fd = esd_open_sound(NULL)) >= 0) {
+      if((mixer_fd = esd_open_sound(this->server_name)) >= 0) {
 	int v = (this->mixer.volume * 256) / 100;
 	
 	esd_set_stream_pan(mixer_fd, this->mixer.source_id, v, v);
@@ -478,6 +481,8 @@
   esd_server_info_t *esd_svinfo;
   int		     server_sample_rate;
   sigset_t           vo_mask, vo_mask_orig;
+  char              *esd_server_name;
+  cfg_entry_t       *config_entry;
 
   /*
    * open stream to ESD server
@@ -491,13 +496,21 @@
    * (Otherwise xine hangs in esd_open_sound on a machine without sound)
    */
 
+  /* We need it to test the esd server, before storing it inside this->server_name */
+
+  config_entry = config->lookup_entry(config, "audio.device.esd_server");
+  if (config_entry)
+    esd_server_name = strdup(config_entry->unknown_value); // str_value!
+  else
+    esd_server_name = NULL;
+
   sigemptyset(&vo_mask);
   sigaddset(&vo_mask, SIGALRM);
   if (sigprocmask(SIG_UNBLOCK, &vo_mask, &vo_mask_orig)) 
     xprintf(class->xine, XINE_VERBOSITY_DEBUG, "audio_esd_out: cannot unblock SIGALRM: %s\n", strerror(errno));
 
   xprintf(class->xine, XINE_VERBOSITY_LOG, _("audio_esd_out: connecting to esd server...\n"));
-  audio_fd = esd_open_sound(NULL);
+  audio_fd = esd_open_sound(esd_server_name);
   err = errno;
 
   if (sigprocmask(SIG_SETMASK, &vo_mask_orig, NULL))
@@ -526,6 +539,7 @@
 
   this                     = (esd_driver_t *) xine_xmalloc (sizeof (esd_driver_t));
   this->xine               = class->xine;
+  this->server_name        = esd_server_name;
   this->pname              = strdup("xine esd audio output plugin");
   this->output_sample_rate = 0;
   this->server_sample_rate = server_sample_rate;

Reply via email to