@@ -62,7 +62,7 @@ TizenResult AudioPlayer::Play() {
62
62
return TizenResult (ret, " player_start failed" );
63
63
}
64
64
should_play_ = false ;
65
- StartPositionUpdates ();
65
+ EmitPositionUpdates ();
66
66
break ;
67
67
}
68
68
default :
@@ -342,6 +342,10 @@ TizenResult AudioPlayer::PreparePlayer() {
342
342
return TizenResult ();
343
343
}
344
344
345
+ void AudioPlayer::EmitPositionUpdates () {
346
+ ecore_main_loop_thread_safe_call_async (StartPositionUpdates, this );
347
+ }
348
+
345
349
TizenResult AudioPlayer::ResetPlayer () {
346
350
player_state_e state;
347
351
auto result = GetPlayerState (state);
@@ -413,7 +417,7 @@ void AudioPlayer::OnPrepared(void *data) {
413
417
TizenResult (ret, " player_start failed" ).Message ());
414
418
return ;
415
419
}
416
- player->StartPositionUpdates ();
420
+ player->EmitPositionUpdates ();
417
421
player->should_play_ = false ;
418
422
}
419
423
@@ -457,14 +461,16 @@ void AudioPlayer::OnError(int code, void *data) {
457
461
player->error_listener_ (player->player_id_ , " Player error: " + error);
458
462
}
459
463
460
- void AudioPlayer::StartPositionUpdates () {
461
- if (!timer_) {
464
+ void AudioPlayer::StartPositionUpdates (void *data) {
465
+ auto *player = reinterpret_cast <AudioPlayer *>(data);
466
+ if (!player->timer_ ) {
462
467
// The audioplayers app facing package expects position
463
468
// update events to fire roughly every 200 milliseconds.
464
469
const double kTimeInterval = 0.2 ;
465
- timer_ = ecore_timer_add (kTimeInterval , OnPositionUpdate, this );
466
- if (!timer_) {
467
- error_listener_ (player_id_, " Failed to add postion update timer." );
470
+ player->timer_ = ecore_timer_add (kTimeInterval , OnPositionUpdate, data);
471
+ if (!player->timer_ ) {
472
+ player->error_listener_ (player->GetPlayerId (),
473
+ " Failed to add postion update timer." );
468
474
}
469
475
}
470
476
}
0 commit comments