Mercurial > audlegacy-plugins
annotate src/scrobbler/plugin.c @ 1025:b70103d4b5ba trunk
[svn] - make scrobbler work again.
| author | yaz |
|---|---|
| date | Fri, 11 May 2007 20:59:58 -0700 |
| parents | 69cf6184edef |
| children | ff0487e9d00d |
| rev | line source |
|---|---|
|
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
1 #include "settings.h" |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
2 #include "config.h" |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
3 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
4 #include <glib.h> |
|
527
d124034ebea3
[svn] - glib/gi18n.h -> audacious/i18n.h for automatic dgettext support
nenolod
parents:
402
diff
changeset
|
5 #include <audacious/i18n.h> |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
6 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
7 #include <gdk/gdkkeysyms.h> |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
8 #include <gtk/gtk.h> |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
9 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
10 #include <audacious/plugin.h> |
|
402
1d50eb0b5a0a
[svn] - chase prefswin -> ui_preferences in audacious core
nenolod
parents:
364
diff
changeset
|
11 #include <audacious/ui_preferences.h> |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
12 #include <audacious/playlist.h> |
|
4
0ad4849f6219
[svn] - the first pass missed some libaudacious references, this fixes them
nenolod
parents:
0
diff
changeset
|
13 #include <audacious/configdb.h> |
| 1025 | 14 #include <audacious/auddrct.h> |
| 719 | 15 #include <audacious/strings.h> |
| 1015 | 16 #include <audacious/main.h> |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
17 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
18 #include <unistd.h> |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
19 #include <stdio.h> |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
20 #include <stdlib.h> |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
21 #include <string.h> |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
22 #include <ctype.h> |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
23 #include <wchar.h> |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
24 #include <sys/time.h> |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
25 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
26 #include "scrobbler.h" |
|
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
27 #include "gerpok.h" |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
28 #include "gtkstuff.h" |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
29 #include "config.h" |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
30 #include "fmt.h" |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
31 #include "configure.h" |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
32 |
| 353 | 33 #define XS_SLEEP 1 |
| 34 #define HS_SLEEP 10 | |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
35 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
36 typedef struct submit_t |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
37 { |
|
553
269841b8fb31
[svn] - submit gerpok tracks on immediate playback begin
nenolod
parents:
527
diff
changeset
|
38 int dosubmit, pos_c, len, gerpok; |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
39 } submit_t; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
40 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
41 static void init(void); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
42 static void cleanup(void); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
43 static void *xs_thread(void *); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
44 static void *hs_thread(void *); |
|
990
238055a6cb8f
[svn] - remove support for hatena music as hatena ceased their musical profile service.
yaz
parents:
880
diff
changeset
|
45 static int sc_going, ge_going; |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
46 static GtkWidget *cfgdlg; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
47 |
| 353 | 48 static GMutex *m_scrobbler; |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
49 static GThread *pt_scrobbler; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
50 static GThread *pt_handshake; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
51 |
| 353 | 52 static GMutex *hs_mutex, *xs_mutex; |
| 53 static GCond *hs_cond, *xs_cond; | |
| 54 | |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
55 static GeneralPlugin xmms_scrobbler = |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
56 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
57 NULL, |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
58 NULL, |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
59 -1, |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
60 NULL, |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
61 init, |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
62 about_show, |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
63 NULL, |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
64 cleanup |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
65 }; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
66 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
67 static void init(void) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
68 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
69 char *username = NULL, *password = NULL; |
|
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
70 char *ge_username = NULL, *ge_password = NULL; |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
71 ConfigDb *cfgfile; |
|
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
72 sc_going = 1; |
|
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
73 ge_going = 1; |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
74 GError **moo = NULL; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
75 cfgdlg = create_cfgdlg(); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
76 |
|
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
77 prefswin_page_new(cfgdlg, "Scrobbler", DATA_DIR "/images/audioscrobbler.png"); |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
78 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
79 if ((cfgfile = bmp_cfg_db_open()) != NULL) { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
80 bmp_cfg_db_get_string(cfgfile, "audioscrobbler", "username", |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
81 &username); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
82 bmp_cfg_db_get_string(cfgfile, "audioscrobbler", "password", |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
83 &password); |
|
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
84 bmp_cfg_db_get_string(cfgfile, "audioscrobbler", "ge_username", |
|
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
85 &ge_username); |
|
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
86 bmp_cfg_db_get_string(cfgfile, "audioscrobbler", "ge_password", |
|
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
87 &ge_password); |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
88 bmp_cfg_db_close(cfgfile); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
89 } |
|
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
90 |
|
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
91 if ((!username || !password) || (!*username || !*password)) |
|
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
92 { |
|
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
93 pdebug("username/password not found - not starting last.fm support", |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
94 DEBUG); |
|
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
95 sc_going = 0; |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
96 } |
|
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
97 else |
| 364 | 98 { |
|
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
99 sc_init(username, password); |
|
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
100 |
| 364 | 101 g_free(username); |
| 102 g_free(password); | |
| 103 } | |
|
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
104 |
|
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
105 if ((!ge_username || !ge_password) || (!*ge_username || !*ge_password)) |
|
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
106 { |
|
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
107 pdebug("username/password not found - not starting Gerpok support", |
|
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
108 DEBUG); |
|
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
109 ge_going = 0; |
|
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
110 } |
|
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
111 else |
| 364 | 112 { |
|
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
113 gerpok_sc_init(ge_username, ge_password); |
|
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
114 |
| 364 | 115 g_free(ge_username); |
| 116 g_free(ge_password); | |
| 117 } | |
|
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
118 |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
119 m_scrobbler = g_mutex_new(); |
| 353 | 120 hs_mutex = g_mutex_new(); |
| 121 xs_mutex = g_mutex_new(); | |
| 122 hs_cond = g_cond_new(); | |
| 123 xs_cond = g_cond_new(); | |
| 124 | |
| 125 if ((pt_scrobbler = g_thread_create(xs_thread, NULL, TRUE, moo)) == NULL) | |
|
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
126 { |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
127 pdebug(fmt_vastr("Error creating scrobbler thread: %s", moo), DEBUG); |
|
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
128 sc_going = 0; |
|
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
129 ge_going = 0; |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
130 return; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
131 } |
|
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
132 |
| 353 | 133 if ((pt_handshake = g_thread_create(hs_thread, NULL, TRUE, moo)) == NULL) |
|
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
134 { |
|
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
135 pdebug(fmt_vastr("Error creating handshake thread: %s", moo), DEBUG); |
|
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
136 sc_going = 0; |
|
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
137 ge_going = 0; |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
138 return; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
139 } |
|
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
140 |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
141 pdebug("plugin started", DEBUG); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
142 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
143 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
144 static void cleanup(void) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
145 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
146 g_free (xmms_scrobbler.description); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
147 xmms_scrobbler.description = NULL; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
148 |
|
108
0eb1e99b7748
[svn] - move prefswin_page_destroy(cfgdlg) to before the plugin logs out of last.fm;
nenolod
parents:
12
diff
changeset
|
149 prefswin_page_destroy(cfgdlg); |
|
0eb1e99b7748
[svn] - move prefswin_page_destroy(cfgdlg) to before the plugin logs out of last.fm;
nenolod
parents:
12
diff
changeset
|
150 |
|
990
238055a6cb8f
[svn] - remove support for hatena music as hatena ceased their musical profile service.
yaz
parents:
880
diff
changeset
|
151 if (!sc_going && !ge_going) |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
152 return; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
153 pdebug("about to lock mutex", DEBUG); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
154 g_mutex_lock(m_scrobbler); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
155 pdebug("locked mutex", DEBUG); |
|
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
156 sc_going = 0; |
|
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
157 ge_going = 0; |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
158 g_mutex_unlock(m_scrobbler); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
159 pdebug("joining threads", DEBUG); |
| 353 | 160 |
| 161 /* wake up waiting threads */ | |
| 162 pdebug("send signal to xs and hs", DEBUG); | |
| 163 g_cond_signal(xs_cond); | |
| 164 g_cond_signal(hs_cond); | |
| 165 | |
| 166 pdebug("wait xs", DEBUG); | |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
167 g_thread_join(pt_scrobbler); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
168 |
| 353 | 169 pdebug("wait hs", DEBUG); |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
170 g_thread_join(pt_handshake); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
171 |
| 353 | 172 g_cond_free(hs_cond); |
| 173 g_cond_free(xs_cond); | |
| 174 g_mutex_free(hs_mutex); | |
| 175 g_mutex_free(xs_mutex); | |
| 176 g_mutex_free(m_scrobbler); | |
| 177 | |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
178 sc_cleaner(); |
|
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
179 gerpok_sc_cleaner(); |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
180 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
181 |
| 880 | 182 static gboolean ishttp(const char *a) |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
183 { |
| 880 | 184 g_return_val_if_fail(a != NULL, FALSE); |
| 719 | 185 return str_has_prefix_nocase(a, "http://"); |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
186 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
187 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
188 /* Following code thanks to nosuke |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
189 * |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
190 * It should probably be cleaned up |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
191 */ |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
192 static submit_t get_song_status(void) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
193 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
194 static int pos_c, playlistlen_c, playtime_c, time_c, |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
195 pos_p = 0, playlistlen_p = 0, playtime_p = 0, |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
196 playtime_i = 0, time_i = 0, |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
197 playtime_ofs = 0; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
198 static char *file_c = NULL, *file_p = NULL; |
| 1015 | 199 Playlist *playlist = playlist_get_active(); |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
200 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
201 static enum playstatus { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
202 ps_stop, ps_play, ps_pause |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
203 } ps_c, ps_p = ps_stop; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
204 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
205 static int submitted = 0, changed, seeked, repeat, |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
206 filechanged, rewind, len = 0; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
207 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
208 static enum state { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
209 start, stop, pause, restart, playing, pausing, stopping |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
210 } playstate; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
211 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
212 submit_t dosubmit; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
213 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
214 struct timeval timetmp; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
215 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
216 /* clear dosubmit */ |
|
553
269841b8fb31
[svn] - submit gerpok tracks on immediate playback begin
nenolod
parents:
527
diff
changeset
|
217 dosubmit.dosubmit = dosubmit.pos_c = dosubmit.len = dosubmit.gerpok = 0; |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
218 |
| 1025 | 219 /* make sure playlist != NULL */ |
| 220 if (!playlist) | |
| 221 return dosubmit; | |
| 222 | |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
223 /* current music number */ |
| 1015 | 224 pos_c = playlist_get_position(playlist); |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
225 /* current file name */ |
| 1015 | 226 file_c = playlist_get_filename(playlist, pos_c); |
| 719 | 227 |
|
744
c380f078aa26
[svn] - scrobbler: check that there are files in playlist at all, before looking up whether they are http sources or not
giacomo
parents:
719
diff
changeset
|
228 if ((file_c != NULL) && (ishttp(file_c))) |
| 719 | 229 return dosubmit; |
| 230 | |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
231 /* total number */ |
| 1015 | 232 playlistlen_c = playlist_get_length(playlist); |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
233 /* current playtime */ |
| 1025 | 234 playtime_c = audacious_drct_get_time(); |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
235 /* total length */ |
| 1015 | 236 len = playlist_get_songtime(playlist, pos_c); |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
237 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
238 /* current time (ms) */ |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
239 gettimeofday(&timetmp, NULL); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
240 time_c = timetmp.tv_sec * 1000 + timetmp.tv_usec / 1000; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
241 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
242 /* current status */ |
| 1025 | 243 if( audacious_drct_get_paused() ) { |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
244 ps_c = ps_pause; |
| 1025 | 245 }else if( audacious_drct_get_playing() ) { |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
246 ps_c = ps_play; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
247 }else{ |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
248 ps_c = ps_stop; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
249 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
250 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
251 /* repeat setting */ |
| 1015 | 252 repeat = cfg.repeat; |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
253 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
254 if( ps_p == ps_stop && ps_c == ps_stop ) playstate = stopping; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
255 else if( ps_p == ps_stop && ps_c == ps_play ) playstate = start; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
256 /* else if( ps_p == ps_stop && ps_c == ps_pause ) ; */ |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
257 else if( ps_p == ps_play && ps_c == ps_play ) playstate = playing; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
258 else if( ps_p == ps_play && ps_c == ps_stop ) playstate = stop; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
259 else if( ps_p == ps_play && ps_c == ps_pause ) playstate = pause; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
260 else if( ps_p == ps_pause && ps_c == ps_pause ) playstate = pausing; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
261 else if( ps_p == ps_pause && ps_c == ps_play ) playstate = restart; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
262 else if( ps_p == ps_pause && ps_c == ps_stop ) playstate = stop; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
263 else playstate = stopping; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
264 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
265 /* filename has changed */ |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
266 if( !(file_p == NULL && file_c == NULL) && |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
267 ((file_p == NULL && file_c != NULL) || |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
268 (file_p != NULL && file_c == NULL) || |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
269 (file_p != NULL && file_c != NULL && strcmp(file_c, file_p))) ){ |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
270 filechanged = 1; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
271 pdebug("*** filechange ***", SUB_DEBUG); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
272 }else{ |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
273 filechanged = 0; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
274 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
275 if( file_c == NULL ){ len = 0; } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
276 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
277 /* whole rewind has occurred (maybe) */ |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
278 if( len != 0 && len - (playtime_p - playtime_c) < 3000 ){ |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
279 rewind = 1; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
280 pdebug("*** rewind ***", SUB_DEBUG); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
281 }else{ |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
282 rewind = 0; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
283 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
284 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
285 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
286 changed = 0; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
287 seeked = 0; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
288 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
289 switch( playstate ){ |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
290 case start: |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
291 pdebug("*** START ***", SUB_DEBUG); |
|
553
269841b8fb31
[svn] - submit gerpok tracks on immediate playback begin
nenolod
parents:
527
diff
changeset
|
292 dosubmit.gerpok = 1; |
| 554 | 293 dosubmit.len = len; |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
294 break; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
295 case stop: |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
296 pdebug("*** STOP ***", SUB_DEBUG); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
297 len = 0; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
298 break; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
299 case pause: |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
300 pdebug("*** PAUSE ***", SUB_DEBUG); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
301 playtime_ofs += playtime_c - playtime_i; /* save playtime */ |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
302 break; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
303 case restart: |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
304 pdebug("*** RESTART ***", SUB_DEBUG); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
305 playtime_i = playtime_c; /* restore playtime */ |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
306 break; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
307 case playing: |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
308 if( (playtime_c < playtime_p) || /* back */ |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
309 ( (playtime_c - playtime_i) - (time_c - time_i) > 3000 ) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
310 /* forward */ |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
311 ) { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
312 seeked = 1; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
313 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
314 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
315 if( filechanged || /* filename has changed */ |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
316 ( !filechanged && /* filename has not changed... */ |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
317 /* (( rewind && (repeat && (!advance || |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
318 (pos_c == 0 && playlistlen_c == 1 )))) || */ |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
319 /* looping with only one file */ |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
320 (( pos_c == 0 && playlistlen_c == 1 && repeat |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
321 && rewind ) || |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
322 /* looping? */ |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
323 ( pos_p == pos_c && rewind ) || |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
324 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
325 ( pos_p != pos_c && seeked ) || |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
326 /* skip from current music to next music, |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
327 which has the same filename as previous one */ |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
328 ( pos_p < pos_c && playtime_c < playtime_p ) || |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
329 /* current song has removed from playlist |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
330 but the next (following) song has the same |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
331 filename */ |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
332 ( playlistlen_p > playlistlen_c |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
333 && playtime_c < playtime_p )))){ |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
334 pdebug("*** CHANGE ***",SUB_DEBUG); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
335 pdebug(fmt_vastr(" filechanged = %d",filechanged),SUB_DEBUG); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
336 pdebug(fmt_vastr(" pos_c = %d",pos_c),SUB_DEBUG); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
337 pdebug(fmt_vastr(" pos_p = %d",pos_p),SUB_DEBUG); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
338 pdebug(fmt_vastr(" rewind = %d", rewind),SUB_DEBUG); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
339 pdebug(fmt_vastr(" seeked = %d", seeked),SUB_DEBUG); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
340 pdebug(fmt_vastr(" playtime_c = %d", playtime_c),SUB_DEBUG); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
341 pdebug(fmt_vastr(" playtime_p = %d", playtime_p),SUB_DEBUG); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
342 pdebug(fmt_vastr(" playlistlen_c = %d", playlistlen_p), |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
343 SUB_DEBUG); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
344 pdebug(fmt_vastr(" playlistlen_p = %d", playlistlen_p), |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
345 SUB_DEBUG); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
346 changed = 1; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
347 seeked = 0; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
348 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
349 if (file_p != NULL) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
350 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
351 g_free(file_p); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
352 file_p = NULL; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
353 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
354 }else if( seeked ) { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
355 seeked = 1; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
356 pdebug("*** SEEK ***", SUB_DEBUG); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
357 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
358 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
359 break; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
360 case pausing: |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
361 if(playtime_c != playtime_p){ |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
362 pdebug("*** SEEK ***", SUB_DEBUG); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
363 seeked = 1; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
364 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
365 break; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
366 case stopping: |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
367 len = 0; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
368 break; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
369 default: |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
370 pdebug("*** unknown state tranfer!!! ***", SUB_DEBUG); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
371 break; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
372 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
373 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
374 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
375 if( playstate == start || changed || (seeked && !submitted) ){ |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
376 /* reset counter */ |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
377 pdebug(" <<< reset counter >>>", SUB_DEBUG); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
378 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
379 submitted = 0; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
380 playtime_ofs = 0; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
381 playtime_i = playtime_c; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
382 time_i = time_c; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
383 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
384 }else{ |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
385 /* check playtime for submitting */ |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
386 if( !submitted ){ |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
387 if( len > 30 * 1000 && |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
388 /* len < 30 *60 * 1000 && // crazy rule!!! */ |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
389 ( |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
390 (playtime_ofs + playtime_c - playtime_i > len / 2) || |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
391 (playtime_ofs + playtime_c - playtime_i > 240 * 1000) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
392 /* (playtime_c - playtime_i > 10 * 1000)// for debug */ |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
393 )){ |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
394 pdebug("*** submitting requirements are satisfied.", |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
395 SUB_DEBUG); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
396 pdebug(fmt_vastr(" len = %d, playtime = %d", |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
397 len / 1000, (playtime_c - playtime_i)/1000 ), |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
398 SUB_DEBUG); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
399 submitted = 1; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
400 dosubmit.dosubmit = 1; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
401 dosubmit.pos_c = pos_c; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
402 dosubmit.len = len; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
403 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
404 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
405 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
406 |
|
553
269841b8fb31
[svn] - submit gerpok tracks on immediate playback begin
nenolod
parents:
527
diff
changeset
|
407 if (playstate != start) |
|
269841b8fb31
[svn] - submit gerpok tracks on immediate playback begin
nenolod
parents:
527
diff
changeset
|
408 dosubmit.gerpok = 0; |
|
269841b8fb31
[svn] - submit gerpok tracks on immediate playback begin
nenolod
parents:
527
diff
changeset
|
409 |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
410 g_free(file_p); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
411 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
412 /* keep current value for next iteration */ |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
413 ps_p = ps_c; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
414 file_p = file_c; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
415 playtime_p = playtime_c; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
416 pos_p = pos_c; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
417 playlistlen_p = playlistlen_c; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
418 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
419 return dosubmit; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
420 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
421 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
422 static void *xs_thread(void *data __attribute__((unused))) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
423 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
424 int run = 1; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
425 submit_t dosubmit; |
| 353 | 426 GTimeVal sleeptime; |
| 427 | |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
428 while (run) { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
429 /* Error catching */ |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
430 if(sc_catch_error()) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
431 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
432 errorbox_show(sc_fetch_error()); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
433 sc_clear_error(); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
434 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
435 |
|
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
436 if(gerpok_sc_catch_error()) |
|
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
437 { |
|
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
438 errorbox_show(gerpok_sc_fetch_error()); |
|
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
439 gerpok_sc_clear_error(); |
|
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
440 } |
|
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
441 |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
442 /* Check for ability to submit */ |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
443 dosubmit = get_song_status(); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
444 |
|
553
269841b8fb31
[svn] - submit gerpok tracks on immediate playback begin
nenolod
parents:
527
diff
changeset
|
445 if(dosubmit.gerpok) { |
|
269841b8fb31
[svn] - submit gerpok tracks on immediate playback begin
nenolod
parents:
527
diff
changeset
|
446 TitleInput *tuple; |
|
269841b8fb31
[svn] - submit gerpok tracks on immediate playback begin
nenolod
parents:
527
diff
changeset
|
447 |
|
269841b8fb31
[svn] - submit gerpok tracks on immediate playback begin
nenolod
parents:
527
diff
changeset
|
448 pdebug("Submitting song.", DEBUG); |
|
269841b8fb31
[svn] - submit gerpok tracks on immediate playback begin
nenolod
parents:
527
diff
changeset
|
449 |
|
269841b8fb31
[svn] - submit gerpok tracks on immediate playback begin
nenolod
parents:
527
diff
changeset
|
450 tuple = playlist_get_tuple(playlist_get_active(), dosubmit.pos_c); |
|
269841b8fb31
[svn] - submit gerpok tracks on immediate playback begin
nenolod
parents:
527
diff
changeset
|
451 |
| 601 | 452 if (tuple == NULL) |
| 453 continue; | |
| 454 | |
|
553
269841b8fb31
[svn] - submit gerpok tracks on immediate playback begin
nenolod
parents:
527
diff
changeset
|
455 if (ishttp(tuple->file_name)) |
|
269841b8fb31
[svn] - submit gerpok tracks on immediate playback begin
nenolod
parents:
527
diff
changeset
|
456 continue; |
|
269841b8fb31
[svn] - submit gerpok tracks on immediate playback begin
nenolod
parents:
527
diff
changeset
|
457 |
|
269841b8fb31
[svn] - submit gerpok tracks on immediate playback begin
nenolod
parents:
527
diff
changeset
|
458 if(tuple->performer != NULL && tuple->track_name != NULL) |
|
269841b8fb31
[svn] - submit gerpok tracks on immediate playback begin
nenolod
parents:
527
diff
changeset
|
459 { |
|
269841b8fb31
[svn] - submit gerpok tracks on immediate playback begin
nenolod
parents:
527
diff
changeset
|
460 pdebug(fmt_vastr( |
|
269841b8fb31
[svn] - submit gerpok tracks on immediate playback begin
nenolod
parents:
527
diff
changeset
|
461 "submitting artist: %s, title: %s", |
|
269841b8fb31
[svn] - submit gerpok tracks on immediate playback begin
nenolod
parents:
527
diff
changeset
|
462 tuple->performer, tuple->track_name), DEBUG); |
|
269841b8fb31
[svn] - submit gerpok tracks on immediate playback begin
nenolod
parents:
527
diff
changeset
|
463 gerpok_sc_addentry(m_scrobbler, tuple, |
|
269841b8fb31
[svn] - submit gerpok tracks on immediate playback begin
nenolod
parents:
527
diff
changeset
|
464 dosubmit.len/1000); |
|
269841b8fb31
[svn] - submit gerpok tracks on immediate playback begin
nenolod
parents:
527
diff
changeset
|
465 } |
|
269841b8fb31
[svn] - submit gerpok tracks on immediate playback begin
nenolod
parents:
527
diff
changeset
|
466 else |
|
269841b8fb31
[svn] - submit gerpok tracks on immediate playback begin
nenolod
parents:
527
diff
changeset
|
467 pdebug("tuple does not contain an artist or a title, not submitting.", DEBUG); |
|
269841b8fb31
[svn] - submit gerpok tracks on immediate playback begin
nenolod
parents:
527
diff
changeset
|
468 } |
|
269841b8fb31
[svn] - submit gerpok tracks on immediate playback begin
nenolod
parents:
527
diff
changeset
|
469 |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
470 if(dosubmit.dosubmit) { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
471 TitleInput *tuple; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
472 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
473 pdebug("Submitting song.", DEBUG); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
474 |
|
363
958855dae693
[svn] - fix other plugins dependant on the playlist framework
nenolod
parents:
353
diff
changeset
|
475 tuple = playlist_get_tuple(playlist_get_active(), dosubmit.pos_c); |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
476 |
| 601 | 477 if (tuple == NULL) |
| 478 continue; | |
| 479 | |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
480 if (ishttp(tuple->file_name)) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
481 continue; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
482 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
483 if(tuple->performer != NULL && tuple->track_name != NULL) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
484 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
485 pdebug(fmt_vastr( |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
486 "submitting artist: %s, title: %s", |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
487 tuple->performer, tuple->track_name), DEBUG); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
488 sc_addentry(m_scrobbler, tuple, |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
489 dosubmit.len/1000); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
490 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
491 else |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
492 pdebug("tuple does not contain an artist or a title, not submitting.", DEBUG); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
493 } |
| 353 | 494 g_get_current_time(&sleeptime); |
| 495 sleeptime.tv_sec += XS_SLEEP; | |
| 496 | |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
497 g_mutex_lock(m_scrobbler); |
|
990
238055a6cb8f
[svn] - remove support for hatena music as hatena ceased their musical profile service.
yaz
parents:
880
diff
changeset
|
498 run = (sc_going != 0 || ge_going != 0); |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
499 g_mutex_unlock(m_scrobbler); |
| 353 | 500 |
| 501 g_mutex_lock(xs_mutex); | |
| 502 g_cond_timed_wait(xs_cond, xs_mutex, &sleeptime); | |
| 503 g_mutex_unlock(xs_mutex); | |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
504 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
505 pdebug("scrobbler thread: exiting", DEBUG); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
506 g_thread_exit(NULL); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
507 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
508 return NULL; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
509 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
510 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
511 static void *hs_thread(void *data __attribute__((unused))) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
512 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
513 int run = 1; |
| 353 | 514 GTimeVal sleeptime; |
| 515 | |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
516 while(run) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
517 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
518 if(sc_idle(m_scrobbler)) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
519 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
520 pdebug("Giving up due to fatal error", DEBUG); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
521 g_mutex_lock(m_scrobbler); |
|
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
522 sc_going = 0; |
| 353 | 523 g_mutex_unlock(m_scrobbler); |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
524 } |
|
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
525 |
|
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
526 if(gerpok_sc_idle(m_scrobbler)) |
|
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
527 { |
|
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
528 pdebug("Giving up due to fatal error", DEBUG); |
|
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
529 g_mutex_lock(m_scrobbler); |
|
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
530 ge_going = 0; |
| 353 | 531 g_mutex_unlock(m_scrobbler); |
|
344
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
532 } |
|
03c1ae10bc8d
[svn] - Merge audacious-scrobbler III, new features include:
nenolod
parents:
108
diff
changeset
|
533 |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
534 g_mutex_lock(m_scrobbler); |
|
990
238055a6cb8f
[svn] - remove support for hatena music as hatena ceased their musical profile service.
yaz
parents:
880
diff
changeset
|
535 run = (sc_going != 0 || ge_going != 0); |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
536 g_mutex_unlock(m_scrobbler); |
| 353 | 537 |
| 538 if(run) { | |
| 539 g_get_current_time(&sleeptime); | |
| 540 sleeptime.tv_sec += HS_SLEEP; | |
| 541 | |
| 542 g_mutex_lock(hs_mutex); | |
| 543 g_cond_timed_wait(hs_cond, hs_mutex, &sleeptime); | |
| 544 g_mutex_unlock(hs_mutex); | |
| 545 } | |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
546 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
547 pdebug("handshake thread: exiting", DEBUG); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
548 g_thread_exit(NULL); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
549 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
550 return NULL; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
551 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
552 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
553 GeneralPlugin *get_gplugin_info(void) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
554 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
555 xmms_scrobbler.description = g_strdup_printf(_("Scrobbler Plugin")); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
556 return &xmms_scrobbler; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
557 } |
