blob: a18dfd110fbd40f24f072d92fe1cab3cbe4520e1 (
plain)
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
|
#include <gtk/gtk.h>
#include <stdio.h>
#include <stdint.h>
#include "interface.h"
#include "support.h"
#include "playlist.h"
#include "psdl.h"
#include "unistd.h"
#include "threading.h"
#include "messagepump.h"
#include "messages.h"
#include "gtkplaylist.h"
#include "codec.h"
GtkWidget *mainwin;
int psdl_terminate = 0;
void
psdl_thread (uintptr_t ctx) {
codec_init_locking ();
psdl_init ();
while (!psdl_terminate) {
uint32_t msg;
uintptr_t ctx;
uint32_t p1;
uint32_t p2;
while (messagepump_pop(&msg, &ctx, &p1, &p2) != -1) {
switch (msg) {
case M_SONGFINISHED:
// play next song in playlists
GDK_THREADS_ENTER();
gtkps_nextsong ();
GDK_THREADS_LEAVE();
break;
case M_PLAYSONG:
GDK_THREADS_ENTER();
gtkps_playsong ();
GDK_THREADS_LEAVE();
break;
case M_PLAYSONGNUM:
GDK_THREADS_ENTER();
gtkps_playsongnum (p1);
GDK_THREADS_LEAVE();
break;
case M_STOPSONG:
GDK_THREADS_ENTER();
gtkps_stopsong ();
GDK_THREADS_LEAVE();
break;
case M_NEXTSONG:
GDK_THREADS_ENTER();
gtkps_nextsong ();
GDK_THREADS_LEAVE();
break;
case M_PREVSONG:
GDK_THREADS_ENTER();
gtkps_prevsong ();
GDK_THREADS_LEAVE();
break;
case M_PAUSESONG:
GDK_THREADS_ENTER();
gtkps_pausesong ();
GDK_THREADS_LEAVE();
break;
case M_PLAYRANDOM:
GDK_THREADS_ENTER();
gtkps_randomsong ();
GDK_THREADS_LEAVE();
break;
case M_SONGSEEK:
if (playlist_current.codec) {
psdl_pause ();
codec_lock ();
playlist_current.codec->seek (p1 / 1000.f);
codec_unlock ();
psdl_unpause ();
}
break;
}
}
usleep(1000);
gtkps_update_songinfo ();
// handle message pump here
}
psdl_free ();
codec_free_locking ();
ps_free ();
}
int
main (int argc, char *argv[]) {
messagepump_init ();
thread_start (psdl_thread, 0);
g_thread_init (NULL);
gdk_threads_init ();
gdk_threads_enter ();
gtk_set_locale ();
gtk_init (&argc, &argv);
/*
* The following code was added by Glade to create one of each component
* (except popup menus), just so that you see something after building
* the project. Delete any components that you don't want shown initially.
*/
mainwin = create_mainwin ();
gtk_widget_show (mainwin);
gtk_main ();
gdk_threads_leave ();
messagepump_free ();
psdl_terminate = 1;
return 0;
}
|