Exemple #1
0
int hwmixer_dstr_open(struct hwmixer_stream * stream, char * drv, char * dev, int fh, char * basename, struct roar_keyval * subnames, size_t subnamelen) {
 struct roar_vio_calls * vio = roar_mm_malloc(sizeof(struct roar_vio_calls));
 struct roar_vio_defaults def;
 struct roar_stream_server * ss;

 if ( vio == NULL )
  return -1;

 if ( fh == -1 ) {
  if ( dev == NULL ) {
   roar_mm_free(vio);
   return -1;
  }

  if ( roar_vio_dstr_init_defaults(&def, ROAR_VIO_DEF_TYPE_NONE, O_WRONLY|O_CREAT|O_TRUNC, 0644) == -1 ) {
   roar_mm_free(vio);
   return -1;
  }

  if ( roar_vio_open_dstr(vio, dev, &def, 1) == -1 ) {
   roar_mm_free(vio);
   return -1;
  }
 } else {
  if ( roar_vio_open_fh(vio, fh) == -1 ) {
   roar_mm_free(vio);
   return -1;
  }
 }

 stream->baseud = vio;

 roar_vio_printf(vio, "No data yet.\n");
 roar_vio_lseek(vio, 0, SEEK_SET);
 roar_vio_sync(vio);

 if (streams_get(stream->basestream, &ss) != -1) {
  ROAR_STREAM(ss)->info.channels = 2;
 } else {
  ROAR_WARN("hwmixer_dstr_open(*): can not get object for basestream %i", stream->basestream);
 }

#ifdef TEST_HWMIXER_SUBSTREAMS
 stream = hwmixer_substream_new(stream);
 if ( stream == NULL ) {
  ROAR_WARN("hwmixer_dstr_open(*): can not create substream");
 } else {
  if (streams_get(stream->stream, &ss) != -1) {
   ROAR_STREAM(ss)->info.channels = 2;
  } else {
   ROAR_WARN("hwmixer_dstr_open(*): can not get object for stream %i", stream->stream);
  }
 }
#endif

 return 0;
}
int cf_wave_close(CODECFILTER_USERDATA_T   inst) {
// struct codecfilter_wave_inst * self = (struct codecfilter_wave_inst *) inst;

 if ( !inst )
  return -1;

 roar_mm_free(inst);
 return 0;
}
Exemple #3
0
int clients_delete (int id) {
 struct roar_client_server * cs;
 int i;
 int close_client_fh = 1;

 ROAR_DBG("clients_delete(id=%i) = ?", id);

 _CHECK_CID(id);

 cs = g_clients[id];

 if ( cs->waits != NULL ) {
  for (i = 0; cs->waits[i] != NULL; i++)
   roar_notify_core_unsubscribe(NULL, cs->waits[i]);

  roar_mm_free(cs->waits);
  cs->waits = NULL;
 }

 roar_notify_core_emit_snoargs(ROAR_OE_BASICS_DELETE, -1, id, ROAR_OT_CLIENT);

 counters_inc(clients, -1);

 if (ROAR_CLIENT(cs)->execed != -1) {
//  return streams_delete(g_clients[id]->execed);
  ROAR_CLIENT(cs)->execed = -1;
  close_client_fh = 0;
 }

 for (i = 0; i < ROAR_CLIENTS_MAX_STREAMS_PER_CLIENT; i++) {
  streams_delete(ROAR_CLIENT(cs)->streams[i]);
 }

 if ( ROAR_CLIENT(cs)->fh != -1 && close_client_fh )
  close(ROAR_CLIENT(cs)->fh);

 roar_nnode_free(&(ROAR_CLIENT(cs)->nnode));

 roar_mm_free(cs);
 g_clients[id] = NULL;

 ROAR_DBG("clients_delete(id=%i) = 0", id);
 return 0;
}
Exemple #4
0
int clients_new (void) {
 int i;
 int s;
 struct roar_client_server * ns;
 struct roar_client * n;

 for (i = 0; i < ROAR_CLIENTS_MAX; i++) {
  if ( g_clients[i] == NULL ) {
   ns = roar_mm_malloc(sizeof(struct roar_client_server));
   n = ROAR_CLIENT(ns);

   memset(ns, 0, sizeof(struct roar_client_server));

   if ( n != NULL ) {
    n->pid    = -1;
    n->uid    = -1;
    n->gid    = -1;
    n->fh     = -1;

    *n->name = 0;
    *n->host = 0;

    n->proto     = ROAR_PROTO_ROARAUDIO;
    n->byteorder = ROAR_BYTEORDER_NETWORK;

    n->acl   = NULL;

    n->execed = -1;
    for (s = 0; s < ROAR_CLIENTS_MAX_STREAMS_PER_CLIENT; s++)
     n->streams[s] = -1;

    if ( roar_nnode_new(&(n->nnode), ROAR_SOCKET_TYPE_UNKNOWN) == -1 ) {
     roar_mm_free(n);
     return -1;
    }

    ns->blockc   = 0;
    ns->waits    = NULL;
    ns->acclev   = ACCLEV_NONE;

    g_clients[i] = ns;

    counters_inc(clients, 1);
    roar_notify_core_emit_snoargs(ROAR_OE_BASICS_NEW, -1, i, ROAR_OT_CLIENT);
    ROAR_DBG("clients_new(void) = %i", i);
    return i;
   } else {
    ROAR_ERR("clients_new(void): Can not alloc memory for new client: %s", strerror(errno));
    ROAR_ERR("clients_new(void) = -1");
    return -1;
   }
  }
 }

 return -1;
}
Exemple #5
0
int     driver_jack_close   (struct roar_vio_calls * vio) {
    struct driver_jack * self = vio->inst;
// close and free everything in here...

    jack_client_close(self->client);

    roar_mm_free(self);

    return 0;
}
int roardsp_speex_prep_uninit (struct roardsp_filter * filter) {
 struct roardsp_speex_prep * self = filter->inst;

 if ( self->preprocess != NULL )
  speex_preprocess_state_destroy(self->preprocess);

 roar_mm_free(self);

 return 0;
}
Exemple #7
0
int hwmixer_dstr_close(struct hwmixer_stream * stream) {
 // are we a substream? if yes we do not clean up anything.
 // streams_delete() will do all our work.
 if ( stream->stream != stream->basestream )
  return 0;

 roar_vio_close(stream->baseud);
 roar_mm_free(stream->baseud);
 return 0;
}
Exemple #8
0
int roar_authfile_close(struct roar_authfile * authfile) {
 if ( authfile == NULL )
  return -1;

 roar_vio_close(&(authfile->vio));

 roar_mm_free(authfile);

 return 0;
}
Exemple #9
0
static void
roar_finish(void *data)
{
	roar_t * self = data;

	g_free(self->host);
	g_free(self->name);
	g_mutex_free(self->lock);

	roar_mm_free(data);
}
Exemple #10
0
int output_buffer_free   (void) {
 ROAR_DBG("output_buffer_init(*): freeing output buffer at %p", g_output_buffer);

 if ( g_output_buffer != NULL )
  roar_mm_free(g_output_buffer);

 g_output_buffer     = NULL;
 g_output_buffer_len = 0;

 return 0;
}
Exemple #11
0
struct roar_authfile * roar_authfile_open(int type, const char * filename, int rw, int version) {
 struct roar_vio_defaults def;
 struct roar_authfile * ret;
 size_t magiclen = 0;

 switch (type) {
  case ROAR_AUTHFILE_TYPE_ESD:
  case ROAR_AUTHFILE_TYPE_PULSE:
   break;
  default:
    return NULL;
   break;
 }

 if ( roar_vio_dstr_init_defaults(&def, ROAR_VIO_DEF_TYPE_NONE, rw ? O_RDWR|O_CREAT : O_RDONLY, 0600) == -1 )
  return NULL;

 if ( (ret = roar_mm_malloc(sizeof(struct roar_authfile))) == NULL )
  return NULL;

 memset(ret, 0, sizeof(struct roar_authfile));

 ret->refc     = 1;
 ret->lockc    = 0;
 ret->type     = type;
 ret->rw       = rw;
 ret->version  = version;
 ret->magiclen = magiclen;

 filename = roar_mm_strdup(filename);

 if ( roar_vio_open_dstr(&(ret->vio), (char*)filename, &def, 1) == -1 ) {
  roar_mm_free((void*)filename);
  roar_mm_free(ret);
  return NULL;
 }

 roar_mm_free((void*)filename);

 return ret;
}
Exemple #12
0
int     roar_vio_pipe_close   (struct roar_vio_calls * vio) {
 struct roar_vio_pipe * self;
 int                    idx;

 if ( vio == NULL )
  return -1;

 if ( (self = (struct roar_vio_pipe *)vio->inst) == NULL )
  return -1;

 self->refcount--;

 switch (self->type) {
  case ROAR_VIO_PIPE_TYPE_BUFFER:
    // this will be a bit more complex as we need to change the flags, too.
   break;
  case ROAR_VIO_PIPE_TYPE_PIPE:
   switch (ROAR_VIO_PIPE_S(self, vio)) {
    case 0:
      close(self->b.p[0]);
      close(self->b.p[3]);
      self->b.p[0] = -1;
      self->b.p[3] = -1;
     break;
    case 1:
      close(self->b.p[1]);
      close(self->b.p[2]);
      self->b.p[1] = -1;
      self->b.p[2] = -1;
     break;
   }
   break;
#ifdef ROAR_HAVE_UNIX
  case ROAR_VIO_PIPE_TYPE_SOCKET:
    close(self->b.p[idx = ROAR_VIO_PIPE_S(self, vio)]);
    self->b.p[idx] = -1;
   break;
#endif
 }

 if ( ! self->refcount ) {
  roar_mm_free(self);
 }

 vio->inst = NULL;
 return 0;
}
Exemple #13
0
int roar_authfile_key_unref(struct roar_authfile_key * key) {
 if ( key == NULL )
  return -1;

 if ( key->refc == 0 ) {
  ROAR_ERR("roar_authfile_key_unref(key=%p): Key has reference count of zero. This is bad. assuming refc=1", key);
  key->refc = 1;
 }

 key->refc--;

 if ( key->refc > 0 )
  return 0;

 roar_mm_free(key);

 return 0;
}
Exemple #14
0
// notify thingys
int clients_wait    (int client, struct roar_event * events, size_t num) {
 struct roar_client_server * cs;
 size_t i, c;

 ROAR_DBG("clients_wait(client=%i, events=%p, num=%llu) = ?", client, events, (long long unsigned int)num);

 _CHECK_CID(client);

 cs = g_clients[client];

 if ( cs->waits != NULL )
  return -1;

 cs->waits = roar_mm_malloc((num+1) * sizeof(struct roar_subscriber *));

 if ( cs->waits == NULL )
  return -1;

 if ( clients_block(client, 0) != 0 )
  return -1;

 for (i = 0; i < num; i++) {
#if defined(DEBUG) && 0
  dbg_notify_cb(NULL, &(events[i]), cs);
#endif
  cs->waits[i] = roar_notify_core_subscribe(NULL, &(events[i]), clients_ncb_wait, cs);
  if ( cs->waits[i] == NULL ) {
   for (c = 0; c < i; c++)
    roar_notify_core_unsubscribe(NULL, cs->waits[c]);
   roar_mm_free(cs->waits);
   cs->waits = NULL;
   clients_block(client, 1);
   return -1;
  }
 }

 cs->waits[num] = NULL;

 ROAR_DBG("clients_wait(client=%i, events=%p, num=%llu) = 0", client, events, (long long unsigned int)num);
 return 0;
}
Exemple #15
0
int driver_jack_open_vio  (struct roar_vio_calls * inst,
                           char * device,
                           struct roar_audio_info * info,
                           int fh,
                           struct roar_stream_server * sstream) {
    struct driver_jack * self;

// we are not FH Safe, return error if fh != -1:
    if ( fh != -1 )
        return -1;

// set up VIO:
    memset(inst, 0, sizeof(struct roar_vio_calls));

    inst->read     = driver_jack_read;
    inst->write    = driver_jack_write;
    inst->lseek    = NULL; // no seeking on this device
    inst->nonblock = driver_jack_nonblock;
    inst->sync     = driver_jack_sync;
    inst->ctl      = driver_jack_ctl;
    inst->close    = driver_jack_close;

// set up internal struct:
    if ( (self = roar_mm_malloc(sizeof(struct driver_jack))) == NULL )
        return -1;

    memset(self, 0, sizeof(struct driver_jack));

    inst->inst     = self;

    if ( (self->client = jack_client_new("roard")) == NULL ) {
        roar_mm_free(self);
        return -1;
    }

// return -1 on error or 0 on no error.
    return 0;
}
Exemple #16
0
int roar_vs_close(roar_vs_t * vss, int killit, int * error) {
    if ( killit != ROAR_VS_TRUE && killit != ROAR_VS_FALSE ) {
        _seterr(ROAR_ERROR_UNKNOWN);
        return -1;
    }

    _ckvss(-1);

    if ( vss->flags & FLAG_STREAM ) {
        if ( killit == ROAR_VS_TRUE ) {
            roar_kick(vss->con, ROAR_OT_STREAM, roar_stream_get_id(&(vss->stream)));
        }

        roar_vio_close(&(vss->vio));
    }

    if ( vss->con == &(vss->con_store) ) {
        roar_disconnect(vss->con);
    }

    roar_mm_free(vss);
    return 0;
}
Exemple #17
0
void clients_ncb_wait(struct roar_notify_core * core, struct roar_event * event, void * userdata) {
 struct roar_client_server * cs = userdata;
 struct roar_message m;
 struct roar_connection con;
 uint16_t * u16 = (uint16_t *) m.data;
 size_t tmp;
 size_t i;

 ROAR_DBG("clients_ncb_wait(core=%p, event=%p, userdata=%p) = ?", core, event, userdata);

 for (i = 0; cs->waits[i] != NULL; i++)
  roar_notify_core_unsubscribe(NULL, cs->waits[i]);

 roar_mm_free(cs->waits);
 cs->waits = NULL;

 // protocol depended handling...
 memset(&m, 0, sizeof(m));
 m.cmd = ROAR_CMD_OK;
 u16[0] = ROAR_HOST2NET16(0); // Version
 u16[1] = ROAR_HOST2NET16(0); // flags

 tmp = sizeof(m.data) - 4;

 roar_event_to_blob(event, m.data + 4, &tmp);

 m.datalen = tmp + 4;

 roar_connect_fh(&con, ROAR_CLIENT(cs)->fh);
 roar_send_message(&con, &m, NULL);
 // ...end of protocol depended handling.

// clients_block(, 1);
 // TODO: FIXME: bad hack...
 cs->blockc--;
}
Exemple #18
0
int roar_vio_open_pipe (struct roar_vio_calls * s0, struct roar_vio_calls * s1, int type, int flags) {
#ifndef ROAR_WITHOUT_VIO_PIPE
 struct roar_vio_pipe * self;
 int                    rw = flags & (O_RDONLY|O_WRONLY|O_RDWR);

 if ( s0 == NULL || s1 == NULL )
  return -1;

 if ( (self = roar_mm_malloc(sizeof(struct roar_vio_pipe))) == NULL )
  return -1;

 memset(self, 0, sizeof(struct roar_vio_pipe));

 self->refcount = 2;
 self->flags    = flags;

 if ( type == ROAR_VIO_PIPE_TYPE_AUTO ) {
#ifdef ROAR_TARGET_WIN32
  type = ROAR_VIO_PIPE_TYPE_BUFFER;
#else
  type = ROAR_VIO_PIPE_TYPE_SOCKET;
#endif
 }

 self->type     = type;

 switch (type) {
  case ROAR_VIO_PIPE_TYPE_BUFFER:
    // no buffers need to be set up here,
    // we handle the NULL pointer in the reader and writer func
    roar_mm_free(self);
    return -1;
   break;
  case ROAR_VIO_PIPE_TYPE_PIPE:
    self->b.p[0] = self->b.p[1] = self->b.p[2] = self->b.p[3] = -1;

    if ( rw == O_RDWR || rw == O_RDONLY )
     if ( pipe(self->b.p) == -1 ) {
      roar_mm_free(self);
      return -1;
     }
    if ( rw == O_RDWR || rw == O_WRONLY )
     if ( pipe((self->b.p) + 2) == -1 ) {
      close(self->b.p[0]);
      close(self->b.p[1]);
      roar_mm_free(self);
      return -1;
     }
   break;
#ifdef ROAR_HAVE_UNIX
  case ROAR_VIO_PIPE_TYPE_SOCKET:
    if ( socketpair(AF_UNIX, SOCK_STREAM, 0, self->b.p) == -1 ) {
     roar_mm_free(self);
     return -1;
    }

    if ( rw == O_RDONLY ) {
     ROAR_SHUTDOWN(self->b.p[0], SHUT_WR);
     ROAR_SHUTDOWN(self->b.p[1], SHUT_RD);
    } else if ( rw == O_WRONLY ) {
     ROAR_SHUTDOWN(self->b.p[0], SHUT_RD);
     ROAR_SHUTDOWN(self->b.p[1], SHUT_WR);
    }
   break;
#endif
  default:
    roar_mm_free(self);
    return -1;
 }

 roar_vio_pipe_init(s0, self, flags);
 roar_vio_pipe_init(s1, self, flags);

 self->s0 = s0;

 return 0;
#else
 return -1;
#endif
}
Exemple #19
0
int roardsp_lowp_uninit(struct roardsp_filter * filter) {

 roar_mm_free(filter->inst);
 return 0;
}