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)
{
return 0;
}
-sframes_t
-AudioSource::length (sframes_t /*pos*/) const
+bool
+AudioSource::empty () const
+{
+ return _length == 0;
+}
+
+framecnt_t
+AudioSource::length (framepos_t /*pos*/) const
{
return _length;
}
void
-AudioSource::update_length (sframes_t pos, sframes_t cnt)
+AudioSource::update_length (framepos_t pos, framecnt_t cnt)
{
if (pos + cnt > _length) {
_length = pos + cnt;
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;
}
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;
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 (nframes_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 */
+ }
+}