13
0

Remove tmpnam usage.

git-svn-id: svn://localhost/ardour2/branches/3.0@5032 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
David Robillard 2009-05-04 02:50:58 +00:00
parent b034d9d05a
commit 4d4f6ee9e5

View File

@ -2954,41 +2954,43 @@ ARDOUR_UI::push_buffer_stats (uint32_t capture, uint32_t playback)
void
ARDOUR_UI::write_buffer_stats ()
{
std::ofstream fout;
struct tm tm;
char buf[64];
char* path;
if ((path = tempnam (0, "ardourBuffering")) == 0) {
char* tmplt = (char*)calloc(strlen("ardourXXXXXX"), sizeof(char));
int fd = mkstemp (tmplt);
if (fd) {
cerr << X_("cannot find temporary name for ardour buffer stats") << endl;
return;
}
fout.open (path);
FILE* fout = fdopen (fd, "w");
if (!fout) {
cerr << string_compose (X_("cannot open file %1 for ardour buffer stats"), path) << endl;
return;
}
for (list<DiskBufferStat>::iterator i = disk_buffer_stats.begin(); i != disk_buffer_stats.end(); ++i) {
std::ostringstream ss;
localtime_r (&(*i).when, &tm);
strftime (buf, sizeof (buf), "%T", &tm);
fout << buf << ' ' << (*i).capture << ' ' << (*i).playback << endl;
fprintf(fout, "%s %u %u\n", buf, (*i).capture, (*i).playback);
}
disk_buffer_stats.clear ();
fout.close ();
fclose (fout);
close (fd);
cerr << "Ardour buffering statistics can be found in: " << path << endl;
free (path);
free (tmplt);
}
void
ARDOUR_UI::disk_overrun_handler ()
{
ENSURE_GUI_THREAD (mem_fun(*this, &ARDOUR_UI::disk_overrun_handler));
write_buffer_stats ();
@ -3009,7 +3011,6 @@ quickly enough to keep up with recording.\n"));
void
ARDOUR_UI::disk_underrun_handler ()
{
ENSURE_GUI_THREAD (mem_fun(*this, &ARDOUR_UI::disk_underrun_handler));
write_buffer_stats ();