hal: fix variable initialization

- in case of failure before frame_size declaration, code will jump
  to exit label which will result in error.
- fix this by declaring variable at the beginning of the function

Bug: 37197465
Test: Non-offload PCM playback on Marlin
Change-Id: I9cf83bd34d9f777b605b8d0d44a46a0ab6be802b
Signed-off-by: David Lin <dtwlin@google.com>
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 11b5a69..db29122 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -2223,6 +2223,9 @@
     int error_code = ERROR_CODE_STANDBY;
 
     lock_output_stream(out);
+    // this is always nonzero
+    const int frame_size = audio_stream_out_frame_size(stream);
+
     if (out->usecase == USECASE_AUDIO_PLAYBACK_MMAP) {
         error_code = ERROR_CODE_WRITE;
         goto exit;
@@ -2244,9 +2247,6 @@
         }
     }
 
-    // this is always nonzero
-    const size_t frame_size = audio_stream_out_frame_size(stream);
-
     if (out->usecase == USECASE_AUDIO_PLAYBACK_OFFLOAD) {
         ALOGVV("%s: writing buffer (%zu bytes) to compress device", __func__, bytes);
         if (out->send_new_metadata) {