Update of /cvsroot/playerstage/code/player/client_libs/libplayerc++
In directory
sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27187/client_libs/libplayerc++
Modified Files:
Tag: release-2-0-patches
aioproxy.cc audioproxy.cc playerc++.cc playererror.h
Log Message:
backported client lib stuff from HEAD
Index: playererror.h
===================================================================
RCS file:
/cvsroot/playerstage/code/player/client_libs/libplayerc++/playererror.h,v
retrieving revision 1.7
retrieving revision 1.7.2.1
diff -C2 -d -r1.7 -r1.7.2.1
*** playererror.h 23 Nov 2005 09:12:51 -0000 1.7
--- playererror.h 9 Jun 2006 01:17:52 -0000 1.7.2.1
***************
*** 7,21 ****
namespace PlayerCc
{
- /** @addtogroup player_clientlib_cplusplus libplayerc++
-
- @{
-
- */
-
- /** @addtogroup player_clientlib_cplusplus_core Core functionality
-
- @{
-
- */
/** @brief The C++ exception class
--- 7,10 ----
***************
*** 50,56 ****
~PlayerError();
};
- /** }@ (core) */
-
- /** }@ (c++) */
}
--- 39,42 ----
Index: playerc++.cc
===================================================================
RCS file:
/cvsroot/playerstage/code/player/client_libs/libplayerc++/playerc++.cc,v
retrieving revision 1.12
retrieving revision 1.12.2.1
diff -C2 -d -r1.12 -r1.12.2.1
*** playerc++.cc 18 Feb 2006 19:13:04 -0000 1.12
--- playerc++.cc 9 Jun 2006 01:17:52 -0000 1.12.2.1
***************
*** 28,33 ****
#include "playerc++.h"
! /** @ingroup player_clientlib_cplusplus
! @defgroup cplusplus_example libplayerc++ example
@brief An example of using libplayerc++
--- 28,50 ----
#include "playerc++.h"
! /** @ingroup clientlibs
! @addtogroup player_clientlib_cplusplus libplayerc++
! @brief A C++ client library for the @ref util_player
!
! The C++ library is built on a "service proxy" model in which the client
! maintains local objects that are proxies for remote services. This library
! wraps the functionality of @ref player_clientlib_libplayerc with a more
! friendly C++ API.
!
! * The core of libplayerc++ is based around the following classes
! * - PlayerCc::PlayerClient
! * - PlayerCc::ClientProxy
! * - PlayerCc::PlayerError
!
! Be sure to see @ref cplusplus_example "this example".
! */
!
! /** @ingroup player_clientlib_cplusplus
! @addtogroup cplusplus_example libplayerc++ example
@brief An example of using libplayerc++
***************
*** 83,88 ****
*/
! /** @ingroup player_clientlib_cplusplus
! @defgroup player_clientlib_multi Signals & multithreading
@brief Boost signal and thread support
--- 100,105 ----
*/
! /** @ingroup player_clientlib_cplusplus
! @addtogroup player_clientlib_multi Signals & multithreading
@brief Boost signal and thread support
Index: aioproxy.cc
===================================================================
RCS file:
/cvsroot/playerstage/code/player/client_libs/libplayerc++/aioproxy.cc,v
retrieving revision 1.6
retrieving revision 1.6.2.1
diff -C2 -d -r1.6 -r1.6.2.1
*** aioproxy.cc 4 Nov 2005 17:57:07 -0000 1.6
--- aioproxy.cc 9 Jun 2006 01:17:52 -0000 1.6.2.1
***************
*** 52,59 ****
mDevice = playerc_aio_create(mClient, aIndex);
if (NULL==mDevice)
! throw PlayerError("LaserProxy::LaserProxy()", "could not create");
if (0 != playerc_aio_subscribe(mDevice, PLAYER_OPEN_MODE))
! throw PlayerError("LaserProxy::LaserProxy()", "could not subscribe");
}
--- 52,59 ----
mDevice = playerc_aio_create(mClient, aIndex);
if (NULL==mDevice)
! throw PlayerError("AioProxy::AioProxy()", "could not create");
if (0 != playerc_aio_subscribe(mDevice, PLAYER_OPEN_MODE))
! throw PlayerError("AioProxy::AioProxy()", "could not subscribe");
}
***************
*** 79,83 ****
{
os << "#AIO (" << c.GetInterface() << ":" << c.GetIndex() << ")" <<
std::endl;
! os << c.GetCount() << std::endl;
if (c.GetCount() < 0)
{
--- 79,83 ----
{
os << "#AIO (" << c.GetInterface() << ":" << c.GetIndex() << ")" <<
std::endl;
! //os << c.GetCount() << std::endl;
if (c.GetCount() < 0)
{
Index: audioproxy.cc
===================================================================
RCS file:
/cvsroot/playerstage/code/player/client_libs/libplayerc++/audioproxy.cc,v
retrieving revision 1.2
retrieving revision 1.2.4.1
diff -C2 -d -r1.2 -r1.2.4.1
*** audioproxy.cc 7 Oct 2005 15:49:30 -0000 1.2
--- audioproxy.cc 9 Jun 2006 01:17:52 -0000 1.2.4.1
***************
*** 24,83 ****
* $Id$
*
- * client-side blobfinder device
*/
#include "playerc++.h"
! void
! AudioProxy::FillData(player_msghdr_t hdr, const char *buffer)
{
! if(hdr.size != sizeof(player_audio_data_t))
{
! if(player_debug_level(-1) >= 1)
! fprintf(stderr,"WARNING: AudioProxy expected %d bytes of "
! "audio data, but received %d. Unexpected results may "
! "ensue.\n",
! sizeof(player_audio_data_t),hdr.size);
}
! frequency0 = ntohs(((player_audio_data_t*)buffer)->frequency0);
! amplitude0 = ntohs(((player_audio_data_t*)buffer)->amplitude0);
! frequency1 = ntohs(((player_audio_data_t*)buffer)->frequency1);
! amplitude1 = ntohs(((player_audio_data_t*)buffer)->amplitude1);
! frequency2 = ntohs(((player_audio_data_t*)buffer)->frequency2);
! amplitude2 = ntohs(((player_audio_data_t*)buffer)->amplitude2);
! frequency3 = ntohs(((player_audio_data_t*)buffer)->frequency3);
! amplitude3 = ntohs(((player_audio_data_t*)buffer)->amplitude3);
! frequency4 = ntohs(((player_audio_data_t*)buffer)->frequency4);
! amplitude4 = ntohs(((player_audio_data_t*)buffer)->amplitude4);
}
! int
! AudioProxy::PlayTone(unsigned short freq,
! unsigned short amp,
! unsigned short dur)
{
! player_audio_cmd_t cmd;
! cmd.frequency = htons(freq);
! cmd.amplitude = htons(amp);
! cmd.duration = htons(dur);
! return(client->Write(m_device_id,
! (const char*)&cmd,sizeof(cmd)));
}
! // interface that all proxies SHOULD provide
! void
! AudioProxy::Print()
{
! printf("#Audio(%d:%d) - %c\n", m_device_id.code,
! m_device_id.index, access);
! printf("(%6u,%6u) (%6u,%6u) (%6u,%6u) (%6u,%6u) (%6u,%6u)\n",
! frequency0,amplitude0,
! frequency1,amplitude1,
! frequency2,amplitude2,
! frequency3,amplitude3,
! frequency4,amplitude4);
}
--- 24,231 ----
* $Id$
*
*/
+ #if HAVE_CONFIG_H
+ #include "config.h"
+ #endif
+
+ #include <cassert>
+ #include <sstream>
+ #include <iomanip>
+
#include "playerc++.h"
+ #include "debug.h"
! using namespace PlayerCc;
!
! AudioProxy::AudioProxy(PlayerClient *aPc, uint aIndex)
! : ClientProxy(aPc, aIndex),
! mDevice(NULL)
{
! Subscribe(aIndex);
! mInfo = &(mDevice->info);
! }
!
! AudioProxy::~AudioProxy()
! {
! Unsubscribe();
! }
!
! void AudioProxy::Subscribe(uint aIndex)
! {
! scoped_lock_t lock(mPc->mMutex);
! mDevice = playerc_audio_create(mClient, aIndex);
! if (mDevice==NULL)
! throw PlayerError("AudioProxy::AudioProxy()", "could not create");
!
! if (playerc_audio_subscribe(mDevice, PLAYER_OPEN_MODE) != 0)
! throw PlayerError("AudioProxy::AudioProxy()", "could not subscribe");
! }
!
! void AudioProxy::Unsubscribe(void)
! {
! assert(mDevice!=NULL);
! scoped_lock_t lock(mPc->mMutex);
! playerc_audio_unsubscribe(mDevice);
! playerc_audio_destroy(mDevice);
! mDevice = NULL;
! }
!
! // interface that all proxies SHOULD provide
! std::ostream& std::operator << (std::ostream& os, const PlayerCc::AudioProxy&
a)
! {
! player_audio_mixer_channel_detail_t channel_detail;
! player_audio_mixer_channel_t channel;
!
! int old_precision = os.precision(3);
! std::_Ios_Fmtflags old_flags = os.flags();
! os.setf(std::ios::fixed);
!
! int NumChannelDetails = a.GetMixerDetailsCount();
! int NumChannels = a.GetChannelCount();
! int MinChan = NumChannels < NumChannelDetails ? NumChannels :
NumChannelDetails;
!
! os << MinChan << " channels:" << std::endl;
! os << "Index\tValue\tState\tType\tName" << std::endl;
! for (int ii = 0; ii < MinChan; ii++)
{
! channel_detail = a.GetMixerDetails(ii);
! channel = a.GetChannel(ii);
! os << ii << '\t'
! << channel.amplitude << '\t'
! << channel.active.state << '\t'
! << channel_detail.type << '\t'
! << channel_detail.name
! << std::endl;
}
! os.precision(old_precision);
! os.flags(old_flags);
!
! return os;
}
!
!
!
! /** @brief Command to play an audio block */
! void AudioProxy::PlayWav(player_audio_wav_t * aData)
{
! scoped_lock_t lock(mPc->mMutex);
! playerc_audio_wav_play_cmd(mDevice, aData);
! }
! /** @brief Command to set recording state */
! void AudioProxy::SetWavStremRec(bool aState)
! {
! scoped_lock_t lock(mPc->mMutex);
! playerc_audio_wav_stream_rec_cmd(mDevice, aState);
! }
! /** @brief Command to play prestored sample */
! void AudioProxy::PlaySample(int aIndex)
! {
! scoped_lock_t lock(mPc->mMutex);
! playerc_audio_sample_play_cmd(mDevice, aIndex);
}
! /** @brief Command to play sequence of tones */
! void AudioProxy::PlaySeq(player_audio_seq_t * aTones)
{
! scoped_lock_t lock(mPc->mMutex);
! playerc_audio_seq_play_cmd(mDevice, aTones);
! }
!
! /** @brief Command to set mixer levels */
! void AudioProxy::SetMixerLevels(player_audio_mixer_channel_list_t * aLevels)
! {
! scoped_lock_t lock(mPc->mMutex);
! playerc_audio_mixer_channel_cmd(mDevice, aLevels);
! }
!
! /** @brief Request to record a single audio block
! result is stored in wav_data */
! void AudioProxy::RecordWav()
! {
! scoped_lock_t lock(mPc->mMutex);
! int ret = playerc_audio_wav_rec(mDevice);
!
! if (ret == -2)
! throw PlayerError("AudioProxy::RecordWav", "NACK", ret);
! else if (ret != 0)
! throw PlayerError("AudioProxy::RecordWav",
! playerc_error_str(),
! ret);
! }
!
! /** @brief Request to load an audio sample */
! void AudioProxy::LoadSample(int aIndex, player_audio_wav_t * aData)
! {
! scoped_lock_t lock(mPc->mMutex);
! int ret = playerc_audio_sample_load(mDevice, aIndex, aData);
!
! if (ret == -2)
! throw PlayerError("AudioProxy::LoadSample", "NACK", ret);
! else if (ret != 0)
! throw PlayerError("AudioProxy::LoadSample",
! playerc_error_str(),
! ret);
}
+ /** @brief Request to retrieve an audio sample
+ Data is stored in wav_data */
+ void AudioProxy::GetSample(int aIndex)
+ {
+ scoped_lock_t lock(mPc->mMutex);
+ int ret = playerc_audio_sample_retrieve(mDevice, aIndex);
+ if (ret == -2)
+ throw PlayerError("AudioProxy::GetSample", "NACK", ret);
+ else if (ret != 0)
+ throw PlayerError("AudioProxy::GetSample",
+ playerc_error_str(),
+ ret);
+ }
+
+ /** @brief Request to record new sample */
+ void AudioProxy::RecordSample(int aIndex)
+ {
+ scoped_lock_t lock(mPc->mMutex);
+ int ret = playerc_audio_sample_rec(mDevice, aIndex);
+
+ if (ret == -2)
+ throw PlayerError("AudioProxy::RecordSample", "NACK", ret);
+ else if (ret != 0)
+ throw PlayerError("AudioProxy::RecordSample",
+ playerc_error_str(),
+ ret);
+ }
+
+ /** @brief Request mixer channel data
+ result is stored in mixer_data*/
+ void AudioProxy::GetMixerLevels()
+ {
+ scoped_lock_t lock(mPc->mMutex);
+ int ret = playerc_audio_get_mixer_levels(mDevice);
+
+ if (ret == -2)
+ throw PlayerError("AudioProxy::GetMixerLevels", "NACK", ret);
+ else if (ret != 0)
+ throw PlayerError("AudioProxy::GetMixerLevels",
+ playerc_error_str(),
+ ret);
+ }
+
+ /** @brief Request mixer channel details list
+ result is stored in channel_details_list*/
+ void AudioProxy::GetMixerDetails()
+ {
+ scoped_lock_t lock(mPc->mMutex);
+ int ret = playerc_audio_get_mixer_details(mDevice);
+
+ if (ret == -2)
+ throw PlayerError("AudioProxy::GetMixerDetails", "NACK", ret);
+ else if (ret != 0)
+ throw PlayerError("AudioProxy::GetMixerDetails",
+ playerc_error_str(),
+ ret);
+ }
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit