static UINT32 audio_total_remaining_ms( void ) { UINT32 data_left = sx_pipe_len_get(SX_VRDMA_LPCM_SLICE) * 10; UINT32 queued_left = sx_audio_sink_ms_left_get(); // printf("total left = %u, data left = %u, queued left = %u\n", // data_left + queued_left, // data_left, // queued_left); return (data_left + queued_left); }
/** * Slice packing thread. * * @param arg */ void slice_packing_thread( void * arg ) { sSX_DESC *desc; desc = NULL; while(1) { UINT32 len = sx_pipe_len_get(SX_VRDMA_SLICE_READY); if(len >= 10) { // More than enough. Try again next iteration. goto next_iter; } UINT32 slices_to_dump = 10 - len; do { desc = sx_pipe_get(SX_VRDMA_SLICE); if(desc == NULL) { goto next_iter; } // Dump slice. video_scheduler_slice_dump(desc); slices_to_dump--; } while (slices_to_dump > 0); next_iter: usleep(2*1000); } }
// -------------------------------------------------------- // decoder_thread // Decoder thread // // Description: // This function defines the decoder thread. // void audio_scheduler_thread( void * arg ) { sSX_DESC *desc; while(1) { if(f_cblk.state == STATE_INACTIVE) { UINT32 len = sx_pipe_len_get(SX_VRDMA_LPCM_SLICE); if(len > (SX_SYSTEM_DELAY_MS / 10)) { f_cblk.state = STATE_ACTIVE; printf("(audio_scheduler): Transition to active. [len = %u]\n", len); goto next_iter; } } else { UINT32 data_left_ms = sx_pipe_len_get(SX_VRDMA_LPCM_SLICE) * 10; UINT32 queued_ms = sx_audio_sink_ms_left_get(); if((data_left_ms + queued_ms) == 0) { f_cblk.state = STATE_INACTIVE; printf("(audio_scheduler): Transition to inactive.\n"); goto next_iter; } if(queued_ms < 200) { UINT32 slices_to_queue = (200 - queued_ms + 10) / 10; do { // Get slice. desc = sx_pipe_get(SX_VRDMA_LPCM_SLICE); if(desc == NULL) { goto next_iter; } // Dump slice. audio_scheduler_slice_dump(desc); slices_to_queue--; } while(slices_to_queue > 0); } } next_iter: usleep(5*1000); } }