-
Notifications
You must be signed in to change notification settings - Fork 10
/
tune.c
147 lines (117 loc) · 4.07 KB
/
tune.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#include "tune.h"
#include "ipc_cmd.h"
#include <string.h>
Service g_tune;
Result tuneInitialize() {
Handle handle = 0;
Result rc = svcConnectToNamedPort(&handle, "tune");
if (R_SUCCEEDED(rc))
serviceCreate(&g_tune, handle);
return rc;
}
void tuneExit() {
serviceClose(&g_tune);
}
Result tuneGetStatus(bool *status) {
u8 tmp=0;
Result rc = serviceDispatchOut(&g_tune, TuneIpcCmd_GetStatus, tmp);
if (R_SUCCEEDED(rc) && status) *status = tmp & 1;
return rc;
}
Result tunePlay() {
return serviceDispatch(&g_tune, TuneIpcCmd_Play);
}
Result tunePause() {
return serviceDispatch(&g_tune, TuneIpcCmd_Pause);
}
Result tuneNext() {
return serviceDispatch(&g_tune, TuneIpcCmd_Next);
}
Result tunePrev() {
return serviceDispatch(&g_tune, TuneIpcCmd_Prev);
}
Result tuneGetVolume(float *out) {
return serviceDispatchOut(&g_tune, TuneIpcCmd_GetVolume, *out);
}
Result tuneSetVolume(float volume) {
return serviceDispatchIn(&g_tune, TuneIpcCmd_SetVolume, volume);
}
Result tuneGetTitleVolume(float *out) {
return serviceDispatchOut(&g_tune, TuneIpcCmd_GetTitleVolume, *out);
}
Result tuneSetTitleVolume(float volume) {
return serviceDispatchIn(&g_tune, TuneIpcCmd_SetTitleVolume, volume);
}
Result tuneGetDefaultTitleVolume(float *out) {
return serviceDispatchOut(&g_tune, TuneIpcCmd_GetDefaultTitleVolume, *out);
}
Result tuneSetDefaultTitleVolume(float volume) {
return serviceDispatchIn(&g_tune, TuneIpcCmd_SetDefaultTitleVolume, volume);
}
Result tuneGetRepeatMode(TuneRepeatMode *state) {
u8 out = 0;
Result rc = serviceDispatchOut(&g_tune, TuneIpcCmd_GetRepeatMode, out);
if (R_SUCCEEDED(rc) && state)
*state = out;
return rc;
}
Result tuneSetRepeatMode(TuneRepeatMode state) {
u8 tmp = state;
return serviceDispatchIn(&g_tune, TuneIpcCmd_SetRepeatMode, tmp);
}
Result tuneGetShuffleMode(TuneShuffleMode *state) {
u8 out = 0;
Result rc = serviceDispatchOut(&g_tune, TuneIpcCmd_GetShuffleMode, out);
if (R_SUCCEEDED(rc) && state)
*state = out;
return rc;
}
Result tuneSetShuffleMode(TuneShuffleMode state) {
u8 tmp = state;
return serviceDispatchIn(&g_tune, TuneIpcCmd_SetShuffleMode, tmp);
}
Result tuneGetPlaylistSize(u32 *count) {
return serviceDispatchOut(&g_tune, TuneIpcCmd_GetPlaylistSize, *count);
}
Result tuneGetPlaylistItem(u32 index, char *out_path, size_t out_path_length) {
return serviceDispatchIn(&g_tune, TuneIpcCmd_GetPlaylistItem, index,
.buffer_attrs = {SfBufferAttr_Out | SfBufferAttr_HipcMapAlias},
.buffers = {{out_path, out_path_length}}, );
}
Result tuneGetCurrentQueueItem(char *out_path, size_t out_path_length, TuneCurrentStats *out) {
return serviceDispatchOut(&g_tune, TuneIpcCmd_GetCurrentQueueItem, *out,
.buffer_attrs = {SfBufferAttr_Out | SfBufferAttr_HipcMapAlias},
.buffers = {{out_path, out_path_length}}, );
}
Result tuneClearQueue() {
return serviceDispatch(&g_tune, TuneIpcCmd_ClearQueue);
}
Result tuneMoveQueueItem(u32 src, u32 dst) {
const struct {
u32 src;
u32 dst;
} in = {src, dst};
return serviceDispatchIn(&g_tune, TuneIpcCmd_MoveQueueItem, in);
}
Result tuneSelect(u32 index) {
return serviceDispatchIn(&g_tune, TuneIpcCmd_Select, index);
}
Result tuneSeek(u32 position) {
return serviceDispatchIn(&g_tune, TuneIpcCmd_Seek, position);
}
Result tuneEnqueue(const char *path, TuneEnqueueType type) {
u8 tmp = type;
size_t path_length = strlen(path);
return serviceDispatchIn(&g_tune, TuneIpcCmd_Enqueue, tmp,
.buffer_attrs = {SfBufferAttr_In | SfBufferAttr_HipcMapAlias},
.buffers = {{path, path_length}}, );
}
Result tuneRemove(u32 index) {
return serviceDispatchIn(&g_tune, TuneIpcCmd_Remove, index);
}
Result tuneQuit() {
return serviceDispatch(&g_tune, TuneIpcCmd_QuitServer);
}
Result tuneGetApiVersion(u32 *version) {
return serviceDispatchOut(&g_tune, TuneIpcCmd_GetApiVersion, *version);
}