aboutsummaryrefslogtreecommitdiffstats
path: root/res/res_musiconhold.c
AgeCommit message (Collapse)AuthorFilesLines
2009-10-06Fix ao2_iterator API to hold references to containers being iterated.kpfleming1-0/+4
See Mantis issue for details of what prompted this change. Additional notes: This patch changes the ao2_iterator API in two ways: F_AO2I_DONTLOCK has become an enum instead of a macro, with a name that fits our naming policy; also, it is now necessary to call ao2_iterator_destroy() on any iterator that has been created. Currently this only releases the reference to the container being iterated, but in the future this could also release other resources used by the iterator, if the iterator implementation changes to use additional resources. (closes issue #15987) Reported by: kpfleming Review: https://reviewboard.asterisk.org/r/383/ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@222152 f38db490-d61c-443f-a65b-d21fe96a405b
2009-06-18Fix memory corruption and leakage related reloads of non files mode MoH classes.russell1-1/+2
For Music on Hold classes that are not files mode, meaning that we are executing an application that will feed us audio data, we use a thread to monitor the external application and read audio from it. This thread also makes use of the MoH class object. In the MoH class destructor, we used pthread_cancel() to ask the thread to exit. Unfortunately, the code did not wait to ensure that the thread actually went away. What needed to be done is a pthread_join() to ensure that the thread fully cleans up before we proceed. By adding this one line, we resolve two significant problems: 1) Since the thread was never joined, it never fully goes away. So, on every reload of non-files mode MoH, an unused thread was sticking around. 2) There was a race condition here where the application monitoring thread could still try to access the MoH class, even though the thread executing the MoH reload has already destroyed it. (issue #15109) Reported by: jvandal (issue #15123) Reported by: axisinternet (issue #15195) Reported by: amorsen (issue AST-208) git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@201600 f38db490-d61c-443f-a65b-d21fe96a405b
2009-06-01If using the old deprecated format, a reload would cause the class to disappear.tilghman1-6/+11
(closes issue #14759) Reported by: lidocaineus Patches: 20090518__issue14759.diff.txt uploaded by tilghman (license 14) Tested by: lmadsen git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@198665 f38db490-d61c-443f-a65b-d21fe96a405b
2009-04-08Fix a small logical error when loading moh classes.mmichelson1-3/+3
We were unconditionally incrementing the number of mohclasses registered. However, we should actually only increment if the call to moh_register was successful. While this probably has never caused problems, I noticed it and decided to fix it anyway. git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@187045 f38db490-d61c-443f-a65b-d21fe96a405b
2009-03-18Improve the build system to *properly* remove unnecessary symbols from the ↵kpfleming1-1/+1
runtime global namespace. Along the way, change the prefixes on some internal-only API calls to use a common prefix. With these changes, for a module to export symbols into the global namespace, it must have *both* the AST_MODFLAG_GLOBAL_SYMBOLS flag and a linker script that allows the linker to leave the symbols exposed in the module's .so file (see res_odbc.exports for an example). git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@182808 f38db490-d61c-443f-a65b-d21fe96a405b
2009-03-18revert commit that included extranous changeskpfleming1-1/+1
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@182807 f38db490-d61c-443f-a65b-d21fe96a405b
2009-03-18Improve the build system to *properly* remove unnecessary symbols from the ↵kpfleming1-1/+1
runtime global namespace. Along the way, change the prefixes on some internal-only API calls to use a common prefix. With these changes, for a module to export symbols into the global namespace, it must have *both* the AST_MODFLAG_GLOBAL_SYMBOLS flag and a linker script that allows the linker to leave the symbols exposed in the module's .so file (see res_odbc.exports for an example). git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@182802 f38db490-d61c-443f-a65b-d21fe96a405b
2009-03-12Fix incorrect usage of strncasecmp... I really meant to use strcasecmp.file1-1/+1
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@181664 f38db490-d61c-443f-a65b-d21fe96a405b
2009-03-12Fix logic flaw in previous commit.file1-1/+1
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@181660 f38db490-d61c-443f-a65b-d21fe96a405b
2009-03-12Fix another scenario where depending on configuration the stream would not ↵file1-1/+1
get read. For custom commands we don't know whether the audio is coming from a stream or not so we are going to have to read the data despite no channels. (closes issue #14416) Reported by: caspy git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@181659 f38db490-d61c-443f-a65b-d21fe96a405b
2009-03-12Fix issue with streaming MOH failing if nobody is listening.file1-2/+2
When a music class is setup to actually provide music on hold from a stream we need to constantly read audio from it since it will constantly be providing audio. This is now done despite there being no channels listening to it. (closes issue #14416) Reported by: caspy git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@181655 f38db490-d61c-443f-a65b-d21fe96a405b
2009-02-24Change include order to make compile on Centos 5 with DAHDItwilson1-1/+4
If BIT_TYPES_DEFINED gets defined before linux/types.h is included, the __s32 type doesn't get defined git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@178266 f38db490-d61c-443f-a65b-d21fe96a405b
2009-02-09Don't overwrite our pointer to the music class when music on hold stops. We ↵file1-9/+3
will use this if it starts again to see if we can resume the music where it left off. (closes issue #14407) Reported by: mostyn git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@174218 f38db490-d61c-443f-a65b-d21fe96a405b
2009-01-29Lose the CAP_NET_ADMIN at every fork, instead of at startup. Otherwise, iftilghman1-5/+21
Asterisk runs as a non-root user and the administrator does a 'restart now', Asterisk loses the ability to set QOS on packets. (closes issue #14004) Reported by: nemo Patches: 20090105__bug14004.diff.txt uploaded by Corydon76 (license 14) Tested by: Corydon76 git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@172438 f38db490-d61c-443f-a65b-d21fe96a405b
2009-01-09Make this compile for mvanbaakrussell1-1/+1
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@168198 f38db490-d61c-443f-a65b-d21fe96a405b
2008-12-22Re-work ref count handling of MoH classes using astobj2 to resolve crashes.russell1-325/+441
(closes issue #13566) Reported by: igorcarneiro Tested by: russell Review: http://reviewboard.digium.com/r/106/ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@166262 f38db490-d61c-443f-a65b-d21fe96a405b
2008-12-19(closes issue #13480)jpeeler1-5/+1
Reported by: tzafrir Replace a bunch of if defined checks for Zaptel/DAHDI through several new defines in dahdi_compat.h. This removes a lot of code duplication. Example from bug: #ifdef HAVE_ZAPTEL fd = open("/dev/zap/pseudo", O_RDWR); #else fd = open("/dev/dahdi/pseudo", O_RDWR); #endif is replaced with: fd = open(DAHDI_FILE_PSEUDO, O_RDRW); git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@165991 f38db490-d61c-443f-a65b-d21fe96a405b
2008-12-18Set the process group ID on the MOH process so that all children will get killedrussell1-6/+7
(closes issue #14099) Reported by: caspy Patches: res_musiconhold.c.patch.killpg.try2 uploaded by caspy (license 645) git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@165661 f38db490-d61c-443f-a65b-d21fe96a405b
2008-12-16Don't try to change working directory if a directory was not configured.russell1-1/+1
(closes issue #14089) Reported by: caspy git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@164605 f38db490-d61c-443f-a65b-d21fe96a405b
2008-12-10Oops, inverted logic for a strcasecmp check. Pointed out by mmichelson, thanks!jpeeler1-1/+1
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@162926 f38db490-d61c-443f-a65b-d21fe96a405b
2008-12-10(closes issue #13229)jpeeler1-5/+5
Reported by: clegall_proformatique Ensure that moh_generate does not return prematurely before local_ast_moh_stop is called. Also, the sleep in mp3_spawn now only occurs for http locations since it seems to have been added originally only for failing media streams. git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@162874 f38db490-d61c-443f-a65b-d21fe96a405b
2008-11-01fix a bunch of potential problems found by gcc 4.3.x, primarily bare strings ↵kpfleming1-4/+16
being passed to printf()-like functions and ignored results from read()/write() and friends git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@153337 f38db490-d61c-443f-a65b-d21fe96a405b
2008-06-13fixed dahdi compatability header from assuming either dahdi or zaptel is ↵jpeeler1-1/+1
installed (may not have either) git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@122663 f38db490-d61c-443f-a65b-d21fe96a405b
2008-06-12Adds DAHDI support alongside Zaptel. DAHDI usage favored, but all Zap stuff ↵jpeeler1-7/+9
should continue working. Release announcement to follow. git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@122314 f38db490-d61c-443f-a65b-d21fe96a405b
2008-05-06Switch to using ast_random() rather than just rand().qwell1-1/+1
This does not fix the bug reported, but I believe it is correct. (from issue #12446) Patches: bug_12446.diff uploaded by snuffy (license 35) git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@115418 f38db490-d61c-443f-a65b-d21fe96a405b
2008-04-23Fix reload/unload for res_musiconhold module.qwell1-19/+38
(closes issue #11575) Reported by: sunder Patches: M11575_14_rev3.diff uploaded by junky (license 177) bug11575_trunk.diff.txt uploaded by jamesgolovich (license 176) git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@114594 f38db490-d61c-443f-a65b-d21fe96a405b
2008-04-22Trivial change to read the number of samples from a frame before calling ↵russell1-1/+1
ast_write() git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@114545 f38db490-d61c-443f-a65b-d21fe96a405b
2008-04-19MOH usage information needs a terminating newline, or elsetilghman1-3/+3
"asterisk -rx 'help moh reload'" will hang. Reported via -dev list, fixed by me. git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@114297 f38db490-d61c-443f-a65b-d21fe96a405b
2008-03-19Add sanity checking for position resuming. We *have* to make sure that the ↵file1-2/+8
position does not exceed the total number of files present, and we have to make sure that the position's filename is the same as previous. These values can change if a music class is reloaded and give unpredictable behavior. (closes issue #11663) Reported by: junky git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@110035 f38db490-d61c-443f-a65b-d21fe96a405b
2008-03-14Fix a potential segfault if chan (or chan->music_state) is NULL.qwell1-13/+16
Closes issue #12210, credit to edantie for pointing this out. git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@108682 f38db490-d61c-443f-a65b-d21fe96a405b
2007-11-06Fix init_classes() so that classes that actually do have files loaded aren'trussell1-1/+1
treated as empty, and immediately destroyed ... git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@89053 f38db490-d61c-443f-a65b-d21fe96a405b
2007-11-06If someone were to delete the files used by an existing MOH class, and thenrussell1-3/+15
issue a reload, further use of that class could result in a crash due to dividing by zero. This set of changes fixes up some places to prevent this from happening. (closes issue #10948) Reported by: jcomellas Patches: res_musiconhold_division_by_zero.patch uploaded by jcomellas (license 282) Additional changes added by me. git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@89037 f38db490-d61c-443f-a65b-d21fe96a405b
2007-10-01Fix randomness. save_pos was being set to 0 initially instead of -1, causing ↵file1-0/+1
it to jump to position 0 when moh started. (closes issue #10859) Reported by: jamesgolovich Patches: asterisk-mohpos2.diff.txt uploaded by jamesgolovich (license 176) git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@84160 f38db490-d61c-443f-a65b-d21fe96a405b
2007-08-27(closes issue #10419)russell1-5/+5
Reported by: mustardman Patches: asterisk-mohposition.diff.txt uploaded by jamesgolovich (license 176) This patch fixes a few problems with music on hold. * Fix issues with starting at the beginning of a file when it shouldn't. * Fix the inuse counter to be decremented even if the class had not been set to be deleted when not in use anymore * Don't arbitrarily limit the number of MOH files to 255 git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@81042 f38db490-d61c-443f-a65b-d21fe96a405b
2007-08-16Fix a little race condition that could cause a crash if two channels had MOHrussell1-3/+1
stopped at the same time that were using a class that had been marked for deletion when its use count hits zero. git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@79792 f38db490-d61c-443f-a65b-d21fe96a405b
2007-08-16This patch fixes a bug where reloading the module with "module reload" did notrussell1-30/+48
delete classes from memory that were no longer in the config. This patch fixes that problem as well as another one. Previously, if you reloaded MOH using the "moh reload" CLI command, which behaved differently than "module reload ...", MOH had to be stopped on every channel and started again immediately. However, there was no way to tell what class was being used, so they would all fall back to the default class. (closes issue #10139) Reported by: blitzrage Patches: asterisk-10139-advanced.diff.txt uploaded by jamesgolovich (license 176) Tested by: jamesgolovich git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@79778 f38db490-d61c-443f-a65b-d21fe96a405b
2007-07-13Merged revisions 75107 via svnmerge from russell1-2/+2
https://origsvn.digium.com/svn/asterisk/branches/1.2 ........ r75107 | russell | 2007-07-13 15:35:22 -0500 (Fri, 13 Jul 2007) | 3 lines Fix a couple potential minor memory leaks. load_moh_classes() could return without destroying the loaded configuration. ........ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@75108 f38db490-d61c-443f-a65b-d21fe96a405b
2007-07-13Merged revisions 75059 via svnmerge from russell1-0/+3
https://origsvn.digium.com/svn/asterisk/branches/1.2 ........ r75059 | russell | 2007-07-13 15:07:21 -0500 (Fri, 13 Jul 2007) | 6 lines Ensure that adding a user to the list of users of a specific music on hold class is not done at the same time as any of the other operations on this list to prevent list corruption. Using the global moh_data lock for this is not ideal, but it is what is used to protect these lists everywhere else in the module, and I am only changing what is necessary to fix the bug. ........ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@75067 f38db490-d61c-443f-a65b-d21fe96a405b
2007-07-12Merged revisions 74814 via svnmerge from file1-9/+9
https://origsvn.digium.com/svn/asterisk/branches/1.2 ........ r74814 | file | 2007-07-12 12:51:24 -0300 (Thu, 12 Jul 2007) | 2 lines Only print out a warning for situations where it is actually helpful. (issue #10187 reported by denke) ........ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@74815 f38db490-d61c-443f-a65b-d21fe96a405b
2007-07-10fix an uninitialized variablerussell1-1/+1
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@74323 f38db490-d61c-443f-a65b-d21fe96a405b
2007-07-09(closes issue #10123)russell1-16/+14
Reported by: blitzrage Patches submitted by: juggie, qwell, me Tested by: blitzrage When trying to find a music on hold class to use, try all of the options, instead of only the first one that is set. Also, change the MusicOnHold applications to not hang up on the channel when a class can not be found. git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@74162 f38db490-d61c-443f-a65b-d21fe96a405b
2007-02-01Merged revisions 53084 via svnmerge from file1-12/+13
https://origsvn.digium.com/svn/asterisk/branches/1.2 ........ r53084 | file | 2007-02-01 15:03:10 -0600 (Thu, 01 Feb 2007) | 2 lines Return previous behavior of having MOH pick up where it was left off. (issue #8672 reported by sinistermidget) ........ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@53088 f38db490-d61c-443f-a65b-d21fe96a405b
2007-01-23Merged revisions 51512 via svnmerge from file1-0/+6
https://origsvn.digium.com/svn/asterisk/branches/1.2 ........ r51512 | file | 2007-01-22 20:41:35 -0500 (Mon, 22 Jan 2007) | 2 lines Yield before reading from zaptel timing source under Solaris so that other threads get a chance to do things. (issue #7875 reported by bob) ........ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@51513 f38db490-d61c-443f-a65b-d21fe96a405b
2006-12-11Merged revisions 48374 via svnmerge from tilghman1-0/+11
https://origsvn.digium.com/svn/asterisk/branches/1.2 ........ r48374 | tilghman | 2006-12-10 18:33:59 -0600 (Sun, 10 Dec 2006) | 5 lines When doing a fork() and exec(), two problems existed (Issue 8086): 1) Ignored signals stayed ignored after the exec(). 2) Signals could possibly fire between the fork() and exec(), causing Asterisk signal handlers within the child to execute, which caused nasty race conditions. ........ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@48375 f38db490-d61c-443f-a65b-d21fe96a405b
2006-12-07Merged revisions 48356 via svnmerge from russell1-0/+1
https://origsvn.digium.com/svn/asterisk/branches/1.2 ........ r48356 | russell | 2006-12-07 13:14:13 -0500 (Thu, 07 Dec 2006) | 3 lines Ensure that the file position is not incremented beyond the total number of files available for playback. (issue #8539, ulogic) ........ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@48357 f38db490-d61c-443f-a65b-d21fe96a405b
2006-11-27Merged revisions 48045 via svnmerge from tilghman1-17/+14
https://origsvn.digium.com/svn/asterisk/branches/1.2 ........ r48045 | tilghman | 2006-11-27 11:15:54 -0600 (Mon, 27 Nov 2006) | 2 lines Random MOH wasn't really random (bug 8381) ........ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@48049 f38db490-d61c-443f-a65b-d21fe96a405b
2006-11-07Merged revisions 47238 via svnmerge from russell1-0/+2
https://origsvn.digium.com/svn/asterisk/branches/1.2 ........ r47238 | russell | 2006-11-06 20:22:58 -0500 (Mon, 06 Nov 2006) | 5 lines If random order is enabled for files mode music on hold, set a random initial position, instead of always starting at the first file, and doing the random operation only when switching to the next file. (bug reported by John Lange on the asterisk-dev mailing list) ........ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@47239 f38db490-d61c-443f-a65b-d21fe96a405b
2006-11-02Reverse change of "show" to "list" and make several other commands more ↵tilghman1-2/+2
consistent with "category verb arguments" git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@47051 f38db490-d61c-443f-a65b-d21fe96a405b
2006-11-02Merged revisions 46964 via svnmerge from russell1-0/+4
https://origsvn.digium.com/svn/asterisk/branches/1.2 ........ r46964 | russell | 2006-11-02 12:47:56 -0500 (Thu, 02 Nov 2006) | 3 lines ignore files in a music on hold directory that begin with '.' (issue #8249, cboie) ........ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@46965 f38db490-d61c-443f-a65b-d21fe96a405b
2006-10-27We should always be using _exit() after a fork() or vfork() instead of exit().russell1-1/+1
This is because exit() does some extra cleanup which in some implementations of vfork(), for example, can actually modify the state of the parent process, causing very weird bugs or crashes. (issue #7971, Nick Gavrikov) git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@46363 f38db490-d61c-443f-a65b-d21fe96a405b