diff options
author | Soeren Apel <soeren@apelpie.net> | 2018-07-09 22:20:24 +0200 |
---|---|---|
committer | Uwe Hermann <uwe@hermann-uwe.de> | 2018-08-30 11:56:38 +0200 |
commit | d4d8ac2a005a091f23bf89cff2ff6fbfc8fcd739 (patch) | |
tree | 28b6aeaeaf5c5f3f588c70cb8a8c36d26048e9df | |
parent | 66cff5a67110b3e9a4884ac3d8f7742d6f755e30 (diff) | |
download | libsigrokdecode-d4d8ac2a005a091f23bf89cff2ff6fbfc8fcd739.tar.gz libsigrokdecode-d4d8ac2a005a091f23bf89cff2ff6fbfc8fcd739.zip |
Make srd_inst_decode() return the actual decoder state, not SRD_OK
-rw-r--r-- | instance.c | 7 | ||||
-rw-r--r-- | libsigrokdecode.h | 3 |
2 files changed, 9 insertions, 1 deletions
@@ -398,6 +398,7 @@ SRD_API struct srd_decoder_inst *srd_inst_new(struct srd_session *sess, di->got_new_samples = FALSE; di->handled_all_samples = FALSE; di->want_wait_terminate = FALSE; + di->decoder_state = SRD_OK; /* * Strictly speaking initialization of statically allocated @@ -471,6 +472,7 @@ static void srd_inst_reset_state(struct srd_decoder_inst *di) di->got_new_samples = FALSE; di->handled_all_samples = FALSE; di->want_wait_terminate = FALSE; + di->decoder_state = SRD_OK; /* Conditions and mutex got reset after joining the thread. */ } @@ -1032,6 +1034,9 @@ static gpointer di_thread(gpointer data) py_res = PyObject_CallMethod(di->py_inst, "decode", NULL); srd_dbg("%s: decode() method terminated.", di->inst_id); + if (!py_res) + di->decoder_state = SRD_ERR; + /* * Make sure to unblock potentially pending srd_inst_decode() * calls in application threads after the decode() method might @@ -1272,7 +1277,7 @@ SRD_PRIV int srd_inst_terminate_reset(struct srd_decoder_inst *di) return ret; } - return SRD_OK; + return di->decoder_state; } /** @private */ diff --git a/libsigrokdecode.h b/libsigrokdecode.h index a26bce9..deba470 100644 --- a/libsigrokdecode.h +++ b/libsigrokdecode.h @@ -277,6 +277,9 @@ struct srd_decoder_inst { /** Requests termination of wait() and decode(). */ gboolean want_wait_terminate; + /** Indicates the current state of the decoder stack. */ + int decoder_state; + GCond got_new_samples_cond; GCond handled_all_samples_cond; GMutex data_mutex; |