using namespace std;
using namespace ARDOUR;
using namespace PBD;
-using Glib::ustring;
bool AudioSource::_build_missing_peakfiles = false;
#define _FPP 256
-AudioSource::AudioSource (Session& s, ustring name)
+AudioSource::AudioSource (Session& s, string name)
: Source (s, DataType::AUDIO, name)
, _length (0)
{
bool ret;
Glib::Mutex::Lock lm (_peaks_ready_lock);
- /* check to see if the peak data is ready. if not
- connect the slot while still holding the lock.
- */
-
if (!(ret = _peaks_built)) {
*connect_here_if_not = new ScopedConnection;
PeaksReady.connect (**connect_here_if_not, MISSING_INVALIDATOR, doThisWhenReady, event_loop);
}
int
-AudioSource::rename_peakfile (ustring newpath)
+AudioSource::rename_peakfile (string newpath)
{
/* caller must hold _lock */
- ustring oldpath = peakpath;
+ string oldpath = peakpath;
if (access (oldpath.c_str(), F_OK) == 0) {
if (rename (oldpath.c_str(), newpath.c_str()) != 0) {
}
int
-AudioSource::initialize_peakfile (bool newfile, ustring audio_path)
+AudioSource::initialize_peakfile (bool newfile, string audio_path)
{
struct stat statbuf;
/* we found it in the peaks dir, so check it out */
- if (statbuf.st_size == 0 || ((nframes_t) statbuf.st_size < ((length(_timeline_position) / _FPP) * sizeof (PeakData)))) {
+ if (statbuf.st_size == 0 || (statbuf.st_size < (off_t) ((length(_timeline_position) / _FPP) * sizeof (PeakData)))) {
// empty
_peaks_built = false;
} else {
goto out;
}
- framepos_t current_frame = 0;
+ framecnt_t current_frame = 0;
framecnt_t cnt = _length;
_peaks_built = false;
}
done_with_peakfile_writes ((cnt == 0));
- }
-
- {
- Glib::Mutex::Lock lm (_peaks_ready_lock);
-
- if (_peaks_built) {
- PeaksReady (); /* EMIT SIGNAL */
+ if (cnt == 0) {
ret = 0;
}
}
}
if (done) {
+ Glib::Mutex::Lock lm (_peaks_ready_lock);
_peaks_built = true;
+ PeaksReady (); /* EMIT SIGNAL */
}
delete _peakfile_descriptor;
_peakfile_descriptor = 0;
}
+/** @param first_frame Offset from the source start of the first frame to process */
int
-AudioSource::compute_and_write_peaks (Sample* buf, framepos_t first_frame, framecnt_t cnt,
+AudioSource::compute_and_write_peaks (Sample* buf, framecnt_t first_frame, framecnt_t cnt,
bool force, bool intermediate_peaks_ready)
{
return compute_and_write_peaks (buf, first_frame, cnt, force, intermediate_peaks_ready, _FPP);
}
int
-AudioSource::compute_and_write_peaks (Sample* buf, framepos_t first_frame, framecnt_t cnt,
+AudioSource::compute_and_write_peaks (Sample* buf, framecnt_t first_frame, framecnt_t cnt,
bool force, bool intermediate_peaks_ready, framecnt_t fpp)
{
Sample* buf2 = 0;
off_t target_length = blocksize * ((first_peak_byte + blocksize + 1) / blocksize);
if (endpos < target_length) {
- ftruncate (_peakfile_fd, target_length);
+ (void) ftruncate (_peakfile_fd, target_length);
/* error doesn't actually matter though, so continue on without testing */
}
}
off_t end = lseek (_peakfile_fd, 0, SEEK_END);
if (end > _peak_byte_max) {
- ftruncate (_peakfile_fd, _peak_byte_max);
+ (void) ftruncate (_peakfile_fd, _peak_byte_max);
}
}
return (end/sizeof(PeakData)) * _FPP;
}
+void
+AudioSource::dec_read_data_count (framecnt_t cnt)
+{
+ uint32_t val = cnt * sizeof (Sample);
+
+ if (val < _read_data_count) {
+ _read_data_count -= val;
+ } else {
+ _read_data_count = 0;
+ }
+}
+
+void
+AudioSource::mark_streaming_write_completed ()
+{
+ Glib::Mutex::Lock lm (_peaks_ready_lock);
+
+ if (_peaks_built) {
+ PeaksReady (); /* EMIT SIGNAL */
+ }
+}