Skip to content

Commit

Permalink
Hackage required to properly stream OggFLAC in the sense of having th…
Browse files Browse the repository at this point in the history
…e decoder somewhere else on the local network or interweb
  • Loading branch information
oneman committed Dec 1, 2010
1 parent ff43001 commit 67e1336
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
23 changes: 18 additions & 5 deletions src/libFLAC/ogg_encoder_aspect.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,24 @@ FLAC__StreamEncoderWriteStatus FLAC__ogg_encoder_aspect_write_callback_wrapper(F
}
}
else {
while(ogg_stream_pageout(&aspect->stream_state, &aspect->page) != 0) {
if(write_callback(encoder, aspect->page.header, aspect->page.header_len, 0, current_frame, client_data) != FLAC__STREAM_ENCODER_WRITE_STATUS_OK)
return FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR;
if(write_callback(encoder, aspect->page.body, aspect->page.body_len, 0, current_frame, client_data) != FLAC__STREAM_ENCODER_WRITE_STATUS_OK)
return FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR;
/* Most clients existing on December 1st 2010 can not handle more than 1 packet per page
* Silent packets are about 613 bytes -David Richards
*/
if (bytes < 700) {
while(ogg_stream_flush(&aspect->stream_state, &aspect->page) != 0) {
if(write_callback(encoder, aspect->page.header, aspect->page.header_len, 0, current_frame, client_data) != FLAC__STREAM_ENCODER_WRITE_STATUS_OK)
return FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR;
if(write_callback(encoder, aspect->page.body, aspect->page.body_len, 0, current_frame, client_data) != FLAC__STREAM_ENCODER_WRITE_STATUS_OK)
return FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR;
}
}
else {
while(ogg_stream_pageout(&aspect->stream_state, &aspect->page) != 0) {
if(write_callback(encoder, aspect->page.header, aspect->page.header_len, 0, current_frame, client_data) != FLAC__STREAM_ENCODER_WRITE_STATUS_OK)
return FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR;
if(write_callback(encoder, aspect->page.body, aspect->page.body_len, 0, current_frame, client_data) != FLAC__STREAM_ENCODER_WRITE_STATUS_OK)
return FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR;
}
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/libFLAC/stream_encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -2151,7 +2151,11 @@ void set_defaults_(FLAC__StreamEncoder *encoder)
encoder->protected_->num_metadata_blocks = 0;

encoder->private_->seek_table = 0;
encoder->private_->disable_constant_subframes = false;
/* constant subframes must be disabled for streaming oggflac
* most clients will pause decoding until the time of
* silence is over, or otherwise misbehave or crash -David Richards
*/
encoder->private_->disable_constant_subframes = true;
encoder->private_->disable_fixed_subframes = false;
encoder->private_->disable_verbatim_subframes = false;
#if FLAC__HAS_OGG
Expand Down

0 comments on commit 67e1336

Please sign in to comment.