コード例 #1
0
ファイル: broadcast.c プロジェクト: ruthmagnus/audacity
int
broadcast_var_set (SF_PRIVATE *psf, const SF_BROADCAST_INFO * info, size_t datasize)
{	char added_history [256] ;
	int added_history_len, len ;

	if (info == NULL)
		return SF_FALSE ;

	if (bc_min_size (info) > datasize)
	{	psf->error = SFE_BAD_BROADCAST_INFO_SIZE ;
		return SF_FALSE ;
		} ;

	added_history_len = gen_coding_history (added_history, sizeof (added_history), &(psf->sf)) ;

	if (psf->broadcast_var != NULL)
	{	size_t coding_hist_offset = offsetof (SF_BROADCAST_INFO, coding_history) ;

		if (psf->broadcast_var->binfo.coding_history_size + added_history_len < datasize - coding_hist_offset)
		{	free (psf->broadcast_var) ;
			psf->broadcast_var = NULL ;
			} ;
		} ;

	if (psf->broadcast_var == NULL)
	{	int size = datasize + added_history_len + 512 ;

		psf->broadcast_var = calloc (1, size) ;
		psf->broadcast_var->size = size ;
		} ;

	memcpy (&(psf->broadcast_var->binfo), info, offsetof (SF_BROADCAST_INFO, coding_history)) ;

	strncpy_crlf (psf->broadcast_var->binfo.coding_history, info->coding_history, bc_var_coding_hist_size (psf->broadcast_var), info->coding_history_size) ;
	len = strlen (psf->broadcast_var->binfo.coding_history) ;

	if (len > 0 && psf->broadcast_var->binfo.coding_history [len] != '\n')
		strncat (psf->broadcast_var->binfo.coding_history, "\r\n", 2) ;

	if (psf->mode == SFM_WRITE)
		strncat (psf->broadcast_var->binfo.coding_history, added_history, strlen (added_history)) ;

	psf->broadcast_var->binfo.coding_history_size = strlen (psf->broadcast_var->binfo.coding_history) ;

	/* Fore coding_history_size to be even. */
	psf->broadcast_var->binfo.coding_history_size += (psf->broadcast_var->binfo.coding_history_size & 1) ? 1 : 0 ;

	/* Currently writing this version. */
	psf->broadcast_var->binfo.version = 1 ;

	return SF_TRUE ;
} /* broadcast_var_set */
コード例 #2
0
ファイル: broadcast.c プロジェクト: Cnotinfor/TopQX_Sound
int
broadcast_var_get (SF_PRIVATE *psf, SF_BROADCAST_INFO * data, size_t datasize)
{	size_t size ;

	if (psf->broadcast_16k == NULL)
		return SF_FALSE ;

	size = SF_MIN (datasize, bc_min_size ((const SF_BROADCAST_INFO *) psf->broadcast_16k)) ;

	memcpy (data, psf->broadcast_16k, size) ;

	return SF_TRUE ;
} /* broadcast_var_get */
コード例 #3
0
ファイル: broadcast.c プロジェクト: ruthmagnus/audacity
int
broadcast_var_get (SF_PRIVATE *psf, SF_BROADCAST_INFO * data, size_t datasize)
{	size_t size ;

	if (psf->broadcast_var == NULL)
		return SF_FALSE ;

	size = SF_MIN (datasize, bc_min_size (&(psf->broadcast_var->binfo))) ;

	memcpy (data, &(psf->broadcast_var->binfo), size) ;

	return SF_TRUE ;
} /* broadcast_var_set */
コード例 #4
0
ファイル: broadcast.c プロジェクト: Cnotinfor/TopQX_Sound
int
broadcast_var_set (SF_PRIVATE *psf, const SF_BROADCAST_INFO * info, size_t datasize)
{	size_t len ;

	if (info == NULL)
		return SF_FALSE ;

	if (bc_min_size (info) > datasize)
	{	psf->error = SFE_BAD_BROADCAST_INFO_SIZE ;
		return SF_FALSE ;
		} ;

	if (datasize >= sizeof (SF_BROADCAST_INFO_16K))
	{	psf->error = SFE_BAD_BROADCAST_INFO_TOO_BIG ;
		return SF_FALSE ;
		} ;

	if (psf->broadcast_16k == NULL)
	{	if ((psf->broadcast_16k = broadcast_var_alloc ()) == NULL)
		{	psf->error = SFE_MALLOC_FAILED	 ;
			return SF_FALSE ;
			} ;
		} ;

	memcpy (psf->broadcast_16k, info, offsetof (SF_BROADCAST_INFO, coding_history)) ;

	psf_strncpy_crlf (psf->broadcast_16k->coding_history, info->coding_history, sizeof (psf->broadcast_16k->coding_history), datasize - offsetof (SF_BROADCAST_INFO, coding_history)) ;
	len = strlen (psf->broadcast_16k->coding_history) ;

	if (len > 0 && psf->broadcast_16k->coding_history [len - 1] != '\n')
		psf_safe_strncat (psf->broadcast_16k->coding_history, "\r\n", sizeof (psf->broadcast_16k->coding_history)) ;

	if (psf->file.mode == SFM_WRITE)
	{	char added_history [256] ;
		size_t added_history_len ;

		added_history_len = gen_coding_history (added_history, sizeof (added_history), &(psf->sf)) ;
		psf_safe_strncat (psf->broadcast_16k->coding_history, added_history, sizeof (psf->broadcast_16k->coding_history)) ;
		} ;

	/* Force coding_history_size to be even. */
	len = strlen (psf->broadcast_16k->coding_history) ;
	len += (len & 1) ? 1 : 2 ;
	psf->broadcast_16k->coding_history_size = len ;

	/* Currently writing this version. */
	psf->broadcast_16k->version = 1 ;

	return SF_TRUE ;
} /* broadcast_var_set */