summaryrefslogtreecommitdiff
path: root/streamer.c
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <waker@users.sourceforge.net>2014-01-04 20:36:58 +0100
committerGravatar Alexey Yakovenko <waker@users.sourceforge.net>2014-01-04 20:36:58 +0100
commit70b138eff4b3d6fa18e338248acc847b205a3f99 (patch)
tree2e15ffce00d9cf6302d825d95cf90ada9d89fb39 /streamer.c
parent226f1af1a67221ca383c5ac9f8678f2e036a01ad (diff)
streamer: fixed increased CPU use at the end of track with stop_after_current=1
Diffstat (limited to 'streamer.c')
-rw-r--r--streamer.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/streamer.c b/streamer.c
index 64bd4669..dd8ecc3d 100644
--- a/streamer.c
+++ b/streamer.c
@@ -85,6 +85,8 @@ static int autoconv_16_to_24 = 0;
static int trace_bufferfill = 0;
+static int stop_after_current = 0;
+
static int streaming_terminate;
// buffer up to 3 seconds at 44100Hz stereo
@@ -1332,11 +1334,12 @@ streamer_next (int bytesread) {
streamer_lock ();
bytes_until_next_song = streamer_ringbuf.remaining + bytesread;
streamer_unlock ();
- if (conf_get_int ("playlist.stop_after_current", 0)) {
+ if (stop_after_current) {
streamer_buffering = 0;
streamer_set_nextsong (-2, -2);
if (conf_get_int ("playlist.stop_after_current_reset", 0)) {
conf_set_int ("playlist.stop_after_current", 0);
+ stop_after_current = 0;
deadbeef->sendmessage (DB_EV_CONFIGCHANGED, 0, 0, 0);
}
}
@@ -1624,7 +1627,7 @@ streamer_thread (void *ctx) {
// add 1ms here to compensate the rounding error
// and another 1ms to buffer slightly faster then playing
alloc_time -= ms+2;
- if (streamer_ringbuf.remaining > STREAM_BUFFER_SIZE / 2 && !streamer_buffering && alloc_time > 0) {
+ if ((bytes_until_next_song > 0 && stop_after_current) || (streamer_ringbuf.remaining > STREAM_BUFFER_SIZE / 2 && !streamer_buffering && alloc_time > 0)) {
usleep (alloc_time * 1000);
}
}
@@ -2452,10 +2455,9 @@ streamer_configchanged (void) {
streamer_reset (1);
}
- int conf_streamer_trace_bufferfill = conf_get_int ("streamer.trace_buffer_fill",0);
- if (conf_streamer_trace_bufferfill != trace_bufferfill) {
- trace_bufferfill = conf_streamer_trace_bufferfill;
- }
+ trace_bufferfill = conf_get_int ("streamer.trace_buffer_fill",0);
+
+ stop_after_current = conf_get_int ("playlist.stop_after_current", 0);
char mapstr[2048];
deadbeef->conf_get_str ("network.ctmapping", DDB_DEFAULT_CTMAPPING, mapstr, sizeof (mapstr));