コード例 #1
0
ファイル: audio_queue.cpp プロジェクト: godexsoft/x2d
 void music_obj<audio_queue_driver>::buffer_callback(AudioQueueBufferRef buffer)
 {
     if (read_packets(buffer) == 0)
     {
         if(loop_)
         {
             packet_index_ = start_packet_index_;
             read_packets(buffer);
         }
     }
 }
コード例 #2
0
ファイル: log_data.c プロジェクト: adamselevan/dicio
void main() {

	
	bzero(&serial_tio, sizeof(serial_tio));

	port_fd = open(USB_PORT, O_RDWR | O_NOCTTY);
	if (port_fd < 0) {
		perror("Failed to open serial port");
		return;
	}

	serial_tio.c_cflag = BAUDRATE | DATABITS | STOPBITS | PARITYON | PARITY | CLOCAL| CREAD;
	serial_tio.c_iflag = IGNPAR;
	serial_tio.c_lflag = ICANON;
	serial_tio.c_cc[VMIN]= 1;
	serial_tio.c_cc[VTIME] = 0;
	tcflush(port_fd, TCIFLUSH);
	tcsetattr (port_fd, TCSANOW, &serial_tio);

	file = fopen("PacketLog.txt","w+");
	if(file < 0) {
	  perror("Failed to open file for writing");
	  return;
	}
	read_packets();
}
コード例 #3
0
ファイル: audio_queue.cpp プロジェクト: godexsoft/x2d
 void music_obj<audio_queue_driver>::prime()
 {
     UInt32 i;
     for (i = 0; i < NUM_BUFFERS; ++i) 
     {
         AudioQueueAllocateBuffer(queue_, BUFFER_SIZE_BYTES, &buffers_[i]);
         if (read_packets(buffers_[i]) == 0)
         {
             break;
         } 
     }
     
     UInt32 frames_primed;
     AudioQueuePrime(queue_, i, &frames_primed);
     
     LOG("Primed %d frames", frames_primed);
 }
コード例 #4
0
ファイル: main.c プロジェクト: Tachiorz/raspi-teletext
int main(int argc, char *argv[])
{
    int ret;
    VC_RECT_T       src_rect;
    VC_RECT_T       dst_rect;

    DISPMANX_UPDATE_HANDLE_T    update;
    uint32_t                    vc_image_ptr;

    bcm_host_init();

    display = vc_dispmanx_display_open( 0 );

    image = calloc( 1, PITCH * HEIGHT ); // buffer 0
    assert(image);

    // initialize image buffer with clock run in
    int n, m, clock = 0x275555;
    for (m=0; m<24; m++) {
        for (n=0; n<HEIGHT; n++) {
            ROW(n)[m] = clock&1;
        }
        clock = clock >> 1;
    }

    // fill up image with filler packets
    // get_packet will return filler because we haven't loaded the fifo yet.
    get_packet(ROW(0)+24);
    for (n=1; n<HEIGHT; n++) {
        memcpy(ROW(n)+24, ROW(0)+24, 336);
    }

    // set up some resources
    vc_dispmanx_rect_set( &image_rect, 0, 0, WIDTH, HEIGHT);
    for (n=0;n<3;n++) {
        resource[n] = vc_dispmanx_resource_create( TYPE, WIDTH, HEIGHT, &vc_image_ptr );
        assert( resource[n] );
        ret = vc_dispmanx_resource_set_palette(  resource[n], palette, 0, sizeof palette );
        assert( ret == 0 );
        ret = vc_dispmanx_resource_write_data(  resource[n], TYPE, PITCH, image, &image_rect );
        assert( ret == 0 );
    }
    vc_dispmanx_rect_set( &image_rect, OFFSET+24, 0, 336, HEIGHT); // from now on, only copy the parts that change

    update = vc_dispmanx_update_start( 10 );
    assert( update );

    vc_dispmanx_rect_set( &src_rect, 0, 0, WIDTH << 16, HEIGHT << 16 );
    vc_dispmanx_rect_set( &dst_rect, 0, 0, 720, HEIGHT );
    element = vc_dispmanx_element_add( update, display, 2000,
                                       &dst_rect, resource[2], &src_rect,
                                       DISPMANX_PROTECTION_NONE,
                                       NULL, NULL, VC_IMAGE_ROT0 );

    ret = vc_dispmanx_update_submit_sync( update );
    assert( ret == 0 );

    // BUG: clear any existing callbacks, even to other apps.
    // https://github.com/raspberrypi/userland/issues/218
    vc_dispmanx_vsync_callback(display, NULL, NULL);

    vc_dispmanx_vsync_callback(display, vsync, NULL);

    if (argc == 2 && argv[1][0] == '-') {
        while(read_packets()) {
            ;
        }
    } else {
        demo();
    }

    vc_dispmanx_vsync_callback(display, NULL, NULL); // disable callback

    update = vc_dispmanx_update_start( 10 );
    assert( update );
    ret = vc_dispmanx_element_remove( update, element );
    assert( ret == 0 );
    ret = vc_dispmanx_update_submit_sync( update );
    assert( ret == 0 );
    for (n=0; n<3; n++) {
        ret = vc_dispmanx_resource_delete( resource[0] );
        assert( ret == 0 );
    }
    ret = vc_dispmanx_display_close( display );
    assert( ret == 0 );

    return 0;
}