/** @internal @This catches events of the glx pipe. * * @param uprobe pointer to probe * @param upipe pointer to pipe throwing the event * @param event event thrown * @param args optional event-specific parameters * @return an error code */ static int upipe_glxplayer_catch_glx(struct uprobe *uprobe, struct upipe *upipe, int event, va_list args) { switch (event) { case UPROBE_GLX_SINK_KEYPRESS: { struct upipe_glxplayer *glxplayer = container_of(uprobe, struct upipe_glxplayer, uprobe_glx_s); unsigned int signature = va_arg(args, unsigned int); assert(signature == UPIPE_GLX_SINK_SIGNATURE); unsigned long key = va_arg(args, unsigned long); switch (key) { case 27: case 'q': { upipe_notice_va(upipe, "exit key pressed (%d), exiting", key); upipe_release(glxplayer->upipe_src_xfer); upipe_mgr_release(glxplayer->src_xfer); break; } case ' ': { if (glxplayer->trickp) { if ( (glxplayer->paused = !glxplayer->paused) ) { upipe_notice(upipe, "Playback paused"); struct urational rate = { .num = 0, .den = 0 }; upipe_trickp_set_rate(glxplayer->upipe_trickp, rate); } else { upipe_notice(upipe, "Playback resumed"); struct urational rate = { .num = 1, .den = 1 }; upipe_trickp_set_rate(glxplayer->upipe_trickp, rate); } } break; } default: upipe_dbg_va(upipe, "key pressed (%d)", key); break; } return UBASE_ERR_NONE; } case UPROBE_GLX_SINK_KEYRELEASE: return UBASE_ERR_NONE; default: break; } return uprobe_throw_next(uprobe, upipe, event, args); }
static void upipe_dveo_asi_sink_stats(struct upipe *upipe) { struct upipe_dveo_asi_sink *upipe_dveo_asi_sink = upipe_dveo_asi_sink_from_upipe(upipe); int fd = upipe_dveo_asi_sink->fd; static uint64_t sum; sum += 188; //upipe_notice_va(upipe, "Wrote %"PRIu64" bytes into the card", sum); int val; if (ioctl(fd, ASI_IOC_TXGETEVENTS, &val) < 0) upipe_err_va(upipe, "ioctl TXGETEVENTS failed (%m)"); else { if (val & ASI_EVENT_TX_BUFFER) upipe_notice(upipe, "driver transmit buffer queue underrun"); if (val & ASI_EVENT_TX_FIFO) upipe_notice(upipe, "onboard transmit FIFO underrun"); if (val & ASI_EVENT_TX_DATA) { upipe_notice(upipe, "transmit data status change"); if (ioctl(fd, ASI_IOC_TXGETTXD, &val) < 0) upipe_err_va(upipe, "ioctl TXGETTXDfailed (%m)"); else upipe_notice_va(upipe, "transmitting: %d", val); } } if (ioctl(fd, ASI_IOC_TXGETBUFLEVEL, &val) < 0) upipe_err_va(upipe, "ioctl TXGETBUFLEVEL failed (%m)"); else { static int old; #define MARGIN 2 if ((val - MARGIN) > old || (val + MARGIN) < old) { float secs = (float)val * 6 * 196 * 8 / 10500000; upipe_notice_va(upipe, "buf level %d -> %.2fs", val, secs); old = val; } } if (ioctl(fd, ASI_IOC_TXGETBYTECOUNT, &val) < 0) upipe_err_va(upipe, "ioctl TXGETBYTECOUNTfailed (%m)"); else { /*static uint64_t byte_sum; byte_sum += val; upipe_notice_va(upipe, "byte count %d -> %"PRIu64, val, byte_sum);*/ } }
/** @internal @This destroys the current audioqueue * @param upipe description structure of the pipe */ static void upipe_osx_audioqueue_sink_remove(struct upipe *upipe) { struct upipe_osx_audioqueue_sink *osx_audioqueue = upipe_osx_audioqueue_sink_from_upipe(upipe); if (unlikely(!osx_audioqueue->queue)) { return; } AudioQueueStop(osx_audioqueue->queue, true); AudioQueueDispose(osx_audioqueue->queue, true); osx_audioqueue->queue = NULL; upipe_notice(upipe, "audioqueue destroyed"); }
static void upipe_dump_input(struct upipe *upipe, struct uref *uref, struct upump **upump_p) { struct upipe_dump *upipe_dump = upipe_dump_from_upipe(upipe); uref_dump(uref, upipe->uprobe); size_t total_size; ubase_assert(uref_block_size(uref, &total_size)); upipe_notice_va(upipe, "dumping ubuf %p of size %zu", uref->ubuf, total_size); if (upipe_dump->max_len != (size_t)-1 && total_size > upipe_dump->max_len) total_size = upipe_dump->max_len; unsigned int count = 0; uint8_t line[16]; int offset = 0; while (total_size) { const uint8_t *buf; int size = total_size; ubase_assert(uref_block_read(uref, offset, &size, &buf)); assert(size != 0); total_size -= size; for (unsigned i = 0; i < size; i++, count++) { line[count % 16] = buf[i]; if (!((count + 1) % 16) || (!total_size && (i + 1 == size))) upipe_dump_line(upipe, count - (count % 16), line, (count % 16) + 1); } ubase_assert(uref_block_unmap(uref, offset)); offset += size; } #define UPIPE_DUMP_SEP \ "--------------------------------------------" \ "-------------------------------------------" upipe_notice(upipe, UPIPE_DUMP_SEP); upipe_dump_output(upipe, uref, upump_p); }
/** @internal @This sets the dvbcsa key. * * @param upipe description structure of the pipe * @param key dvbcsa key to set * @return an error code */ static int upipe_dvbcsa_enc_set_key(struct upipe *upipe, const char *key) { struct upipe_dvbcsa_enc *upipe_dvbcsa_enc = upipe_dvbcsa_enc_from_upipe(upipe); dvbcsa_key_free(upipe_dvbcsa_enc->key); upipe_dvbcsa_enc->key = NULL; if (!key) return UBASE_ERR_NONE; struct ustring_dvbcsa_cw cw = ustring_to_dvbcsa_cw(ustring_from_str(key)); if (unlikely(ustring_is_empty(cw.str) || strlen(key) != cw.str.len)) return UBASE_ERR_INVALID; upipe_notice(upipe, "key chanhed"); upipe_dvbcsa_enc->key = dvbcsa_key_alloc(); UBASE_ALLOC_RETURN(upipe_dvbcsa_enc->key); dvbcsa_key_set(cw.value, upipe_dvbcsa_enc->key); return UBASE_ERR_NONE; }
static uint64_t upipe_dveo_asi_sink_now(struct uclock *uclock) { struct upipe_dveo_asi_sink *upipe_dveo_asi_sink = upipe_dveo_asi_sink_from_uclock(uclock); if (upipe_dveo_asi_sink->fd < 0) return 0; unsigned int val; struct upipe *upipe = &upipe_dveo_asi_sink->upipe; if (ioctl(upipe_dveo_asi_sink->fd, ASI_IOC_TXGET27COUNT, &val) < 0) { upipe_err_va(upipe, "can't get hardware clock (%m)"); return 0; } if (val < upipe_dveo_asi_sink->last_val) { upipe_notice(upipe, "clock wrapping"); upipe_dveo_asi_sink->wraparounds++; } upipe_dveo_asi_sink->last_val = val; return (upipe_dveo_asi_sink->wraparounds << 32) + val; }