Ticket #3959: 3959-v1.patch

File 3959-v1.patch, 1.2 KB (added by danielk, 17 years ago)
  • libs/libmythtv/mpegrecorder.cpp

     
    403403        VERBOSE(VB_IMPORTANT, LOC_WARN + "Unable to set audio mode" + ENO);
    404404    }
    405405
     406    // Get volume min/max values
     407    struct v4l2_queryctrl qctrl;
     408    qctrl.id = V4L2_CID_AUDIO_VOLUME;
     409    if (ioctl(chanfd, VIDIOC_QUERYCTRL, &qctrl) < 0)
     410    {
     411        VERBOSE(VB_IMPORTANT, LOC_WARN +
     412                "Unable to get recording volume parameters(max/min)" + ENO +
     413                "\n\t\t\tusing default range [0,65535].");
     414        qctrl.maximum = 65535;
     415        qctrl.minimum = 0;
     416    }
     417
     418    // calculate volume in card units.
     419    int range = qctrl.maximum - qctrl.minimum;
     420    int value = (int) ((range * audvolume * 0.01f) + qctrl.minimum);
     421    int ctrl_volume = min(qctrl.maximum, max(qctrl.minimum, value));
     422
    406423    // Set recording volume
    407424    struct v4l2_control ctrl;
    408425    ctrl.id = V4L2_CID_AUDIO_VOLUME;
    409     ctrl.value = 65536 / 100 *audvolume;
     426    ctrl.value = ctrl_volume;
    410427
    411428    if (ioctl(chanfd, VIDIOC_S_CTRL, &ctrl) < 0)
    412429    {