ekiga r6300 - in trunk: . lib/engine lib/engine/audioinput/skel lib/engine/audiooutput/null lib/engine/audiooutput/ptlib lib/engine/audiooutput/skel lib/engine/framework lib/engine/hal/dbus lib/engine/hal/skel lib/engine/videoinput/mlogo lib/engine/videoinput/ptlib lib/engine/videoinput/skel src/gui
- From: mschneid svn gnome org
- To: svn-commits-list gnome org
- Subject: ekiga r6300 - in trunk: . lib/engine lib/engine/audioinput/skel lib/engine/audiooutput/null lib/engine/audiooutput/ptlib lib/engine/audiooutput/skel lib/engine/framework lib/engine/hal/dbus lib/engine/hal/skel lib/engine/videoinput/mlogo lib/engine/videoinput/ptlib lib/engine/videoinput/skel src/gui
- Date: Wed, 21 May 2008 22:05:31 +0000 (UTC)
Author: mschneid
Date: Wed May 21 22:05:30 2008
New Revision: 6300
URL: http://svn.gnome.org/viewvc/ekiga?rev=6300&view=rev
Log:
More commenting.
Modified:
trunk/ChangeLog
trunk/lib/engine/audioinput/skel/audioinput-core.cpp
trunk/lib/engine/audioinput/skel/audioinput-core.h
trunk/lib/engine/audioinput/skel/audioinput-gmconf-bridge.cpp
trunk/lib/engine/audiooutput/null/audiooutput-manager-null.cpp
trunk/lib/engine/audiooutput/null/audiooutput-manager-null.h
trunk/lib/engine/audiooutput/ptlib/audiooutput-manager-ptlib.cpp
trunk/lib/engine/audiooutput/ptlib/audiooutput-manager-ptlib.h
trunk/lib/engine/audiooutput/skel/audiooutput-core.cpp
trunk/lib/engine/audiooutput/skel/audiooutput-core.h
trunk/lib/engine/audiooutput/skel/audiooutput-gmconf-bridge.cpp
trunk/lib/engine/audiooutput/skel/audiooutput-info.h
trunk/lib/engine/audiooutput/skel/audiooutput-manager.h
trunk/lib/engine/audiooutput/skel/audiooutput-scheduler.cpp
trunk/lib/engine/audiooutput/skel/audiooutput-scheduler.h
trunk/lib/engine/engine.cpp
trunk/lib/engine/framework/device-def.h
trunk/lib/engine/hal/dbus/hal-manager-dbus.cpp
trunk/lib/engine/hal/skel/hal-core.cpp
trunk/lib/engine/hal/skel/hal-core.h
trunk/lib/engine/hal/skel/hal-manager.h
trunk/lib/engine/videoinput/mlogo/videoinput-manager-mlogo.cpp
trunk/lib/engine/videoinput/ptlib/videoinput-manager-ptlib.cpp
trunk/lib/engine/videoinput/skel/videoinput-core.cpp
trunk/lib/engine/videoinput/skel/videoinput-core.h
trunk/lib/engine/videoinput/skel/videoinput-info.h
trunk/lib/engine/videoinput/skel/videoinput-manager.h
trunk/src/gui/assistant.cpp
trunk/src/gui/main.cpp
trunk/src/gui/preferences.cpp
Modified: trunk/lib/engine/audioinput/skel/audioinput-core.cpp
==============================================================================
--- trunk/lib/engine/audioinput/skel/audioinput-core.cpp (original)
+++ trunk/lib/engine/audioinput/skel/audioinput-core.cpp Wed May 21 22:05:30 2008
@@ -1,4 +1,4 @@
-
+//
/*
* Ekiga -- A VoIP and Video-Conferencing application
* Copyright (C) 2000-2008 Damien Sandras
@@ -43,9 +43,9 @@
using namespace Ekiga;
-AudioPreviewManager::AudioPreviewManager (AudioInputCore& _audio_input_core, AudioOutputCore& _audio_output_core)
+AudioInputCore::AudioPreviewManager::AudioPreviewManager (AudioInputCore& _audio_input_core, AudioOutputCore& _audio_output_core)
: PThread (1000, NoAutoDeleteThread, HighestPriority, "PreviewManager"),
- audio_input_core (_audio_input_core),
+ audio_input_core (_audio_input_core),
audio_output_core (_audio_output_core)
{
/* frame = NULL;
@@ -55,13 +55,13 @@
PWaitAndSignal m(quit_mutex);*/
}
-AudioPreviewManager::~AudioPreviewManager ()
+AudioInputCore::AudioPreviewManager::~AudioPreviewManager ()
{
/* if (!stop_thread)
stop();*/
}
/*
-void PreviewManager::start (unsigned width, unsigned height)
+void AudioInputCore::AudioPreviewManager::start (unsigned width, unsigned height)
{
PTRACE(0, "PreviewManager\tStarting Preview");
stop_thread = false;
@@ -72,7 +72,7 @@
thread_sync_point.Wait ();
}
-void PreviewManager::stop ()
+void AudioInputCore::AudioPreviewManager::stop ()
{
PTRACE(0, "PreviewManager\tStopping Preview");
stop_thread = true;
@@ -87,7 +87,7 @@
display_core.stop();
}
*/
-void AudioPreviewManager::Main ()
+void AudioInputCore::AudioPreviewManager::Main ()
{
/* PWaitAndSignal m(quit_mutex);
thread_sync_point.Signal ();
@@ -114,26 +114,25 @@
preview_manager(*this, _audio_output_core)
{
- PWaitAndSignal m_var(var_mutex);
- PWaitAndSignal m_vol(vol_mutex);
+ PWaitAndSignal m_var(core_mutex);
+ PWaitAndSignal m_vol(volume_mutex);
preview_config.active = false;
preview_config.channels = 0;
preview_config.samplerate = 0;
preview_config.bits_per_sample = 0;
- preview_config.volume = 0;
preview_config.buffer_size = 0;
preview_config.num_buffers = 0;
- new_preview_volume = 0;
stream_config.active = false;
stream_config.channels = 0;
stream_config.samplerate = 0;
stream_config.bits_per_sample = 0;
- stream_config.volume = 0;
stream_config.buffer_size = 0;
stream_config.num_buffers = 0;
- new_stream_volume = 0;
+
+ desired_volume = 0;
+ current_volume = 0;
current_manager = NULL;
audioinput_core_conf_bridge = NULL;
@@ -147,7 +146,7 @@
std::cout << __PRETTY_FUNCTION__ << std::endl;
#endif
- PWaitAndSignal m(var_mutex);
+ PWaitAndSignal m(core_mutex);
if (audioinput_core_conf_bridge)
delete audioinput_core_conf_bridge;
@@ -155,7 +154,7 @@
void AudioInputCore::setup_conf_bridge ()
{
- PWaitAndSignal m(var_mutex);
+ PWaitAndSignal m(core_mutex);
audioinput_core_conf_bridge = new AudioInputCoreConfBridge (*this);
}
@@ -173,7 +172,7 @@
void AudioInputCore::visit_managers (sigc::slot<bool, AudioInputManager &> visitor)
{
- PWaitAndSignal m(var_mutex);
+ PWaitAndSignal m(core_mutex);
bool go_on = true;
for (std::set<AudioInputManager *>::iterator iter = managers.begin ();
@@ -182,20 +181,20 @@
go_on = visitor (*(*iter));
}
-void AudioInputCore::get_audioinput_devices (std::vector <AudioInputDevice> & audioinput_devices)
+void AudioInputCore::get_devices (std::vector <AudioInputDevice> & devices)
{
- PWaitAndSignal m(var_mutex);
+ PWaitAndSignal m(core_mutex);
- audioinput_devices.clear();
+ devices.clear();
for (std::set<AudioInputManager *>::iterator iter = managers.begin ();
iter != managers.end ();
iter++)
- (*iter)->get_devices (audioinput_devices);
+ (*iter)->get_devices (devices);
if (PTrace::CanTrace(4)) {
- for (std::vector<AudioInputDevice>::iterator iter = audioinput_devices.begin ();
- iter != audioinput_devices.end ();
+ for (std::vector<AudioInputDevice>::iterator iter = devices.begin ();
+ iter != devices.end ();
iter++) {
PTRACE(4, "AudioInputCore\tDetected Device: " << *iter);
}
@@ -203,19 +202,62 @@
}
-void AudioInputCore::set_audioinput_device(const AudioInputDevice & audioinput_device)
+void AudioInputCore::set_device(const AudioInputDevice & device)
+{
+ PWaitAndSignal m(core_mutex);
+
+ internal_set_device(device);
+
+ desired_device = device;
+}
+
+
+void AudioInputCore::add_device (const std::string & source, const std::string & device_name, HalManager* /*manager*/)
{
- PWaitAndSignal m(var_mutex);
+ PTRACE(0, "AudioInputCore\tAdding Device " << device_name);
+ PWaitAndSignal m(core_mutex);
+
+ AudioInputDevice device;
+ for (std::set<AudioInputManager *>::iterator iter = managers.begin ();
+ iter != managers.end ();
+ iter++) {
+ if ((*iter)->has_device (source, device_name, device)) {
- internal_set_audioinput_device(audioinput_device);
+ if ( desired_device == device)
+ internal_set_device(desired_device);
- desired_device = audioinput_device;
+ runtime.run_in_main (sigc::bind (device_added.make_slot (), device));
+ }
+ }
}
+void AudioInputCore::remove_device (const std::string & source, const std::string & device_name, HalManager* /*manager*/)
+{
+ PTRACE(0, "AudioInputCore\tRemoving Device " << device_name);
+ PWaitAndSignal m(core_mutex);
+
+ AudioInputDevice device;
+ for (std::set<AudioInputManager *>::iterator iter = managers.begin ();
+ iter != managers.end ();
+ iter++) {
+ if ((*iter)->has_device (source, device_name, device)) {
+
+ if ( current_device == device) {
+
+ AudioInputDevice new_device;
+ new_device.type = AUDIO_INPUT_FALLBACK_DEVICE_TYPE;
+ new_device.source = AUDIO_INPUT_FALLBACK_DEVICE_SOURCE;
+ new_device.name = AUDIO_INPUT_FALLBACK_DEVICE_NAME;
+ internal_set_device( new_device);
+ }
+ runtime.run_in_main (sigc::bind (device_removed.make_slot (), device));
+ }
+ }
+}
void AudioInputCore::start_preview (unsigned channels, unsigned samplerate, unsigned bits_per_sample)
{
- PWaitAndSignal m(var_mutex);
+ PWaitAndSignal m(core_mutex);
PTRACE(4, "AudioInputCore\tStarting preview " << channels << "x" << samplerate << "/" << bits_per_sample);
@@ -241,7 +283,7 @@
void AudioInputCore::stop_preview ()
{
- PWaitAndSignal m(var_mutex);
+ PWaitAndSignal m(core_mutex);
PTRACE(4, "AudioInputCore\tStopping Preview");
@@ -251,14 +293,14 @@
// preview_manager.stop();
internal_close();
- internal_set_device(desired_device);
+ internal_set_manager(desired_device);
preview_config.active = false;
}
void AudioInputCore::set_stream_buffer_size (unsigned buffer_size, unsigned num_buffers)
{
- PWaitAndSignal m(var_mutex);
+ PWaitAndSignal m(core_mutex);
PTRACE(4, "AudioInputCore\tSetting stream buffer size " << num_buffers << "/" << buffer_size);
@@ -271,7 +313,7 @@
void AudioInputCore::start_stream (unsigned channels, unsigned samplerate, unsigned bits_per_sample)
{
- PWaitAndSignal m(var_mutex);
+ PWaitAndSignal m(core_mutex);
PTRACE(4, "AudioInputCore\tStarting stream " << channels << "x" << samplerate << "/" << bits_per_sample);
@@ -291,7 +333,7 @@
void AudioInputCore::stop_stream ()
{
- PWaitAndSignal m(var_mutex);
+ PWaitAndSignal m(core_mutex);
PTRACE(4, "AudioInputCore\tStopping Stream");
@@ -301,7 +343,7 @@
}
internal_close();
- internal_set_device(desired_device);
+ internal_set_manager(desired_device);
stream_config.active = false;
average_level = 0;
@@ -311,7 +353,7 @@
unsigned size,
unsigned & bytes_read)
{
- PWaitAndSignal m_var(var_mutex);
+ PWaitAndSignal m_var(core_mutex);
if (current_manager) {
if (!current_manager->get_frame_data(data, size, bytes_read)) {
@@ -321,17 +363,11 @@
if (current_manager)
current_manager->get_frame_data(data, size, bytes_read); // the default device must always return true
}
-
-
- PWaitAndSignal m_vol(vol_mutex);
- if ((preview_config.active) && (new_preview_volume != preview_config.volume)) {
- current_manager->set_volume (new_preview_volume);
- preview_config.volume = new_preview_volume;
- }
- if ((stream_config.active) && (new_stream_volume != stream_config.volume)) {
- current_manager->set_volume (new_stream_volume);
- stream_config.volume = new_stream_volume;
+ PWaitAndSignal m_vol(volume_mutex);
+ if (desired_volume != current_volume) {
+ current_manager->set_volume (desired_volume);
+ current_volume = desired_volume;
}
}
@@ -341,13 +377,9 @@
void AudioInputCore::set_volume (unsigned volume)
{
- PWaitAndSignal m(vol_mutex);
-
- if (preview_config.active)
- new_preview_volume = volume;
+ PWaitAndSignal m(volume_mutex);
- if (stream_config.active)
- new_stream_volume = volume;
+ desired_volume = volume;
}
void AudioInputCore::on_device_opened (AudioInputDevice device,
@@ -367,9 +399,9 @@
device_error.emit (*manager, device, error_code);
}
-void AudioInputCore::internal_set_audioinput_device(const AudioInputDevice & audioinput_device)
+void AudioInputCore::internal_set_device(const AudioInputDevice & device)
{
- PTRACE(4, "AudioInputCore\tSetting device: " << audioinput_device);
+ PTRACE(4, "AudioInputCore\tSetting device: " << device);
if (preview_config.active)
preview_manager.stop();
@@ -377,7 +409,7 @@
if (preview_config.active || stream_config.active)
internal_close();
- internal_set_device (audioinput_device);
+ internal_set_manager (device);
if (preview_config.active) {
internal_open(preview_config.channels, preview_config.samplerate, preview_config.bits_per_sample);
@@ -399,27 +431,13 @@
}
}
-
-void AudioInputCore::internal_open (unsigned channels, unsigned samplerate, unsigned bits_per_sample)
-{
- PTRACE(4, "AudioInputCore\tOpening device with " << channels << "-" << samplerate << "/" << bits_per_sample );
-
- if (current_manager && !current_manager->open(channels, samplerate, bits_per_sample)) {
-
- internal_set_fallback();
-
- if (current_manager)
- current_manager->open(channels, samplerate, bits_per_sample);
- }
-}
-
-void AudioInputCore::internal_set_device (const AudioInputDevice & audioinput_device)
+void AudioInputCore::internal_set_manager (const AudioInputDevice & device)
{
current_manager = NULL;
for (std::set<AudioInputManager *>::iterator iter = managers.begin ();
iter != managers.end ();
iter++) {
- if ((*iter)->set_device (audioinput_device)) {
+ if ((*iter)->set_device (device)) {
current_manager = (*iter);
}
}
@@ -428,15 +446,37 @@
// we se the default device. The default device
// MUST ALWAYS be loaded and openable
if (current_manager) {
- current_device = audioinput_device;
+ current_device = device;
}
else {
- PTRACE(1, "AudioInputCore\tTried to set unexisting device " << audioinput_device);
+ PTRACE(1, "AudioInputCore\tTried to set unexisting device " << device);
internal_set_fallback();
}
}
+void AudioInputCore::internal_set_fallback()
+{
+ current_device.type = AUDIO_INPUT_FALLBACK_DEVICE_TYPE;
+ current_device.source = AUDIO_INPUT_FALLBACK_DEVICE_SOURCE;
+ current_device.name = AUDIO_INPUT_FALLBACK_DEVICE_NAME;
+ PTRACE(1, "AudioInputCore\tFalling back to " << current_device);
+ internal_set_manager (current_device);
+}
+
+void AudioInputCore::internal_open (unsigned channels, unsigned samplerate, unsigned bits_per_sample)
+{
+ PTRACE(4, "AudioInputCore\tOpening device with " << channels << "-" << samplerate << "/" << bits_per_sample );
+
+ if (current_manager && !current_manager->open(channels, samplerate, bits_per_sample)) {
+
+ internal_set_fallback();
+
+ if (current_manager)
+ current_manager->open(channels, samplerate, bits_per_sample);
+ }
+}
+
void AudioInputCore::internal_close()
{
PTRACE(4, "AudioInputCore\tClosing current device");
@@ -461,60 +501,3 @@
average_level = log10 (9.0*sum/size/32767+1)*1.0;
}
-
-void AudioInputCore::internal_set_fallback()
-{
- current_device.type = AUDIO_INPUT_FALLBACK_DEVICE_TYPE;
- current_device.source = AUDIO_INPUT_FALLBACK_DEVICE_SOURCE;
- current_device.name = AUDIO_INPUT_FALLBACK_DEVICE_NAME;
- PTRACE(1, "AudioInputCore\tFalling back to " << current_device);
- internal_set_device (current_device);
-}
-
-void AudioInputCore::add_device (const std::string & source, const std::string & device, HalManager* /*manager*/)
-{
- PTRACE(0, "AudioInputCore\tAdding Device " << device);
- PWaitAndSignal m(var_mutex);
-
- AudioInputDevice audioinput_device;
- for (std::set<AudioInputManager *>::iterator iter = managers.begin ();
- iter != managers.end ();
- iter++) {
- if ((*iter)->has_device (source, device, audioinput_device)) {
-
- if ( ( desired_device.type == audioinput_device.type ) &&
- ( desired_device.source == audioinput_device.source ) &&
- ( desired_device.name == audioinput_device.name ) ) {
- internal_set_audioinput_device(desired_device);
- }
-
- runtime.run_in_main (sigc::bind (device_added.make_slot (), audioinput_device));
- }
- }
-}
-
-void AudioInputCore::remove_device (const std::string & source, const std::string & device, HalManager* /*manager*/)
-{
- PTRACE(0, "AudioInputCore\tRemoving Device " << device);
- PWaitAndSignal m(var_mutex);
-
- AudioInputDevice audioinput_device;
- for (std::set<AudioInputManager *>::iterator iter = managers.begin ();
- iter != managers.end ();
- iter++) {
- if ((*iter)->has_device (source, device, audioinput_device)) {
- if ( ( current_device.type == audioinput_device.type ) &&
- ( current_device.source == audioinput_device.source ) &&
- ( current_device.name == audioinput_device.name ) ) {
-
- AudioInputDevice new_audioinput_device;
- new_audioinput_device.type = AUDIO_INPUT_FALLBACK_DEVICE_TYPE;
- new_audioinput_device.source = AUDIO_INPUT_FALLBACK_DEVICE_SOURCE;
- new_audioinput_device.name = AUDIO_INPUT_FALLBACK_DEVICE_NAME;
- internal_set_audioinput_device( new_audioinput_device);
- }
-
- runtime.run_in_main (sigc::bind (device_removed.make_slot (), audioinput_device));
- }
- }
-}
Modified: trunk/lib/engine/audioinput/skel/audioinput-core.h
==============================================================================
--- trunk/lib/engine/audioinput/skel/audioinput-core.h (original)
+++ trunk/lib/engine/audioinput/skel/audioinput-core.h Wed May 21 22:05:30 2008
@@ -57,47 +57,15 @@
namespace Ekiga
{
- typedef struct AudioDeviceConfig {
- bool active;
- unsigned channels;
- unsigned samplerate;
- unsigned bits_per_sample;
- unsigned buffer_size;
- unsigned num_buffers;
- unsigned volume;
- };
-
class AudioInputManager;
class AudioInputCore;
-
- class AudioPreviewManager : public PThread
- {
- PCLASSINFO(AudioPreviewManager, PThread);
-
- public:
- AudioPreviewManager(AudioInputCore& _audio_input_core, AudioOutputCore& _audio_output_core);
- ~AudioPreviewManager();
- virtual void start(){};
- virtual void stop(){};
-
- protected:
- void Main (void);
- bool stop_thread;
- char* frame;
- PMutex quit_mutex; /* To exit */
- PSyncPoint thread_sync_point;
- AudioInputCore& audio_input_core;
- AudioOutputCore& audio_output_core;
- };
/**
- * @defgroup audioinput Audio AudioInput
+ * @defgroup audioinput
* @{
*/
-
-
- /** Core object for the audio auioinput support
+ /** Core object for the audio inputsupport
*/
class AudioInputCore
: public Service
@@ -105,16 +73,21 @@
public:
- /* The constructor
- */
+ /** The constructor
+ * @param _runtime reference to Ekiga runtime.
+ * @param _videooutput_core reference ot the audio output core.
+ */
AudioInputCore (Ekiga::Runtime & _runtime, AudioOutputCore& _audio_output_core);
- /* The destructor
+ /** The destructor
*/
~AudioInputCore ();
+ /** Set up gmconf bridge
+ */
void setup_conf_bridge();
+
/*** Service Implementation ***/
/** Returns the name of the service.
@@ -134,56 +107,150 @@
/** Adds a AudioInputManager to the AudioInputCore service.
* @param The manager to be added.
*/
- void add_manager (AudioInputManager &manager);
+ void add_manager (AudioInputManager &manager);
/** Triggers a callback for all Ekiga::AudioInputManager sources of the
* AudioInputCore service.
*/
- void visit_managers (sigc::slot<bool, AudioInputManager &> visitor);
+ void visit_managers (sigc::slot<bool, AudioInputManager &> visitor);
/** This signal is emitted when a Ekiga::AudioInputManager has been
* added to the AudioInputCore Service.
*/
- sigc::signal<void, AudioInputManager &> manager_added;
+ sigc::signal<void, AudioInputManager &> manager_added;
- void get_audioinput_devices(std::vector <AudioInputDevice> & audioinput_devices);
+ /*** AudioInput Device Management ***/
- void set_audioinput_device(const AudioInputDevice & audioinput_device);
-
- /*** VidInput Management ***/
+ /** Get a list of all devices supported by all managers registered to the core.
+ * @param devices a vector of device names to be filled by the core.
+ */
+ void get_devices(std::vector <AudioInputDevice> & devices);
+
+ /** Set a specific device
+ * This function sets the current audio input device. This function can
+ * also be used while in a stream or in preview mode. In that case the old
+ * device is closed and the new device opened automatically.
+ * @param device the new device to be used.
+ */
+ void set_device(const AudioInputDevice & device);
+ /** Inform the core of an added audioinout device
+ * This function is called by the HalCore when an audio device is added.
+ * It determines responsible managers for that specific device and informs the
+ * GUI about the device that was added (via device_added signal).
+ * In case the added device was the desired device and we fell back,
+ * we will reactivate it.
+ * @param source the device source (e.g. alsa).
+ * @param device_name the name of the added device.
+ * @param manager the HalManger detected the addition.
+ */
+ void add_device (const std::string & source, const std::string & device_name, HalManager* manager);
+
+ /** Inform the core of a removed audioinput device
+ * This function is called by the HalCore when an audio device is removed.
+ * It determines responsible managers for that specific device and informs the
+ * GUI about the device that was removed (via device_removed signal).
+ * In case the removed device was the current device we fall back to the
+ * fallback device.
+ * @param source the device source (e.g. alsa).
+ * @param device_name the name of the removed device.
+ * @param manager the HalManger detected the removal.
+ */
+ void remove_device (const std::string & source, const std::string & device_name, HalManager* manager);
+
+
+ /*** AudioInput Stream and Preview Management ***/
+
+ /** Start the preview mode
+ * Contrary to the video input core this can only be done if
+ * the streaming mode NOT active (responsability of the UI).
+ * @param channels the number of channels (1 or 2).
+ * @param samplerate the samplerate.
+ * @param bits_per_sample the number of bits per sample (e.g. 8, 16).
+ */
void start_preview (unsigned channels, unsigned samplerate, unsigned bits_per_sample);
+ /** Stop the preview mode
+ */
void stop_preview ();
+
+ /** Set the number and size of buffers for streaming mode
+ * Will be applied the next time the device is opened.
+ * @param buffer_size the size of each buffer in byte.
+ * @param num_buffers the number of buffers.
+ */
void set_stream_buffer_size (unsigned buffer_size, unsigned num_buffers);
+ /** Start the stream mode
+ * Contrary to the video input core this can only be done if
+ * preview is NOT active (responsability of the UI)
+ * @param channels the number of channels (1 or 2).
+ * @param samplerate the samplerate.
+ * @param bits_per_sample the number of bits per sample (e.g. 8, 16).
+ */
void start_stream (unsigned channels, unsigned samplerate, unsigned bits_per_sample);
+ /** Stop the stream mode
+ */
void stop_stream ();
+
+ /** Get one audio buffer from the current manager.
+ * This function will block until the buffer is completely filled.
+ * Requires the stream or the preview (when being called from the
+ * VideoPreviewManager) to be started.
+ * In case the device returns an error reading the frame, get_frame_data()
+ * falls back to the fallback device and reads the frame from there. Thus
+ * get_frame_data() always returns a frame.
+ * In case a new volume has bee set, it will be applied here.
+ * @param data a pointer to the buffer that is to be filled. The memory has to be allocated already.
+ * @param size the number of bytes to be read
+ * @param bytes_read number of bytes actually read.
+ */
void get_frame_data (char *data, unsigned size, unsigned & bytes_read);
+ /** Set the volume of the next opportunity
+ * Sets the volume to the specified value the next time
+ * get_frame_data() is called.
+ * @param volume The new volume level (0..255).
+ */
void set_volume (unsigned volume);
- void start_average_collection () { calculate_average = true; }
-
- void stop_average_collection () { calculate_average = false; }
+ /** Turn average collecion on and off
+ * The average values can be collected via get_average_level()
+ * @param on_off whether to turn the collection on or off.
+ */
+ void set_average_collection (bool on_off) { calculate_average = on_off; }
+ /** Get the average volume level
+ * Get the average volume level ove the last read buffer.
+ * @return the average volume level.
+ */
float get_average_level () { return average_level; }
- void add_device (const std::string & source, const std::string & device, HalManager* manager);
- void remove_device (const std::string & source, const std::string & device, HalManager* manager);
/*** VidInput Related Signals ***/
-
+
/** See audioinput-manager.h for the API
*/
sigc::signal<void, AudioInputManager &, AudioInputDevice &, AudioInputConfig&> device_opened;
sigc::signal<void, AudioInputManager &, AudioInputDevice &> device_closed;
sigc::signal<void, AudioInputManager &, AudioInputDevice &, AudioInputErrorCodes> device_error;
+
+ /** This signal is emitted when an audio device input has been added to the system.
+ * This signal will be emitted if add_device was called with a device name and
+ * a manager claimed support for this device.
+ * @param device the audio input device that was added.
+ */
sigc::signal<void, AudioInputDevice> device_added;
+
+ /** This signal is emitted when an audio input device has been removed from the system.
+ * This signal will be emitted if remove_device was called with a device name and
+ * a manager claimed support for this device.
+ * @param device the audio input device that was removed.
+ */
sigc::signal<void, AudioInputDevice> device_removed;
private:
@@ -193,28 +260,64 @@
void on_device_closed (AudioInputDevice device, AudioInputManager *manager);
void on_device_error (AudioInputDevice device, AudioInputErrorCodes error_code, AudioInputManager *manager);
- void internal_set_audioinput_device(const AudioInputDevice & audioinput_device);
+ void internal_set_device(const AudioInputDevice & device);
+ void internal_set_manager (const AudioInputDevice & device);
+ void internal_set_fallback();
+
void internal_open (unsigned channels, unsigned samplerate, unsigned bits_per_sample);
void internal_close();
- void internal_set_device (const AudioInputDevice & audioinput_device);
- void internal_set_fallback();
+
void calculate_average_level (const short *buffer, unsigned size);
+ private:
+
+ class AudioPreviewManager : public PThread
+ {
+ PCLASSINFO(AudioPreviewManager, PThread);
+
+ public:
+ AudioPreviewManager(AudioInputCore& _audio_input_core, AudioOutputCore& _audio_output_core);
+ ~AudioPreviewManager();
+ virtual void start(){};
+ virtual void stop(){};
+
+ protected:
+ void Main (void);
+ bool stop_thread;
+ char* frame;
+ PMutex quit_mutex; /* To exit */
+ PSyncPoint thread_sync_point;
+ AudioInputCore& audio_input_core;
+ AudioOutputCore& audio_output_core;
+ };
+
+ typedef struct DeviceConfig {
+ bool active;
+
+ unsigned channels;
+ unsigned samplerate;
+ unsigned bits_per_sample;
+
+ unsigned buffer_size;
+ unsigned num_buffers;
+ };
+
+ private:
+
Ekiga::Runtime & runtime;
-
std::set<AudioInputManager *> managers;
- AudioDeviceConfig preview_config;
- AudioDeviceConfig stream_config;
- unsigned new_preview_volume;
- unsigned new_stream_volume;
+ DeviceConfig preview_config;
+ DeviceConfig stream_config;
AudioInputManager* current_manager;
AudioInputDevice desired_device;
AudioInputDevice current_device;
+ unsigned current_volume;
+ unsigned desired_volume;
- PMutex var_mutex; /* To protect variables that are read and written */
- PMutex vol_mutex; /* To protect variables that are read and written */
+ PMutex core_mutex;
+ PMutex volume_mutex;
AudioPreviewManager preview_manager;
AudioInputCoreConfBridge* audioinput_core_conf_bridge;
Modified: trunk/lib/engine/audioinput/skel/audioinput-gmconf-bridge.cpp
==============================================================================
--- trunk/lib/engine/audioinput/skel/audioinput-gmconf-bridge.cpp (original)
+++ trunk/lib/engine/audioinput/skel/audioinput-gmconf-bridge.cpp Wed May 21 22:05:30 2008
@@ -79,7 +79,7 @@
device.name = AUDIO_INPUT_FALLBACK_DEVICE_NAME;
}
- audioinput_core.set_audioinput_device (device);
+ audioinput_core.set_device (device);
}
}
Modified: trunk/lib/engine/audiooutput/null/audiooutput-manager-null.cpp
==============================================================================
--- trunk/lib/engine/audiooutput/null/audiooutput-manager-null.cpp (original)
+++ trunk/lib/engine/audiooutput/null/audiooutput-manager-null.cpp Wed May 21 22:05:30 2008
@@ -56,59 +56,59 @@
}
-bool GMAudioOutputManager_null::set_device (Ekiga::AudioOutputPrimarySecondary primarySecondary, const Ekiga::AudioOutputDevice & device)
+bool GMAudioOutputManager_null::set_device (Ekiga::AudioOutputPS ps, const Ekiga::AudioOutputDevice & device)
{
if ( ( device.type == DEVICE_TYPE ) &&
( device.source == DEVICE_SOURCE) &&
( device.name == DEVICE_NAME) ) {
- PTRACE(4, "GMAudioOutputManager_null\tSetting Device[" << primarySecondary << "] " << device);
- current_state[primarySecondary].device = device;
+ PTRACE(4, "GMAudioOutputManager_null\tSetting Device[" << ps << "] " << device);
+ current_state[ps].device = device;
return true;
}
return false;
}
-bool GMAudioOutputManager_null::open (Ekiga::AudioOutputPrimarySecondary primarySecondary, unsigned channels, unsigned samplerate, unsigned bits_per_sample)
+bool GMAudioOutputManager_null::open (Ekiga::AudioOutputPS ps, unsigned channels, unsigned samplerate, unsigned bits_per_sample)
{
- current_state[primarySecondary].channels = channels;
- current_state[primarySecondary].samplerate = samplerate;
- current_state[primarySecondary].bits_per_sample = bits_per_sample;
- current_state[primarySecondary].opened = true;
+ current_state[ps].channels = channels;
+ current_state[ps].samplerate = samplerate;
+ current_state[ps].bits_per_sample = bits_per_sample;
+ current_state[ps].opened = true;
- PTRACE(4, "GMAudioOutputManager_null\tOpening Device[" << primarySecondary << "] " << current_state[primarySecondary].device);
+ PTRACE(4, "GMAudioOutputManager_null\tOpening Device[" << ps << "] " << current_state[ps].device);
PTRACE(4, "GMAudioOutputManager_null\tOpening Device with " << channels << "-" << samplerate << "/" << bits_per_sample);
- adaptive_delay[primarySecondary].Restart();
+ adaptive_delay[ps].Restart();
Ekiga::AudioOutputConfig config;
config.volume = 0;
config.modifyable = false;
- runtime.run_in_main (sigc::bind (device_opened.make_slot (), primarySecondary, current_state[primarySecondary].device, config));
+ runtime.run_in_main (sigc::bind (device_opened.make_slot (), ps, current_state[ps].device, config));
return true;
}
-void GMAudioOutputManager_null::close(Ekiga::AudioOutputPrimarySecondary primarySecondary)
+void GMAudioOutputManager_null::close(Ekiga::AudioOutputPS ps)
{
- current_state[primarySecondary].opened = false;
- runtime.run_in_main (sigc::bind (device_closed.make_slot (), primarySecondary, current_state[primarySecondary].device));
+ current_state[ps].opened = false;
+ runtime.run_in_main (sigc::bind (device_closed.make_slot (), ps, current_state[ps].device));
}
-bool GMAudioOutputManager_null::set_frame_data (Ekiga::AudioOutputPrimarySecondary primarySecondary,
+bool GMAudioOutputManager_null::set_frame_data (Ekiga::AudioOutputPS ps,
const char */*data*/,
unsigned size,
unsigned & bytes_written)
{
- if (!current_state[primarySecondary].opened) {
- PTRACE(1, "GMAudioOutputManager_null\tTrying to get frame from closed device[" << primarySecondary << "]");
+ if (!current_state[ps].opened) {
+ PTRACE(1, "GMAudioOutputManager_null\tTrying to get frame from closed device[" << ps << "]");
return true;
}
bytes_written = size;
- adaptive_delay[primarySecondary].Delay(size * 8 / current_state[primarySecondary].bits_per_sample * 1000 / current_state[primarySecondary].samplerate);
+ adaptive_delay[ps].Delay(size * 8 / current_state[ps].bits_per_sample * 1000 / current_state[ps].samplerate);
return true;
}
Modified: trunk/lib/engine/audiooutput/null/audiooutput-manager-null.h
==============================================================================
--- trunk/lib/engine/audiooutput/null/audiooutput-manager-null.h (original)
+++ trunk/lib/engine/audiooutput/null/audiooutput-manager-null.h Wed May 21 22:05:30 2008
@@ -59,13 +59,13 @@
virtual void get_devices (std::vector <Ekiga::AudioOutputDevice> & devices);
- virtual bool set_device (Ekiga::AudioOutputPrimarySecondary primarySecondary, const Ekiga::AudioOutputDevice & device);
+ virtual bool set_device (Ekiga::AudioOutputPS ps, const Ekiga::AudioOutputDevice & device);
- virtual bool open (Ekiga::AudioOutputPrimarySecondary primarySecondary, unsigned channels, unsigned samplerate, unsigned bits_per_sample);
+ virtual bool open (Ekiga::AudioOutputPS ps, unsigned channels, unsigned samplerate, unsigned bits_per_sample);
- virtual void close(Ekiga::AudioOutputPrimarySecondary primarySecondary);
+ virtual void close(Ekiga::AudioOutputPS ps);
- virtual bool set_frame_data (Ekiga::AudioOutputPrimarySecondary primarySecondary,
+ virtual bool set_frame_data (Ekiga::AudioOutputPS ps,
const char *data,
unsigned size,
unsigned & bytes_written);
Modified: trunk/lib/engine/audiooutput/ptlib/audiooutput-manager-ptlib.cpp
==============================================================================
--- trunk/lib/engine/audiooutput/ptlib/audiooutput-manager-ptlib.cpp (original)
+++ trunk/lib/engine/audiooutput/ptlib/audiooutput-manager-ptlib.cpp Wed May 21 22:05:30 2008
@@ -81,77 +81,77 @@
free (sources_array);
}
-bool GMAudioOutputManager_ptlib::set_device (Ekiga::AudioOutputPrimarySecondary primarySecondary, const Ekiga::AudioOutputDevice & device)
+bool GMAudioOutputManager_ptlib::set_device (Ekiga::AudioOutputPS ps, const Ekiga::AudioOutputDevice & device)
{
if ( device.type == DEVICE_TYPE ) {
- PTRACE(4, "GMAudioOutputManager_ptlib\tSetting Device[" << primarySecondary << "] " << device);
- current_state[primarySecondary].device = device;
+ PTRACE(4, "GMAudioOutputManager_ptlib\tSetting Device[" << ps << "] " << device);
+ current_state[ps].device = device;
return true;
}
return false;
}
-bool GMAudioOutputManager_ptlib::open (Ekiga::AudioOutputPrimarySecondary primarySecondary, unsigned channels, unsigned samplerate, unsigned bits_per_sample)
+bool GMAudioOutputManager_ptlib::open (Ekiga::AudioOutputPS ps, unsigned channels, unsigned samplerate, unsigned bits_per_sample)
{
- PTRACE(4, "GMAudioOutputManager_ptlib\tOpening Device " << current_state[primarySecondary].device);
+ PTRACE(4, "GMAudioOutputManager_ptlib\tOpening Device " << current_state[ps].device);
PTRACE(4, "GMAudioOutputManager_ptlib\tOpening Device with " << channels << "-" << samplerate << "/" << bits_per_sample);
- current_state[primarySecondary].channels = channels;
- current_state[primarySecondary].samplerate = samplerate;
- current_state[primarySecondary].bits_per_sample = bits_per_sample;
+ current_state[ps].channels = channels;
+ current_state[ps].samplerate = samplerate;
+ current_state[ps].bits_per_sample = bits_per_sample;
- output_device[primarySecondary] = PSoundChannel::CreateOpenedChannel (current_state[primarySecondary].device.source,
- current_state[primarySecondary].device.name,
+ output_device[ps] = PSoundChannel::CreateOpenedChannel (current_state[ps].device.source,
+ current_state[ps].device.name,
PSoundChannel::Player,
channels,
samplerate,
bits_per_sample);
Ekiga::AudioOutputErrorCodes error_code = Ekiga::AO_ERROR_NONE;
- if (!output_device[primarySecondary])
+ if (!output_device[ps])
error_code = Ekiga::AO_ERROR_DEVICE;
if (error_code != Ekiga::AO_ERROR_NONE) {
- PTRACE(1, "GMAudioOutputManager_ptlib\tEncountered error " << error_code << " while opening device[" << primarySecondary << "]");
- runtime.run_in_main (sigc::bind (device_error.make_slot (), primarySecondary, current_state[primarySecondary].device, error_code));
+ PTRACE(1, "GMAudioOutputManager_ptlib\tEncountered error " << error_code << " while opening device[" << ps << "]");
+ runtime.run_in_main (sigc::bind (device_error.make_slot (), ps, current_state[ps].device, error_code));
return false;
}
unsigned volume;
- output_device[primarySecondary]->GetVolume (volume);
- current_state[primarySecondary].opened = true;
+ output_device[ps]->GetVolume (volume);
+ current_state[ps].opened = true;
Ekiga::AudioOutputConfig config;
config.volume = volume;
config.modifyable = true;
- runtime.run_in_main (sigc::bind (device_opened.make_slot (), primarySecondary, current_state[primarySecondary].device, config));
+ runtime.run_in_main (sigc::bind (device_opened.make_slot (), ps, current_state[ps].device, config));
return true;
}
-void GMAudioOutputManager_ptlib::close(Ekiga::AudioOutputPrimarySecondary primarySecondary)
+void GMAudioOutputManager_ptlib::close(Ekiga::AudioOutputPS ps)
{
- PTRACE(4, "GMAudioOutputManager_ptlib\tClosing device[" << primarySecondary << "] " << current_state[primarySecondary].device);
- if (output_device[primarySecondary]) {
- delete output_device[primarySecondary];
- output_device[primarySecondary] = NULL;
+ PTRACE(4, "GMAudioOutputManager_ptlib\tClosing device[" << ps << "] " << current_state[ps].device);
+ if (output_device[ps]) {
+ delete output_device[ps];
+ output_device[ps] = NULL;
}
- current_state[primarySecondary].opened = false;
- runtime.run_in_main (sigc::bind (device_closed.make_slot (), primarySecondary, current_state[primarySecondary].device));
+ current_state[ps].opened = false;
+ runtime.run_in_main (sigc::bind (device_closed.make_slot (), ps, current_state[ps].device));
}
-void GMAudioOutputManager_ptlib::set_buffer_size (Ekiga::AudioOutputPrimarySecondary primarySecondary, unsigned buffer_size, unsigned num_buffers)
+void GMAudioOutputManager_ptlib::set_buffer_size (Ekiga::AudioOutputPS ps, unsigned buffer_size, unsigned num_buffers)
{
- PTRACE(4, "GMAudioOutputManager_ptlib\tSetting buffer size of device[" << primarySecondary << "] " << buffer_size << "/" << num_buffers);
+ PTRACE(4, "GMAudioOutputManager_ptlib\tSetting buffer size of device[" << ps << "] " << buffer_size << "/" << num_buffers);
- if (output_device[primarySecondary])
- output_device[primarySecondary]->SetBuffers (buffer_size, num_buffers);
+ if (output_device[ps])
+ output_device[ps]->SetBuffers (buffer_size, num_buffers);
}
-bool GMAudioOutputManager_ptlib::set_frame_data (Ekiga::AudioOutputPrimarySecondary primarySecondary,
+bool GMAudioOutputManager_ptlib::set_frame_data (Ekiga::AudioOutputPS ps,
const char *data,
unsigned size,
unsigned & bytes_written)
@@ -159,30 +159,30 @@
bool ret = false;
bytes_written = 0;
- if (!current_state[primarySecondary].opened) {
- PTRACE(1, "GMAudioOutputManager_ptlib\tTrying to get frame from closed device[" << primarySecondary << "]");
+ if (!current_state[ps].opened) {
+ PTRACE(1, "GMAudioOutputManager_ptlib\tTrying to get frame from closed device[" << ps << "]");
return false;
}
- if (output_device[primarySecondary]) {
- ret = output_device[primarySecondary]->Write ((void*)data, size);
+ if (output_device[ps]) {
+ ret = output_device[ps]->Write ((void*)data, size);
if (ret) {
- bytes_written = output_device[primarySecondary]->GetLastWriteCount();
+ bytes_written = output_device[ps]->GetLastWriteCount();
}
else {
PTRACE(1, "GMAudioOutputManager_ptlib\tEncountered error while trying to write data");
- runtime.run_in_main (sigc::bind (device_error.make_slot (), primarySecondary, current_state[primarySecondary].device, Ekiga::AO_ERROR_WRITE));
+ runtime.run_in_main (sigc::bind (device_error.make_slot (), ps, current_state[ps].device, Ekiga::AO_ERROR_WRITE));
}
}
return ret;
}
-void GMAudioOutputManager_ptlib::set_volume (Ekiga::AudioOutputPrimarySecondary primarySecondary, unsigned volume )
+void GMAudioOutputManager_ptlib::set_volume (Ekiga::AudioOutputPS ps, unsigned volume )
{
- PTRACE(4, "GMAudioOutputManager_ptlib\tSetting volume of device [" << primarySecondary << "] to " << volume);
- if (output_device[primarySecondary])
- output_device[primarySecondary]->SetVolume(volume);
+ PTRACE(4, "GMAudioOutputManager_ptlib\tSetting volume of device [" << ps << "] to " << volume);
+ if (output_device[ps])
+ output_device[ps]->SetVolume(volume);
}
bool GMAudioOutputManager_ptlib::has_device(const std::string & sink, const std::string & device_name, Ekiga::AudioOutputDevice & device)
Modified: trunk/lib/engine/audiooutput/ptlib/audiooutput-manager-ptlib.h
==============================================================================
--- trunk/lib/engine/audiooutput/ptlib/audiooutput-manager-ptlib.h (original)
+++ trunk/lib/engine/audiooutput/ptlib/audiooutput-manager-ptlib.h Wed May 21 22:05:30 2008
@@ -61,20 +61,20 @@
virtual void get_devices (std::vector <Ekiga::AudioOutputDevice> & devices);
- virtual bool set_device (Ekiga::AudioOutputPrimarySecondary primarySecondary, const Ekiga::AudioOutputDevice & device);
+ virtual bool set_device (Ekiga::AudioOutputPS ps, const Ekiga::AudioOutputDevice & device);
- virtual bool open (Ekiga::AudioOutputPrimarySecondary primarySecondary, unsigned channels, unsigned samplerate, unsigned bits_per_sample);
+ virtual bool open (Ekiga::AudioOutputPS ps, unsigned channels, unsigned samplerate, unsigned bits_per_sample);
- virtual void close(Ekiga::AudioOutputPrimarySecondary primarySecondary);
+ virtual void close(Ekiga::AudioOutputPS ps);
- virtual void set_buffer_size (Ekiga::AudioOutputPrimarySecondary primarySecondary, unsigned buffer_size, unsigned num_buffers);
+ virtual void set_buffer_size (Ekiga::AudioOutputPS ps, unsigned buffer_size, unsigned num_buffers);
- virtual bool set_frame_data (Ekiga::AudioOutputPrimarySecondary primarySecondary,
+ virtual bool set_frame_data (Ekiga::AudioOutputPS ps,
const char *data,
unsigned size,
unsigned & bytes_written);
- virtual void set_volume (Ekiga::AudioOutputPrimarySecondary primarySecondary, unsigned volume );
+ virtual void set_volume (Ekiga::AudioOutputPS ps, unsigned volume );
virtual bool has_device (const std::string & sink, const std::string & device_name, Ekiga::AudioOutputDevice & device);
Modified: trunk/lib/engine/audiooutput/skel/audiooutput-core.cpp
==============================================================================
--- trunk/lib/engine/audiooutput/skel/audiooutput-core.cpp (original)
+++ trunk/lib/engine/audiooutput/skel/audiooutput-core.cpp Wed May 21 22:05:30 2008
@@ -43,9 +43,9 @@
: runtime (_runtime),
audio_event_scheduler(*this)
{
- PWaitAndSignal m_pri(var_mutex[primary]);
- PWaitAndSignal m_sec(var_mutex[secondary]);
- PWaitAndSignal m_vol(vol_mutex);
+ PWaitAndSignal m_pri(core_mutex[primary]);
+ PWaitAndSignal m_sec(core_mutex[secondary]);
+ PWaitAndSignal m_vol(volume_mutex);
current_primary_config.active = false;
current_primary_config.channels = 0;
@@ -53,8 +53,9 @@
current_primary_config.bits_per_sample = 0;
current_primary_config.buffer_size = 0;
current_primary_config.num_buffers = 0;
- current_primary_config.volume = 0;
- new_primary_volume = 0;
+
+ current_primary_volume = 0;
+ desired_primary_volume = 0;
current_manager[primary] = NULL;
current_manager[secondary] = NULL;
@@ -69,8 +70,8 @@
std::cout << __PRETTY_FUNCTION__ << std::endl;
#endif
- PWaitAndSignal m_pri(var_mutex[primary]);
- PWaitAndSignal m_sec(var_mutex[secondary]);
+ PWaitAndSignal m_pri(core_mutex[primary]);
+ PWaitAndSignal m_sec(core_mutex[secondary]);
if (audiooutput_core_conf_bridge)
delete audiooutput_core_conf_bridge;
@@ -78,8 +79,8 @@
void AudioOutputCore::setup_conf_bridge ()
{
- PWaitAndSignal m_pri(var_mutex[primary]);
- PWaitAndSignal m_sec(var_mutex[secondary]);
+ PWaitAndSignal m_pri(core_mutex[primary]);
+ PWaitAndSignal m_sec(core_mutex[secondary]);
audiooutput_core_conf_bridge = new AudioOutputCoreConfBridge (*this);
}
@@ -96,8 +97,8 @@
void AudioOutputCore::visit_managers (sigc::slot<bool, AudioOutputManager &> visitor)
{
- PWaitAndSignal m_pri(var_mutex[primary]);
- PWaitAndSignal m_sec(var_mutex[secondary]);
+ PWaitAndSignal m_pri(core_mutex[primary]);
+ PWaitAndSignal m_sec(core_mutex[secondary]);
bool go_on = true;
for (std::set<AudioOutputManager *>::iterator iter = managers.begin ();
@@ -106,9 +107,9 @@
go_on = visitor (*(*iter));
}
-void AudioOutputCore::add_event (const std::string & event_name, const std::string & file_name, bool enabled, AudioOutputPrimarySecondary primarySecondary)
+void AudioOutputCore::add_event (const std::string & event_name, const std::string & file_name, AudioOutputPS ps, bool enabled)
{
- audio_event_scheduler.set_file_name(event_name, file_name, enabled, primarySecondary);
+ audio_event_scheduler.set_file_name(event_name, file_name, ps, enabled);
}
void AudioOutputCore::play_file (const std::string & file_name)
@@ -131,21 +132,21 @@
audio_event_scheduler.remove_event_from_queue(event_name);
}
-void AudioOutputCore::get_audiooutput_devices (std::vector <AudioOutputDevice> & audiooutput_devices)
+void AudioOutputCore::get_devices (std::vector <AudioOutputDevice> & devices)
{
- PWaitAndSignal m_pri(var_mutex[primary]);
- PWaitAndSignal m_sec(var_mutex[secondary]);
+ PWaitAndSignal m_pri(core_mutex[primary]);
+ PWaitAndSignal m_sec(core_mutex[secondary]);
- audiooutput_devices.clear();
+ devices.clear();
for (std::set<AudioOutputManager *>::iterator iter = managers.begin ();
iter != managers.end ();
iter++)
- (*iter)->get_devices (audiooutput_devices);
+ (*iter)->get_devices (devices);
if (PTrace::CanTrace(4)) {
- for (std::vector<AudioOutputDevice>::iterator iter = audiooutput_devices.begin ();
- iter != audiooutput_devices.end ();
+ for (std::vector<AudioOutputDevice>::iterator iter = devices.begin ();
+ iter != devices.end ();
iter++) {
PTRACE(4, "AudioOutputCore\tDetected Device: " << *iter);
}
@@ -153,24 +154,22 @@
}
-void AudioOutputCore::set_audiooutput_device(AudioOutputPrimarySecondary primarySecondary, const AudioOutputDevice & audiooutput_device)
+void AudioOutputCore::set_device(AudioOutputPS ps, const AudioOutputDevice & device)
{
- PTRACE(4, "AudioOutputCore\tSetting device[" << primarySecondary << "]: " << audiooutput_device);
+ PTRACE(4, "AudioOutputCore\tSetting device[" << ps << "]: " << device);
- PWaitAndSignal m_sec(var_mutex[secondary]);
+ PWaitAndSignal m_sec(core_mutex[secondary]);
- switch (primarySecondary) {
+ switch (ps) {
case primary:
- var_mutex[primary].Wait();
- internal_set_prim_audiooutput_device (audiooutput_device);
- desired_primary_device = audiooutput_device;
- var_mutex[primary].Signal();
+ core_mutex[primary].Wait();
+ internal_set_primary_device (device);
+ desired_primary_device = device;
+ core_mutex[primary].Signal();
break;
case secondary:
- if ( (audiooutput_device.type == current_device[primary].type) &&
- (audiooutput_device.source == current_device[primary].source) &&
- (audiooutput_device.name == current_device[primary].name) )
+ if (device == current_device[primary])
{
current_manager[secondary] = NULL;
current_device[secondary].type = "";
@@ -178,7 +177,7 @@
current_device[secondary].name = "";
}
else {
- internal_set_device (secondary, audiooutput_device);
+ internal_set_manager (secondary, device);
}
break;
default:
@@ -186,9 +185,53 @@
}
}
+void AudioOutputCore::add_device (const std::string & sink, const std::string & device_name, HalManager* /*manager*/)
+{
+ PTRACE(0, "AudioOutputCore\tAdding Device " << device_name);
+ PWaitAndSignal m_pri(core_mutex[primary]);
+
+ AudioOutputDevice device;
+ for (std::set<AudioOutputManager *>::iterator iter = managers.begin ();
+ iter != managers.end ();
+ iter++) {
+ if ((*iter)->has_device (sink, device_name, device)) {
+
+ if ( desired_primary_device == device ) {
+ internal_set_primary_device(desired_primary_device);
+ }
+
+ runtime.run_in_main (sigc::bind (device_added.make_slot (), device));
+ }
+ }
+}
+
+void AudioOutputCore::remove_device (const std::string & sink, const std::string & device_name, HalManager* /*manager*/)
+{
+ PTRACE(0, "AudioOutputCore\tRemoving Device " << device_name);
+ PWaitAndSignal m_pri(core_mutex[primary]);
+
+ AudioOutputDevice device;
+ for (std::set<AudioOutputManager *>::iterator iter = managers.begin ();
+ iter != managers.end ();
+ iter++) {
+ if ((*iter)->has_device (sink, device_name, device)) {
+ if (device == current_device[primary]) {
+
+ AudioOutputDevice new_device;
+ new_device.type = AUDIO_OUTPUT_FALLBACK_DEVICE_TYPE;
+ new_device.source = AUDIO_OUTPUT_FALLBACK_DEVICE_SOURCE;
+ new_device.name = AUDIO_OUTPUT_FALLBACK_DEVICE_NAME;
+ internal_set_primary_device(new_device);
+ }
+
+ runtime.run_in_main (sigc::bind (device_removed.make_slot (), device));
+ }
+ }
+}
+
void AudioOutputCore::start (unsigned channels, unsigned samplerate, unsigned bits_per_sample)
{
- PWaitAndSignal m_pri(var_mutex[primary]);
+ PWaitAndSignal m_pri(core_mutex[primary]);
if (current_primary_config.active) {
PTRACE(1, "AudioOutputCore\tTrying to start output device although already started");
@@ -207,17 +250,17 @@
void AudioOutputCore::stop()
{
- PWaitAndSignal m_pri(var_mutex[primary]);
+ PWaitAndSignal m_pri(core_mutex[primary]);
average_level = 0;
internal_close(primary);
- internal_set_device(primary, desired_primary_device);
+ internal_set_manager(primary, desired_primary_device);
current_primary_config.active = false;
}
void AudioOutputCore::set_buffer_size (unsigned buffer_size, unsigned num_buffers) {
- PWaitAndSignal m_pri(var_mutex[primary]);
+ PWaitAndSignal m_pri(core_mutex[primary]);
if (current_manager[primary])
current_manager[primary]->set_buffer_size (primary, buffer_size, num_buffers);
@@ -226,12 +269,11 @@
current_primary_config.num_buffers = num_buffers;
}
-
void AudioOutputCore::set_frame_data (const char *data,
unsigned size,
unsigned & bytes_written)
{
- PWaitAndSignal m_pri(var_mutex[primary]);
+ PWaitAndSignal m_pri(core_mutex[primary]);
if (current_manager[primary]) {
if (!current_manager[primary]->set_frame_data(primary, data, size, bytes_written)) {
@@ -242,10 +284,10 @@
current_manager[primary]->set_frame_data(primary, data, size, bytes_written); // the default device must always return true
}
- PWaitAndSignal m_vol(vol_mutex);
- if (new_primary_volume != current_primary_config.volume) {
- current_manager[primary]->set_volume(primary, new_primary_volume);
- current_primary_config.volume = new_primary_volume;
+ PWaitAndSignal m_vol(volume_mutex);
+ if (desired_primary_volume != current_primary_volume) {
+ current_manager[primary]->set_volume(primary, desired_primary_volume);
+ current_primary_volume = desired_primary_volume;
}
}
@@ -253,36 +295,45 @@
calculate_average_level((const short*) data, bytes_written);
}
-void AudioOutputCore::play_buffer(AudioOutputPrimarySecondary primarySecondary, const char* buffer, unsigned long len, unsigned channels, unsigned sample_rate, unsigned bps)
+void AudioOutputCore::set_volume (AudioOutputPS ps, unsigned volume)
+{
+ PWaitAndSignal m_vol(volume_mutex);
+
+ if (ps == primary) {
+ desired_primary_volume = volume;
+ }
+}
+
+void AudioOutputCore::play_buffer(AudioOutputPS ps, const char* buffer, unsigned long len, unsigned channels, unsigned sample_rate, unsigned bps)
{
- switch (primarySecondary) {
+ switch (ps) {
case primary:
- var_mutex[primary].Wait();
+ core_mutex[primary].Wait();
if (!current_manager[primary]) {
PTRACE(1, "AudioOutputCore\tDropping sound event, primary manager not set");
- var_mutex[primary].Signal();
+ core_mutex[primary].Signal();
return;
}
if (current_primary_config.active) {
PTRACE(1, "AudioOutputCore\tDropping sound event, primary device not set");
- var_mutex[primary].Signal();
+ core_mutex[primary].Signal();
return;
}
internal_play(primary, buffer, len, channels, sample_rate, bps);
- var_mutex[primary].Signal();
+ core_mutex[primary].Signal();
break;
case secondary:
- var_mutex[secondary].Wait();
+ core_mutex[secondary].Wait();
if (current_manager[secondary]) {
internal_play(secondary, buffer, len, channels, sample_rate, bps);
- var_mutex[secondary].Signal();
+ core_mutex[secondary].Signal();
}
else {
- var_mutex[secondary].Signal();
+ core_mutex[secondary].Signal();
PTRACE(1, "AudioOutputCore\tNo secondary audiooutput device defined, trying primary");
play_buffer(primary, buffer, len, channels, sample_rate, bps);
}
@@ -292,22 +343,38 @@
}
}
-void AudioOutputCore::internal_set_prim_audiooutput_device(const AudioOutputDevice & audiooutput_device)
+void AudioOutputCore::on_device_opened (AudioOutputPS ps,
+ AudioOutputDevice device,
+ AudioOutputConfig config,
+ AudioOutputManager *manager)
+{
+ device_opened.emit (*manager, ps, device, config);
+}
+
+void AudioOutputCore::on_device_closed (AudioOutputPS ps, AudioOutputDevice device, AudioOutputManager *manager)
+{
+ device_closed.emit (*manager, ps, device);
+}
+
+void AudioOutputCore::on_device_error (AudioOutputPS ps, AudioOutputDevice device, AudioOutputErrorCodes error_code, AudioOutputManager *manager)
+{
+ device_error.emit (*manager, ps, device, error_code);
+}
+
+void AudioOutputCore::internal_set_primary_device(const AudioOutputDevice & device)
{
if (current_primary_config.active)
internal_close(primary);
- if ( (audiooutput_device.type == current_device[secondary].type) &&
- (audiooutput_device.source == current_device[secondary].source) &&
- (audiooutput_device.name == current_device[secondary].name) )
- {
+ if (device == current_device[secondary]) {
+
current_manager[secondary] = NULL;
current_device[secondary].type = "";
current_device[secondary].source = "";
current_device[secondary].name = "";
}
- internal_set_device(primary, audiooutput_device);
+ internal_set_manager(primary, device);
if (current_primary_config.active)
internal_open(primary, current_primary_config.channels, current_primary_config.samplerate, current_primary_config.bits_per_sample);
@@ -317,27 +384,27 @@
current_manager[primary]->set_buffer_size (primary, current_primary_config.buffer_size, current_primary_config.num_buffers);
}
}
-void AudioOutputCore::internal_set_device (AudioOutputPrimarySecondary primarySecondary, const AudioOutputDevice & audiooutput_device)
+void AudioOutputCore::internal_set_manager (AudioOutputPS ps, const AudioOutputDevice & device)
{
- current_manager[primarySecondary] = NULL;
+ current_manager[ps] = NULL;
for (std::set<AudioOutputManager *>::iterator iter = managers.begin ();
iter != managers.end ();
iter++) {
- if ((*iter)->set_device (primarySecondary, audiooutput_device)) {
- current_manager[primarySecondary] = (*iter);
+ if ((*iter)->set_device (ps, device)) {
+ current_manager[ps] = (*iter);
}
}
- if (current_manager[primarySecondary]) {
- current_device[primarySecondary] = audiooutput_device;
+ if (current_manager[ps]) {
+ current_device[ps] = device;
}
else {
- if (primarySecondary == primary) {
- PTRACE(1, "AudioOutputCore\tTried to set unexisting primary device " << audiooutput_device);
+ if (ps == primary) {
+ PTRACE(1, "AudioOutputCore\tTried to set unexisting primary device " << device);
internal_set_primary_fallback();
}
else {
- PTRACE(1, "AudioOutputCore\tTried to set unexisting secondary device " << audiooutput_device);
+ PTRACE(1, "AudioOutputCore\tTried to set unexisting secondary device " << device);
current_device[secondary].type = "";
current_device[secondary].source = "";
current_device[secondary].name = "";
@@ -346,39 +413,30 @@
}
-void AudioOutputCore::on_device_opened (AudioOutputPrimarySecondary primarySecondary,
- AudioOutputDevice device,
- AudioOutputConfig config,
- AudioOutputManager *manager)
-{
- device_opened.emit (*manager, primarySecondary, device, config);
-}
-
-void AudioOutputCore::on_device_closed (AudioOutputPrimarySecondary primarySecondary, AudioOutputDevice device, AudioOutputManager *manager)
-{
- device_closed.emit (*manager, primarySecondary, device);
-}
-
-void AudioOutputCore::on_device_error (AudioOutputPrimarySecondary primarySecondary, AudioOutputDevice device, AudioOutputErrorCodes error_code, AudioOutputManager *manager)
+void AudioOutputCore::internal_set_primary_fallback()
{
- device_error.emit (*manager, primarySecondary, device, error_code);
+ current_device[primary].type = AUDIO_OUTPUT_FALLBACK_DEVICE_TYPE;
+ current_device[primary].source = AUDIO_OUTPUT_FALLBACK_DEVICE_SOURCE;
+ current_device[primary].name = AUDIO_OUTPUT_FALLBACK_DEVICE_NAME;
+ PTRACE(1, "AudioOutputCore\tFalling back to " << current_device[primary]);
+ internal_set_manager(primary, current_device[primary]);
}
-bool AudioOutputCore::internal_open (AudioOutputPrimarySecondary primarySecondary, unsigned channels, unsigned samplerate, unsigned bits_per_sample)
+bool AudioOutputCore::internal_open (AudioOutputPS ps, unsigned channels, unsigned samplerate, unsigned bits_per_sample)
{
- PTRACE(4, "AudioOutputCore\tOpening device["<<primarySecondary<<"] with " << channels<< "-" << samplerate << "/" << bits_per_sample);
+ PTRACE(4, "AudioOutputCore\tOpening device["<<ps<<"] with " << channels<< "-" << samplerate << "/" << bits_per_sample);
- if (!current_manager[primarySecondary]) {
- PTRACE(1, "AudioOutputCore\tUnable to obtain current manager for device["<<primarySecondary<<"]");
+ if (!current_manager[ps]) {
+ PTRACE(1, "AudioOutputCore\tUnable to obtain current manager for device["<<ps<<"]");
return false;
}
- if (!current_manager[primarySecondary]->open(primarySecondary, channels, samplerate, bits_per_sample)) {
- PTRACE(1, "AudioOutputCore\tUnable to open device["<<primarySecondary<<"]");
- if (primarySecondary == primary) {
+ if (!current_manager[ps]->open(ps, channels, samplerate, bits_per_sample)) {
+ PTRACE(1, "AudioOutputCore\tUnable to open device["<<ps<<"]");
+ if (ps == primary) {
internal_set_primary_fallback();
if (current_manager[primary])
- current_manager[primary]->open(primarySecondary, channels, samplerate, bits_per_sample);
+ current_manager[primary]->open(ps, channels, samplerate, bits_per_sample);
return true;
}
else {
@@ -388,31 +446,31 @@
return true;
}
-void AudioOutputCore::internal_close(AudioOutputPrimarySecondary primarySecondary)
+void AudioOutputCore::internal_close(AudioOutputPS ps)
{
PTRACE(4, "AudioOutputCore\tClosing current device");
- if (current_manager[primarySecondary])
- current_manager[primarySecondary]->close(primarySecondary);
+ if (current_manager[ps])
+ current_manager[ps]->close(ps);
}
-void AudioOutputCore::internal_play(AudioOutputPrimarySecondary primarySecondary, const char* buffer, unsigned long len, unsigned channels, unsigned sample_rate, unsigned bps)
+void AudioOutputCore::internal_play(AudioOutputPS ps, const char* buffer, unsigned long len, unsigned channels, unsigned sample_rate, unsigned bps)
{
unsigned long pos = 0;
unsigned bytes_written = 0;
- if (!internal_open ( primarySecondary, channels, sample_rate, bps))
+ if (!internal_open ( ps, channels, sample_rate, bps))
return;
- if (current_manager[primarySecondary]) {
- current_manager[primarySecondary]->set_buffer_size (primarySecondary, 320, 4);
+ if (current_manager[ps]) {
+ current_manager[ps]->set_buffer_size (ps, 320, 4);
do {
- if (!current_manager[primarySecondary]->set_frame_data(primarySecondary, buffer+pos, std::min((unsigned)320, (unsigned) (len - pos)), bytes_written))
+ if (!current_manager[ps]->set_frame_data(ps, buffer+pos, std::min((unsigned)320, (unsigned) (len - pos)), bytes_written))
break;
pos += 320;
} while (pos < len);
}
- internal_close( primarySecondary);
+ internal_close( ps);
}
void AudioOutputCore::calculate_average_level (const short *buffer, unsigned size)
@@ -432,69 +490,3 @@
average_level = log10 (9.0*sum/size/32767+1)*1.0;
}
-
-void AudioOutputCore::set_volume (AudioOutputPrimarySecondary primarySecondary, unsigned volume)
-{
- PWaitAndSignal m_vol(vol_mutex);
-
- if (primarySecondary == primary) {
- new_primary_volume = volume;
- }
-}
-
-void AudioOutputCore::internal_set_primary_fallback()
-{
- current_device[primary].type = AUDIO_OUTPUT_FALLBACK_DEVICE_TYPE;
- current_device[primary].source = AUDIO_OUTPUT_FALLBACK_DEVICE_SOURCE;
- current_device[primary].name = AUDIO_OUTPUT_FALLBACK_DEVICE_NAME;
- PTRACE(1, "AudioOutputCore\tFalling back to " << current_device[primary]);
- internal_set_device(primary, current_device[primary]);
-}
-
-void AudioOutputCore::add_device (const std::string & sink, const std::string & device, HalManager* /*manager*/)
-{
- PTRACE(0, "AudioOutputCore\tAdding Device " << device);
- PWaitAndSignal m_pri(var_mutex[primary]);
-
- AudioOutputDevice audiooutput_device;
- for (std::set<AudioOutputManager *>::iterator iter = managers.begin ();
- iter != managers.end ();
- iter++) {
- if ((*iter)->has_device (sink, device, audiooutput_device)) {
-
- if ( ( desired_primary_device.type == audiooutput_device.type ) &&
- ( desired_primary_device.source == audiooutput_device.source ) &&
- ( desired_primary_device.name == audiooutput_device.name ) ) {
- internal_set_prim_audiooutput_device(desired_primary_device);
- }
-
- runtime.run_in_main (sigc::bind (device_added.make_slot (), audiooutput_device));
- }
- }
-}
-
-void AudioOutputCore::remove_device (const std::string & sink, const std::string & device, HalManager* /*manager*/)
-{
- PTRACE(0, "AudioOutputCore\tRemoving Device " << device);
- PWaitAndSignal m_pri(var_mutex[primary]);
-
- AudioOutputDevice audiooutput_device;
- for (std::set<AudioOutputManager *>::iterator iter = managers.begin ();
- iter != managers.end ();
- iter++) {
- if ((*iter)->has_device (sink, device, audiooutput_device)) {
- if ( (audiooutput_device.type == current_device[primary].type) &&
- (audiooutput_device.source == current_device[primary].source) &&
- (audiooutput_device.name == current_device[primary].name) ) {
-
- AudioOutputDevice new_audiooutput_device;
- new_audiooutput_device.type = AUDIO_OUTPUT_FALLBACK_DEVICE_TYPE;
- new_audiooutput_device.source = AUDIO_OUTPUT_FALLBACK_DEVICE_SOURCE;
- new_audiooutput_device.name = AUDIO_OUTPUT_FALLBACK_DEVICE_NAME;
- internal_set_prim_audiooutput_device(new_audiooutput_device);
- }
-
- runtime.run_in_main (sigc::bind (device_removed.make_slot (), audiooutput_device));
- }
- }
-}
Modified: trunk/lib/engine/audiooutput/skel/audiooutput-core.h
==============================================================================
--- trunk/lib/engine/audiooutput/skel/audiooutput-core.h (original)
+++ trunk/lib/engine/audiooutput/skel/audiooutput-core.h Wed May 21 22:05:30 2008
@@ -57,16 +57,6 @@
namespace Ekiga
{
- typedef struct AudioOutputDeviceConfig {
- bool active;
- unsigned channels;
- unsigned samplerate;
- unsigned bits_per_sample;
- unsigned buffer_size;
- unsigned num_buffers;
- unsigned volume;
- };
-
/**
* @defgroup audiooutput Audio AudioInput
* @{
@@ -83,16 +73,20 @@
public:
- /* The constructor
- */
+ /** The constructor
+ * @param _runtime reference to Ekiga runtime.
+ */
AudioOutputCore (Ekiga::Runtime & _runtime);
- /* The destructor
+ /** The destructor
*/
~AudioOutputCore ();
+ /** Set up gmconf bridge
+ */
void setup_conf_bridge();
+
/*** Service Implementation ***/
/** Returns the name of the service.
@@ -101,108 +95,259 @@
const std::string get_name () const
{ return "audiooutput-core"; }
-
/** Returns the description of the service.
* @return The service description.
*/
const std::string get_description () const
{ return "\tAudioOutput Core managing AudioOutput Manager objects"; }
-
/** Adds a AudioOutputManager to the AudioOutputCore service.
* @param The manager to be added.
*/
- void add_manager (AudioOutputManager &manager);
+ void add_manager (AudioOutputManager &manager);
/** Triggers a callback for all Ekiga::AudioOutputManager sources of the
* AudioOutputCore service.
*/
- void visit_managers (sigc::slot<bool, AudioOutputManager &> visitor);
+ void visit_managers (sigc::slot<bool, AudioOutputManager &> visitor);
/** This signal is emitted when a Ekiga::AudioOutputManager has been
* added to the AudioOutputCore Service.
*/
- sigc::signal<void, AudioOutputManager &> manager_added;
+ sigc::signal<void, AudioOutputManager &> manager_added;
+
+
+ /** Get a list of all devices supported by all managers registered to the core.
+ * @param devices a vector of device names to be filled by the core.
+ */
+ void get_devices(std::vector <AudioOutputDevice> & devices);
- void add_event (const std::string & event_name, const std::string & file_name, bool enabled, AudioOutputPrimarySecondary primarySecondary);
+ /** Set a specific device
+ * This function sets the current primary or secondary audio output device. This function can
+ * also be used while in a stream or in preview mode. In that case the old
+ * device is closed and the new device opened automatically.
+ * @param ps whether referring to the primary or secondary device.
+ * @param device the new device to be used.
+ */
+ void set_device(AudioOutputPS ps, const AudioOutputDevice & device);
+ /** Inform the core of an added audiooutput device
+ * This function is called by the HalCore when an audio output device is added.
+ * It determines responsible managers for that specific device and informs the
+ * GUI about the device that was added (via device_added signal).
+ * In case the added device was the desired device and we fell back,
+ * we will reactivate it.
+ * @param sink the device sink (e.g. alsa).
+ * @param device_name the name of the added device.
+ * @param manager the HalManger detected the addition.
+ */
+ void add_device (const std::string & sink, const std::string & device_name, HalManager* manager);
+
+ /** Inform the core of a removed audiooutput device
+ * This function is called by the HalCore when an audio output device is removed.
+ * It determines responsible managers for that specific device and informs the
+ * GUI about the device that was removed (via device_removed signal).
+ * In case the removed device was the current device we fall back to the
+ * fallback device.
+ * @param sink the device sink (e.g. alsa).
+ * @param device_name the name of the removed device.
+ * @param manager the HalManger detected the removal.
+ */
+ void remove_device (const std::string & sink, const std::string & device_name, HalManager* manager);
+
+
+ /*** Event Management ***/
+
+ /** Add a mapping between event and file name to the event list
+ * An event shall refer to a specific sound file. This mapping is set here.
+ * @param event_name the name of the event.
+ * @param file_name the name of the file.
+ * @param ps whether the event shall be played on the primary or secondary device preferrably.
+ * @param enabled if the event is enabled.
+ */
+ void add_event (const std::string & event_name, const std::string & file_name, AudioOutputPS ps, bool enabled);
+
+ /** Play a sound specified by a file name
+ * Play a sound file once.
+ * The sound will be played in the background as soon as the Scheduler
+ * schedules it.
+ * This function only adds the sound to the Scheduler queue and returns immediately.
+ * The sound will be played on the primary device
+ * @param file_name the name of the file.
+ */
void play_file (const std::string & file_name);
+ /** Play a sound specified by an event name
+ * Play a sound associated to the event speficied by its name once.
+ * The sound will be played in the background as soon as the Scheduler
+ * schedules it.
+ * This function only adds the sound to the Scheduler queue and returns immediately.
+ * The sound will be played on the primary or seconday device depending on
+ * how this specific event was configured. In case it was to be played on the secondary device
+ * and not secondary device is available or configured, it will be played on the primary device.
+ * The event will only be played if it is enabled.
+ * @param event_name the name of the event.
+ */
void play_event (const std::string & event_name);
+ /** Play a sound specified by an event name
+ * Play a sound associated to the event specified by its name repeatingly.
+ * The sound will be played in the background as soon as the Scheduler
+ * schedules it.
+ * This function only adds the sound to the Scheduler queue and returns immediately.
+ * The sound will be played on the primary or seconday device depending on
+ * how this specific event was configured. In case it was to be played on the secondary device
+ * and not secondary device is available or configured, it will be played on the primary device.
+ * The event will only be played if it is enabled.
+ * The event will be removed from the scheduler queue once it has been repeated "repetitions" times
+ * or if it has been removd from the queue via stop_play_event.
+ * @param event_name the name of the event.
+ * @param interval the interval of the repetitions in ms.
+ * @param repetitions the maximum number of repetitions.
+ */
void start_play_event (const std::string & event_name, unsigned interval, unsigned repetitions);
+ /** Stop playing a sound specified by an event name
+ * Stop playing sound associated to the event specified by its name.
+ * If the sound is currently playing, it will not be cut short.
+ * @param event_name the name of the event.
+ */
void stop_play_event (const std::string & event_name);
+ /** Play a sound event buffer
+ * This function is called by the Scheduler in order to play an already loaded sound.
+ * @param ps whether to play the sound on the primary or secondary device.
+ * @param buffer pointer to the sound in raw format.
+ * @param len the length in bytes of the sound.
+ * @param channels the number of channels.
+ * @param sample_rate the samplerate.
+ * @param bps bits per sample.
+ */
+ void play_buffer(AudioOutputPS ps, const char* buffer, unsigned long len, unsigned channels, unsigned sample_rate, unsigned bps);
+
- void get_audiooutput_devices(std::vector <AudioOutputDevice> & audiooutput_devices);
+ /*** Stream Management ***/
- void set_audiooutput_device(AudioOutputPrimarySecondary primarySecondary, const AudioOutputDevice & audiooutput_device);
-
- /*** VidInput Management ***/
+ /** Set the number and size of buffers
+ * Will be applied the next time the device is opened.
+ * @param buffer_size the size of each buffer in byte.
+ * @param num_buffers the number of buffers.
+ */
+ void set_buffer_size (unsigned buffer_size, unsigned num_buffers);
+ /** Start the audio output on the primary device
+ * @param channels the number of channels (1 or 2).
+ * @param samplerate the samplerate.
+ * @param bits_per_sample the number of bits per sample (e.g. 8, 16).
+ */
void start (unsigned channels, unsigned samplerate, unsigned bits_per_sample);
+ /** Stop the audio output of the primary device.
+ */
void stop ();
- void set_buffer_size (unsigned buffer_size, unsigned num_buffers);
-
+ /** Set one audio buffer in the current manager.
+ * This function will pass one buffer to the current manager.
+ * Requires the audio output to be started.
+ * In case the device returns an error writing the frame, set_frame_data()
+ * falls back to the fallback device and writes the frame there. Thus
+ * set_frame_data() always be succesful.
+ * In case a new volume has bee set, it will be applied here.
+ * @param data a pointer to the buffer that is to be written to the device.
+ * @param size the number of bytes to be written.
+ * @param bytes_written number of bytes actually written.
+ */
void set_frame_data (const char *data, unsigned size, unsigned & bytes_written);
- void set_volume (AudioOutputPrimarySecondary primarySecondary, unsigned volume);
+ /** Set the volume of the next opportunity
+ * Sets the volume to the specified value the next time
+ * get_frame_data() is called.
+ * @param ps whether the volume of the primary or seconday device shall be set.
+ * @param volume the new volume level (0..255).
+ */
+ void set_volume (AudioOutputPS ps, unsigned volume);
+
+ /** Turn average collecion on and off
+ * The average values can be collected via get_average_level()
+ * This applies to primary device only.
+ * @param on_off whether to turn the collection on or off.
+ */
+ void set_average_collection (bool on_off) { calculate_average = on_off; }
- void play_buffer(AudioOutputPrimarySecondary primarySecondary, const char* buffer, unsigned long len, unsigned channels, unsigned sample_rate, unsigned bps);
+ /** Get the average volume level
+ * Get the average volume level ove the last read buffer of the primary device.
+ * @return the average volume level.
+ */
+ float get_average_level () { return average_level; }
- void start_average_collection () { calculate_average = true; }
- void stop_average_collection () { calculate_average = false; }
+ /*** Signals ***/
- float get_average_level () { return average_level; }
-
- void add_device (const std::string & sink, const std::string & device, HalManager* manager);
- void remove_device (const std::string & sink, const std::string & device, HalManager* manager);
-
- /*** VidInput Related Signals ***/
-
/** See audiooutput-manager.h for the API
*/
- sigc::signal<void, AudioOutputManager &, AudioOutputPrimarySecondary, AudioOutputDevice&, AudioOutputConfig&> device_opened;
- sigc::signal<void, AudioOutputManager &, AudioOutputPrimarySecondary, AudioOutputDevice&> device_closed;
- sigc::signal<void, AudioOutputManager &, AudioOutputPrimarySecondary, AudioOutputDevice&, AudioOutputErrorCodes> device_error;
+ sigc::signal<void, AudioOutputManager &, AudioOutputPS, AudioOutputDevice&, AudioOutputConfig&> device_opened;
+ sigc::signal<void, AudioOutputManager &, AudioOutputPS, AudioOutputDevice&> device_closed;
+ sigc::signal<void, AudioOutputManager &, AudioOutputPS, AudioOutputDevice&, AudioOutputErrorCodes> device_error;
+
+ /** This signal is emitted when an audio output device has been added to the system.
+ * This signal will be emitted if add_device was called with a device name and
+ * a manager claimed support for this device.
+ * @param device the audio output device that was added.
+ */
sigc::signal<void, AudioOutputDevice> device_added;
+
+ /** This signal is emitted when an audio output device has been removed from the system.
+ * This signal will be emitted if remove_device was called with a device name and
+ * a manager claimed support for this device.
+ * @param device the audio output device that was removed.
+ */
sigc::signal<void, AudioOutputDevice> device_removed;
private:
- void on_device_opened (AudioOutputPrimarySecondary primarySecondary,
+ void on_device_opened (AudioOutputPS ps,
AudioOutputDevice device,
AudioOutputConfig config,
AudioOutputManager *manager);
- void on_device_closed (AudioOutputPrimarySecondary primarySecondary, AudioOutputDevice device, AudioOutputManager *manager);
- void on_device_error (AudioOutputPrimarySecondary primarySecondary, AudioOutputDevice device, AudioOutputErrorCodes error_code, AudioOutputManager *manager);
+ void on_device_closed (AudioOutputPS ps, AudioOutputDevice device, AudioOutputManager *manager);
+ void on_device_error (AudioOutputPS ps, AudioOutputDevice device, AudioOutputErrorCodes error_code, AudioOutputManager *manager);
- void internal_set_prim_audiooutput_device(const AudioOutputDevice & audiooutput_device);
- void internal_set_device (AudioOutputPrimarySecondary primarySecondary, const AudioOutputDevice & audiooutput_device);
- bool internal_open (AudioOutputPrimarySecondary primarySecondary, unsigned channels, unsigned samplerate, unsigned bits_per_sample);
- void internal_close(AudioOutputPrimarySecondary primarySecondary);
- void internal_play(AudioOutputPrimarySecondary primarySecondary, const char* buffer, unsigned long len, unsigned channels, unsigned sample_rate, unsigned bps);
+ void internal_set_primary_device(const AudioOutputDevice & device);
+ void internal_set_manager (AudioOutputPS ps, const AudioOutputDevice & device);
void internal_set_primary_fallback();
+
+ bool internal_open (AudioOutputPS ps, unsigned channels, unsigned samplerate, unsigned bits_per_sample);
+ void internal_close(AudioOutputPS ps);
+
+ void internal_play(AudioOutputPS ps, const char* buffer, unsigned long len, unsigned channels, unsigned sample_rate, unsigned bps);
+
void calculate_average_level (const short *buffer, unsigned size);
std::set<AudioOutputManager *> managers;
-
Ekiga::Runtime & runtime;
- AudioOutputDeviceConfig current_primary_config;
- unsigned new_primary_volume;
- AudioOutputManager* current_manager[2];
- AudioOutputDevice desired_primary_device;
- AudioOutputDevice current_device[2];
+ typedef struct DeviceConfig {
+ bool active;
+ unsigned channels;
+ unsigned samplerate;
+ unsigned bits_per_sample;
+ unsigned buffer_size;
+ unsigned num_buffers;
+ };
+
+ DeviceConfig current_primary_config;
+
+ AudioOutputManager* current_manager[2];
+ AudioOutputDevice desired_primary_device;
+ AudioOutputDevice current_device[2];
+ unsigned desired_primary_volume;
+ unsigned current_primary_volume;
- PMutex var_mutex[2]; /* To protect variables that are read and written */
- PMutex vol_mutex; /* To protect variables that are read and written */
+ PMutex core_mutex[2];
+ PMutex volume_mutex;
AudioOutputCoreConfBridge* audiooutput_core_conf_bridge;
AudioEventScheduler audio_event_scheduler;
+
float average_level;
bool calculate_average;
};
Modified: trunk/lib/engine/audiooutput/skel/audiooutput-gmconf-bridge.cpp
==============================================================================
--- trunk/lib/engine/audiooutput/skel/audiooutput-gmconf-bridge.cpp (original)
+++ trunk/lib/engine/audiooutput/skel/audiooutput-gmconf-bridge.cpp Wed May 21 22:05:30 2008
@@ -97,7 +97,7 @@
device.name = AUDIO_OUTPUT_FALLBACK_DEVICE_NAME;
}
- audioinput_core.set_audiooutput_device (primary, device);
+ audioinput_core.set_device (primary, device);
}
if (key == SOUND_EVENTS_KEY "output_device") {
@@ -120,7 +120,7 @@
device.source = AUDIO_OUTPUT_FALLBACK_DEVICE_SOURCE;
device.name = AUDIO_OUTPUT_FALLBACK_DEVICE_NAME;
}
- audioinput_core.set_audiooutput_device (secondary, device);
+ audioinput_core.set_device (secondary, device);
}
if ( (key == SOUND_EVENTS_KEY "busy_tone_sound") ||
@@ -134,7 +134,7 @@
name = "busy_tone_sound";
file_name = gm_conf_get_string (SOUND_EVENTS_KEY "busy_tone_sound");
enabled = gm_conf_get_bool (SOUND_EVENTS_KEY "enable_busy_tone_sound");
- audioinput_core.add_event (name, file_name, enabled, primary);
+ audioinput_core.add_event (name, file_name, primary, enabled);
}
if ( (key == SOUND_EVENTS_KEY "incoming_call_sound") ||
@@ -148,7 +148,7 @@
name = "incoming_call_sound";
file_name = gm_conf_get_string (SOUND_EVENTS_KEY "incoming_call_sound");
enabled = gm_conf_get_bool (SOUND_EVENTS_KEY "enable_incoming_call_sound");
- audioinput_core.add_event (name, file_name, enabled, secondary);
+ audioinput_core.add_event (name, file_name, secondary, enabled);
}
if ( (key == SOUND_EVENTS_KEY "new_message_sound") ||
@@ -162,7 +162,7 @@
name = "new_message_sound";
file_name = gm_conf_get_string (SOUND_EVENTS_KEY "new_message_sound");
enabled = gm_conf_get_bool (SOUND_EVENTS_KEY "enable_new_message_sound");
- audioinput_core.add_event (name, file_name, enabled, secondary);
+ audioinput_core.add_event (name, file_name, secondary, enabled);
}
@@ -177,7 +177,7 @@
name = "new_voicemail_sound";
file_name = gm_conf_get_string (SOUND_EVENTS_KEY "new_voicemail_sound");
enabled = gm_conf_get_bool (SOUND_EVENTS_KEY "enable_new_voicemail_sound");
- audioinput_core.add_event (name, file_name, enabled, secondary);
+ audioinput_core.add_event (name, file_name, secondary, enabled);
}
if ( (key == SOUND_EVENTS_KEY "ring_tone_sound") ||
@@ -191,7 +191,7 @@
name = "ring_tone_sound";
file_name = gm_conf_get_string (SOUND_EVENTS_KEY "ring_tone_sound");
enabled = gm_conf_get_bool (SOUND_EVENTS_KEY "enable_ring_tone_sound");
- audioinput_core.add_event (name, file_name, enabled, primary);
+ audioinput_core.add_event (name, file_name, primary, enabled);
}
}
Modified: trunk/lib/engine/audiooutput/skel/audiooutput-info.h
==============================================================================
--- trunk/lib/engine/audiooutput/skel/audiooutput-info.h (original)
+++ trunk/lib/engine/audiooutput/skel/audiooutput-info.h Wed May 21 22:05:30 2008
@@ -54,7 +54,7 @@
AO_ERROR_WRITE
};
- enum AudioOutputPrimarySecondary {
+ enum AudioOutputPS {
primary = 0,
secondary
};
Modified: trunk/lib/engine/audiooutput/skel/audiooutput-manager.h
==============================================================================
--- trunk/lib/engine/audiooutput/skel/audiooutput-manager.h (original)
+++ trunk/lib/engine/audiooutput/skel/audiooutput-manager.h Wed May 21 22:05:30 2008
@@ -83,7 +83,7 @@
* @param prim whether to set the primary or secondary device.
* @param device the device to be used.
*/
- virtual bool set_device (AudioOutputPrimarySecondary primarySecondary, const AudioOutputDevice & device) = 0;
+ virtual bool set_device (AudioOutputPS ps, const AudioOutputDevice & device) = 0;
/** Open the device.
* The device must be opened before calling set_frame_data(), set_buffer_size() and set_volume().
@@ -95,11 +95,11 @@
* @param bits_per_sample the number bits per sample.
* @return true if the opening succeeded. False if the device cannot be opened.
*/
- virtual bool open (AudioOutputPrimarySecondary primarySecondary, unsigned channels, unsigned samplerate, unsigned bits_per_sample) = 0;
+ virtual bool open (AudioOutputPS ps, unsigned channels, unsigned samplerate, unsigned bits_per_sample) = 0;
/** Close the device.
*/
- virtual void close (AudioOutputPrimarySecondary /*primarySecondary*/) {};
+ virtual void close (AudioOutputPS /*ps*/) {};
/** Set the buffer size.
* The buffer size must be set before calling set_frame_data().
@@ -108,7 +108,7 @@
* @param buffer_size the size of each buffer in bytes.
* @param num_buffers the number of buffers.
*/
- virtual void set_buffer_size (AudioOutputPrimarySecondary /*primarySecondary*/, unsigned /*buffer_size*/, unsigned /*num_buffers*/) {};
+ virtual void set_buffer_size (AudioOutputPS /*ps*/, unsigned /*buffer_size*/, unsigned /*num_buffers*/) {};
/** Set one audio buffer.
* Requires the device to be opened and the buffer size to be set.
@@ -118,7 +118,7 @@
* @param bytes_written returns the number of bytes actually written. Should be equal to size.
* @return false if the writing failed.
*/
- virtual bool set_frame_data (AudioOutputPrimarySecondary primarySecondary,
+ virtual bool set_frame_data (AudioOutputPS ps,
const char *data,
unsigned size,
unsigned & bytes_written) = 0;
@@ -128,7 +128,7 @@
* @param prim wether the volume of the primary or secondary device shall be set.
* @param volume the new volume (0..255).
*/
- virtual void set_volume (AudioOutputPrimarySecondary /*primarySecondary*/, unsigned /* volume */ ) {};
+ virtual void set_volume (AudioOutputPS /*ps*/, unsigned /* volume */ ) {};
/** Returns true if a specific device is supported by the manager.
* If the device specified by sink and device_name is supported by the manager, true
@@ -148,20 +148,20 @@
* @param device the audio output device that was opened.
* @param config the current audio output device configuration (current volume, etc.).
*/
- sigc::signal<void, AudioOutputPrimarySecondary, AudioOutputDevice, AudioOutputConfig> device_opened;
+ sigc::signal<void, AudioOutputPS, AudioOutputDevice, AudioOutputConfig> device_opened;
/** This signal is emitted when an audio output device is closed.
* @param prim whether the primary or secondary audio output device was closed.
* @param device the audio output device that was closed.
*/
- sigc::signal<void, AudioOutputPrimarySecondary, AudioOutputDevice> device_closed;
+ sigc::signal<void, AudioOutputPS, AudioOutputDevice> device_closed;
/** This signal is emitted when an error occurs when opening an audio output device.
* @param prim whether the primary or secondary audio output device caused the error.
* @param device the audio output device that caused the error.
* @param error_code the audio output device error code.
*/
- sigc::signal<void, AudioOutputPrimarySecondary, AudioOutputDevice, AudioOutputErrorCodes> device_error;
+ sigc::signal<void, AudioOutputPS, AudioOutputDevice, AudioOutputErrorCodes> device_error;
protected:
typedef struct ManagerState {
Modified: trunk/lib/engine/audiooutput/skel/audiooutput-scheduler.cpp
==============================================================================
--- trunk/lib/engine/audiooutput/skel/audiooutput-scheduler.cpp (original)
+++ trunk/lib/engine/audiooutput/skel/audiooutput-scheduler.cpp Wed May 21 22:05:30 2008
@@ -42,7 +42,7 @@
AudioEventScheduler::AudioEventScheduler (AudioOutputCore& _audio_output_core)
: PThread (1000, NoAutoDeleteThread, HighestPriority, "AudioEventScheduler"),
- audio_output_core (_audio_output_core)
+ audio_output_core (_audio_output_core)
{
end_thread = false;
// Since windows does not like to restart a thread that
@@ -71,7 +71,7 @@
char* buffer = NULL;
unsigned long buffer_len = 0;
unsigned channels, sample_rate, bps;
- AudioOutputPrimarySecondary primarySecondary;
+ AudioOutputPS ps;
thread_created.Signal ();
@@ -90,9 +90,9 @@
while (pending_event_list.size() > 0) {
event = *(pending_event_list.begin()); pending_event_list.erase(pending_event_list.begin());
- load_wav(event.name, event.is_file_name, buffer, buffer_len, channels, sample_rate, bps, primarySecondary);
+ load_wav(event.name, event.is_file_name, buffer, buffer_len, channels, sample_rate, bps, ps);
if (buffer) {
- audio_output_core.play_buffer (primarySecondary, buffer, buffer_len, channels, sample_rate, bps);
+ audio_output_core.play_buffer (ps, buffer, buffer_len, channels, sample_rate, bps);
free (buffer);
buffer = NULL;
}
@@ -197,7 +197,7 @@
}
}
-void AudioEventScheduler::load_wav(const std::string & event_name, bool is_file_name, char* & buffer, unsigned long & len, unsigned & channels, unsigned & sample_rate, unsigned & bps, AudioOutputPrimarySecondary & primarySecondary)
+void AudioEventScheduler::load_wav(const std::string & event_name, bool is_file_name, char* & buffer, unsigned long & len, unsigned & channels, unsigned & sample_rate, unsigned & bps, AudioOutputPS & ps)
{
PWAVFile* wav = NULL;
std::string file_name;
@@ -208,10 +208,10 @@
// Shall we also try event name as file name?
if (is_file_name) {
file_name = event_name;
- primarySecondary = primary;
+ ps = primary;
}
else
- if (!get_file_name(event_name, file_name, primarySecondary)) // if this event is disabled
+ if (!get_file_name(event_name, file_name, ps)) // if this event is disabled
return;
PTRACE(4, "AEScheduler\tTrying to load " << file_name << " for event " << event_name);
@@ -245,7 +245,7 @@
}
-bool AudioEventScheduler::get_file_name(const std::string & event_name, std::string & file_name, AudioOutputPrimarySecondary & primarySecondary)
+bool AudioEventScheduler::get_file_name(const std::string & event_name, std::string & file_name, AudioOutputPS & ps)
{
PWaitAndSignal m(event_file_list_mutex);
@@ -257,7 +257,7 @@
if (iter->event_name == event_name) {
file_name = iter->file_name;
- primarySecondary = iter->primarySecondary;
+ ps = iter->ps;
return (iter->enabled);
}
}
@@ -265,7 +265,7 @@
return false;
}
-void AudioEventScheduler::set_file_name(const std::string & event_name, const std::string & file_name, bool enabled, AudioOutputPrimarySecondary primarySecondary)
+void AudioEventScheduler::set_file_name(const std::string & event_name, const std::string & file_name, AudioOutputPS ps, bool enabled)
{
PWaitAndSignal m(event_file_list_mutex);
@@ -278,7 +278,7 @@
if (iter->event_name == event_name) {
iter->file_name = file_name;
iter->enabled = enabled;
- iter->primarySecondary = primarySecondary;
+ iter->ps = ps;
found = true;
break;
}
@@ -289,7 +289,7 @@
event_file_name.event_name = event_name;
event_file_name.file_name = file_name;
event_file_name.enabled = enabled;
- event_file_name.primarySecondary = secondary;
+ event_file_name.ps = secondary;
event_file_list.push_back(event_file_name);
}
}
Modified: trunk/lib/engine/audiooutput/skel/audiooutput-scheduler.h
==============================================================================
--- trunk/lib/engine/audiooutput/skel/audiooutput-scheduler.h (original)
+++ trunk/lib/engine/audiooutput/skel/audiooutput-scheduler.h Wed May 21 22:05:30 2008
@@ -61,7 +61,7 @@
std::string event_name;
std::string file_name;
bool enabled;
- AudioOutputPrimarySecondary primarySecondary;
+ AudioOutputPS ps;
};
class AudioOutputCore;
@@ -74,15 +74,15 @@
~AudioEventScheduler();
void add_event_to_queue(const std::string & name, bool is_file_name, unsigned interval, unsigned repetitions);
void remove_event_from_queue(const std::string & name);
- void set_file_name(const std::string & event_name, const std::string & file_name, bool enabled, AudioOutputPrimarySecondary primarySecondary);
+ void set_file_name(const std::string & event_name, const std::string & file_name, AudioOutputPS ps, bool enabled);
protected:
void Main (void);
void get_pending_event_list (std::vector<AudioEvent> & pending_event_list);
unsigned long get_time_ms();
unsigned get_time_to_next_event();
- bool get_file_name(const std::string & event_name, std::string & file_name, AudioOutputPrimarySecondary & primarySecondary);
- void load_wav(const std::string & event_name, bool is_file_name, char* & buffer, unsigned long & len, unsigned & channels, unsigned & sample_rate, unsigned & bps, AudioOutputPrimarySecondary & primarySecondary);
+ bool get_file_name(const std::string & event_name, std::string & file_name, AudioOutputPS & ps);
+ void load_wav(const std::string & event_name, bool is_file_name, char* & buffer, unsigned long & len, unsigned & channels, unsigned & sample_rate, unsigned & bps, AudioOutputPS & ps);
PSyncPoint run_thread;
bool end_thread;
Modified: trunk/lib/engine/engine.cpp
==============================================================================
--- trunk/lib/engine/engine.cpp (original)
+++ trunk/lib/engine/engine.cpp Wed May 21 22:05:30 2008
@@ -253,12 +253,12 @@
audioinput_core->setup_conf_bridge();
sigc::connection conn;
- conn = hal_core->video_input_device_added.connect (sigc::mem_fun (videoinput_core, &Ekiga::VideoInputCore::add_device));
- conn = hal_core->video_input_device_removed.connect (sigc::mem_fun (videoinput_core, &Ekiga::VideoInputCore::remove_device));
- conn = hal_core->audio_output_device_added.connect (sigc::mem_fun (audiooutput_core, &Ekiga::AudioOutputCore::add_device));
- conn = hal_core->audio_output_device_removed.connect (sigc::mem_fun (audiooutput_core, &Ekiga::AudioOutputCore::remove_device));
- conn = hal_core->audio_input_device_added.connect (sigc::mem_fun (audioinput_core, &Ekiga::AudioInputCore::add_device));
- conn = hal_core->audio_input_device_removed.connect (sigc::mem_fun (audioinput_core, &Ekiga::AudioInputCore::remove_device));
+ conn = hal_core->videoinput_device_added.connect (sigc::mem_fun (videoinput_core, &Ekiga::VideoInputCore::add_device));
+ conn = hal_core->videoinput_device_removed.connect (sigc::mem_fun (videoinput_core, &Ekiga::VideoInputCore::remove_device));
+ conn = hal_core->audiooutput_device_added.connect (sigc::mem_fun (audiooutput_core, &Ekiga::AudioOutputCore::add_device));
+ conn = hal_core->audiooutput_device_removed.connect (sigc::mem_fun (audiooutput_core, &Ekiga::AudioOutputCore::remove_device));
+ conn = hal_core->audioinput_device_added.connect (sigc::mem_fun (audioinput_core, &Ekiga::AudioInputCore::add_device));
+ conn = hal_core->audioinput_device_removed.connect (sigc::mem_fun (audioinput_core, &Ekiga::AudioInputCore::remove_device));
// std::vector<sigc::connection> connections;
//connections.push_back (conn);
}
Modified: trunk/lib/engine/framework/device-def.h
==============================================================================
--- trunk/lib/engine/framework/device-def.h (original)
+++ trunk/lib/engine/framework/device-def.h Wed May 21 22:05:30 2008
@@ -104,19 +104,14 @@
else
return false;
}
-
- bool operator!=( const Device & rhs ) const
+
+ bool operator!=( const Device & rhs ) const
{
- if ( (type != rhs.type) ||
- (source != rhs.source) ||
- (name != rhs.name) )
- return true;
- else
- return false;
+ return (!(*this==rhs));
}
friend std::ostream& operator <<(std::ostream & stream, const Device & device){
- stream << device.type << "/" << device.source << "/" << device.name;
+ stream << device.GetString();
return stream;
}
};
Modified: trunk/lib/engine/hal/dbus/hal-manager-dbus.cpp
==============================================================================
--- trunk/lib/engine/hal/dbus/hal-manager-dbus.cpp (original)
+++ trunk/lib/engine/hal/dbus/hal-manager-dbus.cpp Wed May 21 22:05:30 2008
@@ -149,21 +149,21 @@
if (hal_device.category == "alsa") {
if (hal_device.type == "capture") {
- audio_input_device_added.emit(hal_device.category, hal_device.name);
+ audioinput_device_added.emit(hal_device.category, hal_device.name);
}
else if (hal_device.type == "playback") {
- audio_output_device_added.emit(hal_device.category, hal_device.name);
+ audiooutput_device_added.emit(hal_device.category, hal_device.name);
}
}
else if (hal_device.category == "oss") {
- audio_input_device_added.emit(hal_device.category, hal_device.name);
- audio_output_device_added.emit(hal_device.category, hal_device.name);
+ audioinput_device_added.emit(hal_device.category, hal_device.name);
+ audiooutput_device_added.emit(hal_device.category, hal_device.name);
}
else if (hal_device.category == "video4linux") {
if (hal_device.video_capabilities & 0x01)
- video_input_device_added.emit(hal_device.category, hal_device.name, 0x01);
+ videoinput_device_added.emit(hal_device.category, hal_device.name, 0x01);
if (hal_device.video_capabilities & 0x02)
- video_input_device_added.emit(hal_device.category, hal_device.name, 0x02);
+ videoinput_device_added.emit(hal_device.category, hal_device.name, 0x02);
}
}
@@ -187,21 +187,21 @@
if (iter->category == "alsa") {
if (iter->type == "capture") {
- audio_input_device_removed.emit(iter->category, iter->name);
+ audioinput_device_removed.emit(iter->category, iter->name);
}
else if (iter->type == "playback") {
- audio_output_device_removed.emit(iter->category, iter->name);
+ audiooutput_device_removed.emit(iter->category, iter->name);
}
}
else if (iter->category == "oss") {
- audio_input_device_removed.emit(iter->category, iter->name);
- audio_output_device_removed.emit(iter->category, iter->name);
+ audioinput_device_removed.emit(iter->category, iter->name);
+ audiooutput_device_removed.emit(iter->category, iter->name);
}
else if (iter->category == "video4linux") {
if (iter->video_capabilities & 0x01)
- video_input_device_removed.emit(iter->category, iter->name, 0x01);
+ videoinput_device_removed.emit(iter->category, iter->name, 0x01);
if (iter->video_capabilities & 0x02)
- video_input_device_removed.emit(iter->category, iter->name, 0x02);
+ videoinput_device_removed.emit(iter->category, iter->name, 0x02);
}
Modified: trunk/lib/engine/hal/skel/hal-core.cpp
==============================================================================
--- trunk/lib/engine/hal/skel/hal-core.cpp (original)
+++ trunk/lib/engine/hal/skel/hal-core.cpp Wed May 21 22:05:30 2008
@@ -62,14 +62,14 @@
managers.insert (&manager);
manager_added.emit (manager);
- manager.video_input_device_added.connect (sigc::bind (sigc::mem_fun (this, &HalCore::on_video_input_device_added), &manager));
- manager.video_input_device_removed.connect (sigc::bind (sigc::mem_fun (this, &HalCore::on_video_input_device_removed), &manager));
+ manager.videoinput_device_added.connect (sigc::bind (sigc::mem_fun (this, &HalCore::on_videoinput_device_added), &manager));
+ manager.videoinput_device_removed.connect (sigc::bind (sigc::mem_fun (this, &HalCore::on_videoinput_device_removed), &manager));
- manager.audio_input_device_added.connect (sigc::bind (sigc::mem_fun (this, &HalCore::on_audio_input_device_added), &manager));
- manager.audio_input_device_removed.connect (sigc::bind (sigc::mem_fun (this, &HalCore::on_audio_input_device_removed), &manager));
+ manager.audioinput_device_added.connect (sigc::bind (sigc::mem_fun (this, &HalCore::on_audioinput_device_added), &manager));
+ manager.audioinput_device_removed.connect (sigc::bind (sigc::mem_fun (this, &HalCore::on_audioinput_device_removed), &manager));
- manager.audio_output_device_added.connect (sigc::bind (sigc::mem_fun (this, &HalCore::on_audio_output_device_added), &manager));
- manager.audio_output_device_removed.connect (sigc::bind (sigc::mem_fun (this, &HalCore::on_audio_output_device_removed), &manager));
+ manager.audiooutput_device_added.connect (sigc::bind (sigc::mem_fun (this, &HalCore::on_audiooutput_device_added), &manager));
+ manager.audiooutput_device_removed.connect (sigc::bind (sigc::mem_fun (this, &HalCore::on_audiooutput_device_removed), &manager));
manager.network_interface_up.connect (sigc::bind (sigc::mem_fun (this, &HalCore::on_network_interface_up), &manager));
manager.network_interface_down.connect (sigc::bind (sigc::mem_fun (this, &HalCore::on_network_interface_down), &manager));
@@ -86,28 +86,28 @@
go_on = visitor (*(*iter));
}
-void HalCore::on_video_input_device_added (std::string source, std::string device, unsigned capabilities, HalManager* manager) {
- video_input_device_added.emit (source, device, capabilities, manager);
+void HalCore::on_videoinput_device_added (std::string source, std::string device, unsigned capabilities, HalManager* manager) {
+ videoinput_device_added.emit (source, device, capabilities, manager);
}
-void HalCore::on_video_input_device_removed (std::string source, std::string device, unsigned capabilities, HalManager* manager) {
- video_input_device_removed.emit (source, device, capabilities, manager);
+void HalCore::on_videoinput_device_removed (std::string source, std::string device, unsigned capabilities, HalManager* manager) {
+ videoinput_device_removed.emit (source, device, capabilities, manager);
}
-void HalCore::on_audio_input_device_added (std::string source, std::string device, HalManager* manager) {
- audio_input_device_added.emit (source, device, manager);
+void HalCore::on_audioinput_device_added (std::string source, std::string device, HalManager* manager) {
+ audioinput_device_added.emit (source, device, manager);
}
-void HalCore::on_audio_input_device_removed (std::string source, std::string device, HalManager* manager) {
- audio_input_device_removed.emit (source, device, manager);
+void HalCore::on_audioinput_device_removed (std::string source, std::string device, HalManager* manager) {
+ audioinput_device_removed.emit (source, device, manager);
}
-void HalCore::on_audio_output_device_added (std::string sink, std::string device, HalManager* manager) {
- audio_output_device_added.emit (sink, device, manager);
+void HalCore::on_audiooutput_device_added (std::string sink, std::string device, HalManager* manager) {
+ audiooutput_device_added.emit (sink, device, manager);
}
-void HalCore::on_audio_output_device_removed (std::string sink, std::string device, HalManager* manager) {
- audio_output_device_removed.emit (sink, device, manager);
+void HalCore::on_audiooutput_device_removed (std::string sink, std::string device, HalManager* manager) {
+ audiooutput_device_removed.emit (sink, device, manager);
}
void HalCore::on_network_interface_up (std::string interface_name, std::string ip4_address, HalManager* manager) {
Modified: trunk/lib/engine/hal/skel/hal-core.h
==============================================================================
--- trunk/lib/engine/hal/skel/hal-core.h (original)
+++ trunk/lib/engine/hal/skel/hal-core.h Wed May 21 22:05:30 2008
@@ -120,28 +120,28 @@
/** See hal-manager.h for the API
*/
- sigc::signal<void, const std::string &, const std::string &, unsigned, HalManager*> video_input_device_added;
- sigc::signal<void, const std::string &, const std::string &, unsigned, HalManager*> video_input_device_removed;
+ sigc::signal<void, const std::string &, const std::string &, unsigned, HalManager*> videoinput_device_added;
+ sigc::signal<void, const std::string &, const std::string &, unsigned, HalManager*> videoinput_device_removed;
- sigc::signal<void, const std::string &, const std::string &, HalManager*> audio_input_device_added;
- sigc::signal<void, const std::string &, const std::string &, HalManager*> audio_input_device_removed;
+ sigc::signal<void, const std::string &, const std::string &, HalManager*> audioinput_device_added;
+ sigc::signal<void, const std::string &, const std::string &, HalManager*> audioinput_device_removed;
- sigc::signal<void, const std::string &, const std::string &, HalManager*> audio_output_device_added;
- sigc::signal<void, const std::string &, const std::string &, HalManager*> audio_output_device_removed;
+ sigc::signal<void, const std::string &, const std::string &, HalManager*> audiooutput_device_added;
+ sigc::signal<void, const std::string &, const std::string &, HalManager*> audiooutput_device_removed;
sigc::signal<void, const std::string &, const std::string &, HalManager*> network_interface_up;
sigc::signal<void, const std::string &, const std::string &, HalManager*> network_interface_down;
private:
- void on_video_input_device_added (std::string source, std::string device, unsigned capabilities, HalManager* manager);
- void on_video_input_device_removed (std::string source, std::string device, unsigned capabilities, HalManager* manager);
+ void on_videoinput_device_added (std::string source, std::string device, unsigned capabilities, HalManager* manager);
+ void on_videoinput_device_removed (std::string source, std::string device, unsigned capabilities, HalManager* manager);
- void on_audio_input_device_added (std::string source, std::string device, HalManager* manager);
- void on_audio_input_device_removed (std::string source, std::string device, HalManager* manager);
+ void on_audioinput_device_added (std::string source, std::string device, HalManager* manager);
+ void on_audioinput_device_removed (std::string source, std::string device, HalManager* manager);
- void on_audio_output_device_added (std::string sink, std::string device, HalManager* manager);
- void on_audio_output_device_removed (std::string sink, std::string device, HalManager* manager);
+ void on_audiooutput_device_added (std::string sink, std::string device, HalManager* manager);
+ void on_audiooutput_device_removed (std::string sink, std::string device, HalManager* manager);
void on_network_interface_up (std::string interface_name, std::string ip4_address, HalManager* manager);
void on_network_interface_down (std::string interface_name, std::string ip4_address, HalManager* manager);
Modified: trunk/lib/engine/hal/skel/hal-manager.h
==============================================================================
--- trunk/lib/engine/hal/skel/hal-manager.h (original)
+++ trunk/lib/engine/hal/skel/hal-manager.h Wed May 21 22:05:30 2008
@@ -75,38 +75,38 @@
* @param device the device name.
* @param capabilities source-dependent device capabilites (e.g. V4L1 or V4L2 for video4linux).
*/
- sigc::signal<void, std::string, std::string, unsigned> video_input_device_added;
+ sigc::signal<void, std::string, std::string, unsigned> videoinput_device_added;
/** This signal is emitted when a video input device is removed from the system.
* @param source the video input framework (e.g. video4linux, etc.).
* @param device the device name.
* @param capabilities source-dependent device capabilites (e.g. V4L1 or V4L2 for video4linux).
*/
- sigc::signal<void, std::string, std::string, unsigned> video_input_device_removed;
+ sigc::signal<void, std::string, std::string, unsigned> videoinput_device_removed;
/** This signal is emitted when an audio input device is added to the system.
* @param source the audio input framework (e.g. alsa, oss, etc.).
* @param device the device name.
*/
- sigc::signal<void, std::string, std::string> audio_input_device_added;
+ sigc::signal<void, std::string, std::string> audioinput_device_added;
/** This signal is emitted when an audio input device is removed from the system.
* @param source the audio input framework (e.g. alsa, oss, etc.).
* @param device the device name.
*/
- sigc::signal<void, std::string, std::string> audio_input_device_removed;
+ sigc::signal<void, std::string, std::string> audioinput_device_removed;
/** This signal is emitted when an audio output device is added to the system.
* @param source the audio output framework (e.g. alsa, oss, etc.).
* @param device the device name.
*/
- sigc::signal<void, std::string, std::string> audio_output_device_added;
+ sigc::signal<void, std::string, std::string> audiooutput_device_added;
/** This signal is emitted when an audio output device is removed from the system.
* @param source the audio output framework (e.g. alsa, oss, etc.).
* @param device the device name.
*/
- sigc::signal<void, std::string, std::string> audio_output_device_removed;
+ sigc::signal<void, std::string, std::string> audiooutput_device_removed;
/** This signal is emitted when a network device comes up.
* @param interface_name the interface name (e.g. eth0, etc.).
Modified: trunk/lib/engine/videoinput/mlogo/videoinput-manager-mlogo.cpp
==============================================================================
--- trunk/lib/engine/videoinput/mlogo/videoinput-manager-mlogo.cpp (original)
+++ trunk/lib/engine/videoinput/mlogo/videoinput-manager-mlogo.cpp Wed May 21 22:05:30 2008
@@ -97,13 +97,13 @@
current_state.opened = true;
- Ekiga::VidInputConfig config;
- config.whiteness = 127;
- config.brightness = 127;
- config.colour = 127;
- config.contrast = 127;
- config.modifyable = false;
- runtime.run_in_main (sigc::bind (device_opened.make_slot (), current_state.device, config));
+ Ekiga::VideoInputSettings settings;
+ settings.whiteness = 127;
+ settings.brightness = 127;
+ settings.colour = 127;
+ settings.contrast = 127;
+ settings.modifyable = false;
+ runtime.run_in_main (sigc::bind (device_opened.make_slot (), current_state.device, settings));
return true;
}
Modified: trunk/lib/engine/videoinput/ptlib/videoinput-manager-ptlib.cpp
==============================================================================
--- trunk/lib/engine/videoinput/ptlib/videoinput-manager-ptlib.cpp (original)
+++ trunk/lib/engine/videoinput/ptlib/videoinput-manager-ptlib.cpp Wed May 21 22:05:30 2008
@@ -135,14 +135,14 @@
input_device->GetParameters (&whiteness, &brightness, &colour, &contrast, &hue);
current_state.opened = true;
- Ekiga::VidInputConfig config;
- config.whiteness = whiteness >> 8;
- config.brightness = brightness >> 8;
- config.colour = colour >> 8;
- config.contrast = contrast >> 8;
- config.modifyable = true;
+ Ekiga::VideoInputSettings settings;
+ settings.whiteness = whiteness >> 8;
+ settings.brightness = brightness >> 8;
+ settings.colour = colour >> 8;
+ settings.contrast = contrast >> 8;
+ settings.modifyable = true;
- runtime.run_in_main (sigc::bind (device_opened.make_slot (), current_state.device, config));
+ runtime.run_in_main (sigc::bind (device_opened.make_slot (), current_state.device, settings));
return true;
}
Modified: trunk/lib/engine/videoinput/skel/videoinput-core.cpp
==============================================================================
--- trunk/lib/engine/videoinput/skel/videoinput-core.cpp (original)
+++ trunk/lib/engine/videoinput/skel/videoinput-core.cpp Wed May 21 22:05:30 2008
@@ -25,7 +25,7 @@
/*
- * vidinput-core.cpp - description
+ * videoinput-core.cpp - description
* ------------------------------------------
* begin : written in 2008 by Matthias Schneider
* copyright : (c) 2008 by Matthias Schneider
@@ -44,8 +44,8 @@
using namespace Ekiga;
-PreviewManager::PreviewManager (VideoInputCore& _videoinput_core, VideoOutputCore& _videooutput_core)
-: PThread (1000, NoAutoDeleteThread, HighestPriority, "PreviewManager"),
+VideoInputCore::VideoPreviewManager::VideoPreviewManager (VideoInputCore& _videoinput_core, VideoOutputCore& _videooutput_core)
+: PThread (1000, NoAutoDeleteThread, HighestPriority, "VideoPreviewManager"),
videoinput_core (_videoinput_core),
videooutput_core (_videooutput_core)
{
@@ -53,33 +53,33 @@
// Since windows does not like to restart a thread that
// was never started, we do so here
this->Resume ();
- PWaitAndSignal m(quit_mutex);
+ PWaitAndSignal m(thread_ended);
}
-PreviewManager::~PreviewManager ()
+VideoInputCore::VideoPreviewManager::~VideoPreviewManager ()
{
- if (!stop_thread)
+ if (!end_thread)
stop();
}
-void PreviewManager::start (unsigned width, unsigned height)
+void VideoInputCore::VideoPreviewManager::start (unsigned width, unsigned height)
{
PTRACE(4, "PreviewManager\tStarting Preview");
- stop_thread = false;
+ end_thread = false;
frame = (char*) malloc (unsigned (width * height * 3 / 2));
videooutput_core.start();
this->Restart ();
- thread_sync_point.Wait ();
+ thread_created.Wait ();
}
-void PreviewManager::stop ()
+void VideoInputCore::VideoPreviewManager::stop ()
{
PTRACE(4, "PreviewManager\tStopping Preview");
- stop_thread = true;
+ end_thread = true;
/* Wait for the Main () method to be terminated */
- PWaitAndSignal m(quit_mutex);
+ PWaitAndSignal m(thread_ended);
if (frame) {
free (frame);
@@ -88,17 +88,17 @@
videooutput_core.stop();
}
-void PreviewManager::Main ()
+void VideoInputCore::VideoPreviewManager::Main ()
{
- PWaitAndSignal m(quit_mutex);
- thread_sync_point.Signal ();
+ PWaitAndSignal m(thread_ended);
+ thread_created.Signal ();
if (!frame)
return;
unsigned width = 176;
unsigned height = 144;;
- while (!stop_thread) {
+ while (!end_thread) {
videoinput_core.get_frame_data(frame, width, height);
videooutput_core.set_frame_data(frame, width, height, true, 1);
@@ -114,36 +114,28 @@
: runtime (_runtime),
preview_manager(*this, _videooutput_core)
{
- PWaitAndSignal m_var(var_mutex);
- PWaitAndSignal m_set(set_mutex);
+ PWaitAndSignal m_var(core_mutex);
+ PWaitAndSignal m_set(settings_mutex);
preview_config.active = false;
preview_config.width = 176;
preview_config.height = 144;
preview_config.fps = 30;
- preview_config.settings.brightness = 0;
- preview_config.settings.whiteness = 0;
- preview_config.settings.colour = 0;
- preview_config.settings.contrast = 0;
-
- new_preview_settings.brightness = 0;
- new_preview_settings.whiteness = 0;
- new_preview_settings.colour = 0;
- new_preview_settings.contrast = 0;
stream_config.active = false;
stream_config.width = 176;
stream_config.height = 144;
stream_config.fps = 30;
- stream_config.settings.brightness = 0;
- stream_config.settings.whiteness = 0;
- stream_config.settings.colour = 0;
- stream_config.settings.contrast = 0;
-
- new_stream_settings.brightness = 0;
- new_stream_settings.whiteness = 0;
- new_stream_settings.colour = 0;
- new_stream_settings.contrast = 0;
+
+ current_settings.brightness = 0;
+ current_settings.whiteness = 0;
+ current_settings.colour = 0;
+ current_settings.contrast = 0;
+
+ desired_settings.brightness = 0;
+ desired_settings.whiteness = 0;
+ desired_settings.colour = 0;
+ desired_settings.contrast = 0;
current_manager = NULL;
videoinput_core_conf_bridge = NULL;
@@ -155,7 +147,7 @@
std::cout << __PRETTY_FUNCTION__ << std::endl;
#endif
- PWaitAndSignal m(var_mutex);
+ PWaitAndSignal m(core_mutex);
if (videoinput_core_conf_bridge)
delete videoinput_core_conf_bridge;
@@ -163,7 +155,7 @@
void VideoInputCore::setup_conf_bridge ()
{
- PWaitAndSignal m(var_mutex);
+ PWaitAndSignal m(core_mutex);
videoinput_core_conf_bridge = new VideoInputCoreConfBridge (*this);
}
@@ -181,18 +173,18 @@
void VideoInputCore::visit_managers (sigc::slot<bool, VideoInputManager &> visitor)
{
- PWaitAndSignal m(var_mutex);
+ PWaitAndSignal m(core_mutex);
bool go_on = true;
for (std::set<VideoInputManager *>::iterator iter = managers.begin ();
iter != managers.end () && go_on;
iter++)
go_on = visitor (*(*iter));
-}
+}
void VideoInputCore::get_devices (std::vector <VideoInputDevice> & devices)
{
- PWaitAndSignal m(var_mutex);
+ PWaitAndSignal m(core_mutex);
devices.clear();
@@ -212,45 +204,85 @@
void VideoInputCore::set_device(const VideoInputDevice & device, int channel, VideoInputFormat format)
{
- PWaitAndSignal m(var_mutex);
- internal_set_vidinput_device(device, channel, format);
+ PWaitAndSignal m(core_mutex);
+ internal_set_device(device, channel, format);
desired_device = device;
}
+void VideoInputCore::add_device (const std::string & source, const std::string & device_name, unsigned capabilities, HalManager* /*manager*/)
+{
+ PTRACE(0, "VidInputCore\tAdding Device " << device_name);
+ PWaitAndSignal m(core_mutex);
+
+ VideoInputDevice device;
+ for (std::set<VideoInputManager *>::iterator iter = managers.begin ();
+ iter != managers.end ();
+ iter++) {
+ if ((*iter)->has_device (source, device_name, capabilities, device)) {
+
+ if ( desired_device == device )
+ internal_set_device(device, current_channel, current_format);
+
+ runtime.run_in_main (sigc::bind (device_added.make_slot (), device));
+ }
+ }
+}
+
+void VideoInputCore::remove_device (const std::string & source, const std::string & device_name, unsigned capabilities, HalManager* /*manager*/)
+{
+ PTRACE(0, "VidInputCore\tRemoving Device " << device_name);
+ PWaitAndSignal m(core_mutex);
+
+ VideoInputDevice device;
+ for (std::set<VideoInputManager *>::iterator iter = managers.begin ();
+ iter != managers.end ();
+ iter++) {
+ if ((*iter)->has_device (source, device_name, capabilities, device)) {
+ if ( current_device == device ) {
+
+ VideoInputDevice new_device;
+ new_device.type = VIDEO_INPUT_FALLBACK_DEVICE_TYPE;
+ new_device.source = VIDEO_INPUT_FALLBACK_DEVICE_SOURCE;
+ new_device.name = VIDEO_INPUT_FALLBACK_DEVICE_NAME;
+ internal_set_device(new_device, current_channel, current_format);
+ }
+
+ runtime.run_in_main (sigc::bind (device_removed.make_slot (), device));
+ }
+ }
+}
void VideoInputCore::set_preview_config (unsigned width, unsigned height, unsigned fps)
{
- PWaitAndSignal m(var_mutex);
+ PWaitAndSignal m(core_mutex);
+
+ VideoDeviceConfig new_preview_config(width, height, fps);
- PTRACE(4, "VidInputCore\tSetting new preview config: " << width << "x" << height << "/" << fps);
+ PTRACE(4, "VidInputCore\tSetting new preview config: " << new_preview_config);
// There is only one state where we have to reopen the preview device:
// we have preview enabled, no stream is active and some value has changed
if ( ( preview_config.active && !stream_config.active) &&
- ( preview_config.width != width ||
- preview_config.height != height ||
- preview_config.fps != fps ) )
+ ( preview_config != new_preview_config) )
{
preview_manager.stop();
internal_close();
- internal_open(width, height, fps);
- preview_manager.start(width, height);
+ internal_open(new_preview_config.width, new_preview_config.height, new_preview_config.fps);
+ preview_manager.start(new_preview_config.width, new_preview_config.height);
}
- preview_config.width = width;
- preview_config.height = height;
- preview_config.fps = fps;
+ preview_config = new_preview_config;
}
void VideoInputCore::start_preview ()
{
- PWaitAndSignal m(var_mutex);
+ PWaitAndSignal m(core_mutex);
- PTRACE(4, "VidInputCore\tStarting preview " << preview_config.width << "x" << preview_config.height << "/" << preview_config.fps);
+ PTRACE(4, "VidInputCore\tStarting preview " << preview_config);
if (!preview_config.active && !stream_config.active) {
internal_open(preview_config.width, preview_config.height, preview_config.fps);
- preview_manager.start(preview_config.width,preview_config.height);
+ preview_manager.start(preview_config.width, preview_config.height);
}
preview_config.active = true;
@@ -258,13 +290,13 @@
void VideoInputCore::stop_preview ()
{
- PWaitAndSignal m(var_mutex);
+ PWaitAndSignal m(core_mutex);
PTRACE(4, "VidInputCore\tStopping Preview");
if (preview_config.active && !stream_config.active) {
preview_manager.stop();
internal_close();
- internal_set_device(desired_device, current_channel, current_format);
+ internal_set_manager(desired_device, current_channel, current_format);
}
preview_config.active = false;
@@ -272,31 +304,28 @@
void VideoInputCore::set_stream_config (unsigned width, unsigned height, unsigned fps)
{
- PWaitAndSignal m(var_mutex);
+ PWaitAndSignal m(core_mutex);
+
+ VideoDeviceConfig new_stream_config(width, height, fps);
+ PTRACE(4, "VidInputCore\tSetting new stream config: " << new_stream_config);
- PTRACE(4, "VidInputCore\tSetting new stream config: " << width << "x" << height << "/" << fps);
// We do not support switching of framerate or resolution within a stream
// since many endpoints will probably have problems with that. Also, it would add
// a lot of complexity due to the capabilities exchange. Thus these values will
// not be used until the next start_stream.
- if (!stream_config.active) {
- stream_config.width = width;
- stream_config.height = height;
- stream_config.fps = fps;
- }
+ if (!stream_config.active)
+ stream_config = new_stream_config;
}
void VideoInputCore::start_stream ()
{
- PWaitAndSignal m(var_mutex);
+ PWaitAndSignal m(core_mutex);
- PTRACE(4, "VidInputCore\tStarting stream " << stream_config.width << "x" << stream_config.height << "/" << stream_config.fps);
+ PTRACE(4, "VidInputCore\tStarting stream " << stream_config);
if (preview_config.active && !stream_config.active) {
preview_manager.stop();
- if ( preview_config.width != stream_config.width ||
- preview_config.height != stream_config.height ||
- preview_config.fps != stream_config.fps )
+ if ( preview_config != stream_config )
{
internal_close();
internal_open(stream_config.width, stream_config.height, stream_config.fps);
@@ -312,16 +341,14 @@
void VideoInputCore::stop_stream ()
{
- PWaitAndSignal m(var_mutex);
+ PWaitAndSignal m(core_mutex);
PTRACE(4, "VidInputCore\tStopping Stream");
if (preview_config.active && stream_config.active) {
- if ( preview_config.width != stream_config.width ||
- preview_config.height != stream_config.height ||
- preview_config.fps != stream_config.fps )
+ if ( preview_config != stream_config )
{
internal_close();
- internal_set_device(desired_device, current_channel, current_format);
+ internal_set_manager(desired_device, current_channel, current_format);
internal_open(preview_config.width, preview_config.height, preview_config.fps);
}
preview_manager.start(preview_config.width, preview_config.height);
@@ -329,7 +356,7 @@
if (!preview_config.active && stream_config.active) {
internal_close();
- internal_set_device(desired_device, current_channel, current_format);
+ internal_set_manager(desired_device, current_channel, current_format);
}
stream_config.active = false;
@@ -339,7 +366,7 @@
unsigned & width,
unsigned & height)
{
- PWaitAndSignal m(var_mutex);
+ PWaitAndSignal m(core_mutex);
if (current_manager) {
if (!current_manager->get_frame_data(data, width, height)) {
@@ -357,107 +384,39 @@
if (current_manager)
current_manager->get_frame_data(data, width, height); // the default device must always return true
}
- apply_settings();
- }
-}
-
-void VideoInputCore::apply_settings()
-{
- PWaitAndSignal m_set(set_mutex);
- if (preview_config.active && !stream_config.active) {
-
- if (new_preview_settings.colour != preview_config.settings.colour) {
- current_manager->set_colour (new_preview_settings.colour);
- preview_config.settings.colour = new_preview_settings.colour;
- }
-
- if (new_preview_settings.brightness != preview_config.settings.brightness) {
- current_manager->set_brightness (new_preview_settings.brightness);
- preview_config.settings.brightness = new_preview_settings.brightness;
- }
-
- if (new_preview_settings.whiteness != preview_config.settings.whiteness) {
- current_manager->set_whiteness (new_preview_settings.whiteness);
- preview_config.settings.whiteness = new_preview_settings.whiteness;
- }
-
- if (new_preview_settings.contrast != preview_config.settings.contrast) {
- current_manager->set_contrast (new_preview_settings.contrast);
- preview_config.settings.contrast = new_preview_settings.contrast;
- }
-
- }
-
- if (!preview_config.active && stream_config.active) {
-
- if (new_stream_settings.colour != stream_config.settings.colour) {
- current_manager->set_colour (new_stream_settings.colour);
- stream_config.settings.colour = new_stream_settings.colour;
- }
-
- if (new_stream_settings.brightness != stream_config.settings.brightness) {
- current_manager->set_brightness (new_stream_settings.brightness);
- stream_config.settings.brightness = new_stream_settings.brightness;
- }
-
- if (new_stream_settings.whiteness != stream_config.settings.whiteness) {
- current_manager->set_whiteness (new_stream_settings.whiteness);
- stream_config.settings.whiteness = new_stream_settings.whiteness;
- }
-
- if (new_stream_settings.contrast != stream_config.settings.contrast) {
- current_manager->set_contrast (new_stream_settings.contrast);
- stream_config.settings.contrast = new_stream_settings.contrast;
- }
-
+ internal_apply_settings();
}
}
void VideoInputCore::set_colour (unsigned colour)
{
- PWaitAndSignal m(set_mutex);
- if (preview_config.active && !stream_config.active)
- new_preview_settings.colour = colour;
-
- if (!preview_config.active && stream_config.active)
- new_stream_settings.colour = colour;
+ PWaitAndSignal m(settings_mutex);
+ desired_settings.colour = colour;
}
void VideoInputCore::set_brightness (unsigned brightness)
{
- PWaitAndSignal m(set_mutex);
- if (preview_config.active && !stream_config.active)
- new_preview_settings.brightness = brightness;
-
- if (!preview_config.active && stream_config.active)
- new_stream_settings.brightness = brightness;
+ PWaitAndSignal m(settings_mutex);
+ desired_settings.brightness = brightness;
}
void VideoInputCore::set_whiteness (unsigned whiteness)
{
- PWaitAndSignal m(set_mutex);
- if (preview_config.active && !stream_config.active)
- new_preview_settings.whiteness = whiteness;
-
- if (!preview_config.active && stream_config.active)
- new_stream_settings.whiteness = whiteness;
+ PWaitAndSignal m(settings_mutex);
+ desired_settings.whiteness = whiteness;
}
void VideoInputCore::set_contrast (unsigned contrast)
{
- PWaitAndSignal m(set_mutex);
- if (preview_config.active && !stream_config.active)
- new_preview_settings.contrast = contrast ;
-
- if (!preview_config.active && stream_config.active)
- new_stream_settings.contrast = contrast ;
+ PWaitAndSignal m(settings_mutex);
+ desired_settings.contrast = contrast;
}
void VideoInputCore::on_device_opened (VideoInputDevice device,
- VidInputConfig vidinput_config,
+ VideoInputSettings settings,
VideoInputManager *manager)
{
- device_opened.emit (*manager, device, vidinput_config);
+ device_opened.emit (*manager, device, settings);
}
void VideoInputCore::on_device_closed (VideoInputDevice device, VideoInputManager *manager)
@@ -470,7 +429,7 @@
device_error.emit (*manager, device, error_code);
}
-void VideoInputCore::internal_set_vidinput_device(const VideoInputDevice & device, int channel, VideoInputFormat format)
+void VideoInputCore::internal_set_device(const VideoInputDevice & device, int channel, VideoInputFormat format)
{
PTRACE(4, "VidInputCore\tSetting device: " << device);
@@ -480,7 +439,7 @@
if (preview_config.active || stream_config.active)
internal_close();
- internal_set_device (device, channel, format);
+ internal_set_manager (device, channel, format);
if (preview_config.active && !stream_config.active) {
internal_open(preview_config.width, preview_config.height, preview_config.fps);
@@ -491,19 +450,7 @@
internal_open(stream_config.width, stream_config.height, stream_config.fps);
}
-void VideoInputCore::internal_open (unsigned width, unsigned height, unsigned fps)
-{
- PTRACE(4, "VidInputCore\tOpening device with " << width << "x" << height << "/" << fps );
-
- if (current_manager && !current_manager->open(width, height, fps)) {
-
- internal_set_fallback();
- if (current_manager)
- current_manager->open(width, height, fps);
- }
-}
-
-void VideoInputCore::internal_set_device (const VideoInputDevice & device, int channel, VideoInputFormat format)
+void VideoInputCore::internal_set_manager (const VideoInputDevice & device, int channel, VideoInputFormat format)
{
current_manager = NULL;
for (std::set<VideoInputManager *>::iterator iter = managers.begin ();
@@ -529,12 +476,6 @@
current_format = format;
}
-void VideoInputCore::internal_close()
-{
- PTRACE(4, "VidInputCore\tClosing current device");
- if (current_manager)
- current_manager->close();
-}
void VideoInputCore::internal_set_fallback ()
{
@@ -543,54 +484,49 @@
current_device.name = VIDEO_INPUT_FALLBACK_DEVICE_NAME;
PTRACE(3, "VidInputCore\tFalling back to " << current_device);
- internal_set_device(current_device, current_channel, current_format);
+ internal_set_manager(current_device, current_channel, current_format);
}
-void VideoInputCore::add_device (const std::string & source, const std::string & device_name, unsigned capabilities, HalManager* /*manager*/)
+void VideoInputCore::internal_open (unsigned width, unsigned height, unsigned fps)
{
- PTRACE(0, "VidInputCore\tAdding Device " << device_name);
- PWaitAndSignal m(var_mutex);
-
- VideoInputDevice device;
- for (std::set<VideoInputManager *>::iterator iter = managers.begin ();
- iter != managers.end ();
- iter++) {
- if ((*iter)->has_device (source, device_name, capabilities, device)) {
+ PTRACE(4, "VidInputCore\tOpening device with " << width << "x" << height << "/" << fps );
- if ( ( desired_device.type == device.type ) &&
- ( desired_device.source == device.source ) &&
- ( desired_device.name == device.name ) ) {
- internal_set_vidinput_device(device, current_channel, current_format);
- }
+ if (current_manager && !current_manager->open(width, height, fps)) {
- runtime.run_in_main (sigc::bind (device_added.make_slot (), device));
- }
+ internal_set_fallback();
+ if (current_manager)
+ current_manager->open(width, height, fps);
}
}
-void VideoInputCore::remove_device (const std::string & source, const std::string & device_name, unsigned capabilities, HalManager* /*manager*/)
+void VideoInputCore::internal_close()
{
- PTRACE(0, "VidInputCore\tRemoving Device " << device_name);
- PWaitAndSignal m(var_mutex);
+ PTRACE(4, "VidInputCore\tClosing current device");
+ if (current_manager)
+ current_manager->close();
+}
- VideoInputDevice device;
- for (std::set<VideoInputManager *>::iterator iter = managers.begin ();
- iter != managers.end ();
- iter++) {
- if ((*iter)->has_device (source, device_name, capabilities, device)) {
- if ( ( current_device.type == device.type ) &&
- ( current_device.source == device.source ) &&
- ( current_device.name == device.name ) ) {
+void VideoInputCore::internal_apply_settings()
+{
+ PWaitAndSignal m_set(settings_mutex);
- VideoInputDevice new_device;
- new_device.type = VIDEO_INPUT_FALLBACK_DEVICE_TYPE;
- new_device.source = VIDEO_INPUT_FALLBACK_DEVICE_SOURCE;
- new_device.name = VIDEO_INPUT_FALLBACK_DEVICE_NAME;
- internal_set_vidinput_device(new_device, current_channel, current_format);
- }
+ if (desired_settings.colour != current_settings.colour) {
+ current_manager->set_colour (desired_settings.colour);
+ current_settings.colour = desired_settings.colour;
+ }
- runtime.run_in_main (sigc::bind (device_removed.make_slot (), device));
- }
+ if (desired_settings.brightness != current_settings.brightness) {
+ current_manager->set_brightness (desired_settings.brightness);
+ current_settings.brightness = desired_settings.brightness;
}
-}
+ if (desired_settings.whiteness != current_settings.whiteness) {
+ current_manager->set_whiteness (desired_settings.whiteness);
+ current_settings.whiteness = desired_settings.whiteness;
+ }
+
+ if (desired_settings.contrast != current_settings.contrast) {
+ current_manager->set_contrast (desired_settings.contrast);
+ current_settings.contrast = desired_settings.contrast;
+ }
+}
Modified: trunk/lib/engine/videoinput/skel/videoinput-core.h
==============================================================================
--- trunk/lib/engine/videoinput/skel/videoinput-core.h (original)
+++ trunk/lib/engine/videoinput/skel/videoinput-core.h Wed May 21 22:05:30 2008
@@ -57,43 +57,13 @@
namespace Ekiga
{
- typedef struct DeviceConfig {
- bool active;
- unsigned width;
- unsigned height;
- unsigned fps;
- VidInputConfig settings;
- };
-
- class VideoInputManager;
- class VideoInputCore;
-
- class PreviewManager : public PThread
- {
- PCLASSINFO(PreviewManager, PThread);
-
- public:
- PreviewManager(VideoInputCore& _videoinput_core, VideoOutputCore& _videooutput_core);
- ~PreviewManager();
- virtual void start(unsigned width, unsigned height);
- virtual void stop();
-
- protected:
- void Main (void);
- bool stop_thread;
- char* frame;
- PMutex quit_mutex; /* To exit */
- PSyncPoint thread_sync_point;
- VideoInputCore & videoinput_core;
- VideoOutputCore & videooutput_core;
- };
-
/**
* @defgroup videoinput
* @{
*/
-
+ class VideoInputManager;
+ class VideoInputCore;
/** Core object for the video vidinput support
*/
@@ -103,16 +73,21 @@
public:
- /* The constructor
- */
+ /** The constructor
+ * @param _runtime reference to Ekiga runtime.
+ * @param _videooutput_core reference ot the video output core.
+ */
VideoInputCore (Ekiga::Runtime & _runtime, VideoOutputCore& _videooutput_core);
- /* The destructor
- */
+ /** The destructor
+ */
~VideoInputCore ();
+ /** Set up gmconf bridge
+ */
void setup_conf_bridge();
+
/*** Service Implementation ***/
/** Returns the name of the service.
@@ -128,7 +103,6 @@
const std::string get_description () const
{ return "\tVideoInput Core managing VideoInput Manager objects"; }
-
/** Adds a VideoInputManager to the VideoInputCore service.
* @param The manager to be added.
*/
@@ -145,85 +119,296 @@
sigc::signal<void, VideoInputManager &> manager_added;
+ /*** VideoInput Device Management ***/
+
+ /** Get a list of all devices supported by all managers registered to the core.
+ * @param devices a vector of device names to be filled by the core.
+ */
void get_devices(std::vector <VideoInputDevice> & devices);
+ /** Set a specific device
+ * This function sets the current video input device. This function can
+ * also be used while in a stream or in preview mode. In that case the old
+ * device is closed and the new device opened automatically.
+ * @param device the new device to be used.
+ * @param channel the new channel to be used.
+ * @param format the new format to be used.
+ */
void set_device(const VideoInputDevice & device, int channel, VideoInputFormat format);
-
- /* To transmit a user specified image, pass a pointer to a raw YUV image*/
+
+ /** Inform the core of an added videoinput device
+ * This function is called by the HalCore when a video device is added.
+ * It determines responsible managers for that specific device and informs the
+ * GUI about the device that was added (via device_added signal).
+ * In case the added device was the desired device and we fell back,
+ * we will reactivate it.
+ * @param source the device source (e.g. video4linux).
+ * @param device_name the name of the added device.
+ * @param capabilities used for differentiating V4L1 and V4L2.
+ * @param manager the HalManger detected the addition.
+ */
+ void add_device (const std::string & source, const std::string & device_name, unsigned capabilities, HalManager* manager);
+
+ /** Inform the core of a removed videoinput device
+ * This function is called by the HalCore when a video device is removed.
+ * It determines responsible managers for that specific device and informs the
+ * GUI about the device that was removed (via device_removed signal).
+ * In case the removed device was the current device we fall back to the
+ * fallback device.
+ * @param source the device source (e.g. video4linux).
+ * @param device_name the name of the removed device.
+ * @param capabilities used for differentiating V4L1 and V4L2.
+ * @param manager the HalManger detected the removal.
+ */
+ void remove_device (const std::string & source, const std::string & device_name, unsigned capabilities, HalManager* manager);
+
+ /** Set still image data
+ * In case there is a manager that allows trasmitting a still image,
+ * this function can be used to set the actual image data. All other
+ * managers can safely ignore this function.
+ * @param width the width of the image in pixels.
+ * @param height the height of the image in pixels.
+ * @param data a pointer to the image data in YUV420P format.
+ */
void set_image_data (unsigned width, unsigned height, const char* data);
- /*** VidInput Management ***/
+ /*** VideoInput Stream and Preview Management ***/
+
+ /** Set the preview configuration
+ * This function sets the resolution and framerate for the preview mode. In case
+ * preview is not active (due to active stream or because it is simply off), it will
+ * be applied the next time it is (re)started. In case preview is active,
+ * the new configuration will be applied immediately by closing and reopening the device.
+ * @param width the frame width.
+ * @param height the frame height.
+ * @param fps the frame rate.
+ */
void set_preview_config (unsigned width, unsigned height, unsigned fps);
-
+
+ /** Start the preview mode
+ * Start the preview thread implemented in the PreviewManager.
+ * In case a stream is active, this will not have an effect until the stream is stopped.
+ */
void start_preview ();
+ /** Stop the preview mode
+ */
void stop_preview ();
+
+ /** Set the stream configuration
+ * This function sets the resolution and framerate for the stream mode, which
+ * can be different from the preview configuration due to negotiated capabilities.
+ * The configuration will be applied on the next call of start_stream(), in order
+ * not to confuse simple endpoints that do not support switching of the resolution in
+ * mid-stream.
+ * @param width the frame width.
+ * @param height the frame height.
+ * @param fps the frame rate.
+ */
void set_stream_config (unsigned width, unsigned height, unsigned fps);
+ /** Start the stream mode
+ * In case that the preview mode was active and had a different configuration,
+ * the core will reopen the device automatically.
+ */
void start_stream ();
+ /** Stop the stream mode
+ * In case preview mode has been started, the core will switch to preview mode.
+ * In that case, and if the preview mode has a different configuration,
+ * the core will reopen the device automatically.
+ */
void stop_stream ();
+ /** Get one video frame buffer from the current manager.
+ * This function will block until the buffer is completely filled.
+ * Requires the stream or the preview (when being called from the
+ * VideoPreviewManager) to be started.
+ * In case the device returns an error reading the frame, get_frame_data()
+ * falls back to the fallback device and reads the frame from there. Thus
+ * get_frame_data() always returns a frame.
+ * In case a new brightness, whiteness, etc. has bee set, it will be applied here.
+ * @param data a pointer to the frame buffer that is to be filled. The memory has to be allocated already.
+ * @param width returns the actual width of the frame read.
+ * @param height returns the actual height of the frame read.
+ */
void get_frame_data (char *data,
unsigned & width,
unsigned & height);
+ /** See vidinput-manager.h for the API
+ */
void set_colour (unsigned colour);
void set_brightness (unsigned brightness);
void set_whiteness (unsigned whiteness);
void set_contrast (unsigned contrast);
- void add_device (const std::string & source, const std::string & device_name, unsigned capabilities, HalManager* manager);
- void remove_device (const std::string & source, const std::string & device_name, unsigned capabilities, HalManager* manager);
- /*** VidInput Related Signals ***/
-
+ /*** VideoInput related Signals ***/
+
/** See videoinput-manager.h for the API
*/
- sigc::signal<void, VideoInputManager &, VideoInputDevice &, VidInputConfig&> device_opened;
+ sigc::signal<void, VideoInputManager &, VideoInputDevice &, VideoInputSettings&> device_opened;
sigc::signal<void, VideoInputManager &, VideoInputDevice &> device_closed;
sigc::signal<void, VideoInputManager &, VideoInputDevice &, VideoInputErrorCodes> device_error;
+
+ /** This signal is emitted when a video input has been added to the system.
+ * This signal will be emitted if add_device was called with a device name and
+ * a manager claimed support for this device.
+ * @param device the video input device that was added.
+ */
sigc::signal<void, VideoInputDevice> device_added;
+
+ /** This signal is emitted when a video input has been removed from the system.
+ * This signal will be emitted if remove_device was called with a device name and
+ * a manager claimed support for this device.
+ * @param device the video input device that was removed.
+ */
sigc::signal<void, VideoInputDevice> device_removed;
private:
void on_device_opened (VideoInputDevice device,
- VidInputConfig vidinput_config,
+ VideoInputSettings settings,
VideoInputManager *manager);
void on_device_closed (VideoInputDevice device, VideoInputManager *manager);
void on_device_error (VideoInputDevice device, VideoInputErrorCodes error_code, VideoInputManager *manager);
- void internal_set_vidinput_device(const VideoInputDevice & vidinput_device, int channel, VideoInputFormat format);
+ void internal_set_device(const VideoInputDevice & vidinput_device, int channel, VideoInputFormat format);
+ void internal_set_manager (const VideoInputDevice & vidinput_device, int channel, VideoInputFormat format);
+ void internal_set_fallback ();
+
void internal_open (unsigned width, unsigned height, unsigned fps);
void internal_close();
- void internal_set_device (const VideoInputDevice & vidinput_device, int channel, VideoInputFormat format);
- void internal_set_fallback ();
- void apply_settings();
+ void internal_apply_settings();
+private:
+ /** VideoPreviewManager thread.
+ *
+ * VideoPreviewManager represents a thread that gets frames from the
+ * video input core and passes them to the video output core. This is
+ * used for displaying the preview video. This thread will run only
+ * while preview is active. It is called from the VideoInputCore, which
+ * has the interface to the application for enabling and disabling the preview.
+ */
+ class VideoPreviewManager : public PThread
+ {
+ PCLASSINFO(VideoPreviewManager, PThread);
+
+ public:
+ /** The constructor
+ * @param _videoinput_core reference to the video input core.
+ * @param _videooutput_core reference to the video output core.
+ */
+ VideoPreviewManager(VideoInputCore & _videoinput_core, VideoOutputCore & _videooutput_core);
+
+ /** The destructor
+ */
+ ~VideoPreviewManager();
+
+ /** Start the preview thread.
+ * Start the thread represented by the Main() function. Block until the thread is running.
+ * Requires the the current device to be opened.
+ * In case the resolution is changed, the preview manager has to be stopped and restarted.
+ * @param width the frame width in pixels of the preview video.
+ * @param height the frame width in pixels of the preview video.
+ */
+ virtual void start(unsigned width, unsigned height);
+
+ /** Stop the preview thread.
+ * Stop the thread represented by the Main() function. Blocks until the thread has terminated.
+ */
+ virtual void stop();
+
+ protected:
+ void Main ();
+ char* frame;
+
+ bool end_thread;
+ PMutex thread_ended;
+ PSyncPoint thread_created;
+
+ VideoInputCore & videoinput_core;
+ VideoOutputCore & videooutput_core;
+ };
+
+ /** Class for storing the device configuration.
+ *
+ * This class is used for storing the device configuration when
+ * streaming video or when in preview mode. The device configuration
+ * consists of width, height and framerate. This class can be used to
+ * check whether stream and preview configuration is different and
+ * thus if a device needs to be reopened when switching between stream
+ * and preview mode.
+ */
+ class VideoDeviceConfig
+ {
+ public:
+ bool active;
+ unsigned width;
+ unsigned height;
+ unsigned fps;
+
+ VideoDeviceConfig () {}
+ VideoDeviceConfig (unsigned _width, unsigned _height, unsigned _fps) {
+ width = _width;
+ height = _height;
+ fps = _fps;
+ }
+
+ friend std::ostream& operator <<(std::ostream & stream, const VideoDeviceConfig & config){
+ stream << config.width << "x" << config.height << "/" << config.fps;
+ return stream;
+ }
+
+ VideoDeviceConfig & operator= (const VideoDeviceConfig & rhs)
+ {
+ width = rhs.width;
+ height = rhs.height;
+ fps = rhs.fps;
+ return *this;
+ }
+
+ bool operator==( const VideoDeviceConfig & rhs ) const
+ {
+ if ( (width == rhs.width) &&
+ (height == rhs.height) &&
+ (fps == rhs.fps) )
+ return true;
+ else
+ return false;
+ }
+
+ bool operator!=( const VideoDeviceConfig & rhs ) const
+ {
+ return (!(*this==rhs));
+ }
+
+ };
+
+private:
std::set<VideoInputManager *> managers;
Ekiga::Runtime & runtime;
- DeviceConfig preview_config;
- DeviceConfig stream_config;
-
- VidInputConfig new_stream_settings;
- VidInputConfig new_preview_settings;
+ VideoDeviceConfig preview_config;
+ VideoDeviceConfig stream_config;
- VideoInputManager* current_manager;
- VideoInputDevice desired_device;
- VideoInputDevice current_device;
- Ekiga::VideoInputFormat current_format;
- int current_channel;
+ VideoInputManager* current_manager;
+ VideoInputDevice desired_device;
+ VideoInputDevice current_device;
+ VideoInputFormat current_format;
+ int current_channel;
+ VideoInputSettings current_settings;
+ VideoInputSettings desired_settings;
- PMutex var_mutex; /* To protect variables that are read and written */
- PMutex set_mutex; /* To protect variables that are read and written */
+ PMutex core_mutex;
+ PMutex settings_mutex;
- PreviewManager preview_manager;
+ VideoPreviewManager preview_manager;
VideoInputCoreConfBridge* videoinput_core_conf_bridge;
};
/**
Modified: trunk/lib/engine/videoinput/skel/videoinput-info.h
==============================================================================
--- trunk/lib/engine/videoinput/skel/videoinput-info.h (original)
+++ trunk/lib/engine/videoinput/skel/videoinput-info.h Wed May 21 22:05:30 2008
@@ -59,27 +59,17 @@
static const struct {
int width;
int height;
- }
-
- VideoSizes[NB_VIDEO_SIZES] = {
+ } VideoSizes[NB_VIDEO_SIZES] = {
{ GM_QCIF_WIDTH, GM_QCIF_HEIGHT },
{ GM_CIF_WIDTH, GM_CIF_HEIGHT },
{ GM_4CIF_WIDTH, GM_4CIF_HEIGHT },
{ GM_SIF_WIDTH, GM_SIF_HEIGHT },
{ GM_4SIF_WIDTH, GM_4SIF_HEIGHT },
};
-
- enum VideoInputFormat {
- VI_FORMAT_PAL = 0,
- VI_FORMAT_NTSC,
- VI_FORMAT_SECAM,
- VI_FORMAT_Auto,
- VI_FORMAT_MAX
- };
class VideoInputDevice : public Device {};
- typedef struct VidInputConfig {
+ typedef struct VideoInputSettings {
unsigned whiteness;
unsigned brightness;
unsigned colour;
@@ -87,6 +77,14 @@
bool modifyable;
};
+ enum VideoInputFormat {
+ VI_FORMAT_PAL = 0,
+ VI_FORMAT_NTSC,
+ VI_FORMAT_SECAM,
+ VI_FORMAT_Auto,
+ VI_FORMAT_MAX
+ };
+
enum VideoInputErrorCodes {
VI_ERROR_NONE = 0,
VI_ERROR_DEVICE,
Modified: trunk/lib/engine/videoinput/skel/videoinput-manager.h
==============================================================================
--- trunk/lib/engine/videoinput/skel/videoinput-manager.h (original)
+++ trunk/lib/engine/videoinput/skel/videoinput-manager.h Wed May 21 22:05:30 2008
@@ -159,7 +159,7 @@
* @param device the video input device that was opened.
* @param config the current video input device configuration (current brightness, colour, etc.).
*/
- sigc::signal<void, VideoInputDevice, VidInputConfig> device_opened;
+ sigc::signal<void, VideoInputDevice, VideoInputSettings> device_opened;
/** This signal is emitted when a video input device is closed.
* @param device the video input device that was closed.
Modified: trunk/src/gui/assistant.cpp
==============================================================================
--- trunk/src/gui/assistant.cpp (original)
+++ trunk/src/gui/assistant.cpp Wed May 21 22:05:30 2008
@@ -881,7 +881,7 @@
std::vector <Ekiga::AudioOutputDevice> devices;
device_list.clear();
- audiooutput_core->get_audiooutput_devices(devices);
+ audiooutput_core->get_devices(devices);
for (std::vector<Ekiga::AudioOutputDevice>::iterator iter = devices.begin ();
iter != devices.end ();
@@ -904,7 +904,7 @@
std::vector <Ekiga::AudioInputDevice> devices;
device_list.clear();
- audioinput_core->get_audioinput_devices(devices);
+ audioinput_core->get_devices(devices);
for (std::vector<Ekiga::AudioInputDevice>::iterator iter = devices.begin ();
iter != devices.end ();
Modified: trunk/src/gui/main.cpp
==============================================================================
--- trunk/src/gui/main.cpp (original)
+++ trunk/src/gui/main.cpp Wed May 21 22:05:30 2008
@@ -1003,7 +1003,7 @@
void
on_videoinput_device_opened_cb (Ekiga::VideoInputManager & /* manager */,
Ekiga::VideoInputDevice & /* device */,
- Ekiga::VidInputConfig & config,
+ Ekiga::VideoInputSettings & settings,
gpointer self)
{
gm_main_window_update_sensitivity (GTK_WIDGET (self), TRUE, FALSE, TRUE);
@@ -1013,11 +1013,11 @@
mw = gm_mw_get_mw (GTK_WIDGET (self));
g_return_if_fail (mw != NULL);
- gtk_widget_set_sensitive (GTK_WIDGET (mw->video_settings_frame), config.modifyable ? TRUE : FALSE);
- GTK_ADJUSTMENT (mw->adj_whiteness)->value = config.whiteness;
- GTK_ADJUSTMENT (mw->adj_brightness)->value = config.brightness;
- GTK_ADJUSTMENT (mw->adj_colour)->value = config.colour;
- GTK_ADJUSTMENT (mw->adj_contrast)->value = config.contrast;
+ gtk_widget_set_sensitive (GTK_WIDGET (mw->video_settings_frame), settings.modifyable ? TRUE : FALSE);
+ GTK_ADJUSTMENT (mw->adj_whiteness)->value = settings.whiteness;
+ GTK_ADJUSTMENT (mw->adj_brightness)->value = settings.brightness;
+ GTK_ADJUSTMENT (mw->adj_colour)->value = settings.colour;
+ GTK_ADJUSTMENT (mw->adj_contrast)->value = settings.contrast;
gtk_widget_queue_draw (GTK_WIDGET (mw->video_settings_frame));
}
@@ -1169,12 +1169,12 @@
void
on_audiooutput_device_opened_cb (Ekiga::AudioOutputManager & /*manager*/,
- Ekiga::AudioOutputPrimarySecondary primarySecondary,
+ Ekiga::AudioOutputPS ps,
Ekiga::AudioOutputDevice & /*device*/,
Ekiga::AudioOutputConfig & config,
gpointer self)
{
- if (primarySecondary == Ekiga::secondary)
+ if (ps == Ekiga::secondary)
return;
GmMainWindow *mw = NULL;
@@ -1192,11 +1192,11 @@
void
on_audiooutput_device_closed_cb (Ekiga::AudioOutputManager & /*manager*/,
- Ekiga::AudioOutputPrimarySecondary primarySecondary,
+ Ekiga::AudioOutputPS ps,
Ekiga::AudioOutputDevice & /*device*/,
gpointer self)
{
- if (primarySecondary == Ekiga::secondary)
+ if (ps == Ekiga::secondary)
return;
GmMainWindow *mw = NULL;
@@ -1209,12 +1209,12 @@
void
on_audiooutput_device_error_cb (Ekiga::AudioOutputManager & /*manager */,
- Ekiga::AudioOutputPrimarySecondary primarySecondary,
+ Ekiga::AudioOutputPS ps,
Ekiga::AudioOutputDevice & device,
Ekiga::AudioOutputErrorCodes error_code,
gpointer self)
{
- if (primarySecondary == Ekiga::secondary)
+ if (ps == Ekiga::secondary)
return;
gchar *dialog_title = NULL;
@@ -2589,8 +2589,8 @@
Ekiga::AudioInputCore *audioinput_core = dynamic_cast<Ekiga::AudioInputCore *> (mw->core.get ("audioinput-core"));
Ekiga::AudioOutputCore *audiooutput_core = dynamic_cast<Ekiga::AudioOutputCore *> (mw->core.get ("audiooutput-core"));
- audioinput_core->start_average_collection();
- audiooutput_core->start_average_collection();
+ audioinput_core->set_average_collection(true);
+ audiooutput_core->set_average_collection(true);
mw->levelmeter_timeout_id = g_timeout_add_full (G_PRIORITY_DEFAULT_IDLE, 50, on_signal_level_refresh_cb, data, NULL);
}
@@ -2607,8 +2607,8 @@
Ekiga::AudioOutputCore *audiooutput_core = dynamic_cast<Ekiga::AudioOutputCore *> (mw->core.get ("audiooutput-core"));
g_source_remove (mw->levelmeter_timeout_id);
- audioinput_core->stop_average_collection();
- audiooutput_core->stop_average_collection();
+ audioinput_core->set_average_collection(false);
+ audiooutput_core->set_average_collection(false);
}
static void
Modified: trunk/src/gui/preferences.cpp
==============================================================================
--- trunk/src/gui/preferences.cpp (original)
+++ trunk/src/gui/preferences.cpp Wed May 21 22:05:30 2008
@@ -764,7 +764,7 @@
std::string device_string;
device_list.clear();
- audiooutput_core->get_audiooutput_devices(devices);
+ audiooutput_core->get_devices(devices);
for (std::vector<Ekiga::AudioOutputDevice>::iterator iter = devices.begin ();
iter != devices.end ();
@@ -787,7 +787,7 @@
std::vector <Ekiga::AudioInputDevice> devices;
device_list.clear();
- audioinput_core->get_audioinput_devices(devices);
+ audioinput_core->get_devices(devices);
for (std::vector<Ekiga::AudioInputDevice>::iterator iter = devices.begin ();
iter != devices.end ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]