mpegts_mux_t *mm = ms->s_dvb_mux;
mpegts_mux_instance_t *mmi = mm ? mm->mm_active : NULL;
mpegts_input_t *mi = mmi ? mmi->mmi_input : NULL;
- if (mi == NULL) {
+ if (mi == NULL || (mm->mm_tsdebug_fd < 0 && mm->mm_tsdebug_fd2 < 0)) {
free(tp);
- return;
+ goto end;
}
pthread_mutex_unlock(&t->s_stream_mutex);
- pthread_mutex_lock(&mi->mi_output_lock);
- tp->pos = mm->mm_tsdebug_pos;
memset(tp->pkt, 0xff, sizeof(tp->pkt));
tp->pkt[pos++] = 0x47; /* sync byte */
tp->pkt[pos++] = 0x1f; /* PID MSB */
tp->pkt[pos++] = (crc >> 16) & 0xff;
tp->pkt[pos++] = (crc >> 8) & 0xff;
tp->pkt[pos++] = crc & 0xff;
+ pthread_mutex_lock(&mm->mm_tsdebug_lock);
+ tp->pos = mm->mm_tsdebug_pos;
TAILQ_INSERT_HEAD(&mm->mm_tsdebug_packets, tp, link);
- pthread_mutex_unlock(&mi->mi_output_lock);
+ pthread_mutex_unlock(&mm->mm_tsdebug_lock);
return;
}
#endif
+end:
pthread_mutex_unlock(&t->s_stream_mutex);
}
/*
* Configuration
*/
- char *mm_crid_authority;
- int mm_enabled;
- int mm_epg;
- char *mm_charset;
- int mm_pmt_ac3;
- int mm_eit_tsid_nocheck;
+ char *mm_crid_authority;
+ int mm_enabled;
+ int mm_epg;
+ char *mm_charset;
+ int mm_pmt_ac3;
+ int mm_eit_tsid_nocheck;
uint16_t mm_sid_filter;
/*
* TSDEBUG
*/
#if ENABLE_TSDEBUG
- int mm_tsdebug_fd;
- int mm_tsdebug_fd2;
- off_t mm_tsdebug_pos;
+ pthread_mutex_t mm_tsdebug_lock;
+ int mm_tsdebug_fd;
+ int mm_tsdebug_fd2;
+ off_t mm_tsdebug_pos;
TAILQ_HEAD(, tsdebug_packet) mm_tsdebug_packets;
#endif
};
pktbuf_ref_dec(pb);
}
#if ENABLE_TSDEBUG
- {
+ if (mm->mm_tsdebug_fd >= 0 || mm->mm_tsdebug_fd2 >= 0) {
tsdebug_packet_t *tp, *tp_next;
off_t pos = 0;
size_t used = tsb - mpkt->mp_data;
+ pthread_mutex_lock(&mm->mm_tsdebug_lock);
for (tp = TAILQ_FIRST(&mm->mm_tsdebug_packets); tp; tp = tp_next) {
tp_next = TAILQ_NEXT(tp, link);
assert((tp->pos % 188) == 0);
}
if (pos < used && mm->mm_tsdebug_fd >= 0)
tvh_write(mm->mm_tsdebug_fd, mpkt->mp_data + pos, used - pos);
+ pthread_mutex_unlock(&mm->mm_tsdebug_lock);
}
#endif
mm->mm_last_pid = -1;
+#if ENABLE_TSDEBUG
+ pthread_mutex_init(&mm->mm_tsdebug_lock, NULL);
+ mm->mm_tsdebug_fd = mm->mm_tsdebug_fd2 = -1;
+#endif
+
/* Configuration */
if (conf)
idnode_load(&mm->mm_id, conf);