Commit 4a43012c authored by Conrad Parker's avatar Conrad Parker

Fix support for multichannel playback in ogg123. Patches from Joachim Falk.

Closes ticket:575
Problem verified and patches tested on 6-channel Ogg Vorbis I file.

svn path=/trunk/vorbis-tools/; revision=12188
parent 461417f8
......@@ -55,8 +55,9 @@ extern int exit_status; /* from status.c */
void exit_cleanup ();
void play (char *source_string);
#define PRIMAGIC (2*2*2*2*3*3*3*5*7)
/* take buffer out of the data segment, not the stack */
#define AUDIO_CHUNK_SIZE 4096
#define AUDIO_CHUNK_SIZE ((32768 + PRIMAGIC - 1)/ PRIMAGIC * PRIMAGIC)
unsigned char convbuffer[AUDIO_CHUNK_SIZE];
int convsize = AUDIO_CHUNK_SIZE;
......@@ -362,6 +363,8 @@ int main(int argc, char **argv)
/* Setup buffer */
if (options.buffer_size > 0) {
/* Keep sample size alignment for surround sound with up to 10 channels */
options.buffer_size = (options.buffer_size + PRIMAGIC - 1) / PRIMAGIC * PRIMAGIC;
audio_buffer = buffer_create(options.buffer_size,
options.buffer_size * options.prebuffer / 100,
audio_play_callback, &audio_play_arg,
......
......@@ -137,7 +137,7 @@ int ovf_read (decoder_t *decoder, void *ptr, int nbytes, int *eos,
*audio_fmt = decoder->actual_fmt;
/* Attempt to read as much audio as is requested */
while (nbytes > 0) {
while (nbytes >= audio_fmt->word_size * audio_fmt->channels) {
old_section = priv->current_section;
ret = ov_read(&priv->vf, ptr, nbytes, audio_fmt->big_endian,
......@@ -162,6 +162,9 @@ int ovf_read (decoder_t *decoder, void *ptr, int nbytes, int *eos,
cb->printf_error(decoder->callback_arg, ERROR,
_("=== Vorbis library reported a stream error.\n"));
/* EOF */
*eos = 1;
break;
} else {
bytes_read += ret;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment