Changeset 48f7ca7f70c7228ce8863813aabe89e0f0ae848c
- Timestamp:
- 29/12/07 02:29:48
(1 year ago)
- Author:
- Pierre d'Herbemont <pdherbemont@videolan.org>
- git-committer:
- Pierre d'Herbemont <pdherbemont@videolan.org> 1198891788 +0000
- git-parent:
[8a7b94a1bbfa35cdfd9c5555e75362191546f991]
- git-author:
- Pierre d'Herbemont <pdherbemont@videolan.org> 1198891788 +0000
- Message:
control/media_instance.c:
* Implement MediaInstancePositionChanged? and MediaInstanceTimeChanged? accurately.
control/event.c:
* Register the all event types.
* Don't strdup() in libvlc_event_type_name().
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r7438482 |
r48f7ca7 |
|
| 306 | 306 | libvlc_MediaInstancePaused, |
|---|
| 307 | 307 | libvlc_MediaInstanceReachedEnd, |
|---|
| | 308 | libvlc_MediaInstanceTimeChanged, |
|---|
| 308 | 309 | libvlc_MediaInstancePositionChanged, |
|---|
| 309 | 310 | |
|---|
| … | … | |
| 369 | 370 | struct |
|---|
| 370 | 371 | { |
|---|
| 371 | | long int new_position; |
|---|
| | 372 | float new_position; |
|---|
| 372 | 373 | } media_instance_position_changed; |
|---|
| | 374 | struct |
|---|
| | 375 | { |
|---|
| | 376 | long int new_time; |
|---|
| | 377 | } media_instance_time_changed; |
|---|
| 373 | 378 | |
|---|
| 374 | 379 | /* media list */ |
|---|
| … | … | |
| 415 | 420 | int index; |
|---|
| 416 | 421 | } media_list_view_will_delete_item; |
|---|
| 417 | | /* media list view */ |
|---|
| | 422 | |
|---|
| | 423 | /* media discoverer */ |
|---|
| 418 | 424 | struct |
|---|
| 419 | 425 | { |
|---|
| r9bd2469 |
r48f7ca7 |
|
| 214 | 214 | EVENT(libvlc_MediaDescriptorPreparsedChanged), |
|---|
| 215 | 215 | EVENT(libvlc_MediaDescriptorFreed), |
|---|
| | 216 | EVENT(libvlc_MediaDescriptorStateChanged), |
|---|
| 216 | 217 | |
|---|
| 217 | 218 | EVENT(libvlc_MediaInstancePlayed), |
|---|
| 218 | 219 | EVENT(libvlc_MediaInstancePaused), |
|---|
| 219 | 220 | EVENT(libvlc_MediaInstanceReachedEnd), |
|---|
| | 221 | EVENT(libvlc_MediaInstanceTimeChanged), |
|---|
| 220 | 222 | EVENT(libvlc_MediaInstancePositionChanged), |
|---|
| 221 | 223 | |
|---|
| … | … | |
| 232 | 234 | EVENT(libvlc_MediaListPlayerPlayed), |
|---|
| 233 | 235 | EVENT(libvlc_MediaListPlayerNextItemSet), |
|---|
| 234 | | EVENT(libvlc_MediaListPlayerStopped) |
|---|
| | 236 | EVENT(libvlc_MediaListPlayerStopped), |
|---|
| | 237 | |
|---|
| | 238 | EVENT(libvlc_MediaDiscovererStarted), |
|---|
| | 239 | EVENT(libvlc_MediaDiscovererEnded) |
|---|
| 235 | 240 | #undef EVENT |
|---|
| 236 | 241 | }; |
|---|
| … | … | |
| 241 | 246 | if( event_type >= sizeof(event_type_to_name)/sizeof(event_type_to_name[0])) |
|---|
| 242 | 247 | return unkwown_event_name; |
|---|
| 243 | | return strdup(event_type_to_name[event_type]); |
|---|
| | 248 | return event_type_to_name[event_type]; |
|---|
| 244 | 249 | } |
|---|
| 245 | 250 | |
|---|
| r7f4c808 |
r48f7ca7 |
|
| 133 | 133 | libvlc_event_t event; |
|---|
| 134 | 134 | |
|---|
| 135 | | printf("input_state_changed!!!!!!!!\n"); |
|---|
| 136 | 135 | if( newval.i_int == oldval.i_int ) |
|---|
| 137 | 136 | return VLC_SUCCESS; /* No change since last time, don't propagate */ |
|---|
| … | … | |
| 148 | 147 | break; |
|---|
| 149 | 148 | case PLAYING_S: |
|---|
| 150 | | printf("PLAYING_S!!!!!!!!\n"); |
|---|
| 151 | 149 | libvlc_media_descriptor_set_state( p_mi->p_md, libvlc_Playing, NULL); |
|---|
| 152 | 150 | event.type = libvlc_MediaInstancePlayed; |
|---|
| … | … | |
| 174 | 172 | libvlc_media_instance_t * p_mi = p_userdata; |
|---|
| 175 | 173 | vlc_value_t val; |
|---|
| 176 | | |
|---|
| | 174 | |
|---|
| | 175 | if (!strncmp(psz_cmd, "intf", 4 /* "-change" no need to go further */)) |
|---|
| | 176 | { |
|---|
| | 177 | input_thread_t * p_input = (input_thread_t *)p_this; |
|---|
| | 178 | |
|---|
| | 179 | var_Get( p_input, "state", &val ); |
|---|
| | 180 | if( val.i_int != PLAYING_S ) |
|---|
| | 181 | return VLC_SUCCESS; /* Don't send the position while stopped */ |
|---|
| | 182 | |
|---|
| | 183 | var_Get( p_input, "position", &val ); |
|---|
| | 184 | } |
|---|
| | 185 | else |
|---|
| | 186 | val.i_time = newval.i_time; |
|---|
| | 187 | |
|---|
| | 188 | libvlc_event_t event; |
|---|
| | 189 | event.type = libvlc_MediaInstancePositionChanged; |
|---|
| | 190 | event.u.media_instance_position_changed.new_position = val.f_float; |
|---|
| | 191 | |
|---|
| | 192 | libvlc_event_send( p_mi->p_event_manager, &event ); |
|---|
| | 193 | return VLC_SUCCESS; |
|---|
| | 194 | } |
|---|
| | 195 | |
|---|
| | 196 | /* |
|---|
| | 197 | * input_time_changed (Private) (input var "intf-change" Callback) |
|---|
| | 198 | */ |
|---|
| | 199 | static int |
|---|
| | 200 | input_time_changed( vlc_object_t * p_this, char const * psz_cmd, |
|---|
| | 201 | vlc_value_t oldval, vlc_value_t newval, |
|---|
| | 202 | void * p_userdata ) |
|---|
| | 203 | { |
|---|
| | 204 | libvlc_media_instance_t * p_mi = p_userdata; |
|---|
| | 205 | vlc_value_t val; |
|---|
| | 206 | |
|---|
| 177 | 207 | if (!strncmp(psz_cmd, "intf", 4 /* "-change" no need to go further */)) |
|---|
| 178 | 208 | { |
|---|
| … | … | |
| 192 | 222 | |
|---|
| 193 | 223 | libvlc_event_t event; |
|---|
| 194 | | event.type = libvlc_MediaInstancePositionChanged; |
|---|
| 195 | | event.u.media_instance_position_changed.new_position = val.i_time; |
|---|
| | 224 | event.type = libvlc_MediaInstanceTimeChanged; |
|---|
| | 225 | event.u.media_instance_time_changed.new_time = val.i_time; |
|---|
| 196 | 226 | |
|---|
| 197 | 227 | libvlc_event_send( p_mi->p_event_manager, &event ); |
|---|
| … | … | |
| 248 | 278 | libvlc_event_manager_register_event_type( p_mi->p_event_manager, |
|---|
| 249 | 279 | libvlc_MediaInstancePositionChanged, p_e ); |
|---|
| | 280 | libvlc_event_manager_register_event_type( p_mi->p_event_manager, |
|---|
| | 281 | libvlc_MediaInstanceTimeChanged, p_e ); |
|---|
| 250 | 282 | |
|---|
| 251 | 283 | return p_mi; |
|---|
| … | … | |
| 496 | 528 | var_AddCallback( p_input_thread, "state", input_state_changed, p_mi ); |
|---|
| 497 | 529 | var_AddCallback( p_input_thread, "intf-change", input_position_changed, p_mi ); |
|---|
| | 530 | var_AddCallback( p_input_thread, "intf-change", input_time_changed, p_mi ); |
|---|
| 498 | 531 | |
|---|
| 499 | 532 | /* will be released in media_instance_release() */ |
|---|