Author: titmuss
Date: Fri Nov 7 04:24:20 2008
New Revision: 3307
URL: http://svn.slimdevices.com?rev=3307&root=Jive&view=rev
Log:
Bug: 6442
Description:
Decode to PCM even when paused. This fixes a couple of bugs, an audio glitch
when playback starts and avoiding an auto-pause (that
never resumed) on an audio underrun.
A delay is still needed before the decoder starts, to prevent immediate decoder
underruns at the start of a track. Also (at least on
ip3k) some decoders assume sufficient data to parse the headers at the start of
a track.
The auto start threshold/STMl has been changed to trigger on the bytes
received, not the fullness of the decode buffer. A future
improvement maybe to trigger on the fullness of the output buffer, but Alan
says that this will require a SC change and should be
done in all the player software (squeezeplay, ip3k, etc) at the sametime.
Modified:
7.3/trunk/squeezeplay/src/libmad-0.15.1b/mad.h
7.3/trunk/squeezeplay/src/squeezeplay/share/jive/audio/Playback.lua
7.3/trunk/squeezeplay/src/squeezeplay/src/audio/decode/decode.c
7.3/trunk/squeezeplay/src/squeezeplay/src/audio/decode/decode_output.c
Modified: 7.3/trunk/squeezeplay/src/libmad-0.15.1b/mad.h
URL:
http://svn.slimdevices.com/7.3/trunk/squeezeplay/src/libmad-0.15.1b/mad.h?rev=3307&root=Jive&r1=3306&r2=3307&view=diff
==============================================================================
--- 7.3/trunk/squeezeplay/src/libmad-0.15.1b/mad.h (original)
+++ 7.3/trunk/squeezeplay/src/libmad-0.15.1b/mad.h Fri Nov 7 04:24:20 2008
@@ -24,7 +24,7 @@
extern "C" {
# endif
-# define FPM_DEFAULT
+# define FPM_INTEL
Modified: 7.3/trunk/squeezeplay/src/squeezeplay/share/jive/audio/Playback.lua
URL:
http://svn.slimdevices.com/7.3/trunk/squeezeplay/src/squeezeplay/share/jive/audio/Playback.lua?rev=3307&root=Jive&r1=3306&r2=3307&view=diff
==============================================================================
--- 7.3/trunk/squeezeplay/src/squeezeplay/share/jive/audio/Playback.lua
(original)
+++ 7.3/trunk/squeezeplay/src/squeezeplay/share/jive/audio/Playback.lua Fri Nov
7 04:24:20 2008
@@ -196,7 +196,7 @@
self.stream then
log:info("status OUTPUT UNDERRUN")
- Decode:pause(0) -- auto-pause to prevent glitches
+ Decode:pauseAudio(0) -- auto-pause to prevent glitches
self:sendStatus(status, "STMo")
self.sentOutputUnderrunEvent = true
@@ -216,14 +216,29 @@
self.tracksStarted = status.tracksStarted
end
-
- -- XXXX
- if status.decodeFull > self.threshold and
+ -- Start the decoder when some encoded data is buffered
+ -- FIXME the threshold could be decoder specific?
+ if status.decodeFull > 2048 and
+ (self.autostart == '0' or self.autostart == '1') and
status.decodeState & DECODE_RUNNING == 0 then
+ log:debug("resumeDecoder")
+ Decode:resumeDecoder()
+ end
+
+ -- Start the audio when enough encoded data is been received
+ if status.bytesReceivedL > self.threshold and
+ status.outputTime > 50 and
+ status.audioState & DECODE_RUNNING == 0 then
+
+-- FIXME in a future release we may change the the threshold to use
+-- the amount of audio buffered, see Bug 6442
+-- if status.outputTime / 10 > self.threshold and
+-- status.audioState & DECODE_RUNNING == 0 then
+
if self.autostart == '1' and not self.sentResume then
- log:info("resume decodeFull=", status.decodeFull, "
threshold=", self.threshold)
- Decode:resume()
+ log:info("resume bytesReceivedL=",
status.bytesReceivedL, " outputTime=", status.outputTime, " threshold=",
self.threshold)
+ Decode:resumeAudio()
self.sentResume = true
self.sentDecoderFullEvent = true -- fake it so we don't
send STMl with pause
@@ -404,7 +419,7 @@
-- pause
local interval_ms = data.replayGain
- Decode:pause(interval_ms)
+ Decode:pauseAudio(interval_ms)
if interval_ms == 0 then
self.slimproto:sendStatus('STMp')
end
@@ -419,7 +434,7 @@
-- unpause
local interval_ms = data.replayGain
- Decode:resume(interval_ms)
+ Decode:resumeAudio(interval_ms)
self.slimproto:sendStatus('STMr')
elseif data.command == 't' then
Modified: 7.3/trunk/squeezeplay/src/squeezeplay/src/audio/decode/decode.c
URL:
http://svn.slimdevices.com/7.3/trunk/squeezeplay/src/squeezeplay/src/audio/decode/decode.c?rev=3307&root=Jive&r1=3306&r2=3307&view=diff
==============================================================================
--- 7.3/trunk/squeezeplay/src/squeezeplay/src/audio/decode/decode.c (original)
+++ 7.3/trunk/squeezeplay/src/squeezeplay/src/audio/decode/decode.c Fri Nov 7
04:24:20 2008
@@ -75,7 +75,15 @@
};
-static void decode_resume_handler(void) {
+static void decode_resume_decoder_handler(void) {
+ mqueue_read_complete(&decode_mqueue);
+
+ current_decoder_state = DECODE_STATE_RUNNING;
+ DEBUG_TRACE("resume_decoder decode state: %x audio state %x",
current_decoder_state, current_audio_state);
+}
+
+
+static void decode_resume_audio_handler(void) {
int start_interval;
start_interval = mqueue_read_u32(&decode_mqueue) - SDL_GetTicks();
@@ -85,16 +93,12 @@
start_interval = 0;
}
- DEBUG_TRACE("decode_resume_handler start_interval=%d", start_interval);
+ DEBUG_TRACE("decode_resume_audio_handler start_interval=%d",
start_interval);
fifo_lock(&decode_fifo);
if (start_interval) {
add_silence_ms = start_interval;
- }
-
- if (decoder) {
- current_decoder_state |= DECODE_STATE_RUNNING;
}
if (!fifo_empty(&decode_fifo)) {
@@ -102,28 +106,32 @@
decode_audio->resume();
}
- DEBUG_TRACE("resume decode state: %x audio state %x",
current_decoder_state, current_audio_state);
-
fifo_unlock(&decode_fifo);
-}
-
-
-static void decode_pause_handler(void) {
+
+ DEBUG_TRACE("resume_audio decode state: %x audio state %x",
current_decoder_state, current_audio_state);
+}
+
+
+static void decode_pause_audio_handler(void) {
Uint32 interval;
interval = mqueue_read_u32(&decode_mqueue);
mqueue_read_complete(&decode_mqueue);
DEBUG_TRACE("decode_pause_handler interval=%d", interval);
+
+ fifo_lock(&decode_fifo);
if (interval) {
add_silence_ms = interval;
} else {
- current_decoder_state &= ~DECODE_STATE_RUNNING;
current_audio_state &= ~DECODE_STATE_RUNNING;
decode_audio->pause();
}
- DEBUG_TRACE("pause decode state: %x audio state %x",
current_decoder_state, current_audio_state);
+
+ fifo_unlock(&decode_fifo);
+
+ DEBUG_TRACE("pause_audio decode state: %x audio state %x",
current_decoder_state, current_audio_state);
}
@@ -337,8 +345,25 @@
/*
* lua decoder interface
*/
-
-static int decode_resume(lua_State *L) {
+static int decode_resume_decoder(lua_State *L) {
+
+ /* stack is:
+ * 1: self
+ */
+
+ DEBUG_TRACE("decode_resume_decoder");
+
+ if (mqueue_write_request(&decode_mqueue, decode_resume_decoder_handler,
0)) {
+ mqueue_write_complete(&decode_mqueue);
+ }
+ else {
+ DEBUG_TRACE("Full message queue, dropped resume message");
+ }
+
+ return 0;
+}
+
+static int decode_resume_audio(lua_State *L) {
Uint32 start_jiffies;
/* stack is:
@@ -347,9 +372,9 @@
*/
start_jiffies = (Uint32) luaL_optinteger(L, 2, 0);
- DEBUG_TRACE("decode_resume start_jiffies=%d", start_jiffies);
-
- if (mqueue_write_request(&decode_mqueue, decode_resume_handler,
sizeof(Uint32))) {
+ DEBUG_TRACE("decode_resume_audio start_jiffies=%d", start_jiffies);
+
+ if (mqueue_write_request(&decode_mqueue, decode_resume_audio_handler,
sizeof(Uint32))) {
mqueue_write_u32(&decode_mqueue, start_jiffies);
mqueue_write_complete(&decode_mqueue);
}
@@ -361,7 +386,7 @@
}
-static int decode_pause(lua_State *L) {
+static int decode_pause_audio(lua_State *L) {
Uint32 interval_ms;
/* stack is:
@@ -370,9 +395,9 @@
*/
interval_ms = (Uint32) luaL_optinteger(L, 2, 0);
- DEBUG_TRACE("decode_pause interval_ms=%d", interval_ms);
-
- if (mqueue_write_request(&decode_mqueue, decode_pause_handler,
sizeof(Uint32))) {
+ DEBUG_TRACE("decode_pause_audio interval_ms=%d", interval_ms);
+
+ if (mqueue_write_request(&decode_mqueue, decode_pause_audio_handler,
sizeof(Uint32))) {
mqueue_write_u32(&decode_mqueue, interval_ms);
mqueue_write_complete(&decode_mqueue);
}
@@ -510,7 +535,7 @@
static int decode_status(lua_State *L) {
size_t size, usedbytes;
u32_t bytesL, bytesH;
- u64_t elapsed, delay;
+ u64_t elapsed, delay, output;
lua_newtable(L);
@@ -521,7 +546,11 @@
lua_pushinteger(L, decode_fifo.size);
lua_setfield(L, -2, "outputSize");
-
+
+ output = fifo_bytes_used(&decode_fifo);
+ output = (BYTES_TO_SAMPLES(output) * 1000) / current_sample_rate;
+ lua_pushinteger(L, (u32_t)output);
+ lua_setfield(L, -2, "outputTime");
elapsed = decode_elapsed_samples;
delay = decode_audio->delay ? decode_audio->delay() : 0;
@@ -594,8 +623,9 @@
}
static const struct luaL_Reg decode_f[] = {
- { "resume", decode_resume },
- { "pause", decode_pause },
+ { "resumeDecoder", decode_resume_decoder },
+ { "resumeAudio", decode_resume_audio },
+ { "pauseAudio", decode_pause_audio },
{ "skipAhead", decode_skip_ahead },
{ "stop", decode_stop },
{ "flush", decode_flush },
Modified: 7.3/trunk/squeezeplay/src/squeezeplay/src/audio/decode/decode_output.c
URL:
http://svn.slimdevices.com/7.3/trunk/squeezeplay/src/squeezeplay/src/audio/decode/decode_output.c?rev=3307&root=Jive&r1=3306&r2=3307&view=diff
==============================================================================
--- 7.3/trunk/squeezeplay/src/squeezeplay/src/audio/decode/decode_output.c
(original)
+++ 7.3/trunk/squeezeplay/src/squeezeplay/src/audio/decode/decode_output.c Fri
Nov 7 04:24:20 2008
@@ -440,9 +440,6 @@
buffer += (bytes_write / sizeof(sample_t));
bytes_out -= bytes_write;
}
-
- /* start immediately */
- current_audio_state |= DECODE_STATE_RUNNING;
fifo_unlock(&decode_fifo);
}
_______________________________________________
Jive-checkins mailing list
[email protected]
http://lists.slimdevices.com/cgi-bin/mailman/listinfo/jive-checkins