- if (apiver == 2) {
- /*
- * Create new srd_logic object. Each iteration around the PD's
- * loop will fill one sample into this object.
- */
- logic = PyObject_New(srd_logic, (PyTypeObject *)srd_logic_type);
- Py_INCREF(logic);
- logic->di = (struct srd_decoder_inst *)di;
- logic->abs_start_samplenum = abs_start_samplenum;
- logic->itercnt = 0;
- logic->inbuf = (uint8_t *)inbuf;
- logic->inbuflen = inbuflen;
- logic->sample = PyList_New(2);
- Py_INCREF(logic->sample);
-
- Py_IncRef(di->py_inst);
- if (!(py_res = PyObject_CallMethod(di->py_inst, "decode",
- "KKO", abs_start_samplenum, abs_end_samplenum, logic))) {
- srd_exception_catch("Protocol decoder instance %s",
- di->inst_id);
- return SRD_ERR_PYTHON;
- }
- di->abs_cur_samplenum = abs_end_samplenum;
- Py_DecRef(py_res);
- } else {
- /* If this is the first call, start the worker thread. */
- if (!di->thread_handle) {
- srd_dbg("No worker thread for this decoder stack "
- "exists yet, creating one: %s.", di->inst_id);
- di->thread_handle = g_thread_new(di->inst_id,
- di_thread, di);
- }
+ /* Push the new sample chunk to the worker thread. */
+ g_mutex_lock(&di->data_mutex);
+ di->abs_start_samplenum = abs_start_samplenum;
+ di->abs_end_samplenum = abs_end_samplenum;
+ di->inbuf = inbuf;
+ di->inbuflen = inbuflen;
+ di->got_new_samples = TRUE;
+ di->handled_all_samples = FALSE;
+ di->want_wait_terminate = FALSE;