| 122 | } |
| 123 | |
| 124 | static int srd_inst_send_meta(struct srd_decoder_inst *di, int key, |
| 125 | GVariant *data) |
| 126 | { |
| 127 | PyObject *py_ret; |
| 128 | GSList *l; |
| 129 | struct srd_decoder_inst *next_di; |
| 130 | int ret; |
| 131 | PyGILState_STATE gstate; |
| 132 | |
| 133 | if (key != SRD_CONF_SAMPLERATE) |
| 134 | /* This is the only key we pass on to the decoder for now. */ |
| 135 | return SRD_OK; |
| 136 | |
| 137 | gstate = PyGILState_Ensure(); |
| 138 | |
| 139 | if (PyObject_HasAttrString(di->py_inst, "metadata")) { |
| 140 | py_ret = PyObject_CallMethod(di->py_inst, "metadata", "lK", |
| 141 | (long)SRD_CONF_SAMPLERATE, |
| 142 | (unsigned long long)g_variant_get_uint64(data)); |
| 143 | Py_XDECREF(py_ret); |
| 144 | } |
| 145 | |
| 146 | PyGILState_Release(gstate); |
| 147 | |
| 148 | /* Push metadata to all the PDs stacked on top of this one. */ |
| 149 | for (l = di->next_di; l; l = l->next) { |
| 150 | next_di = l->data; |
| 151 | if ((ret = srd_inst_send_meta(next_di, key, data)) != SRD_OK) |
| 152 | return ret; |
| 153 | } |
| 154 | |
| 155 | return SRD_OK; |
| 156 | } |
| 157 | |
| 158 | /** |
| 159 | * Set a metadata configuration key in a session. |
no outgoing calls
no test coverage detected