* \param row Pointer to a row in the audio file table.
* \param path Result pointer.
*
- * \return Positive on success, negative on errors.
+ * The result is a pointer to mmapped data. The caller must not attempt
+ * to free it.
+ *
+ * \return Standard.
*/
int get_audio_file_path_of_row(const struct osl_row *row, char **path)
{
/* returns shmid on success */
static int save_afd(struct audio_file_data *afd)
{
- size_t path_size = strlen(afd->path) + 1;
- size_t size = sizeof(*afd) + path_size
+ size_t size = sizeof(*afd)
+ 4 * (afd->afhi.chunks_total + 1);
PARA_NOTICE_LOG("size: %zu\n", size);
*(struct audio_file_data *)shm_afd = *afd;
buf = shm_afd;
buf += sizeof(*afd);
- strcpy(buf, afd->path);
- buf += path_size;
save_chunk_table(&afd->afhi, buf);
shm_detach(shm_afd);
return shmid;
*afd = *(struct audio_file_data *)shm_afd;
buf = shm_afd;
buf += sizeof(*afd);
- afd->path = para_strdup(buf);
- buf += strlen(buf) + 1;
afd->afhi.chunk_table = para_malloc((afd->afhi.chunks_total + 1) * 4);
load_chunk_table(&afd->afhi, buf);
shm_detach(shm_afd);
int ret = get_hash_of_row(aft_row, &aft_hash);
struct afsi_change_event_data aced;
struct osl_object map, chunk_table_obj;
- char *tmp;
+ char *tmp, *path;
if (ret < 0)
return ret;
- ret = get_audio_file_path_of_row(aft_row, &afd->path);
+ ret = get_audio_file_path_of_row(aft_row, &path);
if (ret < 0)
return ret;
+ strncpy(afd->path, path, sizeof(afd->path) - 1);
+ afd->path[sizeof(afd->path) - 1] = '\0';
ret = get_afsi_object_of_row(aft_row, &afsi_obj);
if (ret < 0)
return ret;
AFTCOL_CHUNKS, &chunk_table_obj);
if (ret < 0)
return ret;
- ret = mmap_full_file(afd->path, O_RDONLY, &map.data,
+ ret = mmap_full_file(path, O_RDONLY, &map.data,
&map.size, &afd->fd);
if (ret < 0)
goto err;
tmp[sizeof(afd->attributes_string) - 1] = '\0';
strcpy(afd->attributes_string, tmp); /* OK */
free(tmp);
+
aced.aft_row = aft_row;
aced.old_afsi = &afd->afsi;
afs_event(AFSI_CHANGE, NULL, &aced);
/* report real status */
status = vss_status_tohuman(nmmd->vss_status_flags);
flags = vss_get_status_flags(nmmd->vss_status_flags);
- basename = para_basename(nmmd->filename);
- dirname = para_dirname(nmmd->filename);
+ basename = para_basename(nmmd->afd.path);
+ dirname = para_dirname(nmmd->afd.path);
gettimeofday(&now, NULL);
ret = make_message(
"%s:%zu\n" "%s:%s\n" "%s:%lu\n" "%s:%u\n"
status_item_list[SI_AUDIO_INFO2], status_item_list[SI_AUDIO_INFO3]);
strcpy(mmd->afd.afhi.info_string, tmp);
free(tmp);
- mmd->filename[0] = '\0';
+ mmd->afd.path[0] = '\0';
mmd->size = 0;
mmd->events++;
}
map = para_mmap(mmd->size, PROT_READ, MAP_PRIVATE,
passed_fd, 0);
close(passed_fd);
- strcpy(mmd->filename, mmd->afd.path); /* FIXME: check length */
mmd->afd.afhi.header_len = 0; /* default: no header */
mmd->chunks_sent = 0;
mmd->current_chunk = 0;