Mercurial > audlegacy
comparison Plugins/Input/console/Audacious_Driver.cpp @ 96:8dbd2d31c1f7 trunk
[svn] More work
| author | nenolod |
|---|---|
| date | Tue, 01 Nov 2005 21:23:24 -0800 |
| parents | 8247bbf454a8 |
| children | e42694a28331 |
comparison
equal
deleted
inserted
replaced
| 95:8247bbf454a8 | 96:8dbd2d31c1f7 |
|---|---|
| 6 * http://www.slack.net/~ant/libs/ | 6 * http://www.slack.net/~ant/libs/ |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #include "Audacious_Driver.h" | 9 #include "Audacious_Driver.h" |
| 10 | 10 |
| 11 #include <glib/gi18n.h> | |
| 11 #include "libaudacious/configfile.h" | 12 #include "libaudacious/configfile.h" |
| 12 #include "libaudacious/util.h" | 13 #include "libaudacious/util.h" |
| 13 #include "libaudacious/titlestring.h" | 14 #include "libaudacious/titlestring.h" |
| 14 #include "audacious/output.h" | 15 #include "audacious/output.h" |
| 15 #include <gtk/gtk.h> | 16 #include <gtk/gtk.h> |
| 16 | 17 |
| 17 #include <cstring> | 18 #include <cstring> |
| 18 | 19 |
| 19 static Spc_Emu *spc = NULL; | 20 static Spc_Emu *spc = NULL; |
| 20 static GThread *decode_thread; | 21 static GThread *decode_thread; |
| 21 static InputPlugin console_ip; | |
| 22 | 22 |
| 23 static void *play_loop(gpointer arg); | 23 static void *play_loop(gpointer arg); |
| 24 static void console_stop(void); | |
| 25 static void console_pause(gshort p); | |
| 26 static int get_time(void); | |
| 24 | 27 |
| 25 static int is_our_file(gchar *filename) | 28 static int is_our_file(gchar *filename) |
| 26 { | 29 { |
| 27 gchar *ext; | 30 gchar *ext; |
| 28 | 31 |
| 71 spc->start_track(0); | 74 spc->start_track(0); |
| 72 | 75 |
| 73 decode_thread = g_thread_create(play_loop, NULL, FALSE, NULL); | 76 decode_thread = g_thread_create(play_loop, NULL, FALSE, NULL); |
| 74 } | 77 } |
| 75 | 78 |
| 79 static void seek(gint time) | |
| 80 { | |
| 81 // XXX: Not yet implemented | |
| 82 } | |
| 83 | |
| 84 static void console_init(void) | |
| 85 { | |
| 86 // nothing to do here | |
| 87 } | |
| 88 | |
| 89 InputPlugin console_ip = { | |
| 90 NULL, | |
| 91 NULL, | |
| 92 NULL, | |
| 93 console_init, | |
| 94 NULL, | |
| 95 NULL, | |
| 96 is_our_file, | |
| 97 NULL, | |
| 98 play_file, | |
| 99 console_stop, | |
| 100 console_pause, | |
| 101 seek, | |
| 102 NULL, | |
| 103 get_time, | |
| 104 NULL, | |
| 105 NULL, | |
| 106 NULL, | |
| 107 NULL, | |
| 108 NULL, | |
| 109 NULL, | |
| 110 NULL, | |
| 111 NULL, | |
| 112 NULL, | |
| 113 NULL | |
| 114 }; | |
| 115 | |
| 116 static void console_stop(void) | |
| 117 { | |
| 118 g_thread_join(decode_thread); | |
| 119 console_ip.output->close_audio(); | |
| 120 } | |
| 121 | |
| 122 InputPlugin *get_iplugin_info(void) | |
| 123 { | |
| 124 console_ip.description = g_strdup_printf(_("Console music plugin")); | |
| 125 return &console_ip; | |
| 126 } | |
| 127 | |
| 128 static void console_pause(gshort p) | |
| 129 { | |
| 130 console_ip.output->pause(p); | |
| 131 } | |
| 132 | |
| 76 static void *play_loop(gpointer arg) | 133 static void *play_loop(gpointer arg) |
| 77 { | 134 { |
| 78 Music_Emu::sample_t buf[1024]; | 135 Music_Emu::sample_t buf[1024]; |
| 79 | 136 |
| 80 while (spc->play(1024, buf)) | 137 while (spc->play(1024, buf)) |
| 81 { | 138 { |
| 82 produce_audio(console_ip.output->written_time(), | 139 produce_audio(console_ip.output->written_time(), |
| 83 FMT_S16_LE, 2, 1024, (char *) buf, | 140 FMT_S16_LE, 2, 1024, (char *) buf, |
| 84 NULL); | 141 NULL); |
| 85 xmms_usleep(100000); | 142 xmms_usleep(100000); |
| 86 } | 143 } |
| 87 | 144 |
| 88 delete spc; | 145 delete spc; |
| 89 g_thread_exit(NULL); | 146 g_thread_exit(NULL); |
| 90 | 147 |
| 91 return NULL; | 148 return NULL; |
| 92 } | 149 } |
| 93 | 150 |
| 151 static int get_time(void) | |
| 152 { | |
| 153 return console_ip.output->output_time(); | |
| 154 } | |
| 94 | 155 |
