Mercurial > audlegacy
comparison Plugins/Input/console/Audacious_Driver.cpp @ 95:8247bbf454a8 trunk
[svn] Add code for decoder thread.
| author | nenolod |
|---|---|
| date | Tue, 01 Nov 2005 21:09:52 -0800 |
| parents | 2801eda0683f |
| children | 8dbd2d31c1f7 |
comparison
equal
deleted
inserted
replaced
| 94:2801eda0683f | 95:8247bbf454a8 |
|---|---|
| 9 #include "Audacious_Driver.h" | 9 #include "Audacious_Driver.h" |
| 10 | 10 |
| 11 #include "libaudacious/configfile.h" | 11 #include "libaudacious/configfile.h" |
| 12 #include "libaudacious/util.h" | 12 #include "libaudacious/util.h" |
| 13 #include "libaudacious/titlestring.h" | 13 #include "libaudacious/titlestring.h" |
| 14 #include "audacious/output.h" | |
| 14 #include <gtk/gtk.h> | 15 #include <gtk/gtk.h> |
| 15 | 16 |
| 16 #include <cstring> | 17 #include <cstring> |
| 17 | 18 |
| 18 static Spc_Emu *spc = NULL; | 19 static Spc_Emu *spc = NULL; |
| 19 static GThread decode_thread; | 20 static GThread *decode_thread; |
| 21 static InputPlugin console_ip; | |
| 22 | |
| 23 static void *play_loop(gpointer arg); | |
| 20 | 24 |
| 21 static int is_our_file(gchar *filename) | 25 static int is_our_file(gchar *filename) |
| 22 { | 26 { |
| 23 gchar *ext; | 27 gchar *ext; |
| 24 | 28 |
| 33 return 0; | 37 return 0; |
| 34 } | 38 } |
| 35 | 39 |
| 36 static gchar *get_title(gchar *filename) | 40 static gchar *get_title(gchar *filename) |
| 37 { | 41 { |
| 38 TitleInput *input; | |
| 39 gchar *title; | 42 gchar *title; |
| 40 Emu_Std_Reader reader; | 43 Emu_Std_Reader reader; |
| 41 Spc_Emu::header_t header; | 44 Spc_Emu::header_t header; |
| 42 | 45 |
| 43 reader.open(filename); | 46 reader.open(filename); |
| 45 | 48 |
| 46 title = g_strdup(header.song); | 49 title = g_strdup(header.song); |
| 47 | 50 |
| 48 return title; | 51 return title; |
| 49 } | 52 } |
| 53 | |
| 54 static void get_song_info(char *filename, char **title, int *length) | |
| 55 { | |
| 56 (*title) = get_title(filename); | |
| 57 (*length) = -1; | |
| 58 } | |
| 59 | |
| 60 static void play_file(char *filename) | |
| 61 { | |
| 62 Emu_Std_Reader reader; | |
| 63 Spc_Emu::header_t header; | |
| 64 | |
| 65 reader.open(filename); | |
| 66 reader.read(&header, sizeof(header)); | |
| 67 | |
| 68 spc = new Spc_Emu; | |
| 69 spc->init(44100); | |
| 70 spc->load(header, reader); | |
| 71 spc->start_track(0); | |
| 72 | |
| 73 decode_thread = g_thread_create(play_loop, NULL, FALSE, NULL); | |
| 74 } | |
| 75 | |
| 76 static void *play_loop(gpointer arg) | |
| 77 { | |
| 78 Music_Emu::sample_t buf[1024]; | |
| 79 | |
| 80 while (spc->play(1024, buf)) | |
| 81 { | |
| 82 produce_audio(console_ip.output->written_time(), | |
| 83 FMT_S16_LE, 2, 1024, (char *) buf, | |
| 84 NULL); | |
| 85 xmms_usleep(100000); | |
| 86 } | |
| 87 | |
| 88 delete spc; | |
| 89 g_thread_exit(NULL); | |
| 90 | |
| 91 return NULL; | |
| 92 } | |
| 93 | |
| 94 |
