dockapps/AlsaMixer.app/AMixer/AItem.cc

92 lines
2.2 KiB
C++
Raw Normal View History

Clarify project copyright and license, use SPDX Changes/additions in AlsaMixer.app over Mixer.app were lacking a copyright information and and license specifications. Add the missing bits, using a SPDX-License-Identifier. Documentation for the change follows. --------------------------------------------------- From petr.hlavka@avast.com Wed May 2 10:57:44 2018 Delivery-date: Wed, 02 May 2018 08:57:44 +0000 Received: from muffat.debian.org ([209.87.16.33]) by vsrv21575.customer.vlinux.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.91) (envelope-from <petr.hlavka@avast.com>) id 1fDna2-0005LT-O4 for ametzler@bebt.de; Wed, 02 May 2018 08:57:44 +0000 Received: from mail-qk0-x235.google.com ([2607:f8b0:400d:c09::235]) by muffat.debian.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from <petr.hlavka@avast.com>) id 1fDna0-0001VT-VK for ametzler@bebt.de; Wed, 02 May 2018 08:57:41 +0000 Received: by mail-qk0-x235.google.com with SMTP id c70so10628010qkg.0 for <ametzler@debian.org>; Wed, 02 May 2018 01:57:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=avast.com; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=todeyYOMQgF5NFi+g8Ch3ff7DLqVyjdpO1jnkiSCnwQ=; b=dTOhJ1+p5j29A0wiZExWtmDgNHdAYz4TBYldVuTScFHsdG2sEnQQJ0jhLcdJBZWtB/ f9zbg70xN2O++EiXmWzHO///LWZQVvmqxRfWe9e9NinQiftLvebLt0qhNDqGurm0XGuR ElxIv7xaik7A76zuy4RiWLBQPJImsdbkj8w8o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=todeyYOMQgF5NFi+g8Ch3ff7DLqVyjdpO1jnkiSCnwQ=; b=QruIZh5tAR6Ob3A5x4497372oBuHE3qBVI4pMDCb11By/sgVj7VWrzFcEzBKa+sZak J5y4nddBXL7usk4ULNYROXWym6dbjgcqqCX7nEdIQvze9FW7+bM/JMR+a69dxP2MFmVr v2P9F0xCyiU8MLXlvMQqgwmTPuyNAQgHledmWGWFzBjbKgJb7LDwM7Hs3aU7fTyRJm+1 Ue4obJVABrLq398pXAlqupNDMb4F4Ss6/HcBxKhFKugxv5dRNCJFB0VPWl+/L/8qA6Dm 1rUSVtcpoLdD1Tv+wZY9+rnzR4WVj/u/0JPhWIiH4UK4oeq0cLLEiUlVx3z5ZW4/xnlb cmmw== X-Gm-Message-State: ALQs6tCW+VHY1vjrOxqi926/NtpVquOr/uyKzag66grdOQjv2d3QOHcx ITgzzFb/gW/K1WQYcwUDIpKXhav0rQUGhXagXfLCYjezYz8= X-Google-Smtp-Source: AB8JxZrk2YDpWABvmBchDvRP6pMGHcJOS47obZEdkq/pZa72T3z10UOShV65Z5FzTjgF7CmqxSk2hmMpKTIzLbef3mA= X-Received: by 10.55.120.68 with SMTP id t65mr15084912qkc.56.1525251456867; Wed, 02 May 2018 01:57:36 -0700 (PDT) MIME-Version: 1.0 Received: by 10.12.152.219 with HTTP; Wed, 2 May 2018 01:57:36 -0700 (PDT) In-Reply-To: <20180430125042.GA1331@argenau.bebt.de> References: <20180430125042.GA1331@argenau.bebt.de> From: =?UTF-8?Q?Hl=C3=A1vka=2C_Petr?= <petr.hlavka@avast.com> Date: Wed, 2 May 2018 10:57:36 +0200 Message-ID: <CACiAdzoA3hsfNG_5Xm-2wYJyZaEYH=xhK=8BrUq5YWVZRYncDg@mail.gmail.com> Subject: Re: AlsaMixer.app - license? To: Andreas Metzler <ametzler@debian.org> Content-Type: multipart/alternative; boundary="94eb2c0a95da487efd056b354749" Status: RO X-Status: A Content-Length: 3528 --94eb2c0a95da487efd056b354749 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hello Andreas, yes, I'm the author of modification to original Mixer.app (AlsaMixer.app). They should be licensed under the same license as Mixer.app, some info is available in http://repo.or.cz/dockapps.git/blob_plain/HEAD:/AlsaMixer.app/README , section Copyright. Regards, Petr Hlavka. On Mon, Apr 30, 2018 at 2:50 PM, Andreas Metzler <ametzler@debian.org> wrote: > Dear Mr Hl=C3=A1vka, > > I guess that you are the original author of AlsaMixer.app > <https://www.dockapps.net/alsamixerapp>. If that is not case I am > sorry for bothering you unnecessaly but would appreciate if you told > me. - Thanks in advance > > On the other hand if you are the author it would be helpful if you could > clarify the question of licensing. AlsaMixer.app is based on Mixer.app > which is licensed under GNU General Public License version 2 or later. > The modifications and additions for AlsaMixer.app only a carry a > copyright info but no licensing info: > > Copyright > -------------------------------------------------------------- > AlsaMixer.app, 2004, Petr Hlavka > [...] > // AChannel.cc, Petr Hlavka, 2004 > > I guess that your contributions are also available under GPL v2 or > later. Could you confirm this? > > Thanks in advance, kind Regards > > Andreas Metzler > --94eb2c0a95da487efd056b354749 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">Hello Andreas,<div><br></div><div>yes, I&#39;m the author = of modification to original Mixer.app (AlsaMixer.app). They should be licen= sed under the same license as Mixer.app, some info is available in=C2=A0<a = href=3D"http://repo.or.cz/dockapps.git/blob_plain/HEAD:/AlsaMixer.app/READM= E">http://repo.or.cz/dockapps.git/blob_plain/HEAD:/AlsaMixer.app/README</a>= , section Copyright.</div><div><br></div><div>=C2=A0 Regards, Petr Hlavka.= </div></div><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">On Mo= n, Apr 30, 2018 at 2:50 PM, Andreas Metzler <span dir=3D"ltr">&lt;<a href= =3D"mailto:ametzler@debian.org" target=3D"_blank">ametzler@debian.org</a>&g= t;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0= .8ex;border-left:1px #ccc solid;padding-left:1ex">Dear Mr Hl=C3=A1vka,<br> <br> I guess that you are the original author of AlsaMixer.app<br> &lt;<a href=3D"https://www.dockapps.net/alsamixerapp" rel=3D"noreferrer" ta= rget=3D"_blank">https://www.dockapps.net/<wbr>alsamixerapp</a>&gt;. If that= is not case I am <br> sorry for bothering you unnecessaly but would appreciate if you told<br> me. - Thanks in advance<br> <br> On the other hand if you are the author it would be helpful if you could<br= > clarify the question of licensing. AlsaMixer.app is based on Mixer.app<br> which is licensed under GNU General Public License version 2 or later.<br> The modifications and additions for AlsaMixer.app only a carry a<br> copyright info but no licensing info:<br> <br> Copyright<br> ------------------------------<wbr>------------------------------<wbr>--<br= > AlsaMixer.app, 2004, Petr Hlavka<br> [...]<br> // AChannel.cc, Petr Hlavka, 2004<br> <br> I guess that your contributions are also available under GPL v2 or<br> later. Could you confirm this?<br> <br> Thanks in advance, kind Regards<br> <span class=3D"HOEnZb"><font color=3D"#888888"><br> Andreas Metzler<br> </font></span></blockquote></div><br></div>
2018-05-10 10:35:57 +00:00
// AItem.cc
//
// Copyright (C) 2004, Petr Hlavka
//
// SPDX-License-Identifier: GPL-2.0+
#include "AItem.h"
#include "AMixer.h"
#include <alsa/asoundlib.h>
#include <vector>
#define ROUND_POS(x) (long ((long (x) + 0.5 > (x)) ? (x) : (x) + 1))
// load only playback channels, don't care about common items
AItem::AItem(AMixer *m, snd_mixer_elem_t *e) {
mixer = m;
aElem = e;
name = snd_mixer_selem_get_name(aElem);
hPVolume = snd_mixer_selem_has_playback_volume(aElem);
hPSwitch = snd_mixer_selem_has_playback_switch(aElem);
if (hPVolume)
snd_mixer_selem_get_playback_volume_range(aElem, &minPVolume, &maxPVolume);
else
minPVolume = maxPVolume = 0;
for (int channel = 0; channel <= (int) SND_MIXER_SCHN_LAST; channel++) {
if (snd_mixer_selem_has_playback_channel(aElem, (SNDCHID_T) channel)) {
AChannel *ch = new AChannel(this, (SNDCHID_T) channel);
pbChannels.push_back(ch);
}
}
}
AItem::~AItem() {
for (unsigned int i = 0; i < pbChannels.size(); i++)
delete pbChannels[i];
}
// set same volume for all channels in this item in percent
void AItem::setVolumePerc(unsigned int percent) {
if (percent > 100)
percent = 100;
snd_mixer_selem_set_playback_volume_all(aElem, (long) ROUND_POS((minPVolume + (maxPVolume - minPVolume) * percent / 100.0)));
}
// get max channel volume of all channels in this item in percent
unsigned int AItem::getVolumePerc() {
long max_vol = 0, act_vol;
// find the max volume
for (unsigned int i = 0; i < pbChannels.size(); i++)
if ((act_vol = pbChannels[i]->getVolume()) > max_vol)
max_vol = act_vol;
// convert it into percent
if (minPVolume != maxPVolume)
return ((unsigned int) ROUND_POS((max_vol - minPVolume) * 100.0 / (maxPVolume - minPVolume)));
else
return (0);
}
// in this app side of view, item is muted if all channels is muted
bool AItem::isMuted() {
for (unsigned int i = 0; i < pbChannels.size(); i++)
if (!pbChannels[i]->isMuted())
return (false);
return (true);
}
// mute all channels
void AItem::mute() {
snd_mixer_selem_set_playback_switch_all(aElem, false);
}
// unmute all channels
void AItem::unmute() {
snd_mixer_selem_set_playback_switch_all(aElem, true);
}