/** * @brief Scroll vertically a section of the screen. * @note Optional. * @note If x,y + cx,cy is off the screen, the result is undefined. * @note If lines is >= cy, it is equivelent to a area fill with bgcolor. * * @param[in] x, y The start of the area to be scrolled * @param[in] cx, cy The size of the area to be scrolled * @param[in] lines The number of lines to scroll (Can be positive or negative) * @param[in] bgcolor The color to fill the newly exposed area. * * @notapi */ void GDISP_LLD(verticalscroll)(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor) { /* This is marked as "TODO: Test this" in the original GLCD driver. * For now we just leave the GDISP_HARDWARE_SCROLL off. */ static color_t buf[((GDISP_SCREEN_HEIGHT > GDISP_SCREEN_WIDTH ) ? GDISP_SCREEN_HEIGHT : GDISP_SCREEN_WIDTH)]; coord_t row0, row1; unsigned i, gap, abslines; #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; x = GDISP.clipx0; } if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; y = GDISP.clipy0; } if (!lines || cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; if (x+cx > GDISP.clipx1) cx = GDISP.clipx1 - x; if (y+cy > GDISP.clipy1) cy = GDISP.clipy1 - y; #endif abslines = lines < 0 ? -lines : lines; acquire_bus(); if (abslines >= cy) { abslines = cy; gap = 0; } else { gap = cy - abslines; for(i = 0; i < gap; i++) { if(lines > 0) { row0 = y + i + lines; row1 = y + i; } else { row0 = (y - i - 1) + lines; row1 = (y - i - 1); } /* read row0 into the buffer and then write at row1*/ set_viewport(x, row0, cx, 1); lld_lcdReadStreamStart(); lld_lcdReadStream(buf, cx); lld_lcdReadStreamStop(); set_viewport(x, row1, cx, 1); stream_start(); write_data(buf, cx); stream_stop(); } } /* fill the remaining gap */ set_viewport(x, lines > 0 ? (y+gap) : y, cx, abslines); stream_start(); gap = cx*abslines; for(i = 0; i < gap; i++) write_data(bgcolor); stream_stop(); reset_viewport(); release_bus(); }
/** * @brief Scroll vertically a section of the screen. * @note Optional. * @note If x,y + cx,cy is off the screen, the result is undefined. * @note If lines is >= cy, it is equivelent to a area fill with bgcolor. * * @param[in] x, y The start of the area to be scrolled * @param[in] cx, cy The size of the area to be scrolled * @param[in] lines The number of lines to scroll (Can be positive or negative) * @param[in] bgcolor The color to fill the newly exposed area. * * @notapi */ void lld_gdisp_vertical_scroll(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor) { static color_t buf[((GDISP_SCREEN_HEIGHT > GDISP_SCREEN_WIDTH ) ? GDISP_SCREEN_HEIGHT : GDISP_SCREEN_WIDTH)]; coord_t row0, row1; unsigned i, gap, abslines, j; #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; x = GDISP.clipx0; } if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; y = GDISP.clipy0; } if (!lines || cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; if (x+cx > GDISP.clipx1) cx = GDISP.clipx1 - x; if (y+cy > GDISP.clipy1) cy = GDISP.clipy1 - y; #endif abslines = lines < 0 ? -lines : lines; acquire_bus(); if (abslines >= cy) { abslines = cy; gap = 0; } else { gap = cy - abslines; for(i = 0; i < gap; i++) { if(lines > 0) { row0 = y + i + lines; row1 = y + i; } else { row0 = (y - i - 1) + lines; row1 = (y - i - 1); } /* read row0 into the buffer and then write at row1*/ set_viewport(x, row0, cx, 1); stream_start(); j = read_data(); // dummy read for (j = 0; j < cx; j++) buf[j] = read_data(); stream_stop(); set_viewport(x, row1, cx, 1); stream_start(); for (j = 0; j < cx; j++) write_data(buf[j]); stream_stop(); } } /* fill the remaining gap */ set_viewport(x, lines > 0 ? (y+gap) : y, cx, abslines); stream_start(); gap = cx*abslines; for(i = 0; i < gap; i++) write_data(bgcolor); stream_stop(); release_bus(); }
void CLS_DlgStreamPusher::event_loop(struct_stream_info *_pstrct_streaminfo) { if (NULL == _pstrct_streaminfo){ TRACE("NULL == _pstrct_streaminfo"); return; } SDL_Event event; double incr, pos, frac; for (;;) { double x; //判断退出 if (_pstrct_streaminfo->m_abort_request){ break; } SDL_WaitEvent(&event); switch (event.type) { case FF_AUDIO_REFRESH_EVENT: screen_refresh(event.user.data1); _pstrct_streaminfo->m_refresh = 0; break; case FF_VIDEO_REFRESH_EVENT: break; case FF_BREAK_EVENT: break; case FF_QUIT_EVENT: stream_stop(event.user.data1); break; default: break; } } }
/** * @brief Fill an area with a bitmap. * @note Optional - The high level driver can emulate using software. * * @param[in] x, y The start filled area * @param[in] cx, cy The width and height to be filled * @param[in] srcx, srcy The bitmap position to start the fill from * @param[in] srccx The width of a line in the bitmap. * @param[in] buffer The pixels to use to fill the area. * * @notapi */ void GDISP_LLD(blitareaex)(coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, coord_t srcy, coord_t srccx, const pixel_t *buffer) { coord_t endx, endy; unsigned lg; #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; srcx += GDISP.clipx0 - x; x = GDISP.clipx0; } if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; srcy += GDISP.clipy0 - y; y = GDISP.clipy0; } if (srcx+cx > srccx) cx = srccx - srcx; if (cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; if (x+cx > GDISP.clipx1) cx = GDISP.clipx1 - x; if (y+cy > GDISP.clipy1) cy = GDISP.clipy1 - y; #endif acquire_bus(); set_viewport(x, y, cx, cy); stream_start(); endx = srcx + cx; endy = y + cy; lg = srccx - cx; buffer += srcx + srcy * srccx; for(; y < endy; y++, buffer += lg) for(x=srcx; x < endx; x++) write_data(*buffer++); stream_stop(); reset_viewport(); release_bus(); }
/** * @brief Fill an area with a color. * @note Optional - The high level driver can emulate using software. * * @param[in] x, y The start filled area * @param[in] cx, cy The width and height to be filled * @param[in] color The color of the fill * * @notapi */ void GDISP_LLD(fillarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) { unsigned i, area; #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; x = GDISP.clipx0; } if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; y = GDISP.clipy0; } if (cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return; if (x+cx > GDISP.clipx1) cx = GDISP.clipx1 - x; if (y+cy > GDISP.clipy1) cy = GDISP.clipy1 - y; #endif area = cx*cy; acquire_bus(); set_viewport(x, y, cx, cy); stream_start(); for(i = 0; i < area; i++) write_data(color); stream_stop(); reset_viewport(); release_bus(); }
void snd_usb_caiaq_audio_free(struct snd_usb_caiaqdev *dev) { debug("%s(%p)\n", __func__, dev); stream_stop(dev); free_urbs(dev->data_urbs_in); free_urbs(dev->data_urbs_out); kfree(dev->data_cb_info); }
static int snd_usb_caiaq_pcm_prepare(struct snd_pcm_substream *substream) { int bytes_per_sample, bpp, ret, i; int index = substream->number; struct snd_usb_caiaqdev *dev = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime; debug("%s(%p)\n", __func__, substream); if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { dev->period_out_count[index] = BYTES_PER_SAMPLE + 1; dev->audio_out_buf_pos[index] = BYTES_PER_SAMPLE + 1; } else { int in_pos = (dev->spec.data_alignment == 2) ? 0 : 2; dev->period_in_count[index] = BYTES_PER_SAMPLE + in_pos; dev->audio_in_buf_pos[index] = BYTES_PER_SAMPLE + in_pos; } if (dev->streaming) return 0; /* the first client that opens a stream defines the sample rate * setting for all subsequent calls, until the last client closed. */ for (i=0; i < ARRAY_SIZE(rates); i++) if (runtime->rate == rates[i]) dev->pcm_info.rates = 1 << i; snd_pcm_limit_hw_rates(runtime); bytes_per_sample = BYTES_PER_SAMPLE; if (dev->spec.data_alignment == 2) bytes_per_sample++; bpp = ((runtime->rate / 8000) + CLOCK_DRIFT_TOLERANCE) * bytes_per_sample * CHANNELS_PER_STREAM * dev->n_streams; if (bpp > MAX_ENDPOINT_SIZE) bpp = MAX_ENDPOINT_SIZE; ret = snd_usb_caiaq_set_audio_params(dev, runtime->rate, runtime->sample_bits, bpp); if (ret) return ret; ret = stream_start(dev); if (ret) return ret; dev->output_running = 0; wait_event_timeout(dev->prepare_wait_queue, dev->output_running, HZ); if (!dev->output_running) { stream_stop(dev); return -EPIPE; } return 0; }
void appDeinit() { INFO("shutting down application...\n"); gAppAlive = 0; // all threads should implement a loop polling gAppAlive stream_stop(); INFO("application was cleanly exited\n"); }
/** * @brief Clear the display. * @note Optional - The high level driver can emulate using software. * * @param[in] color The color of the pixel * * @notapi */ void lld_gdisp_clear(color_t color) { unsigned i; acquire_bus(); reset_viewport(); set_cursor(0, 0); stream_start(); for(i = 0; i < GDISP_SCREEN_WIDTH * GDISP_SCREEN_HEIGHT; i++) write_data(color); stream_stop(); release_bus(); }
/** * @brief Clear the display. * @note Optional - The high level driver can emulate using software. * * @param[in] color The color of the pixel * * @notapi */ void GDISP_LLD(clear)(color_t color) { unsigned i; acquire_bus(); set_cursor(0, 0); stream_start(); for(i = 0; i < GDISP_SCREEN_WIDTH * GDISP_SCREEN_HEIGHT; i++) write_data(color); stream_stop(); release_bus(); }
static int snd_usb_caiaq_substream_close(struct snd_pcm_substream *substream) { struct snd_usb_caiaqdev *dev = snd_pcm_substream_chip(substream); debug("%s(%p)\n", __func__, substream); if (all_substreams_zero(dev->sub_playback) && all_substreams_zero(dev->sub_capture)) { /* when the last client has stopped streaming, * all sample rates are allowed again */ stream_stop(dev); dev->pcm_info.rates = dev->samplerates; } return 0; }
/** * @brief Get the color of a particular pixel. * @note Optional. * @note If x,y is off the screen, the result is undefined. * * @param[in] x, y The pixel to be read * * @notapi */ color_t lld_gdisp_get_pixel_color(coord_t x, coord_t y) { color_t color; #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP if (x < 0 || x >= GDISP.Width || y < 0 || y >= GDISP.Height) return 0; #endif acquire_bus(); set_cursor(x, y); stream_start(); color = read_data(); // dummy read color = read_data(); stream_stop(); release_bus(); return color; }
/** * @brief Get the color of a particular pixel. * @note Optional. * @note If x,y is off the screen, the result is undefined. * * @param[in] x, y The start of the text * * @notapi */ color_t GDISP_LLD(getpixelcolor)(coord_t x, coord_t y) { /* This routine is marked "DO NOT USE" in the original * GLCD driver. We just keep our GDISP_HARDWARE_READPIXEL * turned off for now. */ color_t color; #if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP if (x < 0 || x >= GDISP.Width || y < 0 || y >= GDISP.Height) return 0; #endif aquire_bus(); set_cursor(x, y); stream_start(); color = lld_lcdReadData(); color = lld_lcdReadData(); stream_stop(); release_bus(); return color; }
/* API: Destroy stream. */ static pj_status_t stream_destroy(pjmedia_aud_stream *strm) { struct mda_stream *stream = (struct mda_stream*)strm; PJ_ASSERT_RETURN(stream, PJ_EINVAL); stream_stop(strm); delete stream->in_engine; stream->in_engine = NULL; delete stream->out_engine; stream->out_engine = NULL; pj_pool_t *pool; pool = stream->pool; if (pool) { stream->pool = NULL; pj_pool_release(pool); } return PJ_SUCCESS; }
/* Call this function as a thread to handle playback. Playback will stop and this thread will return when you call sndmp3_shutdown(). */ static void sndmp3_thread() { int sj; /* Main command loop */ while(sndmp3_status != STATUS_QUIT) { switch(sndmp3_status) { case STATUS_INIT: sndmp3_status = STATUS_READY; break; case STATUS_READY: printf("sndserver: waiting on semaphore\r\n"); sem_wait(sndmp3_halt_sem); printf("sndserver: released from semaphore\r\n"); break; case STATUS_STARTING: /* Initialize streaming driver */ if (stream_init(mpglib_callback) < 0) { sndmp3_status = STATUS_READY; } else { /* stream_start(decinfo.samprate, decinfo.channels - 1); */ stream_start(44100, 1); sndmp3_status = STATUS_PLAYING; } break; case STATUS_REINIT: /* Re-initialize streaming driver */ stream_init(NULL); sndmp3_status = STATUS_READY; break; case STATUS_PLAYING: { sj = jiffies; if (stream_poll() < 0) { if (sndmp3_loop) { printf("sndserver: restarting '%s'\r\n", mp3_last_fn); if (mpglib_init(mp3_last_fn) < 0) { sndmp3_status = STATUS_STOPPING; mp3_last_fn[0] = 0; } } else { printf("sndserver: not restarting\r\n"); stream_stop(); sndmp3_status = STATUS_READY; mp3_last_fn[0] = 0; } // stream_start(); } if (sj == jiffies) thd_pass(); break; } case STATUS_STOPPING: stream_stop(); sndmp3_status = STATUS_READY; break; } } /* Done: clean up */ mpglib_shutdown(); stream_shutdown(); sndmp3_status = STATUS_ZOMBIE; }
int main(int argc, char *argv[]) { int idx, tus; unsigned long ss; struct timeval ts, te; char cappath[128]; if(argc >= 2) { strcpy(cappath, argv[1]); } else { strcpy(cappath, dev_cap); } signal(SIGQUIT, exit_signal); signal(SIGINT, exit_signal); signal(SIGPIPE, SIG_IGN); if(enc_init(CAP_WIDTH, CAP_HEIGHT, FPS_VIDEO, VPU_V_AVC) < 0) { printf("enc_init error\n"); return -1; } if ((fd_cap = open(cappath, O_RDWR)) < 0) { printf("Unable to open [%s]\n", cappath); goto err; } if (setup_cap() < 0) { printf("Unable to setup capture\n"); goto err0; } printf("capture device setup done\n"); if(display_init(dev_out) < 0) { printf("display_init err\n"); goto err0; } if (map_buffers() < 0) { printf("Unable to map v4l2 memory\n"); goto err1; } printf("buffers mapping done\n"); if (stream_start() < 0) { printf("Unable to start stream\n"); goto err2; } printf("Stream starting... with fps=%d\n", FPS_VIDEO); static int xxx = 0; gettimeofday(&ts, 0); fd_enc = open("myenc.h264", O_RDWR | O_CREAT | O_TRUNC, 0666); do { idx = frame_get(); frame_render(idx); frame_put(idx); gettimeofday(&te, 0); tus = (te.tv_sec - ts.tv_sec) * 1000000 + (te.tv_usec - ts.tv_usec); if(tus <= FRAME_DURATION) { if(!exitflag) usleep(FRAME_DURATION - tus); } else { printf("rander a frame with %.3fms\n", tus / 1000.0); } // printf("rander a frame with %.3fms\n", tus / 1000.0); gettimeofday(&ts, 0); } while(!exitflag); close(fd_enc); printf("Stopping stream...\n"); stream_stop(); err2: umap_buffers(); err1: display_exit(); err0: close(fd_cap); err: enc_exit(); return 0; }
int main(int argc, char *argv[]) { int idx, tus, fsize; char capdev_str[128]; unsigned long ss; struct timeval ts, te; if(argc > 1) { // printf(" Usage : %s [file_path]\n", argv[0]); strcpy(capdev_str, argv[1]); } else { strcpy(capdev_str, dev_cap); } signal(SIGQUIT, exit_signal); signal(SIGINT, exit_signal); signal(SIGPIPE, SIG_IGN); if(display_init() < 0) { printf("display init error\n"); return 0; } if(dec_init(CAP_WIDTH, CAP_HEIGHT, VPU_V_MJPG) < 0) { printf("decodec init error\n"); goto err; } if ((fd_cap = open(capdev_str, O_RDWR)) < 0) { printf("Unable to open [%s]\n", capdev_str); goto err0; } if (setup_cap() < 0) { printf("Unable to setup capture\n"); goto err1; } printf("capture device setup done\n"); if (map_buffers() < 0) { printf("Unable to map I/O memory\n"); goto err1; } printf("buffers mapping done\n"); if (stream_start() < 0) { printf("Unable to start stream\n"); goto err2; } printf("Stream starting... with fps=%d\n", FPS_VIDEO); gettimeofday(&ts, 0); do { idx = frame_get(&fsize); frame_render(idx, fsize); frame_put(idx); gettimeofday(&te, 0); tus = (te.tv_sec - ts.tv_sec) * 1000000 + (te.tv_usec - ts.tv_usec); if(tus <= FRAME_DURATION) { if(!exitflag) usleep(FRAME_DURATION - tus); } else { // printf("rander a frame with %.3fms\n", tus / 1000.0); } printf("Rander a frame sz = %d, takes %.3fms\n", fsize, tus / 1000.0); gettimeofday(&ts, 0); } while(!exitflag); printf("Stopping stream...\n"); stream_stop(); err2: umap_buffers(); err1: close(fd_cap); err0: dec_exit(); err: display_exit(); return 0; }