@@ -58,7 +58,7 @@ void AudioPlayer::Play() {
58
58
throw AudioPlayerError (" player_start failed" , get_error_message (ret));
59
59
}
60
60
should_play_ = false ;
61
- EmitPositionUpdates ();
61
+ StartPositionUpdates ();
62
62
break ;
63
63
}
64
64
default :
@@ -284,10 +284,6 @@ void AudioPlayer::PreparePlayer() {
284
284
seeking_ = false ;
285
285
}
286
286
287
- void AudioPlayer::EmitPositionUpdates () {
288
- ecore_main_loop_thread_safe_call_async (StartPositionUpdates, this );
289
- }
290
-
291
287
void AudioPlayer::ResetPlayer () {
292
288
player_state_e state = GetPlayerState ();
293
289
switch (state) {
@@ -340,7 +336,7 @@ void AudioPlayer::OnPrepared(void *data) {
340
336
if (ret != PLAYER_ERROR_NONE) {
341
337
throw AudioPlayerError (" player_start failed" , get_error_message (ret));
342
338
}
343
- player->EmitPositionUpdates ();
339
+ player->StartPositionUpdates ();
344
340
player->should_play_ = false ;
345
341
}
346
342
@@ -381,16 +377,14 @@ void AudioPlayer::OnError(int code, void *data) {
381
377
player->error_listener_ (player->player_id_ , " Player error: " + error);
382
378
}
383
379
384
- void AudioPlayer::StartPositionUpdates (void *data) {
385
- auto *player = reinterpret_cast <AudioPlayer *>(data);
386
- if (!player->timer_ ) {
380
+ void AudioPlayer::StartPositionUpdates () {
381
+ if (!timer_) {
387
382
// The audioplayers app facing package expects position
388
383
// update events to fire roughly every 200 milliseconds.
389
384
const double kTimeInterval = 0.2 ;
390
- player->timer_ = ecore_timer_add (kTimeInterval , OnPositionUpdate, data);
391
- if (!player->timer_ ) {
392
- player->error_listener_ (player->GetPlayerId (),
393
- " Failed to add postion update timer." );
385
+ timer_ = ecore_timer_add (kTimeInterval , OnPositionUpdate, this );
386
+ if (!timer_) {
387
+ error_listener_ (player_id_, " Failed to add postion update timer." );
394
388
}
395
389
}
396
390
}
0 commit comments