From 907ed40fd1b1a1298e5d339f51e68df5f0b63872 Mon Sep 17 00:00:00 2001 From: waker Date: Fri, 30 Nov 2012 21:14:25 +0100 Subject: few minor optimizations --- deadbeef.h | 2 +- main.c | 3 +++ plugins/artwork/artwork.c | 6 ++++++ plugins/gtkui/coverart.c | 6 ++++++ plugins/gtkui/gtkui.c | 6 ++++++ plugins/hotkeys/hotkeys.c | 8 +++++++- streamer.c | 13 +++++++++---- 7 files changed, 38 insertions(+), 6 deletions(-) diff --git a/deadbeef.h b/deadbeef.h index cfe4885c..fd01a0d4 100644 --- a/deadbeef.h +++ b/deadbeef.h @@ -324,7 +324,7 @@ enum ddb_audio_data_type_t { // audio memory constants // since 1.5 -#define DDB_AUDIO_MEMORY_FRAMES 512 +#define DDB_AUDIO_MEMORY_FRAMES 256 // typecasting macros #define DB_PLUGIN(x) ((DB_plugin_t *)(x)) diff --git a/main.c b/main.c index 5bf653cd..eea4caa5 100644 --- a/main.c +++ b/main.c @@ -481,6 +481,9 @@ static int server_terminate; void server_loop (void *ctx) { +#ifdef __linux__ + prctl (PR_SET_NAME, "deadbeef-server", 0, 0, 0, 0); +#endif fd_set rds; int ret; struct timeval timeout = {0, 0}; diff --git a/plugins/artwork/artwork.c b/plugins/artwork/artwork.c index 3ef62755..74fdcc10 100644 --- a/plugins/artwork/artwork.c +++ b/plugins/artwork/artwork.c @@ -5,6 +5,9 @@ #include #include #include +#ifdef __linux__ +#include +#endif #include #include #include @@ -799,6 +802,9 @@ id3v2_skip_str (int enc, uint8_t *ptr, uint8_t *end) { static void fetcher_thread (void *none) { +#ifdef __linux__ + prctl (PR_SET_NAME, "deadbeef-artwork", 0, 0, 0, 0); +#endif for (;;) { trace ("artwork: waiting for signal\n"); deadbeef->cond_wait (cond, mutex); diff --git a/plugins/gtkui/coverart.c b/plugins/gtkui/coverart.c index f98957dc..2a803e51 100644 --- a/plugins/gtkui/coverart.c +++ b/plugins/gtkui/coverart.c @@ -22,6 +22,9 @@ #include #include #include +#ifdef __linux__ +#include +#endif #include "coverart.h" #include "../artwork/artwork.h" #include "gtkui.h" @@ -109,6 +112,9 @@ redraw_playlist_cb (gpointer dt) { void loading_thread (void *none) { +#ifdef __linux__ + prctl (PR_SET_NAME, "deadbeef-gtkui-artwork", 0, 0, 0, 0); +#endif for (;;) { trace ("covercache: waiting for signal\n"); deadbeef->cond_wait (cond, mutex); diff --git a/plugins/gtkui/gtkui.c b/plugins/gtkui/gtkui.c index 79d1ad63..a584b834 100644 --- a/plugins/gtkui/gtkui.c +++ b/plugins/gtkui/gtkui.c @@ -27,6 +27,9 @@ #include #include #include +#ifdef __linux__ +#include +#endif #include "../../gettext.h" #include "gtkui.h" #include "ddblistview.h" @@ -871,6 +874,9 @@ unlock_playlist_columns_cb (void *ctx) { void gtkui_thread (void *ctx) { +#ifdef __linux__ + prctl (PR_SET_NAME, "deadbeef-gtkui", 0, 0, 0, 0); +#endif XInitThreads (); // gtkglext/xcb doesn't work without this // let's start some gtk g_thread_init (NULL); diff --git a/plugins/hotkeys/hotkeys.c b/plugins/hotkeys/hotkeys.c index b2c9f750..a7a1096c 100644 --- a/plugins/hotkeys/hotkeys.c +++ b/plugins/hotkeys/hotkeys.c @@ -22,8 +22,11 @@ #include #include #include -#include "parser.h" +#ifdef __linux__ +#include +#endif +#include "parser.h" #include "hotkeys.h" #include "../../deadbeef.h" #include "actionhandlers.h" @@ -388,6 +391,9 @@ x_err_handler (Display *d, XErrorEvent *evt) { static void hotkeys_event_loop (void *unused) { int i; +#ifdef __linux__ + prctl (PR_SET_NAME, "deadbeef-hotkeys", 0, 0, 0, 0); +#endif while (!finished) { if (need_reset) { diff --git a/streamer.c b/streamer.c index 8737ee3d..79106a9b 100644 --- a/streamer.c +++ b/streamer.c @@ -2099,10 +2099,12 @@ streamer_read (char *bytes, int size) { mutex_unlock (audio_mem_mutex); if (!output->has_volume) { + int mult = 1-audio_is_mute (); char *stream = bytes; int bytesread = sz; if (output->fmt.bps == 16) { - int16_t ivolume = volume_get_amp () * (1-audio_is_mute ()) * 1000; + mult *= 1000; + int16_t ivolume = volume_get_amp () * mult; for (int i = 0; i < bytesread/2; i++) { int16_t sample = *((int16_t*)stream); *((int16_t*)stream) = (int16_t)(((int32_t)sample) * ivolume / 1000); @@ -2110,14 +2112,16 @@ streamer_read (char *bytes, int size) { } } else if (output->fmt.bps == 8) { - int16_t ivolume = volume_get_amp () * (1-audio_is_mute ()) * 255; + mult *= 255; + int16_t ivolume = volume_get_amp () * mult; for (int i = 0; i < bytesread; i++) { *stream = (int8_t)(((int32_t)(*stream)) * ivolume / 1000); stream++; } } else if (output->fmt.bps == 24) { - int16_t ivolume = volume_get_amp () * (1-audio_is_mute ()) * 1000; + mult *= 1000; + int16_t ivolume = volume_get_amp () * mult; for (int i = 0; i < bytesread/3; i++) { int32_t sample = ((unsigned char)stream[0]) | ((unsigned char)stream[1]<<8) | (stream[2]<<16); int32_t newsample = (int64_t)sample * ivolume / 1000; @@ -2128,7 +2132,8 @@ streamer_read (char *bytes, int size) { } } else if (output->fmt.bps == 32 && !output->fmt.is_float) { - int16_t ivolume = volume_get_amp () * (1-audio_is_mute ()) * 1000; + mult *= 1000; + int16_t ivolume = volume_get_amp () * mult; for (int i = 0; i < bytesread/4; i++) { int32_t sample = *((int32_t*)stream); int32_t newsample = (int64_t)sample * ivolume / 1000; -- cgit v1.2.3