marlin r1326 - in trunk: . marlin
- From: iain svn gnome org
- To: svn-commits-list gnome org
- Subject: marlin r1326 - in trunk: . marlin
- Date: Wed, 22 Oct 2008 01:01:55 +0000 (UTC)
Author: iain
Date: Wed Oct 22 01:01:55 2008
New Revision: 1326
URL: http://svn.gnome.org/viewvc/marlin?rev=1326&view=rev
Log:
Bump version to soundtouch 1.3.1
Remove the weird flushing loop
Modified:
trunk/configure.in
trunk/marlin/ChangeLog
trunk/marlin/marlin-channel.c
Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in (original)
+++ trunk/configure.in Wed Oct 22 01:01:55 2008
@@ -96,7 +96,7 @@
AC_SUBST(UNIQUE_CFLAGS)
AC_SUBST(UNIQUE_LIBS)
-PKG_CHECK_MODULES(SOUNDTOUCH, libSoundTouch >= 1.2.1)
+PKG_CHECK_MODULES(SOUNDTOUCH, soundtouch-1.0 >= 1.3.1)
AC_SUBST(SOUNDTOUCH_CFLAGS)
AC_SUBST(SOUNDTOUCH_LIBS)
Modified: trunk/marlin/marlin-channel.c
==============================================================================
--- trunk/marlin/marlin-channel.c (original)
+++ trunk/marlin/marlin-channel.c Wed Oct 22 01:01:55 2008
@@ -1974,7 +1974,6 @@
/* If we're here, we didn't find a 0 */
READ_UNLOCK (channel->lock);
- g_print ("Did not find 0\n");
return orig;
}
@@ -2038,6 +2037,8 @@
buf[(got_frames - 1) - i] = tmp;
}
+ /* insert_point never changes so that the block will always
+ be inserted in the reverse order that it was taken out */
ret = lockless_insert_data (channel, buf, got_frames,
insert_point, ctxt, error);
@@ -2080,7 +2081,7 @@
GError **error)
{
MarlinBlock *block, *b;
- guint64 frames_needed, insert_point;
+ guint64 frames_needed, insert_point, block_start;
float *in_buf, *out_buf;
gboolean ret = TRUE;
@@ -2094,25 +2095,32 @@
lockless_unlink_range (channel, start, finish, &block, ctxt);
b = block;
+ /* When the blocks are unlinked the ranges are recalculated, so
+ start no longer equals block->start */
+ block_start = block->start;
insert_point = start;
- while (frames_needed > 0) {
+
+ /* We take a MARLIN_BLOCK_SIZE, feed it into soundtouch and then
+ extract samples from soundtouch, which will have expanded it to
+ the length we need */
+ while (frames_needed > 0 && block) {
MarlinBlock *next_block;
guint got_frames, frames_avail;
guint processed;
frames_avail = MIN (frames_needed, MARLIN_BLOCK_SIZE);
- got_frames = marlin_block_get_buffer (block, in_buf,
- start, frames_avail,
+ got_frames = marlin_block_get_buffer (block, in_buf,
+ block_start, frames_avail,
&next_block);
marlin_soundtouch_put_samples (soundtouch, in_buf, got_frames);
do {
- processed = marlin_soundtouch_take_samples (soundtouch,
+ processed = marlin_soundtouch_take_samples (soundtouch,
out_buf,
MARLIN_BLOCK_SIZE);
if (processed > 0) {
- g_print ("PRocessed %d\n", processed);
+ g_print ("Processed %d\n", processed);
ret = lockless_insert_data (channel, out_buf,
processed,
insert_point, ctxt,
@@ -2121,15 +2129,16 @@
goto err;
}
- memset (out_buf, 0,
+ memset (out_buf, 0,
MARLIN_BLOCK_SIZE * sizeof (float));
insert_point += processed;
}
} while (processed > 0);
-
- block = next_block;
+
frames_needed -= got_frames;
- start += got_frames;
+
+ block = next_block;
+ block_start += got_frames;
memset (in_buf, 0, MARLIN_BLOCK_SIZE * sizeof (float));
}
@@ -2178,7 +2187,7 @@
MarlinBlock *d_block, *d, *s_block;
float *s_in_buf, *s_out_buf, *d_buf;
float s_ratio, d_ratio;
- guint64 src_length, dest_length;
+ guint64 src_length, dest_length, block_start;
guint64 frames_needed;
float new_tempo;
gboolean ret = TRUE;
@@ -2200,6 +2209,10 @@
lockless_unlink_range (dest, dest_start, dest_end, &d, ctxt);
d_block = d;
+ /* Unlinking the blocks causes their ranges to be recalculated
+ so dest_start no longer equals d_block->start */
+ block_start = d_block->start;
+
s_block = lockless_get_for_frame (src->first, src_start);
s_in_buf = g_new (float, MARLIN_BLOCK_SIZE);
@@ -2207,39 +2220,38 @@
d_buf = g_new (float, MARLIN_BLOCK_SIZE);
frames_needed = src_length;
- while (frames_needed > 0) {
+ while (frames_needed > 0 && s_block && d_block) {
guint s_length, d_length, frames_avail, processed;
MarlinBlock *s_next, *d_next;
int i;
-
+
frames_avail = MIN (frames_needed, MARLIN_BLOCK_SIZE);
s_length = marlin_block_get_buffer (s_block, s_in_buf,
src_start, frames_avail,
&s_next);
-
+
g_print ("need: %llu, got: %u\n", frames_needed, s_length);
marlin_soundtouch_put_samples (soundtouch, s_in_buf, s_length);
- processed = marlin_soundtouch_take_samples
+ processed = marlin_soundtouch_take_samples
(soundtouch, s_out_buf, MARLIN_BLOCK_SIZE);
- process_samples:
- while (processed > 0) {
+ while (processed > 0 && d_block) {
g_print ("Processed: %u\n", processed);
-
+
/* We take a block from the dest that is the same
size as the number of frames we processed and mix
that in */
- d_length = marlin_block_get_buffer (d_block, d_buf,
- dest_start,
- processed,
+ d_length = marlin_block_get_buffer (d_block, d_buf,
+ block_start,
+ processed,
&d_next);
for (i = 0; i < d_length; i++) {
- d_buf[i] = (d_buf[i] * d_ratio) +
+ d_buf[i] = (d_buf[i] * d_ratio) +
(s_out_buf[i] * s_ratio);
}
-
+
ret = lockless_insert_data (dest, d_buf,
d_length,
dest_start,
@@ -2249,32 +2261,35 @@
}
memset (d_buf, 0, MARLIN_BLOCK_SIZE_BYTES);
memset (s_out_buf, 0, MARLIN_BLOCK_SIZE_BYTES);
- dest_start += d_length;
+
+ block_start += d_length;
d_block = d_next;
-
+
g_print ("Dest needs: %llu\n", dest_length - d_length);
- processed = marlin_soundtouch_take_samples
+ processed = marlin_soundtouch_take_samples
(soundtouch, s_out_buf, MARLIN_BLOCK_SIZE);
}
+#if 0
g_print ("Flushing\n");
marlin_soundtouch_flush (soundtouch);
processed = marlin_soundtouch_take_samples
(soundtouch, s_out_buf, MARLIN_BLOCK_SIZE);
+ g_print ("Need: %llu - processed: %u\n", frames_needed, processed);
if (frames_needed > 0 && processed > 0) {
goto process_samples;
} else {
g_print ("Nothing left to flush\n");
}
-
+#endif
frames_needed -= s_length;
s_block = s_next;
src_start += s_length;
-
+
memset (s_in_buf, 0, MARLIN_BLOCK_SIZE_BYTES);
}
-
+
g_print ("Amount of samples left in ST: %d\n", marlin_soundtouch_length (soundtouch));
g_print ("Amount of unprocessed: %d\n", marlin_soundtouch_unprocessed_length (soundtouch));
err:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]