output/{recorder,shout}: call encoder_read() in a loop
This is necessary for Ogg packets that span more than one page.
This commit is contained in:
parent
58e600f408
commit
adbe8c409a
1
NEWS
1
NEWS
|
@ -2,6 +2,7 @@ ver 0.17.3 (2012/??/??)
|
||||||
* output:
|
* output:
|
||||||
- recorder: fix I/O error check
|
- recorder: fix I/O error check
|
||||||
- shout: fix memory leak in error handler
|
- shout: fix memory leak in error handler
|
||||||
|
- recorder, shout: support Ogg packets that span more than one page
|
||||||
|
|
||||||
ver 0.17.2 (2012/09/30)
|
ver 0.17.2 (2012/09/30)
|
||||||
* protocol:
|
* protocol:
|
||||||
|
|
|
@ -295,6 +295,8 @@ encoder_write(struct encoder *encoder, const void *data, size_t length,
|
||||||
/**
|
/**
|
||||||
* Reads encoded data from the encoder.
|
* Reads encoded data from the encoder.
|
||||||
*
|
*
|
||||||
|
* Call this repeatedly until no more data is returned.
|
||||||
|
*
|
||||||
* @param encoder the encoder
|
* @param encoder the encoder
|
||||||
* @param dest the destination buffer to copy to
|
* @param dest the destination buffer to copy to
|
||||||
* @param length the maximum length of the destination buffer
|
* @param length the maximum length of the destination buffer
|
||||||
|
|
|
@ -160,6 +160,7 @@ recorder_output_encoder_to_file(struct recorder_output *recorder,
|
||||||
{
|
{
|
||||||
assert(recorder->fd >= 0);
|
assert(recorder->fd >= 0);
|
||||||
|
|
||||||
|
while (true) {
|
||||||
/* read from the encoder */
|
/* read from the encoder */
|
||||||
|
|
||||||
size_t size = encoder_read(recorder->encoder, recorder->buffer,
|
size_t size = encoder_read(recorder->encoder, recorder->buffer,
|
||||||
|
@ -169,8 +170,10 @@ recorder_output_encoder_to_file(struct recorder_output *recorder,
|
||||||
|
|
||||||
/* write everything into the file */
|
/* write everything into the file */
|
||||||
|
|
||||||
return recorder_write_to_file(recorder, recorder->buffer, size,
|
if (!recorder_write_to_file(recorder, recorder->buffer, size,
|
||||||
error_r);
|
error_r))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
|
|
@ -342,6 +342,7 @@ write_page(struct shout_data *sd, GError **error)
|
||||||
{
|
{
|
||||||
assert(sd->encoder != NULL);
|
assert(sd->encoder != NULL);
|
||||||
|
|
||||||
|
while (true) {
|
||||||
size_t nbytes = encoder_read(sd->encoder,
|
size_t nbytes = encoder_read(sd->encoder,
|
||||||
sd->buffer, sizeof(sd->buffer));
|
sd->buffer, sizeof(sd->buffer));
|
||||||
if (nbytes == 0)
|
if (nbytes == 0)
|
||||||
|
@ -350,6 +351,7 @@ write_page(struct shout_data *sd, GError **error)
|
||||||
int err = shout_send(sd->shout_conn, sd->buffer, nbytes);
|
int err = shout_send(sd->shout_conn, sd->buffer, nbytes);
|
||||||
if (!handle_shout_error(sd, err, error))
|
if (!handle_shout_error(sd, err, error))
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue