Mercurial > audlegacy
comparison Plugins/Input/console/Audacious_Driver.cpp @ 101:59ba6595fdf1 trunk
[svn] More accurate sound reproduction, but there is warbling. Still locks up player on completion.
| author | nenolod |
|---|---|
| date | Tue, 01 Nov 2005 23:15:57 -0800 |
| parents | 05d05f290c04 |
| children | de414e40f772 |
comparison
equal
deleted
inserted
replaced
| 100:05d05f290c04 | 101:59ba6595fdf1 |
|---|---|
| 18 #include <gtk/gtk.h> | 18 #include <gtk/gtk.h> |
| 19 | 19 |
| 20 }; | 20 }; |
| 21 | 21 |
| 22 #include <cstring> | 22 #include <cstring> |
| 23 | |
| 24 #ifdef WORDS_BIGENDIAN | |
| 25 # define MY_FMT FMT_S16_BE | |
| 26 #else | |
| 27 # define MY_FMT FMT_S16_LE | |
| 28 #endif | |
| 23 | 29 |
| 24 static Spc_Emu *spc = NULL; | 30 static Spc_Emu *spc = NULL; |
| 25 static GThread *decode_thread; | 31 static GThread *decode_thread; |
| 26 | 32 |
| 27 static void *play_loop(gpointer arg); | 33 static void *play_loop(gpointer arg); |
| 78 | 84 |
| 79 reader.open(filename); | 85 reader.open(filename); |
| 80 reader.read(&header, sizeof(header)); | 86 reader.read(&header, sizeof(header)); |
| 81 | 87 |
| 82 spc = new Spc_Emu; | 88 spc = new Spc_Emu; |
| 83 spc->init(44100); | 89 spc->init(32000); |
| 84 spc->load(header, reader); | 90 spc->load(header, reader); |
| 85 spc->start_track(0); | 91 spc->start_track(0); |
| 86 | 92 |
| 87 decode_thread = g_thread_create(play_loop, spc, TRUE, NULL); | 93 decode_thread = g_thread_create(play_loop, spc, TRUE, NULL); |
| 88 | 94 |
| 89 if (!console_ip.output->open_audio(FMT_S16_NE, 44100, 1)) | 95 if (!console_ip.output->open_audio(MY_FMT, 32000, 1)) |
| 90 return; | 96 return; |
| 91 | 97 |
| 92 printf("decode_thread started.\n"); | 98 printf("decode_thread started.\n"); |
| 93 } | 99 } |
| 94 | 100 |
| 142 } | 148 } |
| 143 | 149 |
| 144 static void *play_loop(gpointer arg) | 150 static void *play_loop(gpointer arg) |
| 145 { | 151 { |
| 146 Spc_Emu *my_spc = (Spc_Emu *) arg; | 152 Spc_Emu *my_spc = (Spc_Emu *) arg; |
| 147 Music_Emu::sample_t buf[16384]; | 153 Music_Emu::sample_t buf[4096]; |
| 148 | 154 |
| 149 while (my_spc->play(16384, buf) == NULL) | 155 while (my_spc->play(4096, buf) == NULL) |
| 150 { | 156 { |
| 151 console_ip.add_vis_pcm(console_ip.output->written_time(), | 157 console_ip.add_vis_pcm(console_ip.output->written_time(), |
| 152 FMT_S16_NE, 1, 16384, buf); | 158 MY_FMT, 1, 4096, buf); |
| 153 while(console_ip.output->buffer_free() < 16384); | 159 while(console_ip.output->buffer_free() < 4096) |
| 154 console_ip.output->write_audio(buf, 16384); | 160 xmms_usleep(10000); |
| 161 console_ip.output->write_audio(buf, 4096); | |
| 155 } | 162 } |
| 156 | 163 |
| 157 delete spc; | 164 delete spc; |
| 158 g_thread_exit(NULL); | 165 g_thread_exit(NULL); |
| 159 | 166 |
