diff options
-rw-r--r-- | src/demuxers/demux_ogg.c | 13 | ||||
-rw-r--r-- | src/libxineadec/xine_vorbis_decoder.c | 16 | ||||
-rw-r--r-- | src/xine-engine/audio_out.c | 6 | ||||
-rw-r--r-- | src/xine-engine/input_cache.c | 2 | ||||
-rw-r--r-- | src/xine-engine/xine.c | 6 | ||||
-rw-r--r-- | src/xine-utils/utils.c | 10 |
6 files changed, 39 insertions, 14 deletions
diff --git a/src/demuxers/demux_ogg.c b/src/demuxers/demux_ogg.c index eb4f7ba5a..2c06f14ca 100644 --- a/src/demuxers/demux_ogg.c +++ b/src/demuxers/demux_ogg.c @@ -233,13 +233,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; } @@ -1346,7 +1352,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 */ diff --git a/src/libxineadec/xine_vorbis_decoder.c b/src/libxineadec/xine_vorbis_decoder.c index d437c1e4b..4b7a6c15d 100644 --- a/src/libxineadec/xine_vorbis_decoder.c +++ b/src/libxineadec/xine_vorbis_decoder.c @@ -158,7 +158,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; } @@ -219,7 +219,6 @@ static void vorbis_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { */ int i,j; - int clipflag=0; int bout=(samples<this->convsize?samples:this->convsize); audio_buffer_t *audio_buffer; @@ -231,15 +230,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;j<bout;j++){ - int val=mono[j]*32767.f; + int val=(mono[j] + 1.0f) * 32768.f; + val -= 32768; /* might as well guard against clipping */ if(val>32767){ val=32767; - clipflag=1; - } - if(val<-32768){ + } else if(val<-32768){ val=-32768; - clipflag=1; } *ptr=val; ptr+=this->vi.channels; @@ -257,8 +254,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) { diff --git a/src/xine-engine/audio_out.c b/src/xine-engine/audio_out.c index def102ef3..7e43fb5cf 100644 --- a/src/xine-engine/audio_out.c +++ b/src/xine-engine/audio_out.c @@ -287,6 +287,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) { @@ -1596,6 +1597,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); } diff --git a/src/xine-engine/input_cache.c b/src/xine-engine/input_cache.c index 2baa67c7c..30b1ba4aa 100644 --- a/src/xine-engine/input_cache.c +++ b/src/xine-engine/input_cache.c @@ -34,6 +34,7 @@ */ #include "xine_internal.h" +#include <assert.h> #define DEFAULT_BUFFER_SIZE 1024 @@ -190,6 +191,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; } diff --git a/src/xine-engine/xine.c b/src/xine-engine/xine.c index 41eeff02c..097ce99ef 100644 --- a/src/xine-engine/xine.c +++ b/src/xine-engine/xine.c @@ -1193,7 +1193,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; diff --git a/src/xine-utils/utils.c b/src/xine-utils/utils.c index 47c32b713..c5f18a699 100644 --- a/src/xine-utils/utils.c +++ b/src/xine-utils/utils.c @@ -431,6 +431,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; @@ -446,6 +447,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 } |