PcmConvert: add methods Open(), Close()

Replaces Reset() and eliminates the AudioFormat parameters from the
Convert() method.
This commit is contained in:
Max Kellermann
2013-11-11 16:15:38 +01:00
parent 4ee147ea34
commit d2679f59c5
9 changed files with 151 additions and 74 deletions

View File

@@ -90,6 +90,11 @@ int main(int argc, char **argv)
const size_t in_frame_size = in_audio_format.GetFrameSize();
PcmConvert state;
if (!state.Open(in_audio_format, out_audio_format_mask, error)) {
g_printerr("Failed to open PcmConvert: %s\n",
error.GetMessage());
return EXIT_FAILURE;
}
FifoBuffer<uint8_t, 4096> buffer;
@@ -115,9 +120,10 @@ int main(int argc, char **argv)
buffer.Consume(src.size);
size_t length;
output = state.Convert(in_audio_format, src.data, src.size,
out_audio_format, &length, error);
output = state.Convert(src.data, src.size,
&length, error);
if (output == NULL) {
state.Close();
g_printerr("Failed to convert: %s\n", error.GetMessage());
return 2;
}
@@ -125,5 +131,7 @@ int main(int argc, char **argv)
gcc_unused ssize_t ignored = write(1, output, length);
}
state.Close();
return EXIT_SUCCESS;
}