From 443fcac477f3844b4e2dcd867f7e8818b83978a7 Mon Sep 17 00:00:00 2001 From: Matthias Kretz Date: Thu, 15 Nov 2007 15:27:15 +0100 Subject: when the stream is paused fifo_wait_empty will wait forever. In that case we discard all buffers before calling fifo_wait_empty --- src/xine-engine/audio_out.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/xine-engine/audio_out.c b/src/xine-engine/audio_out.c index fb2f495d5..1f54786fc 100644 --- a/src/xine-engine/audio_out.c +++ b/src/xine-engine/audio_out.c @@ -290,6 +290,7 @@ struct audio_fifo_s { int num_buffers; }; +static int ao_set_property (xine_audio_port_t *this_gen, int property, int value); static audio_fifo_t *fifo_new (xine_t *xine) { @@ -1599,6 +1600,11 @@ static void ao_close(xine_audio_port_t *this_gen, xine_stream_t *stream) { xprintf (this->xine, XINE_VERBOSITY_DEBUG, "audio_out: no streams left, closing driver\n"); if (this->audio_loop_running) { + if (this->clock->speed == XINE_SPEED_PAUSE || + (this->clock->speed != XINE_FINE_SPEED_NORMAL && !this->slow_fast_audio)) { + /* discard buffers, otherwise we'll wait forever */ + ao_set_property(this_gen, AO_PROP_DISCARD_BUFFERS, 1); + } /* make sure there are no more buffers on queue */ fifo_wait_empty(this->out_fifo); } -- cgit v1.2.3 From 0d62b545fbba787e72596fcc30177a6e8596a892 Mon Sep 17 00:00:00 2001 From: Matthias Kretz Date: Thu, 15 Nov 2007 15:28:04 +0100 Subject: assert that not more than the buffersize is read --- src/xine-engine/input_cache.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/xine-engine/input_cache.c b/src/xine-engine/input_cache.c index 75c4beb43..fea777a42 100644 --- a/src/xine-engine/input_cache.c +++ b/src/xine-engine/input_cache.c @@ -36,6 +36,7 @@ */ #include "xine_internal.h" +#include #define DEFAULT_BUFFER_SIZE 1024 @@ -192,6 +193,7 @@ static buf_element_t *cache_plugin_read_block(input_plugin_t *this_gen, fifo_buf if (buf) { buf->type = BUF_DEMUX_BLOCK; + assert(todo <= buf->max_size); read_len = cache_plugin_read (this_gen, buf->content, todo); buf->size = read_len; } -- cgit v1.2.3 From e4d811b726b85b7de83fafee24b5c1d05061bc1e Mon Sep 17 00:00:00 2001 From: Matthias Kretz Date: Thu, 15 Nov 2007 15:29:33 +0100 Subject: using select instead of nanosleep the wakeup count reported by powertop is reduced by 50% --- src/xine-utils/utils.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/xine-utils/utils.c b/src/xine-utils/utils.c index fa0c11dbe..ab5d9a2ec 100644 --- a/src/xine-utils/utils.c +++ b/src/xine-utils/utils.c @@ -434,6 +434,7 @@ char *xine_chomp(char *str) { * a thread-safe usecond sleep */ void xine_usec_sleep(unsigned usec) { +#if 0 #if HAVE_NANOSLEEP /* nanosleep is prefered on solaris, because it's mt-safe */ struct timespec ts, remaining; @@ -449,6 +450,15 @@ void xine_usec_sleep(unsigned usec) { usleep(usec); # endif #endif +#else + if (usec < 10000) { + usec = 10000; + } + struct timeval tm; + tm.tv_sec = usec / 1000000; + tm.tv_usec = usec % 1000000; + select(0, 0, 0, 0, &tm); +#endif } -- cgit v1.2.3 From cce0fd6bbc99da33f4064abeb453ade4ca11b05e Mon Sep 17 00:00:00 2001 From: Matthias Kretz Date: Fri, 23 Nov 2007 18:00:34 +0100 Subject: fix read_ogg_packet to really read all of the data; don't go into DEMUX_FINISHED from send_header --- src/demuxers/demux_ogg.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/demuxers/demux_ogg.c b/src/demuxers/demux_ogg.c index a23bfa6b6..d38b2de7a 100644 --- a/src/demuxers/demux_ogg.c +++ b/src/demuxers/demux_ogg.c @@ -236,13 +236,19 @@ static int64_t get_pts (demux_ogg_t *this, int stream_num , int64_t granulepos ) static int read_ogg_packet (demux_ogg_t *this) { char *buffer; long bytes; + long total = 0; while (ogg_sync_pageout(&this->oy,&this->og)!=1) { buffer = ogg_sync_buffer(&this->oy, CHUNKSIZE); bytes = this->input->read(this->input, buffer, CHUNKSIZE); - ogg_sync_wrote(&this->oy, bytes); - if (bytes < CHUNKSIZE/2) { - return 0; + if (bytes == 0) { + if (total == 0) { + printf("read_ogg_packet read nothing\n"); + return 0; + } + break; } + ogg_sync_wrote(&this->oy, bytes); + total += bytes; } return 1; } @@ -1349,7 +1355,6 @@ static void send_header (demux_ogg_t *this) { while (!done) { if (!read_ogg_packet(this)) { - this->status = DEMUX_FINISHED; return; } /* now we've got at least one new page */ -- cgit v1.2.3 From 3a6cd7956f573a2f81354467a038586e1df35d81 Mon Sep 17 00:00:00 2001 From: Matthias Kretz Date: Fri, 23 Nov 2007 18:04:25 +0100 Subject: log if send_headers returned with DEMUX_FINISHED --- src/xine-engine/xine.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/xine-engine/xine.c b/src/xine-engine/xine.c index 01ca48aa2..5b790343b 100644 --- a/src/xine-engine/xine.c +++ b/src/xine-engine/xine.c @@ -1195,7 +1195,11 @@ static int open_internal (xine_stream_t *stream, const char *mrl) { stream->demux_plugin->send_headers (stream->demux_plugin); if (stream->demux_plugin->get_status(stream->demux_plugin) != DEMUX_OK) { - xine_log (stream->xine, XINE_LOG_MSG, _("xine: demuxer failed to start\n")); + if (stream->demux_plugin->get_status(stream->demux_plugin) == DEMUX_FINISHED) { + xine_log (stream->xine, XINE_LOG_MSG, _("xine: demuxer is already done. that was fast!\n")); + } else { + xine_log (stream->xine, XINE_LOG_MSG, _("xine: demuxer failed to start\n")); + } _x_free_demux_plugin(stream, stream->demux_plugin); stream->demux_plugin = NULL; -- cgit v1.2.3 From c1f730ab426636b5fea1dc657d2278950ace5de6 Mon Sep 17 00:00:00 2001 From: Matthias Kretz Date: Fri, 23 Nov 2007 18:06:26 +0100 Subject: fix one warning; remove unused variable; make float->int conversion a bit more accurate (compared to oggdec); fix one debug printf --- src/libxineadec/xine_vorbis_decoder.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/libxineadec/xine_vorbis_decoder.c b/src/libxineadec/xine_vorbis_decoder.c index c7b1e5761..297d16349 100644 --- a/src/libxineadec/xine_vorbis_decoder.c +++ b/src/libxineadec/xine_vorbis_decoder.c @@ -160,7 +160,7 @@ static void vorbis_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { if( (res = vorbis_synthesis_headerin(&this->vi,&this->vc,&this->op)) < 0 ){ /* error case; not a vorbis header */ xine_log(this->stream->xine, XINE_LOG_MSG, "libvorbis: this bitstream does not contain vorbis audio data. Following first 64 bytes (return: %d).\n", res); - xine_hexdump(this->op.packet, this->op.bytes < 64 ? this->op.bytes : 64); + xine_hexdump((char *)this->op.packet, this->op.bytes < 64 ? this->op.bytes : 64); return; } @@ -221,7 +221,6 @@ static void vorbis_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { */ int i,j; - int clipflag=0; int bout=(samplesconvsize?samples:this->convsize); audio_buffer_t *audio_buffer; @@ -233,15 +232,13 @@ static void vorbis_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { ogg_int16_t *ptr=audio_buffer->mem+i; float *mono=pcm[i]; for(j=0;j32767){ val=32767; - clipflag=1; - } - if(val<-32768){ + } else if(val<-32768){ val=-32768; - clipflag=1; } *ptr=val; ptr+=this->vi.channels; @@ -259,8 +256,9 @@ static void vorbis_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { /* tell libvorbis how many samples we actually consumed */ vorbis_synthesis_read(&this->vd,bout); } - } - lprintf("output not open\n"); + } else { + lprintf("output not open\n"); + } } static void vorbis_dispose (audio_decoder_t *this_gen) { -- cgit v1.2.3