diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/flac/flac.c | 2 | ||||
-rw-r--r-- | plugins/gtkui/deadbeef.glade | 2 | ||||
-rw-r--r-- | plugins/gtkui/gtkplaylist.c | 44 | ||||
-rw-r--r-- | plugins/gtkui/interface.c | 1 | ||||
-rw-r--r-- | plugins/gtkui/progress.c | 2 | ||||
-rw-r--r-- | plugins/mpgmad/mpgmad.c | 36 |
6 files changed, 49 insertions, 38 deletions
diff --git a/plugins/flac/flac.c b/plugins/flac/flac.c index 776e3e95..11f8cfe3 100644 --- a/plugins/flac/flac.c +++ b/plugins/flac/flac.c @@ -191,6 +191,7 @@ cflac_init (DB_playItem_t *it) { plugin.free (); return -1; } + buffer = malloc (BUFFERSIZE); if (it->endsample > 0) { startsample = it->startsample; endsample = it->endsample; @@ -208,7 +209,6 @@ cflac_init (DB_playItem_t *it) { } remaining = 0; - buffer = malloc (BUFFERSIZE); return 0; } diff --git a/plugins/gtkui/deadbeef.glade b/plugins/gtkui/deadbeef.glade index c71e3a65..d95bdeb8 100644 --- a/plugins/gtkui/deadbeef.glade +++ b/plugins/gtkui/deadbeef.glade @@ -1177,7 +1177,7 @@ <property name="title" translatable="yes">Adding files...</property> <property name="type">GTK_WINDOW_TOPLEVEL</property> <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property> - <property name="modal">False</property> + <property name="modal">True</property> <property name="resizable">True</property> <property name="destroy_with_parent">False</property> <property name="decorated">True</property> diff --git a/plugins/gtkui/gtkplaylist.c b/plugins/gtkui/gtkplaylist.c index 266fe2c5..9bde04cf 100644 --- a/plugins/gtkui/gtkplaylist.c +++ b/plugins/gtkui/gtkplaylist.c @@ -51,6 +51,14 @@ //#define trace(...) { fprintf(stderr, __VA_ARGS__); } #define trace(fmt,...) +// debug function for gdk_draw_drawable +static inline void +draw_drawable (GdkDrawable *window, GdkGC *gc, GdkDrawable *drawable, int x1, int y1, int x2, int y2, int w, int h) { +// printf ("dd: %p %p %p %d %d %d %d %d %d\n", window, gc, drawable, x1, y1, x2, y2, w, h); + gdk_draw_drawable (window, gc, drawable, x1, y1, x2, y2, w, h); +} + + extern GtkWidget *mainwin; extern GtkStatusIcon *trayicon; extern gtkplaylist_t main_playlist; @@ -289,8 +297,10 @@ gtkpl_redraw_pl_row_novis (gtkplaylist_t *ps, int row, playItem_t *it) { draw_end (); } -void gtkpl_redraw_pl_row (gtkplaylist_t *ps, int row, DB_playItem_t *it) { + if (row < ps->scrollpos || row >= ps->scrollpos+ps->nvisiblerows) { + return; + } int x, y, w, h; GtkWidget *widget = ps->playlist; x = 0; @@ -299,7 +309,7 @@ gtkpl_redraw_pl_row (gtkplaylist_t *ps, int row, DB_playItem_t *it) { h = rowheight; gtkpl_redraw_pl_row_novis (ps, row, it); - gdk_draw_drawable (widget->window, widget->style->black_gc, ps->backbuf, x, y, x, y, w, h); + draw_drawable (widget->window, widget->style->black_gc, ps->backbuf, x, y, x, y, w, h); } void @@ -519,14 +529,14 @@ void gtkpl_expose (gtkplaylist_t *ps, int x, int y, int w, int h) { GtkWidget *widget = ps->playlist; if (widget->window) { - gdk_draw_drawable (widget->window, widget->style->black_gc, ps->backbuf, x, y, x, y, w, h); + draw_drawable (widget->window, widget->style->black_gc, ps->backbuf, x, y, x, y, w, h); } } void gtkpl_expose_header (gtkplaylist_t *ps, int x, int y, int w, int h) { GtkWidget *widget = ps->header; - gdk_draw_drawable (widget->window, widget->style->black_gc, ps->backbuf_header, x, y, x, y, w, h); + draw_drawable (widget->window, widget->style->black_gc, ps->backbuf_header, x, y, x, y, w, h); } void @@ -721,11 +731,11 @@ gtkpl_draw_areasel (GtkWidget *widget, int x, int y) { int dy = max (areaselect_y, areaselect_dy); int w = dx - sx + 1; int h = dy - sy + 1; - //gdk_draw_drawable (widget->window, widget->style->black_gc, ps->backbuf, sx, sy, sx, sy, dx - sx + 1, dy - sy + 1); - gdk_draw_drawable (widget->window, widget->style->black_gc, ps->backbuf, sx, sy, sx, sy, w, 1); - gdk_draw_drawable (widget->window, widget->style->black_gc, ps->backbuf, sx, sy, sx, sy, 1, h); - gdk_draw_drawable (widget->window, widget->style->black_gc, ps->backbuf, sx, sy + h - 1, sx, sy + h - 1, w, 1); - gdk_draw_drawable (widget->window, widget->style->black_gc, ps->backbuf, sx + w - 1, sy, sx + w - 1, sy, 1, h); + //draw_drawable (widget->window, widget->style->black_gc, ps->backbuf, sx, sy, sx, sy, dx - sx + 1, dy - sy + 1); + draw_drawable (widget->window, widget->style->black_gc, ps->backbuf, sx, sy, sx, sy, w, 1); + draw_drawable (widget->window, widget->style->black_gc, ps->backbuf, sx, sy, sx, sy, 1, h); + draw_drawable (widget->window, widget->style->black_gc, ps->backbuf, sx, sy + h - 1, sx, sy + h - 1, w, 1); + draw_drawable (widget->window, widget->style->black_gc, ps->backbuf, sx + w - 1, sy, sx + w - 1, sy, 1, h); } areaselect_dx = x; areaselect_dy = y; @@ -892,7 +902,7 @@ gtkpl_scroll (gtkplaylist_t *ps, int newscroll) { int d = abs (di); if (d < ps->nvisiblerows) { if (di > 0) { - gdk_draw_drawable (ps->backbuf, widget->style->black_gc, ps->backbuf, 0, d * rowheight, 0, 0, widget->allocation.width, widget->allocation.height-d * rowheight); + draw_drawable (ps->backbuf, widget->style->black_gc, ps->backbuf, 0, d * rowheight, 0, 0, widget->allocation.width, widget->allocation.height-d * rowheight); int i; ps->scrollpos = newscroll; int start = ps->nvisiblerows-d-1; @@ -902,7 +912,7 @@ gtkpl_scroll (gtkplaylist_t *ps, int newscroll) { } } else { - gdk_draw_drawable (ps->backbuf, widget->style->black_gc, ps->backbuf, 0, 0, 0, d*rowheight, widget->allocation.width, widget->allocation.height); + draw_drawable (ps->backbuf, widget->style->black_gc, ps->backbuf, 0, 0, 0, d*rowheight, widget->allocation.width, widget->allocation.height); ps->scrollpos = newscroll; int i; for (i = 0; i <= d+1; i++) { @@ -914,7 +924,7 @@ gtkpl_scroll (gtkplaylist_t *ps, int newscroll) { ps->scrollpos = newscroll; gtkpl_draw_playlist (ps, 0, 0, widget->allocation.width, widget->allocation.height); } - gdk_draw_drawable (widget->window, widget->style->black_gc, ps->backbuf, 0, 0, 0, 0, widget->allocation.width, widget->allocation.height); + draw_drawable (widget->window, widget->style->black_gc, ps->backbuf, 0, 0, 0, 0, widget->allocation.width, widget->allocation.height); } } @@ -926,7 +936,7 @@ gtkpl_hscroll (gtkplaylist_t *ps, int newscroll) { gtkpl_header_draw (ps); gtkpl_expose_header (ps, 0, 0, ps->header->allocation.width, ps->header->allocation.height); gtkpl_draw_playlist (ps, 0, 0, widget->allocation.width, widget->allocation.height); - gdk_draw_drawable (widget->window, widget->style->black_gc, ps->backbuf, 0, 0, 0, 0, widget->allocation.width, widget->allocation.height); + draw_drawable (widget->window, widget->style->black_gc, ps->backbuf, 0, 0, 0, 0, widget->allocation.width, widget->allocation.height); } } @@ -978,7 +988,7 @@ gtkpl_keypress (gtkplaylist_t *ps, int keyval, int state) { // // select all // pl_select_all (); // gtkpl_draw_playlist (ps, 0, 0, widget->allocation.width, widget->allocation.height); -// gdk_draw_drawable (widget->window, widget->style->black_gc, ps->backbuf, 0, 0, 0, 0, widget->allocation.width, widget->allocation.height); +// draw_drawable (widget->window, widget->style->black_gc, ps->backbuf, 0, 0, 0, 0, widget->allocation.width, widget->allocation.height); // return; // } // else if ((keyval == GDK_P || keyval == GDK_p) && (state & GDK_CONTROL_MASK)) { @@ -1130,7 +1140,7 @@ gtkpl_track_dragdrop (gtkplaylist_t *ps, int y) { GtkWidget *widget = ps->playlist; if (drag_motion_y != -1) { // erase previous track - gdk_draw_drawable (widget->window, widget->style->black_gc, ps->backbuf, 0, drag_motion_y * rowheight-3, 0, drag_motion_y * rowheight-3, widget->allocation.width, 7); + draw_drawable (widget->window, widget->style->black_gc, ps->backbuf, 0, drag_motion_y * rowheight-3, 0, drag_motion_y * rowheight-3, widget->allocation.width, 7); } if (y == -1) { @@ -1569,10 +1579,6 @@ on_header_motion_notify_event (GtkWidget *widget, } } else if (header_sizing >= 0) { - // limit event rate - if (event->time - last_header_motion_ev < 50 || prev_header_x == event->x) { - return FALSE; - } last_header_motion_ev = event->time; prev_header_x = event->x; gdk_window_set_cursor (widget->window, cursor_sz); diff --git a/plugins/gtkui/interface.c b/plugins/gtkui/interface.c index 88acb8d0..9abc876b 100644 --- a/plugins/gtkui/interface.c +++ b/plugins/gtkui/interface.c @@ -1066,6 +1066,7 @@ create_addprogress (void) addprogress = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (addprogress), "Adding files..."); gtk_window_set_position (GTK_WINDOW (addprogress), GTK_WIN_POS_CENTER_ON_PARENT); + gtk_window_set_modal (GTK_WINDOW (addprogress), TRUE); gtk_window_set_skip_taskbar_hint (GTK_WINDOW (addprogress), TRUE); gtk_window_set_skip_pager_hint (GTK_WINDOW (addprogress), TRUE); diff --git a/plugins/gtkui/progress.c b/plugins/gtkui/progress.c index 4c413dfc..78acf7c4 100644 --- a/plugins/gtkui/progress.c +++ b/plugins/gtkui/progress.c @@ -39,10 +39,12 @@ progress_init (void) { void progress_show (void) { + extern GtkWidget *mainwin; progress_aborted = 0; progress_settext ("Initializing..."); gtk_widget_show_all (progressdlg); gtk_window_present (GTK_WINDOW (progressdlg)); + gtk_window_set_transient_for (GTK_WINDOW (progressdlg), GTK_WINDOW (mainwin)); } void diff --git a/plugins/mpgmad/mpgmad.c b/plugins/mpgmad/mpgmad.c index ab59d207..2262df53 100644 --- a/plugins/mpgmad/mpgmad.c +++ b/plugins/mpgmad/mpgmad.c @@ -183,6 +183,7 @@ cmp3_scan_stream (buffer_t *buffer, int sample) { break; // eof } if (sync != 0xff) { + trace ("[1]frame %d didn't seek to frame end\n", nframe); continue; // not an mpeg frame } else { @@ -191,6 +192,7 @@ cmp3_scan_stream (buffer_t *buffer, int sample) { break; // eof } if ((sync >> 5) != 7) { + trace ("[2]frame %d didn't seek to frame end\n", nframe); continue; } } @@ -211,7 +213,7 @@ cmp3_scan_stream (buffer_t *buffer, int sample) { // sync bits int usync = hdr & 0xffe00000; if (usync != 0xffe00000) { - printf ("fatal error: mp3 header parser is broken\n"); + fprintf (stderr, "fatal error: mp3 header parser is broken\n"); } // mpeg version @@ -219,6 +221,7 @@ cmp3_scan_stream (buffer_t *buffer, int sample) { int ver = (hdr & (3<<19)) >> 19; ver = vertbl[ver]; if (ver < 0) { + trace ("frame %d bad mpeg version %d\n", nframe, (hdr & (3<<19)) >> 19); continue; // invalid frame } @@ -227,16 +230,17 @@ cmp3_scan_stream (buffer_t *buffer, int sample) { int layer = (hdr & (3<<17)) >> 17; layer = ltbl[layer]; if (layer < 0) { + trace ("frame %d bad layer %d\n", nframe, (hdr & (3<<17)) >> 17); continue; // invalid frame } // bitrate - static int brtable[5][16] = { + static const int brtable[5][16] = { { 0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, -1 }, - { 0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, -1 }, - { 0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, -1 }, - { 0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256, -1 }, - { 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, -1 } + { 0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, -1 }, + { 0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, -1 }, + { 0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256, -1 }, + { 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, -1 } }; int bitrate = (hdr & (0x0f<<12)) >> 12; int idx = 0; @@ -248,11 +252,12 @@ cmp3_scan_stream (buffer_t *buffer, int sample) { } bitrate = brtable[idx][bitrate]; if (bitrate <= 0) { + trace ("frame %d bad bitrate %d\n", nframe, (hdr & (0x0f<<12)) >> 12); continue; // invalid frame } // samplerate - static int srtable[3][4] = { + static const int srtable[3][4] = { {44100, 48000, 32000, -1}, {22050, 24000, 16000, -1}, {11025, 12000, 8000, -1}, @@ -260,6 +265,7 @@ cmp3_scan_stream (buffer_t *buffer, int sample) { int samplerate = (hdr & (0x03<<10))>>10; samplerate = srtable[ver-1][samplerate]; if (samplerate < 0) { + trace ("frame %d bad samplerate %d\n", nframe, (hdr & (0x03<<10))>>10); continue; // invalid frame } @@ -273,18 +279,15 @@ cmp3_scan_stream (buffer_t *buffer, int sample) { // check if channel/bitrate combination is valid for layer2 if (layer == 2) { if ((bitrate <= 56 || bitrate == 80) && nchannels != 1) { + trace ("[1]frame %d channel/bitrate combination is bad\n", nframe); continue; // bad frame } if (bitrate >= 224 && nchannels == 1) { + trace ("[2]frame %d channel/bitrate combination is bad\n", nframe); continue; // bad frame } } - // check if emphasis is valid - if ((hdr & 3) == 2) { - continue; // 10 is reserved - } - // packetlength packetlength = 0; bitrate *= 1000; @@ -312,6 +315,7 @@ cmp3_scan_stream (buffer_t *buffer, int sample) { packetlength = samples_per_frame / 8 * bitrate / samplerate + padding; } else { + trace ("frame %d samplerate or bitrate is invalid\n", nframe); continue; } @@ -325,9 +329,7 @@ cmp3_scan_stream (buffer_t *buffer, int sample) { buffer->frameduration = dur; buffer->channels = nchannels; buffer->bitspersample = 16; - if (packetlength != 144) { - trace ("frame %d(@%d) mpeg v%d layer %d bitrate %d samplerate %d packetlength %d framedur %f channels %d\n", nframe, pos, ver, layer, bitrate, samplerate, packetlength, dur, nchannels); - } + //trace ("frame %d(@%d) mpeg v%d layer %d bitrate %d samplerate %d packetlength %d framedur %f channels %d\n", nframe, pos, ver, layer, bitrate, samplerate, packetlength, dur, nchannels); } // try to read xing/info tag (only on initial scans) if (sample <= 0 && !got_xing_header) @@ -501,9 +503,9 @@ cmp3_scan_stream (buffer_t *buffer, int sample) { if (nframe == 0) { return -1; } - trace ("nframes=%d, packetlength=%d\n", nframe, packetlength); buffer->totalsamples = scansamples; - buffer->duration = buffer->totalsamples / buffer->samplerate; +// buffer->duration = buffer->totalsamples / buffer->samplerate; + trace ("nframes=%d, totalsamples=%d, samplerate=%d, dur=%f\n", nframe, scansamples, buffer->samplerate, buffer->duration); return 0; } |