| 595 | } |
| 596 | |
| 597 | static bool cdda_play_func2 (struct cdunit *cdu, int *outpos) |
| 598 | { |
| 599 | int cdda_pos = cdu->cdda_start; |
| 600 | int bufnum; |
| 601 | int oldplay; |
| 602 | int idleframes = 0; |
| 603 | int silentframes = 0; |
| 604 | bool foundsub; |
| 605 | int oldtrack = -1; |
| 606 | bool restart = false; |
| 607 | bool first = true; |
| 608 | |
| 609 | cdu->thread_active = true; |
| 610 | memset(&cdu->cas, 0, sizeof(struct cd_audio_state)); |
| 611 | |
| 612 | while (cdu->cdda_play == 0) |
| 613 | sleep_millis(10); |
| 614 | oldplay = -1; |
| 615 | |
| 616 | cdu->cda_bufon[0] = 0; |
| 617 | cdu->cda_bufon[1] = 0; |
| 618 | bufnum = 0; |
| 619 | |
| 620 | cdu->cda = new cda_audio (CDDA_BUFFERS, 2352, 44100); |
| 621 | |
| 622 | while (cdu->cdda_play > 0) { |
| 623 | |
| 624 | if (oldplay != cdu->cdda_play) { |
| 625 | struct cdtoc *t; |
| 626 | int sector, diff; |
| 627 | struct timespec ts1, ts2; |
| 628 | |
| 629 | idleframes = 0; |
| 630 | silentframes = 0; |
| 631 | foundsub = false; |
| 632 | clock_gettime(CLOCK_REALTIME, &ts1); |
| 633 | cdda_pos = cdu->cdda_start; |
| 634 | oldplay = cdu->cdda_play; |
| 635 | sector = cdu->cd_last_pos = cdda_pos; |
| 636 | t = findtoc (cdu, §or, false); |
| 637 | if (!t) { |
| 638 | sector = cdu->cd_last_pos = cdda_pos + 2 * 75; |
| 639 | t = findtoc (cdu, §or, false); |
| 640 | if (!t) { |
| 641 | write_log (_T("IMAGE CDDA: illegal sector number %d\n"), cdu->cdda_start); |
| 642 | setstate (cdu, AUDIO_STATUS_PLAY_ERROR, -1); |
| 643 | } else { |
| 644 | audio_unpack (cdu, t); |
| 645 | } |
| 646 | } else { |
| 647 | write_log (_T("IMAGE CDDA: playing from %d to %d, track %d ('%s', offset %lld, secoffset %d (%d))\n"), |
| 648 | cdu->cdda_start, cdu->cdda_end, t->track, t->fname, t->offset, sector, t->index1); |
| 649 | oldtrack = t->track; |
| 650 | audio_unpack (cdu, t); |
| 651 | } |
| 652 | idleframes = cdu->cdda_delay_frames; |
| 653 | while (cdu->cdda_paused && cdu->cdda_play > 0) { |
| 654 | sleep_millis(10); |
no test coverage detected