# 21_alsa_dev_pjsip217_log.patch (rebased from 2.12)
#
# alsa_dev.c uses `devs[param->X_id].name` in 16 PJ_LOG calls.
# Patch 05_audio_device renames that field to `alsa_name` (the new
# field added to struct alsa_dev_info, separate from the legacy
# pjmedia_aud_dev_info::name field which is no longer populated for
# ALSA devices in 2.17).
#
# Without this patch the Linux build fails with:
#
#   error: 'struct alsa_dev_info' has no member named 'name';
#          did you mean 'alsa_name'?
#
# at every PJ_LOG site that prints the device name.  An earlier
# version of this patch fixed only 2 of the 16 sites; this revision
# covers all of them.
#
# Linux-only: alsa_dev.c is not compiled on Darwin or Windows.
#
--- pjsip_orig/pjmedia/src/pjmedia-audiodev/alsa_dev.c
+++ pjsip/pjmedia/src/pjmedia-audiodev/alsa_dev.c
@@ -802,7 +802,7 @@
                            0);
     if (result < 0) {
         PJ_LOG (3,(THIS_FILE, "Unable to open playback device '%s', err: %s",
-                  stream->af->devs[param->play_id].name, snd_strerror(result)));
+                  stream->af->devs[param->play_id].alsa_name, snd_strerror(result)));
 
         return PJMEDIA_EAUD_SYSERR;
     }
@@ -815,7 +815,7 @@
     if (result < 0) {
         PJ_LOG (3,(THIS_FILE, "Unable to get configuration for "
             "playback device '%s', err: %s",
-            stream->af->devs[param->play_id].name, snd_strerror(result)));
+            stream->af->devs[param->play_id].alsa_name, snd_strerror(result)));
 
         goto on_error;
     }
@@ -826,7 +826,7 @@
     if (result < 0) {
         PJ_LOG (3,(THIS_FILE, "Unable to set interleaved mode for "
                   "playback device '%s', err: %s",
-                  stream->af->devs[param->play_id].name, snd_strerror(result)));
+                  stream->af->devs[param->play_id].alsa_name, snd_strerror(result)));
 
         goto on_error;
     }
@@ -858,7 +858,7 @@
     if (result < 0) {
         PJ_LOG (3,(THIS_FILE, "Unable to set format %d for "
             "playback device '%s', err: %s", format,
-            stream->af->devs[param->play_id].name, snd_strerror(result)));
+            stream->af->devs[param->play_id].alsa_name, snd_strerror(result)));
 
         goto on_error;
     }
@@ -871,7 +871,7 @@
     if (result < 0) {
         PJ_LOG (3,(THIS_FILE, "Unable to set a channel count of %d for "
                    "playback device '%s', err: %s", param->channel_count,
-                   stream->af->devs[param->play_id].name,snd_strerror(result)));
+                   stream->af->devs[param->play_id].alsa_name,snd_strerror(result)));
 
         goto on_error;
     }
@@ -884,7 +884,7 @@
     if (result < 0) {
         PJ_LOG (3,(THIS_FILE, "Unable to set clock rate: %d for "
                     "playback device '%s', err: %s", param->clock_rate,
-                    stream->af->devs[param->play_id].name,
+                    stream->af->devs[param->play_id].alsa_name,
                     snd_strerror(result)));
 
         goto on_error;
@@ -903,7 +903,7 @@
     if (result < 0) {
         PJ_LOG (3,(THIS_FILE, "Unable to set period size: %d for "
                   "playback device '%s', err: %s", (int)stream->pb_frames,
-                  stream->af->devs[param->play_id].name, snd_strerror(result)));
+                  stream->af->devs[param->play_id].alsa_name, snd_strerror(result)));
 
         goto on_error;
     }
@@ -928,7 +928,7 @@
     if (result < 0) {
         PJ_LOG (3,(THIS_FILE, "Warning: unable to set period size: %d for "
                   "playback device '%s', err: %s", (int)tmp_buf_size,
-                  stream->af->devs[param->play_id].name, snd_strerror(result)));
+                  stream->af->devs[param->play_id].alsa_name, snd_strerror(result)));
     }
 
     stream->param.output_latency_ms = tmp_buf_size / (rate / 1000);
@@ -948,7 +948,7 @@
     if (result < 0) {
         PJ_LOG (3,(THIS_FILE, "Unable to activate the param for "
                   "playback device '%s', err: %s",
-                  stream->af->devs[param->play_id].name, snd_strerror(result)));
+                  stream->af->devs[param->play_id].alsa_name, snd_strerror(result)));
 
         goto on_error;
     }
@@ -996,7 +996,7 @@
                            0);
     if (result < 0) {
         PJ_LOG (3,(THIS_FILE, "Unable to open capture device '%s', err: %s",
-                   stream->af->devs[param->rec_id].name, snd_strerror(result)));
+                   stream->af->devs[param->rec_id].alsa_name, snd_strerror(result)));
 
         return PJMEDIA_EAUD_SYSERR;
     }
@@ -1009,7 +1009,7 @@
     if (result < 0) {
         PJ_LOG (3,(THIS_FILE, "Unable to get configuration for "
             "capture device '%s', err: %s",
-            stream->af->devs[param->rec_id].name, snd_strerror(result)));
+            stream->af->devs[param->rec_id].alsa_name, snd_strerror(result)));
 
         goto on_error;
     }
@@ -1020,7 +1020,7 @@
     if (result < 0) {
         PJ_LOG (3,(THIS_FILE, "Unable to set interleaved mode for "
                   "capture device '%s', err: %s",
-                   stream->af->devs[param->rec_id].name, snd_strerror(result)));
+                   stream->af->devs[param->rec_id].alsa_name, snd_strerror(result)));
 
         goto on_error;
     }
@@ -1052,7 +1052,7 @@
     if (result < 0) {
         PJ_LOG (3,(THIS_FILE, "Unable to set format %d for "
             "capture device '%s', err: %s", format,
-            stream->af->devs[param->rec_id].name, snd_strerror(result)));
+            stream->af->devs[param->rec_id].alsa_name, snd_strerror(result)));
 
         goto on_error;
     }
@@ -1065,7 +1065,7 @@
     if (result < 0) {
         PJ_LOG (3,(THIS_FILE, "Unable to set a channel count of %d for "
                     "capture device '%s', err: %s", param->channel_count,
-                    stream->af->devs[param->rec_id].name,snd_strerror(result)));
+                    stream->af->devs[param->rec_id].alsa_name,snd_strerror(result)));
 
         goto on_error;
     }
@@ -1077,7 +1077,7 @@
     if (result < 0) {
         PJ_LOG (3,(THIS_FILE, "Unable to set clock rate: %d for "
                     "capture device '%s', err: %s", param->clock_rate,
-                    stream->af->devs[param->rec_id].name,
+                    stream->af->devs[param->rec_id].alsa_name,
                     snd_strerror(result)));
 
         goto on_error;
@@ -1096,7 +1096,7 @@
     if (result < 0) {
         PJ_LOG (3,(THIS_FILE, "Unable to set period size: %d for "
                    "capture device '%s', err: %s", (int)stream->ca_frames,
-                   stream->af->devs[param->rec_id].name, snd_strerror(result)));
+                   stream->af->devs[param->rec_id].alsa_name, snd_strerror(result)));
 
         goto on_error;
     }
@@ -1120,7 +1120,7 @@
     if (result < 0) {
         PJ_LOG (3,(THIS_FILE, "Warning: unable to set period size: %d for "
                    "capture device '%s', err: %s", (int)tmp_buf_size,
-                   stream->af->devs[param->rec_id].name, snd_strerror(result)));
+                   stream->af->devs[param->rec_id].alsa_name, snd_strerror(result)));
     }
 
     stream->param.input_latency_ms = tmp_buf_size / (rate / 1000);
@@ -1140,7 +1140,7 @@
     if (result < 0) {
         PJ_LOG (3,(THIS_FILE, "Unable to activate the param for "
                    "capture device '%s', err: %s",
-                   stream->af->devs[param->rec_id].name, snd_strerror(result)));
+                   stream->af->devs[param->rec_id].alsa_name, snd_strerror(result)));
 
         goto on_error;
     }
