output/recorder: make variables more local
This commit is contained in:
@@ -77,13 +77,12 @@ recorder_output_init(const struct config_param *param, GError **error_r)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *encoder_name;
|
|
||||||
const struct encoder_plugin *encoder_plugin;
|
|
||||||
|
|
||||||
/* read configuration */
|
/* read configuration */
|
||||||
|
|
||||||
encoder_name = config_get_block_string(param, "encoder", "vorbis");
|
const char *encoder_name =
|
||||||
encoder_plugin = encoder_plugin_get(encoder_name);
|
config_get_block_string(param, "encoder", "vorbis");
|
||||||
|
const struct encoder_plugin *encoder_plugin =
|
||||||
|
encoder_plugin_get(encoder_name);
|
||||||
if (encoder_plugin == NULL) {
|
if (encoder_plugin == NULL) {
|
||||||
g_set_error(error_r, recorder_output_quark(), 0,
|
g_set_error(error_r, recorder_output_quark(), 0,
|
||||||
"No such encoder: %s", encoder_name);
|
"No such encoder: %s", encoder_name);
|
||||||
@@ -126,25 +125,24 @@ recorder_output_finish(struct audio_output *ao)
|
|||||||
*/
|
*/
|
||||||
static bool
|
static bool
|
||||||
recorder_output_encoder_to_file(struct recorder_output *recorder,
|
recorder_output_encoder_to_file(struct recorder_output *recorder,
|
||||||
GError **error_r)
|
GError **error_r)
|
||||||
{
|
{
|
||||||
size_t size = 0, position, nbytes;
|
|
||||||
|
|
||||||
assert(recorder->fd >= 0);
|
assert(recorder->fd >= 0);
|
||||||
|
|
||||||
/* read from the encoder */
|
/* read from the encoder */
|
||||||
|
|
||||||
size = encoder_read(recorder->encoder, recorder->buffer,
|
size_t size = encoder_read(recorder->encoder, recorder->buffer,
|
||||||
sizeof(recorder->buffer));
|
sizeof(recorder->buffer));
|
||||||
if (size == 0)
|
if (size == 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
/* write everything into the file */
|
/* write everything into the file */
|
||||||
|
|
||||||
position = 0;
|
size_t position = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
nbytes = write(recorder->fd, recorder->buffer + position,
|
size_t nbytes = write(recorder->fd,
|
||||||
size - position);
|
recorder->buffer + position,
|
||||||
|
size - position);
|
||||||
if (nbytes > 0) {
|
if (nbytes > 0) {
|
||||||
position += (size_t)nbytes;
|
position += (size_t)nbytes;
|
||||||
if (position >= size)
|
if (position >= size)
|
||||||
@@ -169,7 +167,6 @@ recorder_output_open(struct audio_output *ao,
|
|||||||
GError **error_r)
|
GError **error_r)
|
||||||
{
|
{
|
||||||
struct recorder_output *recorder = (struct recorder_output *)ao;
|
struct recorder_output *recorder = (struct recorder_output *)ao;
|
||||||
bool success;
|
|
||||||
|
|
||||||
/* create the output file */
|
/* create the output file */
|
||||||
|
|
||||||
@@ -185,8 +182,7 @@ recorder_output_open(struct audio_output *ao,
|
|||||||
|
|
||||||
/* open the encoder */
|
/* open the encoder */
|
||||||
|
|
||||||
success = encoder_open(recorder->encoder, audio_format, error_r);
|
if (!encoder_open(recorder->encoder, audio_format, error_r)) {
|
||||||
if (!success) {
|
|
||||||
close(recorder->fd);
|
close(recorder->fd);
|
||||||
unlink(recorder->path);
|
unlink(recorder->path);
|
||||||
return false;
|
return false;
|
||||||
|
Reference in New Issue
Block a user