[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Traverso-commit] traverso/src/core DiskIO.cpp DiskIO.h Peak.cpp ...
From: |
Remon Sijrier |
Subject: |
[Traverso-commit] traverso/src/core DiskIO.cpp DiskIO.h Peak.cpp ... |
Date: |
Fri, 12 Oct 2007 19:38:52 +0000 |
CVSROOT: /sources/traverso
Module name: traverso
Changes by: Remon Sijrier <r_sijrier> 07/10/12 19:38:52
Modified files:
src/core : DiskIO.cpp DiskIO.h Peak.cpp ReadSource.cpp
ReadSource.h Song.cpp WriteSource.cpp
WriteSource.h
Log message:
* Use a dedicated DecodeBuffer for ResampleAudioReaders' readers. Makes
DecodeBuffer much cleaner, and seems to solve problems I have now when
audiodevice samplerate != file samplerate
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/DiskIO.cpp?cvsroot=traverso&r1=1.49&r2=1.50
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/DiskIO.h?cvsroot=traverso&r1=1.23&r2=1.24
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/Peak.cpp?cvsroot=traverso&r1=1.61&r2=1.62
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/ReadSource.cpp?cvsroot=traverso&r1=1.72&r2=1.73
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/ReadSource.h?cvsroot=traverso&r1=1.40&r2=1.41
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/Song.cpp?cvsroot=traverso&r1=1.147&r2=1.148
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/WriteSource.cpp?cvsroot=traverso&r1=1.38&r2=1.39
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/WriteSource.h?cvsroot=traverso&r1=1.20&r2=1.21
Patches:
Index: DiskIO.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/DiskIO.cpp,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -b -r1.49 -r1.50
--- DiskIO.cpp 12 Oct 2007 08:56:26 -0000 1.49
+++ DiskIO.cpp 12 Oct 2007 19:38:51 -0000 1.50
@@ -153,6 +153,7 @@
framebuffer[0] = new audio_sample_t[audiodevice().get_sample_rate() *
writebuffertime];
m_decodebuffer = new DecodeBuffer;
+ m_resampleDecodeBuffer = new DecodeBuffer;
// Move this instance to the workthread
moveToThread(m_diskThread);
@@ -170,6 +171,7 @@
delete cpuTimeBuffer;
delete [] framebuffer[0];
delete m_decodebuffer;
+ delete m_resampleDecodeBuffer;
}
/**
@@ -195,8 +197,7 @@
foreach(ReadSource* source, m_readSources) {
if (m_sampleRateChanged) {
-
source->set_output_rate(audiodevice().get_sample_rate());
- source->prepare_buffer();
+ source->set_diskio(this);
}
source->rb_seek_to_file_position(location);
}
@@ -214,9 +215,10 @@
}
-void DiskIO::output_rate_changed()
+void DiskIO::output_rate_changed(int rate)
{
m_sampleRateChanged = true;
+ m_outputRate = rate;
}
@@ -369,10 +371,11 @@
{
PENTER2;
+ source->set_diskio(this);
+
QMutexLocker locker(&mutex);
m_readSources.append(source);
- source->prepare_buffer();
}
/**
@@ -386,7 +389,6 @@
PENTER2;
source->set_diskio(this);
- source->prepare_buffer();
QMutexLocker locker(&mutex);
@@ -502,3 +504,4 @@
}
//eof
+
Index: DiskIO.h
===================================================================
RCS file: /sources/traverso/traverso/src/core/DiskIO.h,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- DiskIO.h 28 Aug 2007 19:51:52 -0000 1.23
+++ DiskIO.h 12 Oct 2007 19:38:51 -0000 1.24
@@ -55,7 +55,7 @@
static const int bufferdividefactor = 5;
void prepare_for_seek();
- void output_rate_changed();
+ void output_rate_changed(int rate);
void register_read_source(ReadSource* source);
void register_write_source(WriteSource* source);
@@ -66,6 +66,8 @@
trav_time_t get_cpu_time();
int get_write_buffers_fill_status();
int get_read_buffers_fill_status();
+ int get_output_rate() {return m_outputRate;}
+ DecodeBuffer* get_resample_decode_buffer() {return
m_resampleDecodeBuffer;}
private:
Song* m_song;
@@ -88,6 +90,8 @@
audio_sample_t* framebuffer[2];
audio_sample_t* m_readbuffer;
DecodeBuffer* m_decodebuffer;
+ DecodeBuffer* m_resampleDecodeBuffer;
+ int m_outputRate;
void update_time_usage();
Index: Peak.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/Peak.cpp,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -b -r1.61 -r1.62
--- Peak.cpp 10 Oct 2007 19:45:00 -0000 1.61
+++ Peak.cpp 12 Oct 2007 19:38:51 -0000 1.62
@@ -84,7 +84,7 @@
if (rs) {
// This Peak object was created by AudioClip, meant for reading
peak data
m_source = resources_manager()->get_readsource(rs->get_id());
- m_source->set_output_rate(44100);
+ m_source->set_output_rate(44100, true);
} else {
// No ReadSource object? Then it's created by WriteSource for
on the fly
// peak data creation, no m_source needed!
@@ -272,7 +272,7 @@
// Check if this zoom level has as many data as requested.
if ( (pixelcount + offset) >
data->headerdata.peakDataSizeForLevel[zoomLevel - SAVING_ZOOM_FACTOR]) {
// YES we know that sometimes we ommit the very last
'pixel' to avoid painting artifacts...
- PERROR("pixelcount exceeds available data size!
(pixelcount is: %d, available is %d", pixelcount,
data->headerdata.peakDataSizeForLevel[zoomLevel - SAVING_ZOOM_FACTOR] -
offset);
+// PERROR("pixelcount exceeds available data size!
(pixelcount is: %d, available is %d", pixelcount,
data->headerdata.peakDataSizeForLevel[zoomLevel - SAVING_ZOOM_FACTOR] -
offset);
// pixelcount =
data->headerdata.peakDataSizeForLevel[zoomLevel - SAVING_ZOOM_FACTOR] - offset;
}
@@ -613,7 +613,7 @@
}
}
- m_source->set_output_rate(m_source->get_file_rate());
+ m_source->set_output_rate(m_source->get_file_rate(), true);
DecodeBuffer decodebuffer;
@@ -661,7 +661,7 @@
printf("Process time: %d seconds\n\n", (int)(processtime/1000));
#endif
- m_source->set_output_rate(44100);
+ m_source->set_output_rate(44100, true);
return ret;
}
@@ -675,7 +675,7 @@
}
}
int rate = m_source->get_file_rate();
- m_source->set_output_rate(rate);
+ m_source->set_output_rate(rate, true);
nframes_t startframe = startlocation.to_frame(rate);
nframes_t endframe = endlocation.to_frame(rate);
int startpos = startframe / NORMALIZE_CHUNK_SIZE;
@@ -731,7 +731,7 @@
delete [] readbuffer;
- m_source->set_output_rate(44100);
+ m_source->set_output_rate(44100, true);
return maxamp;
}
Index: ReadSource.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/ReadSource.cpp,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -b -r1.72 -r1.73
--- ReadSource.cpp 12 Oct 2007 08:56:27 -0000 1.72
+++ ReadSource.cpp 12 Oct 2007 19:38:51 -0000 1.73
@@ -219,9 +219,6 @@
m_syncInProgress = 0;
m_bufferUnderRunDetected = m_wasActivated = 0;
- bool useResampling = config().get_property("Conversion",
"DynamicResampling", true).toBool();
- int converter_type = config().get_property("Conversion",
"RTResamplingConverterType", 2).toInt();
-
// There should be another config option for ConverterType to use for
export (higher quality)
//converter_type = config().get_property("Conversion",
"ExportResamplingConverterType", 0).toInt();
m_audioReader = new ResampleAudioReader(m_fileName, m_decodertype);
@@ -233,10 +230,10 @@
return COULD_NOT_OPEN_FILE;
}
- if (useResampling) {
- set_output_rate(audiodevice().get_sample_rate());
+ int converter_type = config().get_property("Conversion",
"RTResamplingConverterType", 2).toInt();
m_audioReader->set_converter_type(converter_type);
- }
+
+ set_output_rate(m_audioReader->get_file_rate());
// (re)set the decoder type
m_decodertype = m_audioReader->decoder_type();
@@ -265,15 +262,22 @@
}
-void ReadSource::set_output_rate(int rate)
+void ReadSource::set_output_rate(int rate, bool forceRate)
{
Q_ASSERT(rate > 0);
if (! m_audioReader) {
+ printf("ReadSource::set_output_rate: No audioreader!\n");
return;
}
+ bool useResampling = config().get_property("Conversion",
"DynamicResampling", true).toBool();
+ if (useResampling || forceRate) {
m_audioReader->set_output_rate(rate);
+ } else {
+ set_output_rate(m_audioReader->get_file_rate());
+ }
+
m_outputRate = rate;
// The length could have become slightly smaller/larger due
@@ -311,7 +315,7 @@
return source;
}
-void ReadSource::set_audio_clip( AudioClip * clip )
+void ReadSource::set_audio_clip(AudioClip* clip)
{
PENTER;
Q_ASSERT(clip);
@@ -509,6 +513,11 @@
void ReadSource::start_resync(TimeRef& position)
{
// printf("starting resync!\n");
+ if (m_needSync || m_syncInProgress) {
+ printf("start_resync still in progress!\n");
+ return;
+ }
+
m_syncPos = position;
m_rbReady = 0;
m_needSync = 1;
@@ -526,6 +535,7 @@
void ReadSource::sync(DecodeBuffer* buffer)
{
PENTER2;
+ printf("source::sync: %s\n", QS_C(m_fileName));
if (!m_audioReader) {
return;
@@ -554,7 +564,7 @@
-void ReadSource::prepare_buffer( )
+void ReadSource::prepare_rt_buffers( )
{
PENTER;
@@ -627,3 +637,15 @@
return pm().get_project()->get_rate();
}
+void ReadSource::set_diskio(DiskIO * diskio)
+{
+ m_diskio = diskio;
+ set_output_rate(m_diskio->get_output_rate());
+ prepare_rt_buffers();
+ if (m_audioReader) {
+ printf("setting resample decode buffer\n");
+
m_audioReader->set_resample_decode_buffer(m_diskio->get_resample_decode_buffer());
+ }
+
+}
+
Index: ReadSource.h
===================================================================
RCS file: /sources/traverso/traverso/src/core/ReadSource.h,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -b -r1.40 -r1.41
--- ReadSource.h 10 Oct 2007 16:41:57 -0000 1.40
+++ ReadSource.h 12 Oct 2007 19:38:51 -0000 1.41
@@ -31,6 +31,7 @@
class AudioClip;
struct BufferStatus;
class DecodeBuffer;
+class DiskIO;
class ReadSource : public AudioSource
{
@@ -66,21 +67,24 @@
void set_active(bool active);
void set_audio_clip(AudioClip* clip);
+ void set_diskio(DiskIO* diskio);
const nframes_t get_nframes() const;
int get_file_rate() const;
const TimeRef& get_length() const {return m_length;}
void sync(DecodeBuffer* buffer);
void process_ringbuffer(DecodeBuffer* buffer, bool seeking=false);
- void prepare_buffer();
+ void prepare_rt_buffers();
size_t is_active() const;
BufferStatus* get_buffer_status();
- void set_output_rate(int rate);
+ void set_output_rate(int rate, bool forceRate=false);
+
private:
ResampleAudioReader* m_audioReader;
AudioClip* m_clip;
+ DiskIO* m_diskio;
int m_refcount;
int m_error;
bool m_silent;
Index: Song.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/Song.cpp,v
retrieving revision 1.147
retrieving revision 1.148
diff -u -b -r1.147 -r1.148
--- Song.cpp 12 Oct 2007 10:06:30 -0000 1.147
+++ Song.cpp 12 Oct 2007 19:38:51 -0000 1.148
@@ -127,6 +127,8 @@
#endif
m_diskio = new DiskIO(this);
+ m_currentSampleRate = audiodevice().get_sample_rate();
+ m_diskio->output_rate_changed(m_currentSampleRate);
connect(this, SIGNAL(seekStart()), m_diskio, SLOT(seek()),
Qt::QueuedConnection);
connect(this, SIGNAL(prepareRecording()), this,
SLOT(prepare_recording()));
@@ -168,7 +170,6 @@
m_transportLocation = 0;
m_mode = EDIT;
m_sbx = m_sby = 0;
- m_currentSampleRate = audiodevice().get_sample_rate();
m_pluginChain = new PluginChain(this, this);
m_fader = m_pluginChain->get_fader();
@@ -442,7 +443,7 @@
resize_buffer(false, spec->blocksize);
renderDecodeBuffer = new DecodeBuffer;
- renderDecodeBuffer->use_custom_destination_buffer(true);
+// renderDecodeBuffer->use_custom_destination_buffer(true);
return 1;
}
@@ -957,7 +958,7 @@
if (m_currentSampleRate != audiodevice().get_sample_rate()) {
m_currentSampleRate = audiodevice().get_sample_rate();
- m_diskio->output_rate_changed();
+ m_diskio->output_rate_changed(m_currentSampleRate);
TimeRef location = m_transportLocation;
location.add_frames(1, audiodevice().get_sample_rate());
Index: WriteSource.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/WriteSource.cpp,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -b -r1.38 -r1.39
--- WriteSource.cpp 27 Sep 2007 20:55:50 -0000 1.38
+++ WriteSource.cpp 12 Oct 2007 19:38:51 -0000 1.39
@@ -461,7 +461,7 @@
rb_file_write(readSpace);
}
-void WriteSource::prepare_buffer( )
+void WriteSource::prepare_rt_buffers( )
{
m_bufferSize = m_sampleRate * DiskIO::writebuffertime;
m_chunkSize = m_bufferSize / DiskIO::bufferdividefactor;
@@ -473,6 +473,7 @@
void WriteSource::set_diskio( DiskIO * io )
{
m_diskio = io;
+ prepare_rt_buffers();
}
//eof
Index: WriteSource.h
===================================================================
RCS file: /sources/traverso/traverso/src/core/WriteSource.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- WriteSource.h 24 Sep 2007 00:57:50 -0000 1.20
+++ WriteSource.h 12 Oct 2007 19:38:51 -0000 1.21
@@ -54,7 +54,6 @@
int finish_export();
void set_process_peaks(bool process);
void set_recording(int rec);
- void prepare_buffer();
size_t is_recording() const;
@@ -83,6 +82,8 @@
void* m_output_data;
+ void prepare_rt_buffers();
+
signals:
void exportFinished();
};
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Traverso-commit] traverso/src/core DiskIO.cpp DiskIO.h Peak.cpp ...,
Remon Sijrier <=