aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard <q@1bpm.net>2025-03-20 00:34:54 +0000
committerRichard <q@1bpm.net>2025-03-20 00:34:54 +0000
commit0b65c17a4a94b71f8e3c628fa5721c5aa154dae0 (patch)
treecd5ada89058e661814ebfa7077cde47185030533
parent829225b247862bf637adb65862d9134164776d84 (diff)
downloadcsound-shout-0b65c17a4a94b71f8e3c628fa5721c5aa154dae0.tar.gz
csound-shout-0b65c17a4a94b71f8e3c628fa5721c5aa154dae0.tar.bz2
csound-shout-0b65c17a4a94b71f8e3c628fa5721c5aa154dae0.zip
additional deinit, threading test
-rw-r--r--src/opcodes.cpp44
1 files changed, 43 insertions, 1 deletions
diff --git a/src/opcodes.cpp b/src/opcodes.cpp
index 9e95508..89460a4 100644
--- a/src/opcodes.cpp
+++ b/src/opcodes.cpp
@@ -262,6 +262,43 @@ struct shoutsetmeta : csnd::InPlug<3> {
}
};
+/*
+class SendThread : public csnd::Thread { // in progress...
+ MYFLT* bufferL;
+ MYFLT* bufferR;
+ ShoutSession* session;
+ lame_global_flags* lame;
+ int wpos;
+
+ SendThread(csnd::Csound *csound, ShoutSession* shoutSession, lame_global_flags* lameFlags) :
+ Thread(csound), session(shoutSession), lame(lameFlags) {
+ wpos = 0;
+ };
+
+ uintptr_t run() {
+ if (inbufferPos >= inbufferSize) {
+ outSize += lame_encode_buffer_int(lame, inbufferL, inbufferR, inbufferSize, outbuffer, outMaxSize);
+ //std::cout << shout_delay(session->shout) << "\n";
+ shout_sync(session->shout);
+ shout_send(session->shout, outbuffer, outSize);
+ inbufferPos = 0;
+ outSize = 0;
+ }
+
+ }
+
+ void send() {
+
+ }
+
+ int addbuffer(MYFLT* left, MYFLT* right, int size) {
+ memcpy(bufferL + wpos, left, size);
+ memcpy(bufferR + wpos, right, size);
+ wpos += size;
+ }
+}
+*/
+
struct shoutsend : csnd::InPlug<4> {
ARGO = "";
ARGI = "iaaj";
@@ -283,6 +320,7 @@ struct shoutsend : csnd::InPlug<4> {
if (!lame) {
return csound->init_error("Could not setup LAME");
}
+ csound->plugin_deinit(this);
lame_set_num_channels(lame, 2);
lame_set_in_samplerate(lame, csound->sr());
lame_set_quality(lame, (args[3] == FL(-1)) ? 4 : (int) args[3]);
@@ -299,6 +337,11 @@ struct shoutsend : csnd::InPlug<4> {
return OK;
}
+ int deinit() {
+ lame_close(lame);
+ return OK;
+ }
+
int aperf() {
for (int i = 0; i < nsmps; i ++) {
inbufferL[inbufferPos] = (int) (args(1)[i] * INT_MAX);
@@ -306,7 +349,6 @@ struct shoutsend : csnd::InPlug<4> {
if (inbufferPos >= inbufferSize) {
outSize += lame_encode_buffer_int(lame, inbufferL, inbufferR, inbufferSize, outbuffer, outMaxSize);
//std::cout << shout_delay(session->shout) << "\n";
- //shout_sync(session->shout);
shout_send(session->shout, outbuffer, outSize);
inbufferPos = 0;
outSize = 0;