RetroArch
switch_audio_compat.h
Go to the documentation of this file.
1 #ifndef _SWITCH_AUDIO_COMPAT_H
2 #define _SWITCH_AUDIO_COMPAT_H
3 
4 #ifdef HAVE_LIBNX
5 #include <switch.h>
6 #else
7 #include <libtransistor/nx.h>
8 #endif
9 
10 #ifdef HAVE_LIBNX
11 
12 /* libnx definitions */
13 
14 /* threading */
15 typedef Mutex compat_mutex;
16 typedef Thread compat_thread;
17 typedef CondVar compat_condvar;
18 
19 #define compat_thread_create(thread, func, data, stack_size, prio, cpu) \
20  threadCreate(thread, func, data, stack_size, prio, cpu)
21 #define compat_thread_start(thread) \
22  threadStart(thread)
23 #define compat_thread_join(thread) \
24  threadWaitForExit(thread)
25 #define compat_thread_close(thread) \
26  threadClose(thread)
27 #define compat_mutex_create(mutex) \
28  mutexInit(mutex)
29 #define compat_mutex_lock(mutex) \
30  mutexLock(mutex)
31 #define compat_mutex_unlock(mutex) \
32  mutexUnlock(mutex)
33 #define compat_condvar_create(condvar) \
34  condvarInit(condvar)
35 #define compat_condvar_wait(condvar, mutex) \
36  condvarWait(condvar, mutex)
37 #define compat_condvar_wake_all(condvar) \
38  condvarWakeAll(condvar)
39 
40 /* audio */
41 typedef AudioOutBuffer compat_audio_out_buffer;
42 #define switch_audio_ipc_init audoutInitialize
43 #define switch_audio_ipc_finalize audoutExit
44 #define switch_audio_ipc_output_get_released_buffer(a, b) audoutGetReleasedAudioOutBuffer(&a->current_buffer, &b)
45 #define switch_audio_ipc_output_append_buffer(a, b) audoutAppendAudioOutBuffer(b)
46 #define switch_audio_ipc_output_stop(a) audoutStopAudioOut()
47 #define switch_audio_ipc_output_start(a) audoutStartAudioOut()
48 
49 #else
50 
51 /* libtransistor definitions */
52 
53 typedef result_t Result;
54 #define R_FAILED(r) ((r) != RESULT_OK)
55 
56 /* threading */
57 typedef trn_mutex_t compat_mutex;
58 typedef trn_thread_t compat_thread;
59 typedef trn_condvar_t compat_condvar;
60 
61 #define compat_thread_create(thread, func, data, stack_size, prio, cpu) \
62  trn_thread_create(thread, func, data, prio, cpu, stack_size, NULL)
63 #define compat_thread_start(thread) \
64  trn_thread_start(thread)
65 #define compat_thread_join(thread) \
66  trn_thread_join(thread, -1)
67 #define compat_thread_close(thread) \
68  trn_thread_destroy(thread)
69 #define compat_mutex_create(mutex) \
70  trn_mutex_create(mutex)
71 #define compat_mutex_lock(mutex) \
72  trn_mutex_lock(mutex)
73 #define compat_mutex_unlock(mutex) \
74  trn_mutex_unlock(mutex)
75 #define compat_condvar_create(condvar) \
76  trn_condvar_create(condvar)
77 #define compat_condvar_wait(condvar, mutex) \
78  trn_condvar_wait(condvar, mutex, -1)
79 #define compat_condvar_wake_all(condvar) \
80  trn_condvar_signal(condvar, -1)
81 
82 /* audio */
83 typedef audio_output_buffer_t compat_audio_out_buffer;
84 #define switch_audio_ipc_init audio_ipc_init
85 #define switch_audio_ipc_finalize audio_ipc_finalize
86 #define switch_audio_ipc_output_get_released_buffer(a, b) audio_ipc_output_get_released_buffer(&a->output, &b, &a->current_buffer)
87 #define switch_audio_ipc_output_append_buffer(a, b) audio_ipc_output_append_buffer(&a->output, b)
88 #define switch_audio_ipc_output_stop(a) audio_ipc_output_stop(&a->output)
89 #define switch_audio_ipc_output_start(a) audio_ipc_output_start(&a->output)
90 
91 #endif
92 
93 #endif
trn_mutex_t compat_mutex
Definition: switch_audio_compat.h:57
result_t Result
Definition: switch_audio_compat.h:53
trn_condvar_t compat_condvar
Definition: switch_audio_compat.h:59
trn_thread_t compat_thread
Definition: switch_audio_compat.h:58
audio_output_buffer_t compat_audio_out_buffer
Definition: switch_audio_compat.h:83