Example #1
0
	void memory_registry::register_memory(const std::string& src_path, const std::string& dst_path, const checksum& builder_checksum) {
		register_memory(memory(
			src_path,
			make_file_state(src_path),
			make_file_state(dst_path),
			builder_checksum));
	}
Example #2
0
void set_up_snd_io(chan_info *cp, int i, int fd, const char *filename, file_info *hdr, bool post_close)
{
  snd_io *io;
  snd_file_open_descriptors(fd,
			    filename,
			    hdr->format,
			    hdr->data_location,
			    hdr->chans,
			    hdr->type);
  io = make_file_state(fd, hdr, i, 0,
		       (post_close) ? MAX_BUFFER_SIZE : MIX_FILE_BUFFER_SIZE);
  cp->sounds[0] = make_snd_data_file(filename, io,
				     copy_header(hdr->name, hdr),
				     DONT_DELETE_ME, cp->edit_ctr, i);
  if (post_close) 
    {
      snd_data *sd;
      sd = cp->sounds[0]; 
      sd->open = FD_CLOSED; 
      io->fd = -1;
      if (mus_file_close(fd) != 0)
	snd_error("can't close file %s: %s", filename, snd_io_strerror());
    }
  /* this is not as crazy as it looks -- we've read in the first 64K (or whatever) samples,
   * and may need this file channel for other opens, so this file can be closed until reposition_file_state_buffers
   */
}
Example #3
0
snd_data *copy_snd_data(snd_data *sd, mus_long_t beg, int bufsize)
{
  snd_data *sf;
  snd_io *io;
  int fd;
  file_info *hdr;
  hdr = sd->hdr;
  fd = snd_open_read(sd->filename);
  if (fd == -1) 
    return(NULL);
  snd_file_open_descriptors(fd,
			    sd->filename,
			    hdr->format,
			    hdr->data_location,
			    hdr->chans,
			    hdr->type);
  during_open(fd, sd->filename, SND_COPY_READER);
  io = make_file_state(fd, hdr, sd->chan, beg, bufsize);
  sf = (snd_data *)calloc(1, sizeof(snd_data));
  sf->type = sd->type;
  sf->buffered_data = io->arrays[sd->chan];
  sf->io = io;
  sf->filename = mus_strdup(sd->filename);
  sf->hdr = hdr;
  sf->temporary = DONT_DELETE_ME;
  sf->edit_ctr = sd->edit_ctr;
  sf->open = FD_OPEN;
  sf->inuse = false;
  sf->copy = true;
  return(sf);
}
Example #4
0
	memory_compare_result memory_registry::compare_to_memory(const std::string& src_path_key, const std::vector<std::string>& src_paths, const std::vector<std::string>& dst_paths, const checksum& builder_checksum) const {
		auto iter = _memory_map.find(src_path_key);
		if (iter == _memory_map.end()) {
			return memory_compare_result::NO_MEMORY_FOUND;
		}

		if (iter->second._builder_checksum != builder_checksum) {
			return memory_compare_result::BUILDER_CHECKSUM_CHANGED;
		}

		if (iter->second._src_file_states.size() != src_paths.size()) {
			return memory_compare_result::SRC_FILE_COUNT_CHANGED;
		}

		for (unsigned int src_i = 0; src_i < src_paths.size(); ++src_i) {
			if (iter->second._src_file_states.at(src_i) != make_file_state(src_paths.at(src_i))) {
				return memory_compare_result::SRC_FILE_CHANGED;
			}
		}

		if (iter->second._dst_file_states.size() != dst_paths.size()) {
			return memory_compare_result::DST_FILE_COUNT_CHANGED;
		}

		for (unsigned int dst_i = 0; dst_i < dst_paths.size(); ++dst_i) {
			if (!_file_system.does_file_exist(dst_paths.at(dst_i))) {
				return memory_compare_result::DST_FILE_NOT_FOUND;
			}

			if (iter->second._dst_file_states.at(dst_i) != make_file_state(dst_paths.at(dst_i))) {
				return memory_compare_result::DST_FILE_CHANGED;
			}
		}

		return memory_compare_result::NO_DIFFERENCES;
	}