Esempio n. 1
0
static int start_rsd(int fd, rsound_t *rd)
{
   int flags = fcntl(fd, F_GETFD);
   if ( flags < 0 )
      return -1;

   if ( rd->conn.socket == -1 )
   {
      char *ident = "OSS emulation";
      rsd_set_param(rd, RSD_IDENTITY, ident);
      if ( rsd_start(rd) < 0 )
         return -1;
   }

   // Now we should reroute our socket to fd

   if ( dup2(rd->conn.socket, fd) < 0 )
      return -1;

   if ( flags & O_NONBLOCK )
   {
      int i = fd2index(fd);
      if ( i >= 0 )
         _rd[i].nonblock = 1;
      else
         return -1;
   }

   return 0;
}
Esempio n. 2
0
static bool rs_start(void *data)
{
   rsd_t *rsd = (rsd_t*)data;
   if (rsd_start(rsd->rd) < 0)
      return false;

   return true;
}
Esempio n. 3
0
static void *rs_init(const char *device, unsigned rate, unsigned latency)
{
   int channels, format;
   rsd_t *rsd = (rsd_t*)calloc(1, sizeof(rsd_t));
   if (!rsd)
      return NULL;

   rsound_t *rd;

   if (rsd_init(&rd) < 0)
   {
      free(rsd);
      return NULL;
   }

   rsd->cond_lock = slock_new();
   rsd->cond = scond_new();

   rsd->buffer = fifo_new(1024 * 4);

   channels = 2;
   format   = RSD_S16_NE;

   rsd_set_param(rd, RSD_CHANNELS, &channels);
   rsd_set_param(rd, RSD_SAMPLERATE, &rate);
   rsd_set_param(rd, RSD_LATENCY, &latency);

   if (device)
      rsd_set_param(rd, RSD_HOST, (void*)device);

   rsd_set_param(rd, RSD_FORMAT, &format);

   rsd_set_callback(rd, rsound_audio_cb, err_cb, 256, rsd);

   if (rsd_start(rd) < 0)
   {
      free(rsd);
      rsd_free(rd);
      return NULL;
   }

   rsd->rd = rd;
   return rsd;
}
Esempio n. 4
0
File: ao_rsound.c Progetto: agiz/mpv
static int init(struct ao *ao)
{
    struct priv *priv = ao->priv;

    if (rsd_init(&priv->rd) < 0)
        return -1;

    if (priv->host && priv->host[0])
        rsd_set_param(priv->rd, RSD_HOST, priv->host);

    if (priv->port && priv->port[0])
        rsd_set_param(priv->rd, RSD_PORT, priv->port);

    // Actual channel layout unknown.
    struct mp_chmap_sel sel = {0};
    mp_chmap_sel_add_waveext_def(&sel);
    if (!ao_chmap_sel_adjust(ao, &sel, &ao->channels)) {
        rsd_free(priv->rd);
        return -1;
    }

    rsd_set_param(priv->rd, RSD_SAMPLERATE, &ao->samplerate);
    rsd_set_param(priv->rd, RSD_CHANNELS, &ao->channels.num);

    ao->format = af_fmt_from_planar(ao->format);

    int rsd_format = set_format(ao);
    rsd_set_param(priv->rd, RSD_FORMAT, &rsd_format);

    if (rsd_start(priv->rd) < 0) {
        rsd_free(priv->rd);
        return -1;
    }

    return 0;
}
Esempio n. 5
0
int     driver_rsound_open         (struct roar_vio_calls * inst, char * device, struct roar_audio_info * info, int fh, struct roar_stream_server * sstream) {
 rsound_t * self;
 int tmp, tmp2;

 if ( fh != -1 )
  return -1;

 if ( rsd_init(&self) == -1 ) {
  ROAR_DBG("driver_rsound_open(*): rsd_init(&self) failed.");
  return -1;
 }

 if ( device != NULL ) {
  if ( rsd_set_param(self, RSD_HOST, device) == -1 ) {
   ROAR_DBG("driver_rsound_open(*): rsd_set_param(self, RSD_HOST, device) failed.");
   rsd_free(self);
   return -1;
  }
 }

 tmp = info->channels;
 if ( rsd_set_param(self, RSD_CHANNELS, &tmp) == -1 ) {
  ROAR_DBG("driver_rsound_open(*): rsd_set_param(self, RSD_CHANNELS, &tmp) failed.");
  rsd_free(self);
  return -1;
 }

 if ( tmp != info->channels ) {
  rsd_free(self);
  return -1;
 }

 tmp = info->rate;
 if ( rsd_set_param(self, RSD_SAMPLERATE, &tmp) == -1 ) {
  ROAR_DBG("driver_rsound_open(*): rsd_set_param(self, RSD_SAMPLERATE, &tmp) failed.");
  rsd_free(self);
  return -1;
 }

 if ( tmp != info->rate ) {
  rsd_free(self);
  return -1;
 }

 tmp = -1; // unknown by RSound

 switch (info->codec) {
  case ROAR_CODEC_PCM_S_LE:
    switch (info->bits) {
     case  8: tmp = RSD_S8;     break;
     case 16: tmp = RSD_S16_LE; break;
    }
   break;
  case ROAR_CODEC_PCM_S_BE:
    switch (info->bits) {
     case  8: tmp = RSD_S8;     break;
     case 16: tmp = RSD_S16_BE; break;
    }
   break;
  case ROAR_CODEC_PCM_S_PDP:
    switch (info->bits) {
     case  8: tmp = RSD_S8;     break;
    }
   break;
  case ROAR_CODEC_PCM_U_LE:
    switch (info->bits) {
     case  8: tmp = RSD_U8;     break;
     case 16: tmp = RSD_U16_LE; break;
    }
   break;
  case ROAR_CODEC_PCM_U_BE:
    switch (info->bits) {
     case  8: tmp = RSD_U8;     break;
     case 16: tmp = RSD_U16_BE; break;
    }
   break;
  case ROAR_CODEC_PCM_U_PDP:
    switch (info->bits) {
     case  8: tmp = RSD_U8;     break;
    }
   break;
 }

 if ( tmp == -1 ) {
  ROAR_DBG("driver_rsound_open(*): Codec/Bits not supported by RSound");
  rsd_free(self);
  return -1;
 }

 tmp2 = tmp;

 if ( rsd_set_param(self, RSD_FORMAT, &tmp) == -1 ) {
  ROAR_DBG("driver_rsound_open(*): rsd_set_param(self, RSD_FORMAT, &tmp={0x%x->0x%x}) failed.", tmp2, tmp);
  rsd_free(self);
  return -1;
 }

 if ( tmp != tmp2 ) {
  rsd_free(self);
  return -1;
 }

 if ( rsd_start(self) == -1 ) {
  ROAR_DBG("driver_rsound_open(*): rsd_start(self) failed.");
  rsd_free(self);
  return -1;
 }

 memset(inst, 0, sizeof(struct roar_vio_calls));

 inst->inst  = self;
 inst->close = driver_rsound_close;
 inst->write = driver_rsound_write;

 return 0;
}
Esempio n. 6
0
File: ao_rsound.c Progetto: agiz/mpv
static void reset(struct ao *ao)
{
    struct priv *priv = ao->priv;
    rsd_stop(priv->rd);
    rsd_start(priv->rd);
}