]> git.proxmox.com Git - mirror_qemu.git/blame - replay/replay-audio.c
Revert "audio: fix pc speaker init"
[mirror_qemu.git] / replay / replay-audio.c
CommitLineData
3d4d16f4
PD
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 "sysemu/replay.h"
15#include "replay-internal.h"
16#include "sysemu/sysemu.h"
17#include "audio/audio.h"
18
19void replay_audio_out(int *played)
20{
21 if (replay_mode == REPLAY_MODE_RECORD) {
d759c951 22 g_assert(replay_mutex_locked());
3d4d16f4 23 replay_save_instructions();
3d4d16f4
PD
24 replay_put_event(EVENT_AUDIO_OUT);
25 replay_put_dword(*played);
3d4d16f4 26 } else if (replay_mode == REPLAY_MODE_PLAY) {
d759c951 27 g_assert(replay_mutex_locked());
3d4d16f4 28 replay_account_executed_instructions();
3d4d16f4
PD
29 if (replay_next_event_is(EVENT_AUDIO_OUT)) {
30 *played = replay_get_dword();
31 replay_finish_event();
3d4d16f4 32 } else {
3d4d16f4
PD
33 error_report("Missing audio out event in the replay log");
34 abort();
35 }
36 }
37}
38
39void replay_audio_in(int *recorded, void *samples, int *wpos, int size)
40{
41 int pos;
42 uint64_t left, right;
43 if (replay_mode == REPLAY_MODE_RECORD) {
d759c951 44 g_assert(replay_mutex_locked());
3d4d16f4 45 replay_save_instructions();
3d4d16f4
PD
46 replay_put_event(EVENT_AUDIO_IN);
47 replay_put_dword(*recorded);
48 replay_put_dword(*wpos);
49 for (pos = (*wpos - *recorded + size) % size ; pos != *wpos
50 ; pos = (pos + 1) % size) {
51 audio_sample_to_uint64(samples, pos, &left, &right);
52 replay_put_qword(left);
53 replay_put_qword(right);
54 }
3d4d16f4 55 } else if (replay_mode == REPLAY_MODE_PLAY) {
d759c951 56 g_assert(replay_mutex_locked());
3d4d16f4 57 replay_account_executed_instructions();
3d4d16f4
PD
58 if (replay_next_event_is(EVENT_AUDIO_IN)) {
59 *recorded = replay_get_dword();
60 *wpos = replay_get_dword();
61 for (pos = (*wpos - *recorded + size) % size ; pos != *wpos
62 ; pos = (pos + 1) % size) {
63 left = replay_get_qword();
64 right = replay_get_qword();
65 audio_sample_from_uint64(samples, pos, left, right);
66 }
67 replay_finish_event();
3d4d16f4 68 } else {
3d4d16f4
PD
69 error_report("Missing audio in event in the replay log");
70 abort();
71 }
72 }
73}