From 653d5a769c8e6c55c7ac2f6fdc871dafb30f47b8 Mon Sep 17 00:00:00 2001 From: snow Date: Sun, 30 Aug 2020 08:46:28 -0700 Subject: [PATCH] Some code cleanup --- src/netbsdout.cc | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/netbsdout.cc b/src/netbsdout.cc index c52d44a..d60baf8 100644 --- a/src/netbsdout.cc +++ b/src/netbsdout.cc @@ -13,7 +13,6 @@ #include #include - class NetBSDOutput : public OutputPlugin { public: @@ -34,19 +33,16 @@ public: void close_audio (); int write_audio (const void * data, int size); + void pause (bool pause); void period_wait (); - - void drain (); + int get_delay (); void set_volume(StereoVolume volume); StereoVolume get_volume(); - int get_delay (); - - void pause (bool pause); - void flush (); + void drain (); }; __attribute__((visibility("default"))) NetBSDOutput aud_plugin_instance; @@ -114,16 +110,21 @@ NetBSDOutput::cleanup () close (audio_fd); } +/* + * Converts the format libaudcore provides to something usable + * in audio_info_t, then passes along the information to the + * audio device. + */ bool NetBSDOutput::open_audio (int format, int rate, int chans, String & error) { - // TODO: + /* TODO: Use FMT_S24_* or FMT_S24_3* */ audio_info_t info; int props; - // Audacious->NetBSD format table + /* Audacious->NetBSD format table */ static const struct fmt_conv fmt_table[] = { {FMT_S8, AUDIO_ENCODING_SLINEAR, 8}, {FMT_U8, AUDIO_ENCODING_ULINEAR, 8}, @@ -153,6 +154,7 @@ NetBSDOutput::open_audio (int format, AUDIO_INITINFO (&info); + /* Loop to find the right format, if it's supported */ for (auto & conv : fmt_table) { if (conv.aud_format == format) { cur_format = conv; @@ -165,13 +167,14 @@ NetBSDOutput::open_audio (int format, return false; } - info.play.channels = chans; info.play.encoding = cur_format.encoding; info.play.precision = cur_format.bits; + + /* Channels and sample rate are straightforward, at least */ + info.play.channels = chans; info.play.sample_rate = rate; info.mode = AUMODE_PLAY; - if (ioctl (audio_fd, AUDIO_SETINFO, & info) == -1) { error = String (str_printf ("Failed to set track info on %s: %s.\n", @@ -185,7 +188,7 @@ NetBSDOutput::open_audio (int format, void NetBSDOutput::close_audio () { - AUDDBG ("close_audio is a stub!\n"); // XXX + AUDDBG ("close_audio is a stub!\n"); /* XXX */ } int @@ -330,7 +333,7 @@ NetBSDOutput::flush () StereoVolume NetBSDOutput::get_volume () { - // too noisy, even for debug... + /* too noisy, even for debug... */ // AUDDBG ("get_volume: Stub!\n"); return {100, 100}; // XXX