@@ -274,9 +274,8 @@ TEST(EventTest, FlipEventTest) {
274274
275275 // Now we can wait on the flip event equeue prepared earlier.
276276 OrbisKernelEvent ev {};
277- memset (&ev, 0 , sizeof (ev));
278- s32 count = 0 ;
279- result = handle->waitFlipEvent (&ev, 1 , &count, nullptr );
277+ s32 count = 0 ;
278+ result = handle->waitFlipEvent (&ev, 1 , &count, -1 );
280279 UNSIGNED_INT_EQUALS (0 , result);
281280 CHECK_EQUAL (1 , count);
282281
@@ -294,14 +293,10 @@ TEST(EventTest, FlipEventTest) {
294293 CHECK_EQUAL (0x100 , ev_data.flip_arg );
295294
296295 // Flip events only trigger once.
297- memset (&ev, 0 , sizeof (ev));
298- count = 0 ;
299- u32 timeout = 1000 ;
300- result = handle->waitFlipEvent (&ev, 1 , &count, &timeout);
296+ result = handle->waitFlipEvent (&ev, 1 , &count, 1000 );
301297 UNSIGNED_INT_EQUALS (ORBIS_KERNEL_ERROR_ETIMEDOUT, result);
302298
303299 // Check flip status
304- memset (&status, 0 , sizeof (status));
305300 result = handle->getStatus (&status);
306301 UNSIGNED_INT_EQUALS (0 , result);
307302
@@ -312,9 +307,8 @@ TEST(EventTest, FlipEventTest) {
312307 UNSIGNED_INT_EQUALS (0 , result);
313308
314309 // Now we can wait on the flip event equeue prepared earlier.
315- memset (&ev, 0 , sizeof (ev));
316310 count = 0 ;
317- result = handle->waitFlipEvent (&ev, 1 , &count, nullptr );
311+ result = handle->waitFlipEvent (&ev, 1 , &count, - 1 );
318312 UNSIGNED_INT_EQUALS (0 , result);
319313 CHECK_EQUAL (1 , count);
320314
@@ -329,14 +323,10 @@ TEST(EventTest, FlipEventTest) {
329323 CHECK_EQUAL (0x200 , ev_data.flip_arg );
330324
331325 // Flip events only trigger once.
332- memset (&ev, 0 , sizeof (ev));
333- count = 0 ;
334- timeout = 1000 ;
335- result = handle->waitFlipEvent (&ev, 1 , &count, &timeout);
326+ result = handle->waitFlipEvent (&ev, 1 , &count, 1000 );
336327 UNSIGNED_INT_EQUALS (ORBIS_KERNEL_ERROR_ETIMEDOUT, result);
337328
338329 // Check flip status
339- memset (&status, 0 , sizeof (status));
340330 result = handle->getStatus (&status);
341331 UNSIGNED_INT_EQUALS (0 , result);
342332
@@ -358,9 +348,7 @@ TEST(EventTest, FlipEventTest) {
358348 PrintFlipStatus (&status);
359349
360350 // Now we can wait on the flip event equeue prepared earlier.
361- memset (&ev, 0 , sizeof (ev));
362- count = 0 ;
363- result = handle->waitFlipEvent (&ev, 1 , &count, nullptr );
351+ result = handle->waitFlipEvent (&ev, 1 , &count, -1 );
364352 UNSIGNED_INT_EQUALS (0 , result);
365353 CHECK_EQUAL (1 , count);
366354
@@ -372,16 +360,13 @@ TEST(EventTest, FlipEventTest) {
372360 CHECK_EQUAL (0x100 , ev_data.flip_arg );
373361
374362 // Check flip status
375- memset (&status, 0 , sizeof (status));
376363 result = handle->getStatus (&status);
377364 UNSIGNED_INT_EQUALS (0 , result);
378365
379366 PrintFlipStatus (&status);
380367
381368 // We did two submits, so the video out event should fire again.
382- memset (&ev, 0 , sizeof (ev));
383- count = 0 ;
384- result = handle->waitFlipEvent (&ev, 1 , &count, nullptr );
369+ result = handle->waitFlipEvent (&ev, 1 , &count, -1 );
385370 UNSIGNED_INT_EQUALS (0 , result);
386371 CHECK_EQUAL (1 , count);
387372
@@ -393,7 +378,6 @@ TEST(EventTest, FlipEventTest) {
393378 CHECK_EQUAL (0x300 , ev_data.flip_arg );
394379
395380 // Check flip status
396- memset (&status, 0 , sizeof (status));
397381 result = handle->getStatus (&status);
398382 UNSIGNED_INT_EQUALS (0 , result);
399383
@@ -405,25 +389,17 @@ TEST(EventTest, FlipEventTest) {
405389 result = handle->flipFrame (0x500 );
406390 UNSIGNED_INT_EQUALS (0 , result);
407391
408- // Use sceVideoOutGetFlipStatus to wait for both flips to complete
409- memset (&status, 0 , sizeof (status));
410- result = handle->getStatus (&status);
392+ // Wait for all flips to occur
393+ result = handle->waitFlip ();
411394 UNSIGNED_INT_EQUALS (0 , result);
412- while (status.num_flip_pending != 0 ) {
413- sceKernelUsleep (1000 );
414-
415- memset (&status, 0 , sizeof (status));
416- result = handle->getStatus (&status);
417- UNSIGNED_INT_EQUALS (0 , result);
418- }
419395
420396 // Both flips are done, check status and event
397+ result = handle->getStatus (&status);
398+ UNSIGNED_INT_EQUALS (0 , result);
421399 PrintFlipStatus (&status);
422400
423401 // Check returned data
424- memset (&ev, 0 , sizeof (ev));
425- count = 0 ;
426- result = handle->waitFlipEvent (&ev, 1 , &count, nullptr );
402+ result = handle->waitFlipEvent (&ev, 1 , &count, -1 );
427403 UNSIGNED_INT_EQUALS (0 , result);
428404 CHECK_EQUAL (1 , count);
429405
@@ -435,9 +411,7 @@ TEST(EventTest, FlipEventTest) {
435411 CHECK_EQUAL (0x500 , ev_data.flip_arg );
436412
437413 // Shouldn't trigger again.
438- memset (&ev, 0 , sizeof (ev));
439- count = 0 ;
440- result = handle->waitFlipEvent (&ev, 1 , &count, &timeout);
414+ result = handle->waitFlipEvent (&ev, 1 , &count, 1000 );
441415 UNSIGNED_INT_EQUALS (ORBIS_KERNEL_ERROR_ETIMEDOUT, result);
442416
443417 // Now test EOP flips
@@ -448,21 +422,14 @@ TEST(EventTest, FlipEventTest) {
448422 result = handle->submitAndFlip (0x3000 );
449423 UNSIGNED_INT_EQUALS (0 , result);
450424
451- // Print status
452- do {
453- memset (&status, 0 , sizeof (status));
454- result = handle->getStatus (&status);
455- UNSIGNED_INT_EQUALS (0 , result);
456-
457- sceKernelUsleep (10000 );
458- } while (status.num_flip_pending != 0 );
425+ // Wait for all flips to occur
426+ result = handle->waitFlip ();
427+ UNSIGNED_INT_EQUALS (0 , result);
459428
460429 PrintFlipStatus (&status);
461430
462431 // Wait for EOP flip to occur.
463- memset (&ev, 0 , sizeof (ev));
464- count = 0 ;
465- result = handle->waitFlipEvent (&ev, 1 , &count, nullptr );
432+ result = handle->waitFlipEvent (&ev, 1 , &count, -1 );
466433 UNSIGNED_INT_EQUALS (0 , result);
467434 CHECK_EQUAL (1 , count);
468435
@@ -479,7 +446,6 @@ TEST(EventTest, FlipEventTest) {
479446 CHECK_EQUAL (0x3000 , ev_data.flip_arg );
480447
481448 // Print status again.
482- memset (&status, 0 , sizeof (status));
483449 result = handle->getStatus (&status);
484450 UNSIGNED_INT_EQUALS (0 , result);
485451 PrintFlipStatus (&status);
@@ -488,9 +454,7 @@ TEST(EventTest, FlipEventTest) {
488454 UNSIGNED_INT_EQUALS (0 , result);
489455
490456 // Wait for EOP flip to occur.
491- memset (&ev, 0 , sizeof (ev));
492- count = 0 ;
493- result = handle->waitFlipEvent (&ev, 1 , &count, nullptr );
457+ result = handle->waitFlipEvent (&ev, 1 , &count, -1 );
494458 UNSIGNED_INT_EQUALS (0 , result);
495459 CHECK_EQUAL (1 , count);
496460
@@ -501,7 +465,6 @@ TEST(EventTest, FlipEventTest) {
501465 CHECK_EQUAL (0x30000000000 , ev_data.flip_arg );
502466
503467 // Print status again.
504- memset (&status, 0 , sizeof (status));
505468 result = handle->getStatus (&status);
506469 UNSIGNED_INT_EQUALS (0 , result);
507470 PrintFlipStatus (&status);
@@ -515,20 +478,12 @@ TEST(EventTest, FlipEventTest) {
515478 result = handle->flipFrame (0x10000 );
516479 UNSIGNED_INT_EQUALS (0 , result);
517480
518- // Wait for flip
519- do {
520- memset (&status, 0 , sizeof (status));
521- result = handle->getStatus (&status);
522- UNSIGNED_INT_EQUALS (0 , result);
523-
524- sceKernelUsleep (10000 );
525- } while (status.num_flip_pending != 0 );
481+ // Wait for all flips to occur
482+ result = handle->waitFlip ();
483+ UNSIGNED_INT_EQUALS (0 , result);
526484
527485 OrbisKernelEvent events[2 ];
528- memset (events, 0 , sizeof (events));
529- count = 0 ;
530- timeout = 10000 ;
531- result = handle->waitFlipEvent (events, 2 , &count, &timeout);
486+ result = handle->waitFlipEvent (events, 2 , &count, 10000 );
532487 UNSIGNED_INT_EQUALS (0 , result);
533488 // Despite adding another flip event, we still only get the one event.
534489 CHECK_EQUAL (1 , count);
@@ -548,19 +503,11 @@ TEST(EventTest, FlipEventTest) {
548503 result = handle->flipFrame (0x10000 );
549504 UNSIGNED_INT_EQUALS (0 , result);
550505
551- // Wait for flip
552- do {
553- memset (&status, 0 , sizeof (status));
554- result = handle->getStatus (&status);
555- UNSIGNED_INT_EQUALS (0 , result);
556-
557- sceKernelUsleep (10000 );
558- } while (status.num_flip_pending != 0 );
506+ // Wait for all flips to occur
507+ result = handle->waitFlip ();
508+ UNSIGNED_INT_EQUALS (0 , result);
559509
560- memset (events, 0 , sizeof (events));
561- count = 0 ;
562- timeout = 10000 ;
563- result = handle->waitFlipEvent (events, 2 , &count, &timeout);
510+ result = handle->waitFlipEvent (events, 2 , &count, 10000 );
564511 UNSIGNED_INT_EQUALS (0 , result);
565512 // Despite adding another flip event, we still only get the one event.
566513 CHECK_EQUAL (1 , count);
@@ -572,6 +519,24 @@ TEST(EventTest, FlipEventTest) {
572519 CHECK (events[0 ].user_data != 0 );
573520 CHECK_EQUAL (2 , *(u64 *)events[0 ].user_data );
574521
522+ // Delete the event
523+ result = handle->deleteFlipEvent ();
524+ UNSIGNED_INT_EQUALS (0 , result);
525+
526+ // This should result in having no events.
527+ // Trigger a flip
528+ result = handle->flipFrame (0x10000 );
529+ UNSIGNED_INT_EQUALS (0 , result);
530+
531+ // Wait for all flips to occur
532+ result = handle->waitFlip ();
533+ UNSIGNED_INT_EQUALS (0 , result);
534+
535+ // Wait for event.
536+ result = handle->waitFlipEvent (events, 1 , &count, 10000 );
537+ // Since there's no event left, nothing will be triggered when the flip occurs.
538+ UNSIGNED_INT_EQUALS (ORBIS_KERNEL_ERROR_ETIMEDOUT, result);
539+
575540 // Clean up after test
576541 delete (handle);
577542}
0 commit comments