- i_y_margin = i_render_height / 15;
- i_x_margin = i_y_margin + i_margin_right;
- i_y_margin += i_margin_top;
- i_width = i_render_width / 20;
- i_height = i_width;
- i_x = i_render_width - i_x_margin - i_width;
- i_y = i_y_margin;
-
- /* Create subpicture region and picture */
- CreatePicture( p_subpic, i_x, i_y, i_width, i_height );
-
- if( i_type == OSD_PAUSE_ICON )
- {
- int i_bar_width = i_width / 3;
- DrawRect( p_subpic, 0, 0, i_bar_width - 1, i_height -1, STYLE_FILLED );
- DrawRect( p_subpic, i_width - i_bar_width, 0,
- i_width - 1, i_height - 1, STYLE_FILLED );
- }
- else if( i_type == OSD_PLAY_ICON )
- {
- int i_mid = i_height >> 1;
- int i_delta = ( i_width - i_mid ) >> 1;
- int i_y2 = ( ( i_height - 1 ) >> 1 ) * 2;
- DrawTriangle( p_subpic, i_delta, 0, i_width - i_delta, i_y2,
- STYLE_FILLED );
- }
- else if( i_type == OSD_SPEAKER_ICON || i_type == OSD_MUTE_ICON )
- {
- int i_mid = i_height >> 1;
- int i_delta = ( i_width - i_mid ) >> 1;
- int i_y2 = ( ( i_height - 1 ) >> 1 ) * 2;
- DrawRect( p_subpic, i_delta, i_mid / 2, i_width - i_delta,
- i_height - 1 - i_mid / 2, STYLE_FILLED );
- DrawTriangle( p_subpic, i_width - i_delta, 0, i_delta, i_y2,
- STYLE_FILLED );
- if( i_type == OSD_MUTE_ICON )
- {
- uint8_t *p_a = p_subpic->p_region->p_picture->A_PIXELS;
- int i_pitch = p_subpic->p_region->p_picture->Y_PITCH;
- int i;
- for( i = 1; i < i_pitch; i++ )
- {
- int k = i + ( i_height - i - 1 ) * i_pitch;
- p_a[ k ] = 0xff - p_a[ k ];
- }
- }
+ subpicture_updater_sys_t *sys = malloc(sizeof(*sys));
+ if (!sys)
+ return;
+ sys->type = type;
+ sys->position = position;
+
+ subpicture_updater_t updater = {
+ .pf_validate = OSDWidgetValidate,
+ .pf_update = OSDWidgetUpdate,
+ .pf_destroy = OSDWidgetDestroy,
+ .p_sys = sys,
+ };
+ subpicture_t *subpic = subpicture_New(&updater);
+ if (!subpic) {
+ free(sys);
+ return;