windows support
This commit is contained in:
parent
35213ac652
commit
ad6df6e3fd
6 changed files with 52 additions and 54 deletions
|
|
@ -4,7 +4,7 @@
|
||||||
#include <stb_ds.h>
|
#include <stb_ds.h>
|
||||||
|
|
||||||
static MDEAudio audio;
|
static MDEAudio audio;
|
||||||
pthread_mutex_t audio_mutex;
|
MDEMutex audio_mutex;
|
||||||
queue_t* queue = NULL;
|
queue_t* queue = NULL;
|
||||||
int queue_seek = -1;
|
int queue_seek = -1;
|
||||||
int paused = 0;
|
int paused = 0;
|
||||||
|
|
@ -13,7 +13,7 @@ int repeated = 0;
|
||||||
static void handler(MDEAudio handle, void* user, void* data, int frames) {
|
static void handler(MDEAudio handle, void* user, void* data, int frames) {
|
||||||
memset(data, 0, frames * 2 * 2);
|
memset(data, 0, frames * 2 * 2);
|
||||||
|
|
||||||
pthread_mutex_lock(&audio_mutex);
|
MDEMutexLock(audio_mutex);
|
||||||
if(queue_seek != -1 && !paused) {
|
if(queue_seek != -1 && !paused) {
|
||||||
int from_frames = frames * queue[queue_seek].sound->context->sample_rate / MDEAudioRate;
|
int from_frames = frames * queue[queue_seek].sound->context->sample_rate / MDEAudioRate;
|
||||||
float* from = malloc(from_frames * sizeof(*from) * 2);
|
float* from = malloc(from_frames * sizeof(*from) * 2);
|
||||||
|
|
@ -47,13 +47,13 @@ static void handler(MDEAudio handle, void* user, void* data, int frames) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&audio_mutex);
|
MDEMutexUnlock(audio_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void audio_init(void) {
|
void audio_init(void) {
|
||||||
audio = MDEAudioOpen(handler, NULL);
|
audio = MDEAudioOpen(handler, NULL);
|
||||||
|
|
||||||
pthread_mutex_init(&audio_mutex, NULL);
|
audio_mutex = MDEMutexCreate();
|
||||||
|
|
||||||
MDEAudioStart(audio);
|
MDEAudioStart(audio);
|
||||||
}
|
}
|
||||||
|
|
@ -64,10 +64,10 @@ void audio_queue(const char* path) {
|
||||||
q.sound = MDESoundOpen(q.path);
|
q.sound = MDESoundOpen(q.path);
|
||||||
q.frames = 0;
|
q.frames = 0;
|
||||||
|
|
||||||
pthread_mutex_lock(&audio_mutex);
|
MDEMutexLock(audio_mutex);
|
||||||
arrput(queue, q);
|
arrput(queue, q);
|
||||||
if(queue_seek == -1) queue_seek = arrlen(queue) - 1;
|
if(queue_seek == -1) queue_seek = arrlen(queue) - 1;
|
||||||
|
|
||||||
ui_set_play_queue(arrlen(queue));
|
ui_set_play_queue(arrlen(queue));
|
||||||
pthread_mutex_unlock(&audio_mutex);
|
MDEMutexUnlock(audio_mutex);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
13
mauplay/db.c
13
mauplay/db.c
|
|
@ -29,13 +29,14 @@ int db_exec(const char* s) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int db_init(void) {
|
int db_init(void) {
|
||||||
struct passwd* pwd = getpwuid(getuid());
|
char* conf = MDEDirectoryConfigPath();
|
||||||
char* dir = malloc(strlen(pwd->pw_dir) + 1 + strlen(".config/mauplay") + 1);
|
char* dir = malloc(strlen(conf) + 8 + 1);
|
||||||
char* path;
|
char* path;
|
||||||
int st = 0;
|
int st = 0;
|
||||||
|
|
||||||
strcpy(dir, pwd->pw_dir);
|
strcpy(dir, conf);
|
||||||
strcat(dir, "/.config/mauplay");
|
strcat(dir, "/mauplay");
|
||||||
|
free(conf);
|
||||||
|
|
||||||
MDEDirectoryCreate(dir, 0755);
|
MDEDirectoryCreate(dir, 0755);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,12 +12,9 @@
|
||||||
/* External */
|
/* External */
|
||||||
|
|
||||||
/* Standard */
|
/* Standard */
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <pwd.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <pthread.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#define ALBUMWIDTH 128
|
#define ALBUMWIDTH 128
|
||||||
|
|
||||||
|
|
@ -73,11 +70,11 @@ void ui_set_artists(int v);
|
||||||
void ui_set_genres(int v);
|
void ui_set_genres(int v);
|
||||||
|
|
||||||
/* audio.c */
|
/* audio.c */
|
||||||
extern pthread_mutex_t audio_mutex;
|
extern MDEMutex audio_mutex;
|
||||||
extern queue_t* queue;
|
extern queue_t* queue;
|
||||||
extern int queue_seek;
|
extern int queue_seek;
|
||||||
extern int paused;
|
extern int paused;
|
||||||
extern int repeated;
|
extern int repeated;
|
||||||
|
|
||||||
void audio_init(void);
|
void audio_init(void);
|
||||||
void audio_queue(const char* path);
|
void audio_queue(const char* path);
|
||||||
|
|
|
||||||
49
mauplay/ui.c
49
mauplay/ui.c
|
|
@ -105,7 +105,7 @@ static void tree_activate(MwWidget handle, void* user, void* client) {
|
||||||
if(current != NULL) free(current);
|
if(current != NULL) free(current);
|
||||||
current = NULL;
|
current = NULL;
|
||||||
if(client == play_queue) {
|
if(client == play_queue) {
|
||||||
pthread_mutex_lock(&audio_mutex);
|
MDEMutexLock(audio_mutex);
|
||||||
for(i = 0; i < arrlen(queue); i++) {
|
for(i = 0; i < arrlen(queue); i++) {
|
||||||
char buf[64];
|
char buf[64];
|
||||||
int ind = shgeti(db_musics, queue[i].path);
|
int ind = shgeti(db_musics, queue[i].path);
|
||||||
|
|
@ -121,7 +121,7 @@ static void tree_activate(MwWidget handle, void* user, void* client) {
|
||||||
|
|
||||||
MwListBoxPacketSet(p, index, 3, buf);
|
MwListBoxPacketSet(p, index, 3, buf);
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&audio_mutex);
|
MDEMutexUnlock(audio_mutex);
|
||||||
}
|
}
|
||||||
if(client == all_music) {
|
if(client == all_music) {
|
||||||
for(i = 0; i < shlen(db_musics); i++) {
|
for(i = 0; i < shlen(db_musics); i++) {
|
||||||
|
|
@ -203,7 +203,7 @@ static void tree_activate(MwWidget handle, void* user, void* client) {
|
||||||
|
|
||||||
static void list_activate(MwWidget handle, void* user, void* client) {
|
static void list_activate(MwWidget handle, void* user, void* client) {
|
||||||
if(ui_last == play_queue) {
|
if(ui_last == play_queue) {
|
||||||
pthread_mutex_lock(&audio_mutex);
|
MDEMutexLock(audio_mutex);
|
||||||
if(queue_seek != -1) {
|
if(queue_seek != -1) {
|
||||||
queue[queue_seek].frames = 0;
|
queue[queue_seek].frames = 0;
|
||||||
MDESoundSeek(queue[queue_seek].sound, 0);
|
MDESoundSeek(queue[queue_seek].sound, 0);
|
||||||
|
|
@ -211,7 +211,7 @@ static void list_activate(MwWidget handle, void* user, void* client) {
|
||||||
queue_seek = (*(int*)client) - 1;
|
queue_seek = (*(int*)client) - 1;
|
||||||
queue[queue_seek].frames = 0;
|
queue[queue_seek].frames = 0;
|
||||||
MDESoundSeek(queue[queue_seek].sound, 0);
|
MDESoundSeek(queue[queue_seek].sound, 0);
|
||||||
pthread_mutex_unlock(&audio_mutex);
|
MDEMutexUnlock(audio_mutex);
|
||||||
} else if(ui_last == all_music) {
|
} else if(ui_last == all_music) {
|
||||||
audio_queue(db_musics[(*(int*)client) - 1].key);
|
audio_queue(db_musics[(*(int*)client) - 1].key);
|
||||||
} else if(ui_last == albums || ui_last == artists || ui_last == genres) {
|
} else if(ui_last == albums || ui_last == artists || ui_last == genres) {
|
||||||
|
|
@ -284,7 +284,7 @@ static void list_activate(MwWidget handle, void* user, void* client) {
|
||||||
int queue_last = -1;
|
int queue_last = -1;
|
||||||
|
|
||||||
static void window_tick(MwWidget handle, void* user, void* client) {
|
static void window_tick(MwWidget handle, void* user, void* client) {
|
||||||
pthread_mutex_lock(&audio_mutex);
|
MDEMutexLock(audio_mutex);
|
||||||
if(queue_last != queue_seek && queue_seek != -1) {
|
if(queue_last != queue_seek && queue_seek != -1) {
|
||||||
int ind;
|
int ind;
|
||||||
char* buf;
|
char* buf;
|
||||||
|
|
@ -320,12 +320,13 @@ static void window_tick(MwWidget handle, void* user, void* client) {
|
||||||
MwForceRender(album);
|
MwForceRender(album);
|
||||||
|
|
||||||
if(ui_last == play_queue) {
|
if(ui_last == play_queue) {
|
||||||
pthread_mutex_unlock(&audio_mutex);
|
MDEMutexUnlock(audio_mutex);
|
||||||
MwDispatchUserHandler(tree, MwNactivateHandler, ui_last);
|
MwDispatchUserHandler(tree, MwNactivateHandler, ui_last);
|
||||||
pthread_mutex_lock(&audio_mutex);
|
MDEMutexLock(audio_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
ind = shgeti(db_musics, queue[queue_seek].path);
|
ind = shgeti(db_musics, queue[queue_seek].path);
|
||||||
|
|
||||||
buf = malloc(strlen(db_musics[ind].title) + 1 + strlen(db_musics[ind].artist) + 1);
|
buf = malloc(strlen(db_musics[ind].title) + 1 + strlen(db_musics[ind].artist) + 1);
|
||||||
|
|
||||||
buf[0] = 0;
|
buf[0] = 0;
|
||||||
|
|
@ -373,7 +374,7 @@ static void window_tick(MwWidget handle, void* user, void* client) {
|
||||||
MwForceRender(album);
|
MwForceRender(album);
|
||||||
}
|
}
|
||||||
queue_last = queue_seek;
|
queue_last = queue_seek;
|
||||||
pthread_mutex_unlock(&audio_mutex);
|
MDEMutexUnlock(audio_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void seekbar_changed(MwWidget handle, void* user, void* client) {
|
static void seekbar_changed(MwWidget handle, void* user, void* client) {
|
||||||
|
|
@ -381,7 +382,7 @@ static void seekbar_changed(MwWidget handle, void* user, void* client) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void bskipback_activate(MwWidget handle, void* user, void* client) {
|
static void bskipback_activate(MwWidget handle, void* user, void* client) {
|
||||||
pthread_mutex_lock(&audio_mutex);
|
MDEMutexLock(audio_mutex);
|
||||||
if(queue_seek == -1) {
|
if(queue_seek == -1) {
|
||||||
queue_seek = 0;
|
queue_seek = 0;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -393,33 +394,33 @@ static void bskipback_activate(MwWidget handle, void* user, void* client) {
|
||||||
} else {
|
} else {
|
||||||
queue_seek = -1;
|
queue_seek = -1;
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&audio_mutex);
|
MDEMutexUnlock(audio_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void bplay_activate(MwWidget handle, void* user, void* client) {
|
static void bplay_activate(MwWidget handle, void* user, void* client) {
|
||||||
pthread_mutex_lock(&audio_mutex);
|
MDEMutexLock(audio_mutex);
|
||||||
paused = 0;
|
paused = 0;
|
||||||
pthread_mutex_unlock(&audio_mutex);
|
MDEMutexUnlock(audio_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void bpause_activate(MwWidget handle, void* user, void* client) {
|
static void bpause_activate(MwWidget handle, void* user, void* client) {
|
||||||
pthread_mutex_lock(&audio_mutex);
|
MDEMutexLock(audio_mutex);
|
||||||
paused = 1;
|
paused = 1;
|
||||||
pthread_mutex_unlock(&audio_mutex);
|
MDEMutexUnlock(audio_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void bstop_activate(MwWidget handle, void* user, void* client) {
|
static void bstop_activate(MwWidget handle, void* user, void* client) {
|
||||||
pthread_mutex_lock(&audio_mutex);
|
MDEMutexLock(audio_mutex);
|
||||||
if(queue_seek != -1) {
|
if(queue_seek != -1) {
|
||||||
queue[queue_seek].frames = 0;
|
queue[queue_seek].frames = 0;
|
||||||
MDESoundSeek(queue[queue_seek].sound, 0);
|
MDESoundSeek(queue[queue_seek].sound, 0);
|
||||||
}
|
}
|
||||||
queue_seek = -1;
|
queue_seek = -1;
|
||||||
pthread_mutex_unlock(&audio_mutex);
|
MDEMutexUnlock(audio_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void bskipfwd_activate(MwWidget handle, void* user, void* client) {
|
static void bskipfwd_activate(MwWidget handle, void* user, void* client) {
|
||||||
pthread_mutex_lock(&audio_mutex);
|
MDEMutexLock(audio_mutex);
|
||||||
if(queue_seek == -1) {
|
if(queue_seek == -1) {
|
||||||
queue_seek = 0;
|
queue_seek = 0;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -431,16 +432,16 @@ static void bskipfwd_activate(MwWidget handle, void* user, void* client) {
|
||||||
} else {
|
} else {
|
||||||
queue_seek = -1;
|
queue_seek = -1;
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&audio_mutex);
|
MDEMutexUnlock(audio_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void brepeat_activate(MwWidget handle, void* user, void* client) {
|
static void brepeat_activate(MwWidget handle, void* user, void* client) {
|
||||||
pthread_mutex_lock(&audio_mutex);
|
MDEMutexLock(audio_mutex);
|
||||||
repeated = repeated ? 0 : 1;
|
repeated = repeated ? 0 : 1;
|
||||||
MwVaApply(brepeat,
|
MwVaApply(brepeat,
|
||||||
MwNpixmap, repeated ? pxrepeatsong : pxrepeat,
|
MwNpixmap, repeated ? pxrepeatsong : pxrepeat,
|
||||||
NULL);
|
NULL);
|
||||||
pthread_mutex_unlock(&audio_mutex);
|
MDEMutexUnlock(audio_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void file_fc_chosen(MwWidget handle, void* user, void* client) {
|
static void file_fc_chosen(MwWidget handle, void* user, void* client) {
|
||||||
|
|
@ -459,7 +460,7 @@ static void menu_menu(MwWidget handle, void* user, void* client) {
|
||||||
} else if(client == file_add_playlist) {
|
} else if(client == file_add_playlist) {
|
||||||
MwWidget fc = MwFileChooser(window, "Choose a playlist to add");
|
MwWidget fc = MwFileChooser(window, "Choose a playlist to add");
|
||||||
MwAddUserHandler(fc, MwNfileChosenHandler, playlist_fc_chosen, NULL);
|
MwAddUserHandler(fc, MwNfileChosenHandler, playlist_fc_chosen, NULL);
|
||||||
}else if(client == help_about){
|
} else if(client == help_about) {
|
||||||
MDEAboutDialog(window, "mauplay", VERSION, pxradio);
|
MDEAboutDialog(window, "mauplay", VERSION, pxradio);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -471,7 +472,7 @@ static void list_mouseup(MwWidget handle, void* user, void* client) {
|
||||||
if(m->button != MwLLMouseRight) return;
|
if(m->button != MwLLMouseRight) return;
|
||||||
if((s = MwGetInteger(list, MwNvalue)) == -1) return;
|
if((s = MwGetInteger(list, MwNvalue)) == -1) return;
|
||||||
|
|
||||||
pthread_mutex_lock(&audio_mutex);
|
MDEMutexLock(audio_mutex);
|
||||||
MwListBoxDelete(list, s);
|
MwListBoxDelete(list, s);
|
||||||
arrdel(queue, s - 1);
|
arrdel(queue, s - 1);
|
||||||
ui_set_play_queue(arrlen(queue));
|
ui_set_play_queue(arrlen(queue));
|
||||||
|
|
@ -485,7 +486,7 @@ static void list_mouseup(MwWidget handle, void* user, void* client) {
|
||||||
if(arrlen(queue) <= queue_seek) {
|
if(arrlen(queue) <= queue_seek) {
|
||||||
queue_seek = arrlen(queue) - 1;
|
queue_seek = arrlen(queue) - 1;
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&audio_mutex);
|
MDEMutexUnlock(audio_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ui_init(void) {
|
void ui_init(void) {
|
||||||
|
|
@ -498,7 +499,7 @@ void ui_init(void) {
|
||||||
file_add_directory = MwMenuAdd(menu, m, "Add Directory");
|
file_add_directory = MwMenuAdd(menu, m, "Add Directory");
|
||||||
file_add_playlist = MwMenuAdd(menu, m, "Add Playlist");
|
file_add_playlist = MwMenuAdd(menu, m, "Add Playlist");
|
||||||
|
|
||||||
m = MwMenuAdd(menu, NULL, "?Help");
|
m = MwMenuAdd(menu, NULL, "?Help");
|
||||||
help_about = MwMenuAdd(menu, m, "About");
|
help_about = MwMenuAdd(menu, m, "About");
|
||||||
|
|
||||||
ui_list_reset(NULL);
|
ui_list_reset(NULL);
|
||||||
|
|
|
||||||
13
mbiff/mail.c
13
mbiff/mail.c
|
|
@ -4,16 +4,17 @@ static time_t last = 0;
|
||||||
static char* mailpath;
|
static char* mailpath;
|
||||||
|
|
||||||
void init_mail(void) {
|
void init_mail(void) {
|
||||||
struct stat s;
|
struct stat s;
|
||||||
struct passwd* pwd = getpwuid(getuid());
|
char* name = MDEUsersGetUsername();
|
||||||
|
|
||||||
if(getenv("MAIL") != NULL) {
|
if(getenv("MAIL") != NULL) {
|
||||||
mailpath = malloc(strlen(getenv("MAIL")) + strlen(pwd->pw_name) + 1);
|
mailpath = malloc(strlen(getenv("MAIL")) + strlen(name) + 1);
|
||||||
sprintf(mailpath, getenv("MAIL"), pwd->pw_name);
|
sprintf(mailpath, getenv("MAIL"), name);
|
||||||
} else {
|
} else {
|
||||||
mailpath = malloc(strlen(_PATH_MAILDIR) + 1 + strlen(pwd->pw_name) + 1);
|
mailpath = malloc(strlen(_PATH_MAILDIR) + 1 + strlen(name) + 1);
|
||||||
sprintf(mailpath, _PATH_MAILDIR "/%s", pwd->pw_name);
|
sprintf(mailpath, _PATH_MAILDIR "/%s", name);
|
||||||
}
|
}
|
||||||
|
free(name);
|
||||||
|
|
||||||
if(stat(mailpath, &s) == 0) {
|
if(stat(mailpath, &s) == 0) {
|
||||||
last = s.st_mtime;
|
last = s.st_mtime;
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,6 @@
|
||||||
|
|
||||||
/* Standard */
|
/* Standard */
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <pwd.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue