mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-24 07:27:44 +01:00
Create export temporary files in the export directory
git-svn-id: svn://localhost/ardour2/branches/3.0@13371 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
b5c5fc7a08
commit
c8a4bdc4a4
2 changed files with 31 additions and 4 deletions
|
|
@ -1,5 +1,7 @@
|
||||||
#include "ardour/export_graph_builder.h"
|
#include "ardour/export_graph_builder.h"
|
||||||
|
|
||||||
|
#include <glibmm/miscutils.h>
|
||||||
|
|
||||||
#include "audiographer/process_context.h"
|
#include "audiographer/process_context.h"
|
||||||
#include "audiographer/general/chunker.h"
|
#include "audiographer/general/chunker.h"
|
||||||
#include "audiographer/general/interleaver.h"
|
#include "audiographer/general/interleaver.h"
|
||||||
|
|
@ -17,6 +19,7 @@
|
||||||
#include "ardour/export_filename.h"
|
#include "ardour/export_filename.h"
|
||||||
#include "ardour/export_format_specification.h"
|
#include "ardour/export_format_specification.h"
|
||||||
#include "ardour/export_timespan.h"
|
#include "ardour/export_timespan.h"
|
||||||
|
#include "ardour/session_directory.h"
|
||||||
#include "ardour/sndfile_helpers.h"
|
#include "ardour/sndfile_helpers.h"
|
||||||
|
|
||||||
#include "pbd/file_utils.h"
|
#include "pbd/file_utils.h"
|
||||||
|
|
@ -292,6 +295,12 @@ ExportGraphBuilder::SFC::operator== (FileSpec const & other_config) const
|
||||||
ExportGraphBuilder::Normalizer::Normalizer (ExportGraphBuilder & parent, FileSpec const & new_config, framecnt_t /*max_frames*/)
|
ExportGraphBuilder::Normalizer::Normalizer (ExportGraphBuilder & parent, FileSpec const & new_config, framecnt_t /*max_frames*/)
|
||||||
: parent (parent)
|
: parent (parent)
|
||||||
{
|
{
|
||||||
|
std::string tmpfile_path = parent.session.session_directory().export_path();
|
||||||
|
tmpfile_path = Glib::build_filename(tmpfile_path, "XXXXXX");
|
||||||
|
char tmpfile_path_buf[tmpfile_path.size() + 1];
|
||||||
|
std::copy(tmpfile_path.begin(), tmpfile_path.end(), tmpfile_path_buf);
|
||||||
|
tmpfile_path_buf[tmpfile_path.size()] = '\0';
|
||||||
|
|
||||||
config = new_config;
|
config = new_config;
|
||||||
uint32_t const channels = config.channel_config->get_n_chans();
|
uint32_t const channels = config.channel_config->get_n_chans();
|
||||||
max_frames_out = 4086 - (4086 % channels); // TODO good chunk size
|
max_frames_out = 4086 - (4086 % channels); // TODO good chunk size
|
||||||
|
|
@ -305,7 +314,7 @@ ExportGraphBuilder::Normalizer::Normalizer (ExportGraphBuilder & parent, FileSpe
|
||||||
normalizer->add_output (threader);
|
normalizer->add_output (threader);
|
||||||
|
|
||||||
int format = ExportFormatBase::F_RAW | ExportFormatBase::SF_Float;
|
int format = ExportFormatBase::F_RAW | ExportFormatBase::SF_Float;
|
||||||
tmp_file.reset (new TmpFile<float> (format, channels, config.format->sample_rate()));
|
tmp_file.reset (new TmpFile<float> (tmpfile_path_buf, format, channels, config.format->sample_rate()));
|
||||||
tmp_file->FileWritten.connect_same_thread (post_processing_connection,
|
tmp_file->FileWritten.connect_same_thread (post_processing_connection,
|
||||||
boost::bind (&Normalizer::start_post_processing, this));
|
boost::bind (&Normalizer::start_post_processing, this));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
#ifndef AUDIOGRAPHER_TMP_FILE_H
|
#ifndef AUDIOGRAPHER_TMP_FILE_H
|
||||||
#define AUDIOGRAPHER_TMP_FILE_H
|
#define AUDIOGRAPHER_TMP_FILE_H
|
||||||
|
|
||||||
|
#include <cstdio>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "sndfile_writer.h"
|
#include "sndfile_writer.h"
|
||||||
#include "sndfile_reader.h"
|
#include "sndfile_reader.h"
|
||||||
|
|
||||||
|
|
@ -13,6 +16,12 @@ class TmpFile : public SndfileWriter<T>, public SndfileReader<T>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
/// \a filename_template must match the requirements for mkstemp, i.e. end in "XXXXXX"
|
||||||
|
TmpFile (char * filename_template, int format, ChannelCount channels, framecnt_t samplerate)
|
||||||
|
: SndfileHandle (mkstemp(filename_template), true, SndfileBase::ReadWrite, format, channels, samplerate)
|
||||||
|
, filename (filename_template)
|
||||||
|
{}
|
||||||
|
|
||||||
TmpFile (int format, ChannelCount channels, framecnt_t samplerate)
|
TmpFile (int format, ChannelCount channels, framecnt_t samplerate)
|
||||||
: SndfileHandle (fileno (tmpfile()), true, SndfileBase::ReadWrite, format, channels, samplerate)
|
: SndfileHandle (fileno (tmpfile()), true, SndfileBase::ReadWrite, format, channels, samplerate)
|
||||||
{}
|
{}
|
||||||
|
|
@ -20,6 +29,15 @@ class TmpFile : public SndfileWriter<T>, public SndfileReader<T>
|
||||||
TmpFile (TmpFile const & other) : SndfileHandle (other) {}
|
TmpFile (TmpFile const & other) : SndfileHandle (other) {}
|
||||||
using SndfileHandle::operator=;
|
using SndfileHandle::operator=;
|
||||||
|
|
||||||
|
~TmpFile()
|
||||||
|
{
|
||||||
|
if (!filename.empty()) {
|
||||||
|
std::remove(filename.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string filename;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue