Coverage Report

Created: 2026-11-20 08:13

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/qemu/replay/replay-audio.c
Line
Count
Source
1
/*
2
 * replay-audio.c
3
 *
4
 * Copyright (c) 2010-2017 Institute for System Programming
5
 *                         of the Russian Academy of Sciences.
6
 *
7
 * This work is licensed under the terms of the GNU GPL, version 2 or later.
8
 * See the COPYING file in the top-level directory.
9
 *
10
 */
11
12
#include "qemu/osdep.h"
13
#include "qemu/error-report.h"
14
#include "system/replay.h"
15
#include "replay-internal.h"
16
17
void replay_audio_out(size_t *played)
18
1.83M
{
19
1.83M
    if (replay_mode == REPLAY_MODE_RECORD) {
20
0
        g_assert(replay_mutex_locked());
21
0
        replay_save_instructions();
22
0
        replay_put_event(EVENT_AUDIO_OUT);
23
0
        replay_put_qword(*played);
24
1.83M
    } else if (replay_mode == REPLAY_MODE_PLAY) {
25
0
        g_assert(replay_mutex_locked());
26
0
        replay_account_executed_instructions();
27
0
        if (replay_next_event_is(EVENT_AUDIO_OUT)) {
28
0
            *played = replay_get_qword();
29
0
            replay_finish_event();
30
0
        } else {
31
0
            error_report("Missing audio out event in the replay log");
32
0
            abort();
33
0
        }
34
0
    }
35
1.83M
}
36
37
void replay_audio_in_start(size_t *nsamples)
38
2.15M
{
39
2.15M
    if (replay_mode == REPLAY_MODE_RECORD) {
40
0
        g_assert(replay_mutex_locked());
41
0
        replay_save_instructions();
42
0
        replay_put_event(EVENT_AUDIO_IN);
43
0
        replay_put_qword(*nsamples);
44
0
        replay_state.n_audio_samples = *nsamples;
45
2.15M
    } else if (replay_mode == REPLAY_MODE_PLAY) {
46
0
        g_assert(replay_mutex_locked());
47
0
        replay_account_executed_instructions();
48
0
        if (replay_next_event_is(EVENT_AUDIO_IN)) {
49
0
            *nsamples = replay_get_qword();
50
0
            replay_state.n_audio_samples = *nsamples;
51
0
        } else {
52
0
            error_report("Missing audio in event in the replay log");
53
0
            abort();
54
0
        }
55
0
    }
56
2.15M
}
57
58
void replay_audio_in_sample_lr(uint64_t *left, uint64_t *right)
59
300M
{
60
300M
    if (replay_mode == REPLAY_MODE_RECORD) {
61
0
        replay_put_qword(*left);
62
0
        replay_put_qword(*right);
63
300M
    } else if (replay_mode == REPLAY_MODE_PLAY) {
64
0
        *left = replay_get_qword();
65
0
        *right = replay_get_qword();
66
300M
    } else {
67
300M
        return;
68
300M
    }
69
70
300M
    assert(replay_state.n_audio_samples > 0);
71
0
    replay_state.n_audio_samples--;
72
0
}
73
74
void replay_audio_in_finish(void)
75
2.15M
{
76
2.15M
    assert(replay_state.n_audio_samples == 0);
77
78
2.15M
    if (replay_mode == REPLAY_MODE_PLAY) {
79
0
        replay_finish_event();
80
0
    }
81
2.15M
}