mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 12:16:00 +00:00
Merged revisions 297821 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8 ................ r297821 | tilghman | 2010-12-07 16:51:05 -0600 (Tue, 07 Dec 2010) | 18 lines Merged revisions 297819 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.6.2 ................ r297819 | tilghman | 2010-12-07 16:40:45 -0600 (Tue, 07 Dec 2010) | 11 lines Merged revisions 297818 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r297818 | tilghman | 2010-12-07 16:35:50 -0600 (Tue, 07 Dec 2010) | 4 lines Use non-deprecated APIs for CoreAudio Review: https://reviewboard.asterisk.org/r/1040/ ........ ................ ................ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@297822 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
13
Makefile
13
Makefile
@@ -801,8 +801,17 @@ config:
|
|||||||
cat contrib/init.d/rc.archlinux.asterisk | sed 's|__ASTERISK_ETC_DIR__|$(ASTETCDIR)|;s|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > contrib/init.d/rc.asterisk.tmp ; \
|
cat contrib/init.d/rc.archlinux.asterisk | sed 's|__ASTERISK_ETC_DIR__|$(ASTETCDIR)|;s|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > contrib/init.d/rc.asterisk.tmp ; \
|
||||||
$(INSTALL) -m 755 contrib/init.d/rc.asterisk.tmp $(DESTDIR)/etc/rc.d/asterisk ; \
|
$(INSTALL) -m 755 contrib/init.d/rc.asterisk.tmp $(DESTDIR)/etc/rc.d/asterisk ; \
|
||||||
rm -f contrib/init.d/rc.asterisk.tmp ; \
|
rm -f contrib/init.d/rc.asterisk.tmp ; \
|
||||||
elif [ -d $(DESTDIR)/Library/LaunchDaemons -a ! -f $(DESTDIR)/Library/LaunchDaemons/org.asterisk.asterisk.plist ] ; then \
|
elif [ -d $(DESTDIR)/Library/LaunchDaemons ]; then \
|
||||||
$(INSTALL) -m 644 contrib/init.d/org.asterisk.asterisk.plist $(DESTDIR)/Library/LaunchDaemons/org.asterisk.asterisk.plist; \
|
if [ ! -f $(DESTDIR)/Library/LaunchDaemons/org.asterisk.asterisk.plist ]; then \
|
||||||
|
sed 's|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;' < contrib/init.d/org.asterisk.asterisk.plist > asterisk.plist ; \
|
||||||
|
$(INSTALL) -m 644 asterisk.plist $(DESTDIR)/Library/LaunchDaemons/org.asterisk.asterisk.plist; \
|
||||||
|
rm -f asterisk.plist; \
|
||||||
|
fi; \
|
||||||
|
if [ ! -f $(DESTDIR)/Library/LaunchDaemons/org.asterisk.muted.plist ]; then \
|
||||||
|
sed 's|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;' < contrib/init.d/org.asterisk.muted.plist > muted.plist ; \
|
||||||
|
$(INSTALL) -m 644 muted.plist $(DESTDIR)/Library/LaunchDaemons/org.asterisk.muted.plist; \
|
||||||
|
rm -f muted.plist; \
|
||||||
|
fi; \
|
||||||
elif [ -f /etc/slackware-version ]; then \
|
elif [ -f /etc/slackware-version ]; then \
|
||||||
echo "Slackware is not currently supported, although an init script does exist for it."; \
|
echo "Slackware is not currently supported, although an init script does exist for it."; \
|
||||||
else \
|
else \
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
<plist version="1.0">
|
<plist version="1.0">
|
||||||
<dict>
|
<dict>
|
||||||
<key>Label</key>
|
<key>Label</key>
|
||||||
<string>org.asterisk.asterisk.launchagent</string>
|
<string>org.asterisk.asterisk</string>
|
||||||
<key>Disabled</key>
|
<key>Disabled</key>
|
||||||
<false/><!-- Change this to '<true/>' to disable Asterisk -->
|
<false/><!-- Change this to '<true/>' to disable Asterisk -->
|
||||||
<key>UserName</key>
|
<key>UserName</key>
|
||||||
@@ -19,10 +19,10 @@
|
|||||||
<key>Umask</key>
|
<key>Umask</key>
|
||||||
<integer>7</integer><!-- 0007 -->
|
<integer>7</integer><!-- 0007 -->
|
||||||
<key>Program</key>
|
<key>Program</key>
|
||||||
<string>/usr/local/sbin/asterisk</string>
|
<string>__ASTERISK_SBIN_DIR__/asterisk</string>
|
||||||
<key>ProgramArguments</key>
|
<key>ProgramArguments</key>
|
||||||
<array>
|
<array>
|
||||||
<string>/usr/local/sbin/asterisk</string>
|
<string>__ASTERISK_SBIN_DIR__/asterisk</string>
|
||||||
<string>-f</string><!-- Don't fork. This option is mandatory when running with launchd. -->
|
<string>-f</string><!-- Don't fork. This option is mandatory when running with launchd. -->
|
||||||
</array>
|
</array>
|
||||||
<key>EnvironmentVariables</key>
|
<key>EnvironmentVariables</key>
|
||||||
|
33
contrib/init.d/org.asterisk.muted.plist
Normal file
33
contrib/init.d/org.asterisk.muted.plist
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>Label</key>
|
||||||
|
<string>org.asterisk.muted</string>
|
||||||
|
<key>Disabled</key>
|
||||||
|
<true/>
|
||||||
|
<key>UserName</key>
|
||||||
|
<string>asterisk</string>
|
||||||
|
<key>GroupName</key>
|
||||||
|
<string>asterisk</string>
|
||||||
|
<key>KeepAlive</key>
|
||||||
|
<true/>
|
||||||
|
<key>RunAtLoad</key>
|
||||||
|
<true/>
|
||||||
|
<key>Umask</key>
|
||||||
|
<integer>7</integer><!-- 0007 -->
|
||||||
|
<key>Program</key>
|
||||||
|
<string>__ASTERISK_SBIN_DIR__/muted</string>
|
||||||
|
<key>ProgramArguments</key>
|
||||||
|
<array>
|
||||||
|
<string>__ASTERISK_SBIN_DIR__/muted</string>
|
||||||
|
<string>-f</string>
|
||||||
|
</array>
|
||||||
|
<key>StandardInPath</key>
|
||||||
|
<string>/dev/null</string>
|
||||||
|
<key>StandardOutPath</key>
|
||||||
|
<string>/dev/null</string>
|
||||||
|
<key>StandardErrorPath</key>
|
||||||
|
<string>/dev/null</string>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
@@ -39,6 +39,9 @@
|
|||||||
|
|
||||||
#ifdef __Darwin__
|
#ifdef __Darwin__
|
||||||
#include <CoreAudio/AudioHardware.h>
|
#include <CoreAudio/AudioHardware.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <pwd.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
#elif defined(__linux__) || defined(__FreeBSD__) || defined(__GLIBC__)
|
#elif defined(__linux__) || defined(__FreeBSD__) || defined(__GLIBC__)
|
||||||
#include <sys/soundcard.h>
|
#include <sys/soundcard.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -54,7 +57,9 @@
|
|||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
|
||||||
static char *config = "/etc/muted.conf";
|
#define ast_strlen_zero(a) (!(*(a)))
|
||||||
|
|
||||||
|
static char *config = "/etc/asterisk/muted.conf";
|
||||||
|
|
||||||
static char host[256] = "";
|
static char host[256] = "";
|
||||||
static char user[256] = "";
|
static char user[256] = "";
|
||||||
@@ -349,17 +354,25 @@ static float getvol(void)
|
|||||||
AudioDeviceID device;
|
AudioDeviceID device;
|
||||||
UInt32 size;
|
UInt32 size;
|
||||||
UInt32 channels[2];
|
UInt32 channels[2];
|
||||||
|
AudioObjectPropertyAddress OutputAddr = { kAudioHardwarePropertyDefaultOutputDevice, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
|
||||||
|
AudioObjectPropertyAddress ChannelAddr = { kAudioDevicePropertyPreferredChannelsForStereo, kAudioDevicePropertyScopeOutput, kAudioObjectPropertyElementWildcard };
|
||||||
|
AudioObjectPropertyAddress VolumeAddr = { kAudioDevicePropertyVolumeScalar, kAudioDevicePropertyScopeOutput, };
|
||||||
|
|
||||||
size = sizeof(device);
|
size = sizeof(device);
|
||||||
err = AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOutputDevice, &size, &device);
|
err = AudioObjectGetPropertyData(kAudioObjectSystemObject, &OutputAddr, 0, NULL, &size, &device);
|
||||||
size = sizeof(channels);
|
size = sizeof(channels);
|
||||||
if (!err)
|
if (!err) {
|
||||||
err = AudioDeviceGetProperty(device, 0, false, kAudioDevicePropertyPreferredChannelsForStereo, &size, &channels);
|
err = AudioObjectGetPropertyData(device, &ChannelAddr, 0, NULL, &size, &channels);
|
||||||
|
}
|
||||||
size = sizeof(vol);
|
size = sizeof(vol);
|
||||||
if (!err)
|
if (!err) {
|
||||||
err = AudioDeviceGetProperty(device, channels[0], false, kAudioDevicePropertyVolumeScalar, &size, &volumeL);
|
VolumeAddr.mElement = channels[0];
|
||||||
if (!err)
|
err = AudioObjectGetPropertyData(device, &VolumeAddr, 0, NULL, &size, &volumeL);
|
||||||
err = AudioDeviceGetProperty(device, channels[1], false, kAudioDevicePropertyVolumeScalar, &size, &volumeR);
|
}
|
||||||
|
if (!err) {
|
||||||
|
VolumeAddr.mElement = channels[1];
|
||||||
|
err = AudioObjectGetPropertyData(device, &VolumeAddr, 0, NULL, &size, &volumeR);
|
||||||
|
}
|
||||||
if (!err)
|
if (!err)
|
||||||
vol = (volumeL < volumeR) ? volumeR : volumeL;
|
vol = (volumeL < volumeR) ? volumeR : volumeL;
|
||||||
else {
|
else {
|
||||||
@@ -385,16 +398,23 @@ static int setvol(float vol)
|
|||||||
AudioDeviceID device;
|
AudioDeviceID device;
|
||||||
UInt32 size;
|
UInt32 size;
|
||||||
UInt32 channels[2];
|
UInt32 channels[2];
|
||||||
|
AudioObjectPropertyAddress OutputAddr = { kAudioHardwarePropertyDefaultOutputDevice, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
|
||||||
|
AudioObjectPropertyAddress ChannelAddr = { kAudioDevicePropertyPreferredChannelsForStereo, kAudioDevicePropertyScopeOutput, kAudioObjectPropertyElementWildcard };
|
||||||
|
AudioObjectPropertyAddress VolumeAddr = { kAudioDevicePropertyVolumeScalar, kAudioDevicePropertyScopeOutput, };
|
||||||
|
|
||||||
size = sizeof(device);
|
size = sizeof(device);
|
||||||
err = AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOutputDevice, &size, &device);
|
err = AudioObjectGetPropertyData(kAudioObjectSystemObject, &OutputAddr, 0, NULL, &size, &device);
|
||||||
size = sizeof(channels);
|
size = sizeof(channels);
|
||||||
err = AudioDeviceGetProperty(device, 0, false, kAudioDevicePropertyPreferredChannelsForStereo, &size, &channels);
|
err = AudioObjectGetPropertyData(device, &ChannelAddr, 0, NULL, &size, &channels);
|
||||||
size = sizeof(vol);
|
size = sizeof(vol);
|
||||||
if (!err)
|
if (!err) {
|
||||||
err = AudioDeviceSetProperty(device, 0, channels[0], false, kAudioDevicePropertyVolumeScalar, size, &volumeL);
|
VolumeAddr.mElement = channels[0];
|
||||||
if (!err)
|
err = AudioObjectSetPropertyData(device, &VolumeAddr, 0, NULL, size, &volumeL);
|
||||||
err = AudioDeviceSetProperty(device, 0, channels[1], false, kAudioDevicePropertyVolumeScalar, size, &volumeR);
|
}
|
||||||
|
if (!err) {
|
||||||
|
VolumeAddr.mElement = channels[1];
|
||||||
|
err = AudioObjectSetPropertyData(device, &VolumeAddr, 0, NULL, size, &volumeR);
|
||||||
|
}
|
||||||
if (err) {
|
if (err) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -692,9 +712,33 @@ int main(int argc, char *argv[])
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
fprintf(stderr, "Mac OS X detected. Use 'launchd -d muted -f' to launch.\n");
|
const char *found = NULL, *paths[] = {
|
||||||
|
"/Library/LaunchAgents/org.asterisk.muted.plist",
|
||||||
|
"/Library/LaunchDaemons/org.asterisk.muted.plist",
|
||||||
|
"contrib/init.d/org.asterisk.muted.plist",
|
||||||
|
"<path-to-asterisk-source>/contrib/init.d/org.asterisk.muted.plist" };
|
||||||
|
char userpath[256];
|
||||||
|
struct stat unused;
|
||||||
|
struct passwd *pwd = getpwuid(getuid());
|
||||||
|
int i;
|
||||||
|
|
||||||
|
snprintf(userpath, sizeof(userpath), "%s%s", pwd->pw_dir, paths[0]);
|
||||||
|
if (!stat(userpath, &unused)) {
|
||||||
|
found = userpath;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!found) {
|
||||||
|
for (i = 0; i < 3; i++) {
|
||||||
|
if (!stat(paths[i], &unused)) {
|
||||||
|
found = paths[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stderr, "Mac OS X detected. Use 'launchctl load -w %s' to launch.\n", found ? found : paths[3]);
|
||||||
exit(1);
|
exit(1);
|
||||||
#endif
|
#endif /* !defined(HAVE_SBIN_LAUNCHD */
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
for(;;) {
|
for(;;) {
|
||||||
|
Reference in New Issue
Block a user