[Pkg-javascript-commits] [node-groove] 01/03: Backport patch to fix cpu usage
Felipe Sateler
fsateler at moszumanska.debian.org
Fri May 15 22:35:24 UTC 2015
This is an automated email from the git hooks/post-receive script.
fsateler pushed a commit to branch jessie
in repository node-groove.
commit e7907d4b8fe633698b280677f3e5d69a4c7d3dfb
Author: Felipe Sateler <fsateler at debian.org>
Date: Fri May 15 19:04:49 2015 -0300
Backport patch to fix cpu usage
---
.../0001-fix-emitting-buffer-event-too-often.patch | 62 ++++++++++++++++++++++
debian/patches/series | 1 +
2 files changed, 63 insertions(+)
diff --git a/debian/patches/0001-fix-emitting-buffer-event-too-often.patch b/debian/patches/0001-fix-emitting-buffer-event-too-often.patch
new file mode 100644
index 0000000..bbc5cb6
--- /dev/null
+++ b/debian/patches/0001-fix-emitting-buffer-event-too-often.patch
@@ -0,0 +1,62 @@
+From: Andrew Kelley <superjoe30 at gmail.com>
+Date: Thu, 14 May 2015 09:28:25 -0700
+Subject: fix emitting 'buffer' event too often
+
+no longer burns the CPU
+---
+ src/gn_encoder.cc | 15 +++++++++++++--
+ src/gn_encoder.h | 1 +
+ 2 files changed, 14 insertions(+), 2 deletions(-)
+
+diff --git a/src/gn_encoder.cc b/src/gn_encoder.cc
+index 0791292..474141f 100644
+--- a/src/gn_encoder.cc
++++ b/src/gn_encoder.cc
+@@ -93,7 +93,10 @@ static void EventThreadEntry(void *arg) {
+ GNEncoder::EventContext *context = reinterpret_cast<GNEncoder::EventContext *>(arg);
+ while (groove_encoder_buffer_peek(context->encoder, 1) > 0) {
+ uv_mutex_lock(&context->mutex);
+- uv_async_send(&context->event_async);
++ if (context->emit_buffer_ok) {
++ context->emit_buffer_ok = false;
++ uv_async_send(&context->event_async);
++ }
+ uv_cond_wait(&context->cond, &context->mutex);
+ uv_mutex_unlock(&context->mutex);
+ }
+@@ -180,6 +183,7 @@ Handle<Value> GNEncoder::Create(const Arguments& args) {
+ GNEncoder *gn_encoder = node::ObjectWrap::Unwrap<GNEncoder>(instance);
+ EventContext *context = new EventContext;
+ gn_encoder->event_context = context;
++ context->emit_buffer_ok = true;
+ context->event_cb = Persistent<Function>::New(Local<Function>::Cast(args[0]));
+ context->encoder = encoder;
+
+@@ -372,7 +376,14 @@ Handle<Value> GNEncoder::GetBuffer(const Arguments& args) {
+ GrooveEncoder *encoder = gn_encoder->encoder;
+
+ GrooveBuffer *buffer;
+- switch (groove_encoder_buffer_get(encoder, &buffer, 0)) {
++ int buf_result = groove_encoder_buffer_get(encoder, &buffer, 0);
++
++ uv_mutex_lock(&gn_encoder->event_context->mutex);
++ gn_encoder->event_context->emit_buffer_ok = true;
++ uv_cond_signal(&gn_encoder->event_context->cond);
++ uv_mutex_unlock(&gn_encoder->event_context->mutex);
++
++ switch (buf_result) {
+ case GROOVE_BUFFER_YES: {
+ Local<Object> object = Object::New();
+
+diff --git a/src/gn_encoder.h b/src/gn_encoder.h
+index 063bf60..958815e 100644
+--- a/src/gn_encoder.h
++++ b/src/gn_encoder.h
+@@ -19,6 +19,7 @@ class GNEncoder : public node::ObjectWrap {
+ uv_mutex_t mutex;
+ GrooveEncoder *encoder;
+ v8::Persistent<v8::Function> event_cb;
++ bool emit_buffer_ok;
+ };
+
+ GrooveEncoder *encoder;
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..3040e56
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1 @@
+0001-fix-emitting-buffer-event-too-often.patch
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-groove.git
More information about the Pkg-javascript-commits
mailing list