コード例 #1
0
ファイル: audio_hw.c プロジェクト: LeMaker/android-actions
/* must be called with hw device and output stream mutexes locked */
static int start_output_stream(struct stream_out *out)
{
    ALOGV("usb:audio_hw::out start_output_stream(card:%d device:%d)",
          out->profile->card, out->profile->device);

    return proxy_open(&out->proxy);
}
コード例 #2
0
ファイル: stormfs.c プロジェクト: JeremyOT/stormfs
static int
stormfs_open(const char *path, struct fuse_file_info *fi)
{
  FILE *fp;
  int fd;
  int result;
  struct file *f;

  DEBUG("open: %s\n", path);

  if((result = valid_path(path)) != 0)
    return result;

  if(fi->flags & O_TRUNC)
    if((result = stormfs_truncate(path, 0)) != 0)
      return result;

  f = cache_get(path);
  if(cache_file_valid(f)) {
    char *cp = cache_path(f);

    fp = fopen(cp, "a+");
    free(cp);

    if(fp == NULL)
      return -errno;
    if((fd = fileno(fp)) == -1)
      return -errno;

    fi->fh = fd;

    return 0;
  }

  // file not available in cache, download it.
  if((fd = cache_create_file(f)) == -1)
    return -1; // FIXME: need to return proper errors here.
  if((fp = fdopen(fd, "a+")) == NULL)
    return -errno;

  if((result = proxy_open(path, fp)) != 0) {
    fclose(fp);
    return result;
  }

  fi->fh = fd;

  return result;
}
コード例 #3
0
ファイル: stormfs.c プロジェクト: JeremyOT/stormfs
static int
stormfs_readlink(const char *path, char *buf, size_t size)
{
  int fd;
  FILE *fp = NULL;
  int result;
  struct stat st;
  struct file *f;

  DEBUG("readlink: %s\n", path);

  if((result = valid_path(path)) != 0)
    return result;

  if(size <= 0)
    return 0;

  --size; // save the null byte

  f = cache_get(path);
  if(cache_file_valid(f)) {
    char *cp = cache_path(f);

    fp = fopen(cp, "a+");
    free(cp);

    if(fp == NULL)
      return -errno;
    if((fd = fileno(fp)) == -1)
      return -errno;
  } else {
    // file not available in cache, download it.
    if((fd = cache_create_file(f)) == -1)
      return -EIO;
    if((fp = fdopen(fd, "a+")) == NULL)
      return -errno;

    if((result = proxy_open(path, fp)) != 0) {
      fclose(fp);
      return result;
    }
  }

  if(fstat(fd, &st) != 0) {
    close(fd);
    return -errno;
  }

  if(st.st_size < (off_t) size)
    size = st.st_size;

  if(pread(fd, buf, size, 0) == -1) {
    close(fd);
    return -errno;
  }

  buf[size] = 0;
  if(close(fd) != 0)
    return -errno;

  return 0;
}
コード例 #4
0
/* must be called with hw device and output stream mutexes locked */
static int start_input_stream(struct stream_in *in)
{
    ALOGV("ustart_input_stream(card:%d device:%d)", in->profile->card, in->profile->device);

    return proxy_open(&in->proxy);
}