Skip to content

Commit

Permalink
named instrument async behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
vlazzarini committed Aug 12, 2021
1 parent 69af438 commit 45290c0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Engine/csound_orc_compile.c
Expand Up @@ -1836,14 +1836,15 @@ int csoundCompileTreeInternal(CSOUND *csound, TREE *root, int async) {
return CSOUND_ERROR;
}

/* now add the instruments with names, assigning them fake instr numbers */
named_instr_assign_numbers(csound, engineState);

if (engineState != &csound->engineState) {
OPDS *ids = csound->ids;
/* any compilation other than the first one */
/* merge ENGINE_STATE */
/* lock to ensure thread-safety */
if (!async) {
/* now add the instruments with names, assigning them fake instr numbers */
named_instr_assign_numbers(csound, engineState);
if (!csound->oparms->realtime)
csoundLockMutex(csound->API_lock);
merge_state(csound, engineState, typeTable, ids);
Expand All @@ -1857,6 +1858,8 @@ int csoundCompileTreeInternal(CSOUND *csound, TREE *root, int async) {
csoundSpinUnLock(&csound->alloc_spinlock);
}
} else {
/* now add the instruments with names, assigning them fake instr numbers */
named_instr_assign_numbers(csound, engineState);
/* first compilation */
insert_opcodes(csound, csound->opcodeInfo, engineState);
ip = engineState->instxtanchor.nxtinstxt;
Expand Down
3 changes: 3 additions & 0 deletions Top/threadsafe.c
Expand Up @@ -50,6 +50,8 @@ int csoundScoreEventAbsoluteInternal(CSOUND *csound, char type,
void set_channel_data_ptr(CSOUND *csound, const char *name,
void *ptr, int newSize);

void named_instr_assign_numbers(CSOUND *csound, ENGINE_STATE *engineState);

enum {INPUT_MESSAGE=1, READ_SCORE, SCORE_EVENT, SCORE_EVENT_ABS,
TABLE_COPY_OUT, TABLE_COPY_IN, TABLE_SET, MERGE_STATE, KILL_INSTANCE};

Expand Down Expand Up @@ -222,6 +224,7 @@ void message_dequeue(CSOUND *csound) {
sizeof(TYPE_TABLE *));
memcpy(&ids, msg->args + 2*ARG_ALIGN,
sizeof(OPDS *));
named_instr_assign_numbers(csound, e);
merge_state(csound, e, t, ids);
}
break;
Expand Down

0 comments on commit 45290c0

Please sign in to comment.