Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4d921f67 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "qahw: test: Pass correct channel mask and wave header length"

parents dfc068c3 d13c1a39
Loading
Loading
Loading
Loading
+16 −7
Original line number Diff line number Diff line
@@ -329,9 +329,12 @@ void *start_input(void *thread_param)
  strlcat(param, params->profile, sizeof(param));
  qahw_in_set_parameters(in_handle, param);

  fprintf(log_file, "\n Please speak into the microphone for %lf seconds, handle(%d)\n", params->record_length, params->handle);
  /* Caution: Below ADL log shouldnt be altered without notifying automation APT since it used for
   * automation testing
   */
  fprintf(log_file, "\n ADL: Please speak into the microphone for %lf seconds, handle(%d)\n", params->record_length, params->handle);
  if (log_file != stdout)
      fprintf(stdout, "\n Please speak into the microphone for %lf seconds, handle(%d)\n", params->record_length, params->handle);
      fprintf(stdout, "\n ADL: Please speak into the microphone for %lf seconds, handle(%d)\n", params->record_length, params->handle);

  snprintf(file_name + name_len, sizeof(file_name) - name_len, "%d.wav", (0x99A - params->handle));
  FILE *fd = fopen(file_name,"w");
@@ -467,14 +470,17 @@ void *start_input(void *thread_param)
          fprintf(stdout, "could not close input stream %d, handle(%d)\n",rc, params->handle);
  }

  /* Print instructions to access the file. */
  fprintf(log_file, "\n\n The audio recording has been saved to %s. Please use adb pull to get "
  /* Print instructions to access the file.
   * Caution: Below ADL log shouldnt be altered without notifying automation APT since it used for
   * automation testing
   */
  fprintf(log_file, "\n\n ADL: The audio recording has been saved to %s. Please use adb pull to get "
         "the file and play it using audacity. The audio data has the "
         "following characteristics:\n Sample rate: %i\n Format: %d\n "
         "Num channels: %i, handle(%d)\n\n",
         file_name, params->config.sample_rate, params->config.format, params->channels, params->handle);
  if (log_file != stdout)
      fprintf(stdout, "\n\n The audio recording has been saved to %s. Please use adb pull to get "
      fprintf(stdout, "\n\n ADL: The audio recording has been saved to %s. Please use adb pull to get "
         "the file and play it using audacity. The audio data has the "
         "following characteristics:\n Sample rate: %i\n Format: %d\n "
         "Num channels: %i, handle(%d)\n\n",
@@ -893,9 +899,12 @@ sourcetrack_error:
        fprintf(log_file, "could not unload hal %d \n",ret);
    }

    fprintf(log_file, "\n Done with hal record test \n");
    /* Caution: Below ADL log shouldnt be altered without notifying automation APT since it used
     * for automation testing
     */
    fprintf(log_file, "\n ADL: Done with hal record test \n");
    if (log_file != stdout) {
        fprintf(stdout, "\n Done with hal record test \n");
        fprintf(stdout, "\n ADL: Done with hal record test \n");
        fclose(log_file);
    }
    wakelock_acquired = request_wake_lock(wakelock_acquired, false);
+25 −22
Original line number Diff line number Diff line
@@ -58,6 +58,10 @@
#define KVPAIRS_MAX 100
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[1]))

#define FORMAT_DESCRIPTOR_SIZE 12
#define SUBCHUNK1_SIZE(x) ((8) + (x))
#define SUBCHUNK2_SIZE 8

static int get_wav_header_length (FILE* file_stream);
static void init_streams(void);

@@ -718,9 +722,12 @@ void *start_stream_playback (void* stream_data)
                        qahw_out_drain(params->out_handle, QAHW_DRAIN_ALL);
                        pthread_cond_wait(&params->drain_cond, &params->drain_lock);
                        fprintf(log_file, "stream %d: out of compress drain\n", params->stream_index);
                        fprintf(log_file, "stream %d: playback completed successfully\n", params->stream_index);
                        pthread_mutex_unlock(&params->drain_lock);
                    }
            /* Caution: Below ADL log shouldnt be altered without notifying automation APT since
             * it used for automation testing
             */
                    fprintf(log_file, "ADL: stream %d: playback completed successfully\n", params->stream_index);
                }
                exit = true;
                continue;
@@ -1012,7 +1019,7 @@ static void get_file_format(stream_config *stream_info)
    }
    stream_info->config.sample_rate = stream_info->config.offload_info.sample_rate;
    stream_info->config.format = stream_info->config.offload_info.format;
    stream_info->config.channel_mask = stream_info->config.offload_info.channel_mask = audio_channel_in_mask_from_count(stream_info->channels);
    stream_info->config.channel_mask = stream_info->config.offload_info.channel_mask = audio_channel_out_mask_from_count(stream_info->channels);
    return;
}

@@ -1183,6 +1190,9 @@ static int get_kvpairs_string(char *kvpairs, const char *key, char *value) {
        return -1;

    parms = str_parms_create_str(kvpairs);
    if (parms == NULL)
        return -1;

    if (str_parms_get_str(parms, key, value, KVPAIRS_MAX) < 0)
        return -1;

@@ -1207,7 +1217,7 @@ static int get_pcm_format(char *kvpairs) {
   /*
    * for now we assume usb hal/pcm device announces suport for one format ONLY
    */
    for (i = 0; i < sizeof(format_table); i++) {
    for (i = 0; i < (sizeof(format_table)/sizeof(format_table[0])); i++) {
        if(!strncmp(format_table[i].string, value, sizeof(value))) {
            match = true;
            break;
@@ -1345,8 +1355,8 @@ static int detect_stream_params(stream_config *stream) {
        param_string = qahw_out_get_parameters(stream->out_handle, QAHW_PARAMETER_STREAM_SUP_CHANNELS);

    if ((ch = get_channels(param_string)) <= 0) {
        fprintf(log_file, "Unable to extract channels =(%d) string(%s)\n", ch, param_string);
        fprintf(stderr, "Unable to extract channels =(%d) string(%s)\n", ch, param_string);
        fprintf(log_file, "Unable to extract channels =(%d) string(%s)\n", ch, param_string == NULL ? "null":param_string);
        fprintf(stderr, "Unable to extract channels =(%d) string(%s)\n", ch, param_string == NULL ? "null":param_string);
        return -1;
    }
    stream->config.channel_mask = audio_channel_in_mask_from_count(ch);
@@ -1517,20 +1527,7 @@ static int get_wav_header_length (FILE* file_stream)
        fprintf(log_file, "This is not a valid wav file \n");
        fprintf(stderr, "This is not a valid wav file \n");
    } else {
          switch (subchunk_size) {
          case 16:
              fprintf(log_file, "44-byte wav header \n");
              wav_header_len = 44;
              break;
          case 18:
              fprintf(log_file, "46-byte wav header \n");
              wav_header_len = 46;
              break;
          default:
              fprintf(log_file, "Header contains extra data and is larger than 46 bytes: subchunk_size=%d \n", subchunk_size);
              wav_header_len = subchunk_size;
              break;
          }
         wav_header_len = FORMAT_DESCRIPTOR_SIZE + SUBCHUNK1_SIZE(subchunk_size) + SUBCHUNK2_SIZE;
    }
    return wav_header_len;
}
@@ -1787,7 +1784,10 @@ int main(int argc, char* argv[]) {

    wakelock_acquired = request_wake_lock(wakelock_acquired, true);
    num_of_streams = i+1;
    fprintf(log_file, "Starting audio hal tests for streams : %d\n", num_of_streams);
    /* Caution: Below ADL log shouldnt be altered without notifying automation APT since it used
     * for automation testing
     */
    fprintf(log_file, "ADL: Starting audio hal tests for streams : %d\n", num_of_streams);

    if (kpi_mode == true && num_of_streams > 1) {
        fprintf(log_file, "kpi-mode is not supported for multi-playback usecase\n");
@@ -1946,7 +1946,7 @@ exit:
        if (stream_param[i].file_stream != nullptr)
            fclose(stream_param[i].file_stream);
        else if (AUDIO_DEVICE_NONE != stream_param[i].input_device) {
            if (stream->in_handle) {
            if (stream != NULL && stream->in_handle) {
                rc = qahw_close_input_stream(stream->in_handle);
                if (rc) {
                    fprintf(log_file, "input stream could not be closed\n");
@@ -1963,6 +1963,9 @@ exit:
        fclose(log_file);

    wakelock_acquired = request_wake_lock(wakelock_acquired, false);
    fprintf(log_file, "\nBYE BYE\n");
    /* Caution: Below ADL log shouldnt be altered without notifying automation APT since it used
     * for automation testing
     */
    fprintf(log_file, "\nADL: BYE BYE\n");
    return 0;
}