output/recorder: move more functions into the struct

This commit is contained in:
Max Kellermann 2015-01-07 18:52:47 +01:00
parent d83127722f
commit 7a2af0fbf4
1 changed files with 13 additions and 12 deletions

View File

@ -69,6 +69,8 @@ struct RecorderOutput {
return base.Configure(param, error_r); return base.Configure(param, error_r);
} }
static RecorderOutput *Create(const config_param &param, Error &error);
bool Configure(const config_param &param, Error &error); bool Configure(const config_param &param, Error &error);
bool Open(AudioFormat &audio_format, Error &error); bool Open(AudioFormat &audio_format, Error &error);
@ -82,6 +84,8 @@ struct RecorderOutput {
bool EncoderToFile(Error &error); bool EncoderToFile(Error &error);
void SendTag(const Tag &tag); void SendTag(const Tag &tag);
size_t Play(const void *chunk, size_t size, Error &error);
}; };
static constexpr Domain recorder_output_domain("recorder_output"); static constexpr Domain recorder_output_domain("recorder_output");
@ -116,8 +120,8 @@ RecorderOutput::Configure(const config_param &param, Error &error)
return true; return true;
} }
static AudioOutput * RecorderOutput *
recorder_output_init(const config_param &param, Error &error) RecorderOutput::Create(const config_param &param, Error &error)
{ {
RecorderOutput *recorder = new RecorderOutput(); RecorderOutput *recorder = new RecorderOutput();
@ -131,7 +135,7 @@ recorder_output_init(const config_param &param, Error &error)
return nullptr; return nullptr;
} }
return &recorder->base; return recorder;
} }
static void static void
@ -252,14 +256,11 @@ recorder_output_send_tag(AudioOutput *ao, const Tag &tag)
recorder.SendTag(tag); recorder.SendTag(tag);
} }
static size_t inline size_t
recorder_output_play(AudioOutput *ao, const void *chunk, size_t size, RecorderOutput::Play(const void *chunk, size_t size, Error &error)
Error &error)
{ {
RecorderOutput *recorder = (RecorderOutput *)ao; return encoder_write(encoder, chunk, size, error) &&
EncoderToFile(error)
return encoder_write(recorder->encoder, chunk, size, error) &&
recorder->EncoderToFile(error)
? size : 0; ? size : 0;
} }
@ -268,7 +269,7 @@ typedef AudioOutputWrapper<RecorderOutput> Wrapper;
const struct AudioOutputPlugin recorder_output_plugin = { const struct AudioOutputPlugin recorder_output_plugin = {
"recorder", "recorder",
nullptr, nullptr,
recorder_output_init, &Wrapper::Init,
recorder_output_finish, recorder_output_finish,
nullptr, nullptr,
nullptr, nullptr,
@ -276,7 +277,7 @@ const struct AudioOutputPlugin recorder_output_plugin = {
&Wrapper::Close, &Wrapper::Close,
nullptr, nullptr,
recorder_output_send_tag, recorder_output_send_tag,
recorder_output_play, &Wrapper::Play,
nullptr, nullptr,
nullptr, nullptr,
nullptr, nullptr,