mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-27 17:07:40 +01:00
fix up generation of BWF field contents to avoid truncation and use correct date
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@3645 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
32b40f065b
commit
b00aa11d61
2 changed files with 43 additions and 34 deletions
|
|
@ -20,6 +20,7 @@
|
|||
#include <cstring>
|
||||
#include <cerrno>
|
||||
#include <climits>
|
||||
#include <cstdarg>
|
||||
|
||||
#include <pwd.h>
|
||||
#include <sys/utsname.h>
|
||||
|
|
@ -31,6 +32,7 @@
|
|||
#include <ardour/sndfilesource.h>
|
||||
#include <ardour/sndfile_helpers.h>
|
||||
#include <ardour/utils.h>
|
||||
#include <ardour/version.h>
|
||||
|
||||
#include "i18n.h"
|
||||
|
||||
|
|
@ -46,6 +48,22 @@ const AudioFileSource::Flag SndFileSource::default_writable_flags = AudioFileSou
|
|||
AudioFileSource::Removable|
|
||||
AudioFileSource::RemovableIfEmpty|
|
||||
AudioFileSource::CanRename);
|
||||
|
||||
static void
|
||||
snprintf_bounded_null_filled (char* target, size_t target_size, char* fmt, ...)
|
||||
{
|
||||
char buf[target_size+1];
|
||||
va_list ap;
|
||||
|
||||
va_start (ap, fmt);
|
||||
vsnprintf (buf, target_size+1, fmt, ap);
|
||||
va_end (ap);
|
||||
|
||||
memset (target, 0, target_size);
|
||||
memcpy (target, buf, target_size);
|
||||
|
||||
}
|
||||
|
||||
SndFileSource::SndFileSource (Session& s, const XMLNode& node)
|
||||
: AudioFileSource (s, node)
|
||||
{
|
||||
|
|
@ -142,21 +160,12 @@ SndFileSource::SndFileSource (Session& s, ustring path, SampleFormat sfmt, Heade
|
|||
_broadcast_info = new SF_BROADCAST_INFO;
|
||||
memset (_broadcast_info, 0, sizeof (*_broadcast_info));
|
||||
|
||||
snprintf (_broadcast_info->description, sizeof (_broadcast_info->description), "BWF %s", _name.c_str());
|
||||
|
||||
struct utsname utsinfo;
|
||||
|
||||
if (uname (&utsinfo)) {
|
||||
error << string_compose(_("FileSource: cannot get host information for BWF header (%1)"), strerror(errno)) << endmsg;
|
||||
return;
|
||||
}
|
||||
|
||||
snprintf (_broadcast_info->originator, sizeof (_broadcast_info->originator), "ardour:%s:%s:%s:%s:%s)",
|
||||
Glib::get_real_name().c_str(),
|
||||
utsinfo.nodename,
|
||||
utsinfo.sysname,
|
||||
utsinfo.release,
|
||||
utsinfo.version);
|
||||
snprintf_bounded_null_filled (_broadcast_info->description, sizeof (_broadcast_info->description), "BWF %s", _name.c_str());
|
||||
snprintf_bounded_null_filled (_broadcast_info->originator, sizeof (_broadcast_info->originator), "ardour %d.%d.%d %s",
|
||||
libardour2_major_version,
|
||||
libardour2_minor_version,
|
||||
libardour2_micro_version,
|
||||
Glib::get_real_name().c_str());
|
||||
|
||||
_broadcast_info->version = 1;
|
||||
_broadcast_info->time_reference_low = 0;
|
||||
|
|
@ -164,7 +173,7 @@ SndFileSource::SndFileSource (Session& s, ustring path, SampleFormat sfmt, Heade
|
|||
|
||||
/* XXX do something about this field */
|
||||
|
||||
snprintf (_broadcast_info->umid, sizeof (_broadcast_info->umid), "%s", "fnord");
|
||||
snprintf_bounded_null_filled (_broadcast_info->umid, sizeof (_broadcast_info->umid), "%s", "fnord");
|
||||
|
||||
/* coding history is added by libsndfile */
|
||||
|
||||
|
|
@ -536,25 +545,25 @@ SndFileSource::setup_broadcast_info (nframes_t when, struct tm& now, time_t tnow
|
|||
|
||||
int random_code = random() % 999999999;
|
||||
|
||||
snprintf (_broadcast_info->originator_reference, sizeof (_broadcast_info->originator_reference), "%2s%3s%12s%02d%02d%02d%9d",
|
||||
Config->get_bwf_country_code().c_str(),
|
||||
Config->get_bwf_organization_code().c_str(),
|
||||
bwf_serial_number,
|
||||
now.tm_hour,
|
||||
now.tm_min,
|
||||
now.tm_sec,
|
||||
random_code);
|
||||
snprintf_bounded_null_filled (_broadcast_info->originator_reference, sizeof (_broadcast_info->originator_reference), "%2s%3s%12s%02d%02d%02d%9d",
|
||||
Config->get_bwf_country_code().c_str(),
|
||||
Config->get_bwf_organization_code().c_str(),
|
||||
bwf_serial_number,
|
||||
now.tm_hour,
|
||||
now.tm_min,
|
||||
now.tm_sec,
|
||||
random_code);
|
||||
|
||||
snprintf (_broadcast_info->origination_date, sizeof (_broadcast_info->origination_date), "%4d-%02d-%02d",
|
||||
1900 + now.tm_year,
|
||||
now.tm_mon,
|
||||
now.tm_mday);
|
||||
snprintf_bounded_null_filled (_broadcast_info->origination_date, sizeof (_broadcast_info->origination_date), "%4d-%02d-%02d",
|
||||
1900 + now.tm_year,
|
||||
now.tm_mon + 1, // shift range from 0..11 to 1..12
|
||||
now.tm_mday);
|
||||
|
||||
snprintf_bounded_null_filled (_broadcast_info->origination_time, sizeof (_broadcast_info->origination_time), "%02d:%02d:%02d",
|
||||
now.tm_hour,
|
||||
now.tm_min,
|
||||
now.tm_sec);
|
||||
|
||||
snprintf (_broadcast_info->origination_time, sizeof (_broadcast_info->origination_time), "%02d:%02d:%02d",
|
||||
now.tm_hour,
|
||||
now.tm_min,
|
||||
now.tm_sec);
|
||||
|
||||
/* now update header position taking header offset into account */
|
||||
|
||||
set_header_timeline_position ();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __ardour_svn_revision_h__
|
||||
#define __ardour_svn_revision_h__
|
||||
static const char* ardour_svn_revision = "3530";
|
||||
static const char* ardour_svn_revision = "3581";
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue