-
Notifications
You must be signed in to change notification settings - Fork 0
/
spotify_session_callbacks.c
237 lines (188 loc) · 4.62 KB
/
spotify_session_callbacks.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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include "spotify_session_callbacks.h"
/* We need access to spotify_get_events and events struct */
#include "spotify_int.h"
#include "spotify_events_int.h"
static void
logged_in(sp_session *session, sp_error error)
{
spotify_t *spotify;
spotify = sp_session_userdata(session);
assert(spotify);
spotify_listen(spotify);
}
static void
logged_out(sp_session *session)
{
spotify_t *spotify;
fprintf(stderr, "Log out successful...\n");
spotify = sp_session_userdata(session);
assert(spotify);
spotify_unlisten(spotify);
}
static void
metadata_updated(sp_session *session)
{
spotify_t *spotify;
spotify = sp_session_userdata(session);
assert(spotify);
}
static void
connection_error(sp_session *session, sp_error error)
{
spotify_t *spotify;
spotify = sp_session_userdata(session);
assert(spotify);
}
static void
message_to_user(sp_session *session, const char *message)
{
spotify_t *spotify;
spotify = sp_session_userdata(session);
assert(spotify);
}
static void
notify_main_thread(sp_session *session)
{
spotify_t *spotify;
spotify_events_t *events;
spotify = sp_session_userdata(session);
assert(spotify);
events = spotify_get_events(spotify);
event_active(events->process_event, 0, 0);
}
static int
music_delivery(sp_session *session, const sp_audioformat *format, const void *frames, int num_frames)
{
spotify_t *spotify;
spotify = sp_session_userdata(session);
assert(spotify);
return 0;
}
static void
play_token_lost(sp_session *session)
{
spotify_t *spotify;
spotify = sp_session_userdata(session);
assert(spotify);
}
static void
log_message(sp_session *session, const char *data)
{
spotify_t *spotify;
spotify = sp_session_userdata(session);
assert(spotify);
fprintf(stderr, "%s", data);
}
static void
end_of_track(sp_session *session)
{
spotify_t *spotify;
spotify = sp_session_userdata(session);
assert(spotify);
}
static void
streaming_error(sp_session *session, sp_error error)
{
spotify_t *spotify;
spotify = sp_session_userdata(session);
assert(spotify);
}
static void
userinfo_updated(sp_session *session)
{
spotify_t *spotify;
spotify = sp_session_userdata(session);
assert(spotify);
}
static void
start_playback(sp_session *session)
{
spotify_t *spotify;
spotify = sp_session_userdata(session);
assert(spotify);
}
static void
stop_playback(sp_session *session)
{
spotify_t *spotify;
spotify = sp_session_userdata(session);
assert(spotify);
}
static void
get_audio_buffer_stats(sp_session *session, sp_audio_buffer_stats *stats)
{
spotify_t *spotify;
spotify = sp_session_userdata(session);
assert(spotify);
}
static void
offline_status_updated(sp_session *session)
{
spotify_t *spotify;
spotify = sp_session_userdata(session);
assert(spotify);
}
static void
offline_error(sp_session *session, sp_error error)
{
spotify_t *spotify;
spotify = sp_session_userdata(session);
assert(spotify);
}
static void
credentials_blob_updated(sp_session *session, const char *blob)
{
spotify_t *spotify;
spotify = sp_session_userdata(session);
assert(spotify);
}
static void
connectionstate_updated(sp_session *session)
{
spotify_t *spotify;
spotify = sp_session_userdata(session);
assert(spotify);
}
static void
scrobble_error(sp_session *session, sp_error error)
{
spotify_t *spotify;
spotify = sp_session_userdata(session);
assert(spotify);
}
static void
private_session_mode_changed(sp_session *session, bool is_private)
{
spotify_t *spotify;
spotify = sp_session_userdata(session);
assert(spotify);
}
void
spotify_session_callbacks(sp_session_callbacks *callbacks)
{
assert(callbacks);
callbacks->logged_in = &logged_in;
callbacks->logged_out = &logged_out;
callbacks->metadata_updated = &metadata_updated;
callbacks->connection_error = &connection_error;
callbacks->message_to_user = &message_to_user;
callbacks->notify_main_thread = ¬ify_main_thread;
callbacks->music_delivery = &music_delivery;
callbacks->play_token_lost = &play_token_lost;
callbacks->log_message = &log_message;
callbacks->end_of_track = &end_of_track;
callbacks->streaming_error = &streaming_error;
callbacks->userinfo_updated = &userinfo_updated;
callbacks->start_playback = &start_playback;
callbacks->stop_playback = &stop_playback;
callbacks->get_audio_buffer_stats = &get_audio_buffer_stats;
callbacks->offline_status_updated = &offline_status_updated;
callbacks->offline_error = &offline_error;
callbacks->credentials_blob_updated = &credentials_blob_updated;
callbacks->connectionstate_updated = &connectionstate_updated;
callbacks->scrobble_error = &scrobble_error;
callbacks->private_session_mode_changed = &private_session_mode_changed;
}