meson: move accelerator dependency checks together
[qemu/ar7.git] / replay / replay-audio.c
blob91854f02ea0dc6e06adb08b0b1a6fab90501b314
1 /*
2 * replay-audio.c
4 * Copyright (c) 2010-2017 Institute for System Programming
5 * of the Russian Academy of Sciences.
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.
12 #include "qemu/osdep.h"
13 #include "qemu/error-report.h"
14 #include "sysemu/replay.h"
15 #include "replay-internal.h"
16 #include "audio/audio.h"
18 void replay_audio_out(size_t *played)
20 if (replay_mode == REPLAY_MODE_RECORD) {
21 g_assert(replay_mutex_locked());
22 replay_save_instructions();
23 replay_put_event(EVENT_AUDIO_OUT);
24 replay_put_qword(*played);
25 } else if (replay_mode == REPLAY_MODE_PLAY) {
26 g_assert(replay_mutex_locked());
27 replay_account_executed_instructions();
28 if (replay_next_event_is(EVENT_AUDIO_OUT)) {
29 *played = replay_get_qword();
30 replay_finish_event();
31 } else {
32 error_report("Missing audio out event in the replay log");
33 abort();
38 void replay_audio_in(size_t *recorded, void *samples, size_t *wpos, size_t size)
40 int pos;
41 uint64_t left, right;
42 if (replay_mode == REPLAY_MODE_RECORD) {
43 g_assert(replay_mutex_locked());
44 replay_save_instructions();
45 replay_put_event(EVENT_AUDIO_IN);
46 replay_put_qword(*recorded);
47 replay_put_qword(*wpos);
48 for (pos = (*wpos - *recorded + size) % size ; pos != *wpos
49 ; pos = (pos + 1) % size) {
50 audio_sample_to_uint64(samples, pos, &left, &right);
51 replay_put_qword(left);
52 replay_put_qword(right);
54 } else if (replay_mode == REPLAY_MODE_PLAY) {
55 g_assert(replay_mutex_locked());
56 replay_account_executed_instructions();
57 if (replay_next_event_is(EVENT_AUDIO_IN)) {
58 *recorded = replay_get_qword();
59 *wpos = replay_get_qword();
60 for (pos = (*wpos - *recorded + size) % size ; pos != *wpos
61 ; pos = (pos + 1) % size) {
62 left = replay_get_qword();
63 right = replay_get_qword();
64 audio_sample_from_uint64(samples, pos, left, right);
66 replay_finish_event();
67 } else {
68 error_report("Missing audio in event in the replay log");
69 abort();