<html>
 <body>
  <div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
   <table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 solid;">
    <tr>
     <td>
      This is an automatically generated e-mail. To reply, visit:
      <a href="https://reviewboard.asterisk.org/r/1580/">https://reviewboard.asterisk.org/r/1580/</a>
     </td>
    </tr>
   </table>
   <br />


<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" style="background-image: url('https://reviewboard.asterisk.org/media/rb/images/review_request_box_top_bg.png'); background-position: left top; background-repeat: repeat-x; border: 1px black solid;">
 <tr>
  <td>

<div>Review request for Asterisk Developers and David Vossel.</div>
<div>By mjordan.</div>





<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">When audio formats were changed to 64 bits, audio formats bit masks were no longer contiguous.  Previously, a comparison operator could be used with AST_FORMAT_AUDIO_MASK to check if a format was audio - however, since AUDIO_FORMAT_MASK now includes audio formats that have a bit mask value greater than some video formats, this no longer works and a bitwise AND operator must be used.  The check to delete a scheduled audio / video read callback in file.c still used a comparison check.  As a result, regardless of the format, the stream was treated as audio and would not be descheduled properly.  If a video stream was stopped before it reached the end of the file, the read callback would not be removed from the scheduler, and the next time the scheduler was called (which could be on a subsequent audio file), the video callback would be called on an already disposed of stream.

This patch fixes that by properly checking for the audio / video masks.  It also consolidates the closing of the audio / video streams into a single private function to reduce code duplication between ast_closestream and the filestream_destructor.

I also searched through the rest of the codebase for any other improper checking of a format against AUDIO_FORMAT_MASK - while comparison operators are used against AST_FORMAT_AUDIO_MASK in a few other places (such as in while loops), in those locations, the format is still explicitly checked as to whether or not it is audio using a bitwise AND operator.</pre>
  </td>
 </tr>
</table>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Tested using a video softphone and h.264.  Tested listening back a recorded video message and using DTMF tones to interrupt the playback multiple times in various locations.  Tested also listening to the recorded video message using audio only.  In all cases the playback works correctly with this patch.</pre>
  </td>
 </tr>
</table>



<div style="margin-top: 1.5em;">
 <b style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Bugs: </b>


 <a href="https://issues.asterisk.org/jira/browse/ASTERISK-18682">ASTERISK-18682</a>


</div>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">

 <li>/branches/1.8/main/file.c <span style="color: grey">(344607)</span></li>

</ul>

<p><a href="https://reviewboard.asterisk.org/r/1580/diff/" style="margin-left: 3em;">View Diff</a></p>




  </td>
 </tr>
</table>




  </div>
 </body>
</html>