Skip to content

Commit

Permalink
merged last changes with ts3plugin before release.
Browse files Browse the repository at this point in the history
  • Loading branch information
tekert committed Dec 11, 2014
1 parent ad5aade commit b4a1218
Show file tree
Hide file tree
Showing 12 changed files with 297 additions and 176 deletions.
303 changes: 176 additions & 127 deletions VolumeOptions_TS3Plugin/src/audiomonitor_wasapi.cpp

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions VolumeOptions_TS3Plugin/src/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,12 @@ const char* ts3plugin_author() {
/* Plugin description */
const char* ts3plugin_description() {
/* If you want to use wchar_t, see ts3plugin_name() on how to use */
return "Lower volume of other audio sessions while someone talks.\n"
return "Changes volume of other audio sessions while someone talks.\n"
"Configurable filter settings, per client, channel or audio session.\n"
"Maintains user audio sessions volume level on restore.\n"
"Keeps user default audio volume on restore.\n"
"\n"
"Currently in beta testing, Endpoint device selection comming in the future.\n"
"A linux version too.\n"
"\n"
"Open Source: https://github.com/tekert/VolumeOptions\n";
}
Expand Down
38 changes: 35 additions & 3 deletions VolumeOptions_TS3Plugin/src/vo_gui.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,32 @@
/*
Copyright (c) 2014, Paul Dolcet
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of VolumeOptions nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifdef _WIN32

Expand All @@ -7,7 +36,6 @@
#include <windows.h>
#include <minmax.h> // for max
#include <commctrl.h>
#include <tchar.h>
#include "../resources/gui_resource.h"

#include <string>
Expand All @@ -22,7 +50,7 @@ processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
// 0 for modal, 1 for modeless.
#define VO_MODELESS_DIALOG_GUI 1

// Saved opened HWND windows, to easily close them
// To sabe current GUI threads, so we can abort them easily.
struct DialogID
{
HWND hDlg;
Expand Down Expand Up @@ -51,6 +79,7 @@ void DestroyAllOpenedDialogs()
g_opened_hwnds.clear();
}


// 3 ways to get current process module load base address. HINSTANCE HMODULE POINTER
HMODULE GetCurrentModule()
{
Expand All @@ -76,7 +105,8 @@ EXTERN_C IMAGE_DOS_HEADER __ImageBase;
#define HINST_THISCOMPONENT ((HINSTANCE)&__ImageBase)
#endif

// Helper class to control activation context

// Helper class to control activation context on modules
// http://msdn.microsoft.com/en-us/library/aa375197.aspx
class CActivationContext
{
Expand Down Expand Up @@ -156,6 +186,7 @@ void InitIsolationAware(HINSTANCE hInst)
// activation context on component (dll, module, etc) unload.
}


// Description:
// Creates a tooltip for an item in a dialog box.
// tuned for volumeoptions config dialog.
Expand Down Expand Up @@ -249,6 +280,7 @@ BOOL CenterWindow(HWND hwndWindow)
return FALSE;
}


/*
Sets tooltip descriptions for volumeoptions config dialog
*/
Expand Down
11 changes: 6 additions & 5 deletions VolumeOptions_TS3Plugin/src/vo_ts3plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ VolumeOptions::VolumeOptions(const vo::volume_options_settings& settings)
{
m_vo_settings = settings;
// nothing to parse from here, audiomonitor settings will be parsed when set.

m_paudio_monitor->SetSettings(m_vo_settings.monitor_settings);
}

/*
Expand All @@ -86,8 +88,6 @@ VolumeOptions::VolumeOptions()
// Create the audio monitor and send settings to parse, it will return parsed settings.
if (!m_paudio_monitor)
m_paudio_monitor = AudioMonitor::create();

m_paudio_monitor->SetSettings(m_vo_settings.monitor_settings);
}

VolumeOptions::~VolumeOptions()
Expand All @@ -113,8 +113,9 @@ void VolumeOptions::set_config_file(const std::string &configFile)
}

/*
Tries to open configFile and set settings
it will create and/or update the file if some options are missing.
Tries to open configFile and set settings.
It will create and/or update the file if some options are missing.
*/
int VolumeOptions::set_settings_from_file(const std::string &configFile, bool create_if_notfound)
{
Expand Down Expand Up @@ -351,7 +352,7 @@ volume_options_settings VolumeOptions::parse_ptree(boost::property_tree::ptree&
std::string included_pid_list, def_included_pid_list;
std::string excluded_pid_list, def_excluded_pid_list;

// Convert sets to list of strings separated by ; to use them in case of missing ptree value.
// Convert set to list of strings separated by ; to use them in case of missing ptree value.
parse_set(def_mon_settings.included_process, def_included_process_list);
parse_set(def_mon_settings.excluded_process, def_excluded_process_list);
parse_set(def_mon_settings.included_pids, def_included_pid_list);
Expand Down
21 changes: 13 additions & 8 deletions VolumeOptions_TS3Plugin/volumeoptions/audiomonitor_wasapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,30 +117,34 @@ class AudioSession : public std::enable_shared_from_this < AudioSession >
AudioSession(IAudioSessionControl *pSessionControl,
const std::weak_ptr<AudioMonitor>& spAudioMonitor, float default_volume_fix = -1.0f);

void ShutdownSession();

void InitEvents();
void StopEvents();

void state_changed_callback_handler(AudioSessionState newstatus);

float GetCurrentVolume() const;
HRESULT ApplyVolumeSettings(); // TODO: or make it public with async and bool restore_vol optional merging restorevolume

float GetCurrentVolume() const;
void UpdateDefaultVolume(const float new_def);

enum class resume_t { NORMAL = false, NO_DELAY = true };
HRESULT RestoreVolume(resume_t callback_type = resume_t::NORMAL);
void RestoreVolume(resume_t callback_type = resume_t::NORMAL);
void RestoreHolderCallback(boost::system::error_code const& e = boost::system::error_code());

void ChangeVolume(const float v);

void touch(); // sets m_last_modified_on now().
void set_state(AudioSessionState state);

AudioSessionState m_current_state;
AudioSessionState m_current_state; // auto updated with session events.

float m_default_volume; // always marks user default volume of this SID group session
bool m_is_volume_at_default; // if true, session volume is at user default volume

bool m_excluded_flag;
bool m_excluded_flag; // true if this session is temporarily exluded for volume change.
bool m_session_dead; // only true when all internal wasapi references all released with ShutdownSession().

DWORD m_pid;
std::wstring m_sid;
Expand Down Expand Up @@ -176,8 +180,8 @@ class AudioSession : public std::enable_shared_from_this < AudioSession >
class AudioMonitor : public std::enable_shared_from_this < AudioMonitor >
{
public:
/* Created with STOPPED status */

/* Created with STOPPED status */
// static std::shared_ptr<AudioMonitor> create(vo::monitor_settings&& settings,
//const std::wstring& device_id = L"") // if no variadic template support
template<typename ...T>
Expand All @@ -189,7 +193,7 @@ class AudioMonitor : public std::enable_shared_from_this < AudioMonitor >
AudioMonitor& operator= (const AudioMonitor&) = delete; // non copyassignable
~AudioMonitor();

/* audio_endpoints: returns a DeviceID -> DeviceName map with current audio rendering devices */
// audio_endpoints: returns a DeviceID -> DeviceName map with current audio rendering devices
static HRESULT GetEndpointsInfo(std::map<std::wstring, std::wstring>& audio_endpoints,
DWORD dwStateMask = DEVICE_STATE_ACTIVE);
static std::set<std::wstring> GetCurrentMonitoredEndpoints();
Expand All @@ -202,7 +206,7 @@ class AudioMonitor : public std::enable_shared_from_this < AudioMonitor >

/* If Resume is used while Stopped it will use Start() */
long Stop(); // Stops all events and deletes all saved sessions restoring default state.
long Pause(); // Restores volume on all sessions and freezes volume change.
long Pause(); // Restores volume on all sessions and locks volume change.
long Start(); // Resumes/Starts volume change and reapplies saved settings.
#ifdef _DEBUG
long Refresh(); // DEBUG Gets all current sessions in SndVol
Expand Down Expand Up @@ -255,7 +259,8 @@ class AudioMonitor : public std::enable_shared_from_this < AudioMonitor >
// Main sessions container type

// Used to delay or cancel all volume restores session_this_pointer -> timer
std::unordered_map<const AudioSession*, std::unique_ptr<boost::asio::steady_timer>> m_pending_restores; //TODO: try to merge it with saved_sessions, new container or class
typedef std::unordered_map<const AudioSession*, std::unique_ptr<boost::asio::steady_timer>> t_pending_restores;
t_pending_restores m_pending_restores;

bool m_auto_change_volume_flag; // SELFNOTE: we can delete this and use m_current_status, either way..
//monitor_status_t m_current_status;
Expand Down
16 changes: 8 additions & 8 deletions VolumeOptions_TS3Plugin/volumeoptions/utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of VolumeOptions nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
* Neither the name of VolumeOptions nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Expand Down
18 changes: 9 additions & 9 deletions VolumeOptions_TS3Plugin/volumeoptions/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@ Customized by Paul Dolcet.
//for now i use a incremental number from tool verbuild.

// START verbuild generated numbers
#define VERSION_FULL 0.9.340.36
#define VERSION_FULL 0.9.344.37

#define VERSION_DATE "2014-12-07"
#define VERSION_TIME "21:58:29"
#define VERSION_DATE "2014-12-11"
#define VERSION_TIME "17:46:01"
#define VERSION_BASEYEAR 2014

#define VERSION_MAJOR 0
#define VERSION_MINOR 9
#define VERSION_BUILDNO 340
#define VERSION_EXTEND 36
#define VERSION_BUILDNO 344
#define VERSION_EXTEND 37

#define VERSION_FILE 0,9,340,36
#define VERSION_PRODUCT 0,9,340,36
#define VERSION_FILESTR "0,9,340,36"
#define VERSION_PRODUCTSTR "0,9,340,36"
#define VERSION_FILE 0,9,344,37
#define VERSION_PRODUCT 0,9,344,37
#define VERSION_FILESTR "0,9,344,37"
#define VERSION_PRODUCTSTR "0,9,344,37"
// END verbuild generation


Expand Down
36 changes: 34 additions & 2 deletions VolumeOptions_TS3Plugin/volumeoptions/vo_gui.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,48 @@
/*
Copyright (c) 2014, Paul Dolcet
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of VolumeOptions nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef WINDOWS_PLUGIN_GUI_H
#define WINDOWS_PLUGIN_GUI_H

#include "../volumeoptions/vo_ts3plugin.h"

// parent can be null
// Opens a modeless dialog box on current thread.
int DialogThread(vo::VolumeOptions* vo, void* parent = nullptr);

// Signals all GUI threads to cancel message processing and return.
void DestroyAllOpenedDialogs();


// DEBUG
#ifdef _DEBUG
int DialogThread2();
#endif


#endif
6 changes: 3 additions & 3 deletions VolumeOptions_TS3Plugin/volumeoptions/vo_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

namespace vo {

// SndVol Library individual Session settings
// SndVol Library Session settings
struct session_settings
{
session_settings()
Expand All @@ -53,12 +53,12 @@ struct session_settings
// Session settings
bool change_only_active_sessions;
bool treat_vol_as_percentage;
float vol_reduction; // 0.0 to 1.0
float vol_reduction;
std::chrono::milliseconds vol_up_delay; // delay to restore default volume.
};


// SndVol Library configurable settings
// SndVol Library settings
struct monitor_settings
{
monitor_settings()
Expand Down
4 changes: 2 additions & 2 deletions VolumeOptions_test/src/vo_ts3plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ VolumeOptions::VolumeOptions(const vo::volume_options_settings& settings)
{
m_vo_settings = settings;
// nothing to parse from here, audiomonitor settings will be parsed when set.

m_paudio_monitor->SetSettings(m_vo_settings.monitor_settings);
}

/*
Expand All @@ -86,8 +88,6 @@ VolumeOptions::VolumeOptions()
// Create the audio monitor and send settings to parse, it will return parsed settings.
if (!m_paudio_monitor)
m_paudio_monitor = AudioMonitor::create();

m_paudio_monitor->SetSettings(m_vo_settings.monitor_settings);
}

VolumeOptions::~VolumeOptions()
Expand Down
Loading

0 comments on commit b4a1218

Please sign in to comment.