Mercurial > audlegacy-plugins
comparison src/lame/out_lame.c @ 858:9429121d61ec trunk
[svn] - implement real buffer_free() and buffer_playing().
- remove unused code.
- apply cast to (short *) in lame_encode_xx()
- change version number from 0.2d6 to 0.2.
author | yaz |
---|---|
date | Wed, 14 Mar 2007 23:34:56 -0700 |
parents | b006af49413e |
children | d801d8ce24fb |
comparison
equal
deleted
inserted
replaced
857:bad7c89d7ba0 | 858:9429121d61ec |
---|---|
30 #include <audacious/util.h> | 30 #include <audacious/util.h> |
31 | 31 |
32 #include <lame/lame.h> | 32 #include <lame/lame.h> |
33 | 33 |
34 #define ENCBUFFER_SIZE 35000 | 34 #define ENCBUFFER_SIZE 35000 |
35 #define OUT_LAME_VER "0.2d6" | 35 #define OUT_LAME_VER "0.2" |
36 #define DEBUG 1 | 36 /* #define DEBUG 1 */ |
37 #undef DEBUG | |
38 | 37 |
39 GtkWidget *configure_win = NULL, *path_vbox; | 38 GtkWidget *configure_win = NULL, *path_vbox; |
40 GtkWidget *path_hbox, *path_label, *path_entry, *path_browse, | 39 GtkWidget *path_hbox, *path_label, *path_entry, *path_browse, |
41 *path_dirbrowser = NULL; | 40 *path_dirbrowser = NULL; |
42 GtkWidget *configure_separator; | 41 GtkWidget *configure_separator; |
139 static gint outlame_open(AFormat fmt, gint rate, gint nch); | 138 static gint outlame_open(AFormat fmt, gint rate, gint nch); |
140 static void outlame_write(void *ptr, gint length); | 139 static void outlame_write(void *ptr, gint length); |
141 static void outlame_close(void); | 140 static void outlame_close(void); |
142 static void outlame_flush(gint time); | 141 static void outlame_flush(gint time); |
143 static void outlame_pause(short p); | 142 static void outlame_pause(short p); |
144 static gint outlame_free(void); | 143 static gint outlame_buffer_free(void); |
145 static gint outlame_playing(void); | 144 static gint outlame_buffer_playing(void); |
146 static gint outlame_get_written_time(void); | 145 static gint outlame_get_written_time(void); |
147 static gint outlame_get_output_time(void); | 146 static gint outlame_get_output_time(void); |
148 static void outlame_configure(void); | 147 static void outlame_configure(void); |
149 | 148 |
150 lame_global_flags *gfp; | 149 lame_global_flags *gfp; |
165 outlame_open, | 164 outlame_open, |
166 outlame_write, | 165 outlame_write, |
167 outlame_close, | 166 outlame_close, |
168 outlame_flush, | 167 outlame_flush, |
169 outlame_pause, | 168 outlame_pause, |
170 outlame_free, | 169 outlame_buffer_free, |
171 outlame_playing, | 170 outlame_buffer_playing, |
172 outlame_get_output_time, | 171 outlame_get_output_time, |
173 outlame_get_written_time, | 172 outlame_get_written_time, |
174 NULL | 173 NULL |
175 }; | 174 }; |
176 | 175 |
301 | 300 |
302 gchar *filename, *title = NULL, *temp; | 301 gchar *filename, *title = NULL, *temp; |
303 gint pos; | 302 gint pos; |
304 int b_use_path_anyway = 0; | 303 int b_use_path_anyway = 0; |
305 gchar *tmpfilename = NULL; | 304 gchar *tmpfilename = NULL; |
306 gchar *tmp = NULL; | |
307 | 305 |
308 /* store open paramators for reopen */ | 306 /* store open paramators for reopen */ |
309 oldfmt = fmt; oldrate = rate; oldnch = nch; | 307 oldfmt = fmt; oldrate = rate; oldnch = nch; |
310 | 308 |
311 /* So all the values will be reset to the ones saved */ | 309 /* So all the values will be reset to the ones saved */ |
361 } | 359 } |
362 printf("file_path = %s\n", file_path); | 360 printf("file_path = %s\n", file_path); |
363 printf("anyway = %d\n", b_use_path_anyway); | 361 printf("anyway = %d\n", b_use_path_anyway); |
364 #endif | 362 #endif |
365 | 363 |
366 // if (tuple && b_use_source_file_path == 1 && b_use_path_anyway == 0) { | |
367 if (tuple && !b_use_path_anyway) { | 364 if (tuple && !b_use_path_anyway) { |
368 if (b_prepend_track_number && tuple->track_number) { | 365 if (b_prepend_track_number && tuple->track_number) { |
369 filename = g_strdup_printf("%s/%.02d %s.mp3", | 366 filename = g_strdup_printf("%s/%.02d %s.mp3", |
370 b_use_source_file_path ? tuple->file_path : file_path, | 367 b_use_source_file_path ? tuple->file_path : file_path, |
371 tuple->track_number, title); | 368 tuple->track_number, title); |
486 static void outlame_write(void *ptr, gint length) | 483 static void outlame_write(void *ptr, gint length) |
487 { | 484 { |
488 | 485 |
489 if (inch == 1) { | 486 if (inch == 1) { |
490 encout = | 487 encout = |
491 lame_encode_buffer(gfp, ptr, ptr, length / 2, encbuffer, | 488 lame_encode_buffer(gfp, (short *)ptr, (short *)ptr, length / 2, encbuffer, |
492 ENCBUFFER_SIZE); | 489 ENCBUFFER_SIZE); |
493 } | 490 } |
494 else { | 491 else { |
495 encout = | 492 encout = |
496 lame_encode_buffer_interleaved(gfp, ptr, length / 4, encbuffer, | 493 lame_encode_buffer_interleaved(gfp, (short *)ptr, length / 4, encbuffer, |
497 ENCBUFFER_SIZE); | 494 ENCBUFFER_SIZE); |
498 } | 495 } |
499 fwrite(encbuffer, 1, encout, output_file); | 496 fwrite(encbuffer, 1, encout, output_file); |
500 written += encout; | 497 written += encout; |
501 olen += length; | 498 olen += length; |
545 | 542 |
546 static void outlame_pause(short p) | 543 static void outlame_pause(short p) |
547 { | 544 { |
548 } | 545 } |
549 | 546 |
550 static gint outlame_free(void) | 547 static gint outlame_buffer_free(void) |
551 { | 548 { |
552 return 1000000; | 549 return ENCBUFFER_SIZE - encout; |
553 } | 550 } |
554 | 551 |
555 static gint outlame_playing(void) | 552 static gint outlame_buffer_playing(void) |
556 { | 553 { |
557 return 0; | 554 #ifdef DEBUG |
555 printf("lame: buffer_playing = %d\n", encout ? 1 : 0); | |
556 #endif | |
557 return encout ? 1 : 0; | |
558 } | 558 } |
559 | 559 |
560 static gint outlame_get_written_time(void) | 560 static gint outlame_get_written_time(void) |
561 { | 561 { |
562 gint time; | 562 gint time; |
833 inside = 0; | 833 inside = 0; |
834 } | 834 } |
835 } | 835 } |
836 | 836 |
837 } | 837 } |
838 | |
839 static void path_dirbrowser_cb(gchar * dir) | |
840 { | |
841 gtk_entry_set_text(GTK_ENTRY(path_entry), dir); | |
842 } | |
843 | |
844 #if 0 | |
845 static void path_browse_cb(GtkWidget * w, gpointer data) | |
846 { | |
847 if (!path_dirbrowser) { | |
848 path_dirbrowser = | |
849 xmms_create_dir_browser | |
850 ("Select the directory where you want to store the output files:", | |
851 file_path, GTK_SELECTION_SINGLE, path_dirbrowser_cb); | |
852 gtk_signal_connect(GTK_OBJECT(path_dirbrowser), "destroy", | |
853 GTK_SIGNAL_FUNC(gtk_widget_destroyed), | |
854 &path_dirbrowser); | |
855 gtk_window_set_transient_for(GTK_WINDOW(path_dirbrowser), | |
856 GTK_WINDOW(configure_win)); | |
857 gtk_widget_show(path_dirbrowser); | |
858 } | |
859 } | |
860 #endif | |
861 | 838 |
862 static void use_source_file_path_cb(GtkToggleButton * togglebutton, | 839 static void use_source_file_path_cb(GtkToggleButton * togglebutton, |
863 gpointer user_data) | 840 gpointer user_data) |
864 { | 841 { |
865 if (gtk_toggle_button_get_active | 842 if (gtk_toggle_button_get_active |