Hi

Attached are couple of fixes for current j6t branch.

First patch fixes crash that may be triggered by any plugin.

Second patch fixes audio-video synchronization while using ALSA sound output.

Einar
From 0585eda248483aae4d2f5340aaafedad7378f5c0 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Einar=20R=C3=BCnkaru?= <eina...@smail.ee>
Date: Sun, 19 Dec 2010 19:41:46 +0200
Subject: [PATCH] Fixed potential crash in plugins

PLUGIN_THREAD macros use thread autodelete feature, so
after run() completes, thread is destroyed.
Clear thread pointer at the end of run(), then
PLUGIN_DESTRUCTOR does not refer to already deleted
thread object
---
 cinelerra/pluginclient.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/cinelerra/pluginclient.h b/cinelerra/pluginclient.h
index f1a340b..2b20e66 100644
--- a/cinelerra/pluginclient.h
+++ b/cinelerra/pluginclient.h
@@ -112,6 +112,7 @@ void thread_class::run() \
 	int result = window->run_window(); \
 /* This is needed when the GUI is closed from itself */ \
 	if(result) plugin->client_side_close(); \
+	plugin->thread = 0; \
 }
 
 
-- 
1.6.0.4

From b7f2064d4e18d5da24bc48ee1d3b197c5e9f2d4f Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Einar=20R=C3=BCnkaru?= <eina...@smail.ee>
Date: Sun, 19 Dec 2010 20:01:28 +0200
Subject: [PATCH] Fixed synchronization in ALSA backend

Delay from ALSA driver was unreachable at the moment of
storing it for later use. Second problem was that delay
was asked before writing of buffer and the size of
the last buffer was not taken into account.
---
 cinelerra/audioalsa.C |    7 +------
 cinelerra/audioalsa.h |    2 +-
 2 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/cinelerra/audioalsa.C b/cinelerra/audioalsa.C
index f356917..c3bc9b1 100644
--- a/cinelerra/audioalsa.C
+++ b/cinelerra/audioalsa.C
@@ -480,11 +480,6 @@ int AudioALSA::write_buffer(char *buffer, int size)
 	while(attempts < 2 && !done && !interrupted)
 	{
 // Buffers written must be equal to period_time
-// Update timing
- 		snd_pcm_sframes_t delay;
- 		snd_pcm_delay(get_output(), &delay);
-		snd_pcm_avail_update(get_output());
-
 		device->Thread::enable_cancel();
 		if(snd_pcm_writei(get_output(), 
 			buffer, 
@@ -508,7 +503,7 @@ int AudioALSA::write_buffer(char *buffer, int size)
 	if(done)
 	{
 		timer_lock->lock("AudioALSA::write_buffer");
-		this->delay = delay;
+		snd_pcm_delay(get_output(), &delay);
 		timer->update();
 		samples_written += samples;
 		timer_lock->unlock();
diff --git a/cinelerra/audioalsa.h b/cinelerra/audioalsa.h
index ff28ae9..479efa8 100644
--- a/cinelerra/audioalsa.h
+++ b/cinelerra/audioalsa.h
@@ -62,7 +62,7 @@ private:
 	snd_pcm_t *dsp_in, *dsp_out, *dsp_duplex;
 	int64_t samples_written;
 	Timer *timer;
-	int delay;
+	snd_pcm_sframes_t delay;
 	Mutex *timer_lock;
 	int interrupted;
 };
-- 
1.6.0.4

Reply via email to