~damg/ubuntu/quantal/asterisk/LP1097687

« back to all changes in this revision

Viewing changes to .pc/moh_datadir/res/res_musiconhold.c

  • Committer: Bazaar Package Importer
  • Author(s): Lorenzo De Liso
  • Date: 2010-10-15 22:24:34 UTC
  • mfrom: (1.2.8 upstream) (8.3.8 sid)
  • Revision ID: james.westby@ubuntu.com-20101015222434-iy328q8in3lajzlv
Tags: 1:1.6.2.9-2ubuntu1
* Merge from debian unstable, remaining changes:
  - debian/control:
    + Build-depend on hardening-wrapper
    + Change Maintainer
    + Removed Uploaders field.
    + Removed Debian Vcs-Svn entry and replaced with ubuntu-voip Vcs-Bzr,
      to reflect divergence in packages.
  - debian/rules: Make use of hardening-wrapper
  - debian/asterisk.init: chown /dev/dahdi
  - debian/backports/hardy: add file
  - debian/backports/asterisk.init.hardy: add file
 

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
 
33
33
#include "asterisk.h"
34
34
 
35
 
ASTERISK_FILE_VERSION(__FILE__, "$Revision: 250790 $")
 
35
ASTERISK_FILE_VERSION(__FILE__, "$Revision: 260373 $")
36
36
 
37
37
#include <ctype.h>
38
38
#include <signal.h>
329
329
        state->sample_queue += samples;
330
330
 
331
331
        while (state->sample_queue > 0) {
 
332
                ast_channel_lock(chan);
332
333
                if ((f = moh_files_readframe(chan))) {
 
334
                        /* We need to be sure that we unlock
 
335
                         * the channel prior to calling
 
336
                         * ast_write. Otherwise, the recursive locking
 
337
                         * that occurs can cause deadlocks when using
 
338
                         * indirect channels, like local channels
 
339
                         */
 
340
                        ast_channel_unlock(chan);
333
341
                        state->samples += f->samples;
334
342
                        state->sample_queue -= f->samples;
335
343
                        res = ast_write(chan, f);
338
346
                                ast_log(LOG_WARNING, "Failed to write frame to '%s': %s\n", chan->name, strerror(errno));
339
347
                                return -1;
340
348
                        }
341
 
                } else
 
349
                } else {
 
350
                        ast_channel_unlock(chan);
342
351
                        return -1;      
 
352
                }
343
353
        }
344
354
        return res;
345
355
}
1432
1442
 
1433
1443
static void local_ast_moh_stop(struct ast_channel *chan)
1434
1444
{
1435
 
        struct moh_files_state *state = chan->music_state;
1436
1445
        ast_clear_flag(chan, AST_FLAG_MOH);
1437
1446
        ast_deactivate_generator(chan);
1438
1447
 
1439
 
        if (state) {
 
1448
        ast_channel_lock(chan);
 
1449
        if (chan->music_state) {
1440
1450
                if (chan->stream) {
1441
1451
                        ast_closestream(chan->stream);
1442
1452
                        chan->stream = NULL;
1448
1458
                "Channel: %s\r\n"
1449
1459
                "UniqueID: %s\r\n",
1450
1460
                chan->name, chan->uniqueid);
 
1461
        ast_channel_unlock(chan);
1451
1462
}
1452
1463
 
1453
1464
static void moh_class_destructor(void *obj)