26
26
27
27
#include <plugins/omxplayer_video_player.h>
28
28
29
+ #define LOG_ERROR (...) fprintf(stderr, "[omxplayer video player plugin] " __VA_ARGS__)
30
+ #ifdef DEBUG
31
+ # define LOG_DEBUG (...) fprintf(stderr, "[omxplayer video player plugin] " __VA_ARGS__)
32
+ #else
33
+ # define LOG_DEBUG (...) do {} while (0)
34
+ #endif
35
+
29
36
static struct {
30
37
bool initialized ;
31
38
@@ -190,18 +197,17 @@ static int on_mount(
190
197
zpos = -126 ;
191
198
}
192
199
193
-
194
200
struct aa_rect rect = get_aa_bounding_rect (params -> rect );
195
201
196
202
return cqueue_enqueue (
197
203
& player -> mgr -> task_queue ,
198
204
& (struct omxplayer_mgr_task ) {
199
205
.type = kUpdateView ,
200
206
.responsehandle = NULL ,
201
- .offset_x = rect .offset .x ,
202
- .offset_y = rect .offset .y ,
203
- .width = rect .size .x ,
204
- .height = rect .size .y ,
207
+ .offset_x = round ( rect .offset .x ) ,
208
+ .offset_y = round ( rect .offset .y ) ,
209
+ .width = round ( rect .size .x ) ,
210
+ .height = round ( rect .size .y ) ,
205
211
.zpos = zpos ,
206
212
.orientation = get_orientation_from_rotation (params -> rotation )
207
213
}
@@ -617,6 +623,8 @@ static void *mgr_entry(void *userdata) {
617
623
goto fail_kill_registered_player ;
618
624
}
619
625
626
+
627
+ LOG_DEBUG ("respond success on_create(). player_id: %" PRId64 "\n" , mgr -> player -> player_id );
620
628
// creation was a success! respond to the dart-side with our player id.
621
629
platch_respond_success_std (task .responsehandle , & STDINT64 (mgr -> player -> player_id ));
622
630
@@ -761,14 +769,19 @@ static void *mgr_entry(void *userdata) {
761
769
platch_respond_success_std (task .responsehandle , NULL );
762
770
} else if (task .type == kUpdateView ) {
763
771
char video_pos_str [256 ];
772
+
773
+ // Use integers here even if omxplayer supports floats because if we print floats,
774
+ // snprintf might use `,` as the decimal delimiter depending on the locale.
775
+ // This is only an issue because I set the application to be locale-aware using setlocale(LC_ALL, "")
776
+ // since that's needed for locale support.
764
777
snprintf (
765
778
video_pos_str ,
766
779
sizeof (video_pos_str ),
767
- "%f %f %f %f " ,
768
- ( double ) task .offset_x ,
769
- ( double ) task .offset_y ,
770
- ( double ) ( task .offset_x + task .width ) ,
771
- ( double ) ( task .offset_y + task .height )
780
+ "%d %d %d %d " ,
781
+ task .offset_x ,
782
+ task .offset_y ,
783
+ task .offset_x + task .width ,
784
+ task .offset_y + task .height
772
785
);
773
786
774
787
ok = sd_bus_call_method (
@@ -1019,6 +1032,8 @@ static int on_initialize(
1019
1032
return respond_init_failed (responsehandle );
1020
1033
}
1021
1034
1035
+ LOG_DEBUG ("on_initialize\n" );
1036
+
1022
1037
return platch_respond_success_std (responsehandle , NULL );
1023
1038
}
1024
1039
@@ -1110,6 +1125,15 @@ static int on_create(
1110
1125
);
1111
1126
}
1112
1127
1128
+ LOG_DEBUG (
1129
+ "on_create(sourceType: %s, asset: %s, uri: \"%s\", packageName: %s, formatHint: %s)\n" ,
1130
+ source_type == kDataSourceTypeAsset ? "asset" : source_type == kDataSourceTypeNetwork ? "network" : "file" ,
1131
+ asset ,
1132
+ uri ,
1133
+ package_name ,
1134
+ format_hint
1135
+ );
1136
+
1113
1137
mgr = calloc (1 , sizeof * mgr );
1114
1138
if (mgr == NULL ) {
1115
1139
return platch_respond_native_error_std (responsehandle , ENOMEM );
@@ -1209,6 +1233,8 @@ static int on_dispose(
1209
1233
return ok ;
1210
1234
}
1211
1235
1236
+ LOG_DEBUG ("on_dispose(%" PRId64 ")\n" , player -> player_id );
1237
+
1212
1238
return cqueue_enqueue (& player -> mgr -> task_queue , & (const struct omxplayer_mgr_task ) {
1213
1239
.type = kDispose ,
1214
1240
.responsehandle = responsehandle
@@ -1237,6 +1263,8 @@ static int on_set_looping(
1237
1263
);
1238
1264
}
1239
1265
1266
+ LOG_DEBUG ("on_set_looping(player_id: %" PRId64 ", looping: %s)\n" , player -> player_id , loop ? "yes" : "no" );
1267
+
1240
1268
return cqueue_enqueue (& player -> mgr -> task_queue , & (const struct omxplayer_mgr_task ) {
1241
1269
.type = kSetLooping ,
1242
1270
.loop = loop ,
@@ -1266,6 +1294,8 @@ static int on_set_volume(
1266
1294
);
1267
1295
}
1268
1296
1297
+ LOG_DEBUG ("on_set_volume(player_id: %" PRId64 ", volume: %f)\n" , player -> player_id , volume );
1298
+
1269
1299
return cqueue_enqueue (& player -> mgr -> task_queue , & (const struct omxplayer_mgr_task ) {
1270
1300
.type = kSetVolume ,
1271
1301
.volume = volume ,
@@ -1283,6 +1313,8 @@ static int on_play(
1283
1313
ok = get_player_from_map_arg (arg , & player , responsehandle );
1284
1314
if (ok != 0 ) return ok ;
1285
1315
1316
+ LOG_DEBUG ("on_play(player_id: %" PRId64 ")\n" , player -> player_id );
1317
+
1286
1318
return cqueue_enqueue (& player -> mgr -> task_queue , & (const struct omxplayer_mgr_task ) {
1287
1319
.type = kPlay ,
1288
1320
.responsehandle = responsehandle
@@ -1299,6 +1331,8 @@ static int on_get_position(
1299
1331
ok = get_player_from_map_arg (arg , & player , responsehandle );
1300
1332
if (ok != 0 ) return ok ;
1301
1333
1334
+ LOG_DEBUG ("on_get_position(player_id: %" PRId64 ")\n" , player -> player_id );
1335
+
1302
1336
return cqueue_enqueue (& player -> mgr -> task_queue , & (const struct omxplayer_mgr_task ) {
1303
1337
.type = kGetPosition ,
1304
1338
.responsehandle = responsehandle
@@ -1327,6 +1361,8 @@ static int on_seek_to(
1327
1361
);
1328
1362
}
1329
1363
1364
+ LOG_DEBUG ("on_seek_to(player_id: %" PRId64 ", position: %" PRId64 ")\n" , player -> player_id , position );
1365
+
1330
1366
return cqueue_enqueue (& player -> mgr -> task_queue , & (const struct omxplayer_mgr_task ) {
1331
1367
.type = kSetPosition ,
1332
1368
.position = position ,
@@ -1344,6 +1380,8 @@ static int on_pause(
1344
1380
ok = get_player_from_map_arg (arg , & player , responsehandle );
1345
1381
if (ok != 0 ) return ok ;
1346
1382
1383
+ LOG_DEBUG ("on_pause(player_id: %" PRId64 ")\n" , player -> player_id );
1384
+
1347
1385
return cqueue_enqueue (& player -> mgr -> task_queue , & (const struct omxplayer_mgr_task ) {
1348
1386
.type = kPause ,
1349
1387
.responsehandle = responsehandle
@@ -1371,10 +1409,11 @@ static int on_create_platform_view(
1371
1409
"Expected `arg['platformViewId']` to be an integer."
1372
1410
);
1373
1411
}
1412
+
1413
+ LOG_DEBUG ("on_create_platform_view(player_id: %" PRId64 ", platform view id: %" PRId64 ")\n" , player -> player_id , view_id );
1374
1414
1375
1415
if (player -> has_view ) {
1376
- fprintf (stderr , "[omxplayer_video_player plugin] Flutter attempted to register more than one platform view for one player instance.\n" );
1377
-
1416
+ LOG_ERROR ("Flutter attempted to register more than one platform view for one player instance.\n" );
1378
1417
return platch_respond_illegal_arg_std (
1379
1418
responsehandle ,
1380
1419
"Attempted to register more than one platform view for this player instance."
@@ -1421,22 +1460,16 @@ static int on_dispose_platform_view(
1421
1460
);
1422
1461
}
1423
1462
1463
+ LOG_DEBUG ("on_dispose_platform_view(player_id: %" PRId64 ", platform view id: %" PRId64 ")\n" , player -> player_id , view_id );
1464
+
1424
1465
if (player -> view_id != view_id ) {
1425
- fprintf (
1426
- stderr ,
1427
- "[omxplayer_video_player plugin] Flutter attempted to dispose an omxplayer platform view that is not associated with this player.\n"
1428
- );
1466
+ LOG_ERROR ("Flutter attempted to dispose an omxplayer platform view that is not associated with this player.\n" );
1429
1467
1430
1468
return platch_respond_illegal_arg_std (responsehandle , "Attempted to dispose on omxplayer view that is not associated with `arg['playerId']`." );
1431
1469
} else {
1432
1470
ok = compositor_remove_view_callbacks (view_id );
1433
1471
if (ok != 0 ) {
1434
- fprintf (
1435
- stderr ,
1436
- "[omxplayer_video_player plugin] Could not remove view callbacks for platform view %" PRId64 ". compositor_remove_view_callbacks: %s\n" ,
1437
- view_id ,
1438
- strerror (ok )
1439
- );
1472
+ LOG_ERROR ("Could not remove view callbacks for platform view %" PRId64 ". compositor_remove_view_callbacks: %s\n" , view_id , strerror (ok ));
1440
1473
return platch_respond_native_error_std (responsehandle , ok );
1441
1474
}
1442
1475
0 commit comments