1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
|
/*
* Copyright (C) 2005-2008 by Daniel Wagner
*
* This file is part of FFADO
* FFADO = Free FireWire (pro-)audio drivers for Linux
*
* FFADO is based upon FreeBoB.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "libavc/audiosubunit/avc_function_block.h"
#include "libutil/serialize.h"
#include "libutil/cmd_serialize.h"
#include "libieee1394/ieee1394service.h"
#include <cerrno>
const bool bVerbose = false;
using namespace AVC;
using namespace Util;
using namespace Util::Cmd;
short int
getPan( Ieee1394Service& ieee1394service, int node_id, int ffb_id,
FunctionBlockCmd::EControlAttribute control_attrib )
{
FunctionBlockCmd fbCmd( ieee1394service,
FunctionBlockCmd::eFBT_Feature,
ffb_id,
control_attrib );
fbCmd.setNodeId( node_id );
fbCmd.setSubunitId( 0x00 );
fbCmd.setCommandType( AVCCommand::eCT_Status );
fbCmd.m_pFBFeature->m_audioChannelNumber = 2;
fbCmd.m_pFBFeature->m_controlSelector=FunctionBlockFeature::eCSE_Feature_LRBalance;
AVC::FunctionBlockFeatureLRBalance lr;
fbCmd.m_pFBFeature->m_pLRBalance = lr.clone();
fbCmd.m_pFBFeature->m_pLRBalance->m_lrBalance = 0;
fbCmd.setVerbose( bVerbose );
if (bVerbose) {
ieee1394service.setVerboseLevel( DEBUG_LEVEL_VERBOSE );
}
if ( !fbCmd.fire() ) {
printf( "cmd failed\n" );
}
if ( bVerbose ) {
CoutSerializer se;
fbCmd.serialize( se );
}
return fbCmd.m_pFBFeature->m_pLRBalance->m_lrBalance;
}
bool
setPan( Ieee1394Service& ieee1394service, int node_id, int ffb_id, int pan )
{
FunctionBlockCmd fbCmd( ieee1394service,
FunctionBlockCmd::eFBT_Feature,
ffb_id,
FunctionBlockCmd::eCA_Current );
fbCmd.setNodeId( node_id );
fbCmd.setSubunitId( 0x00 );
fbCmd.setCommandType( AVCCommand::eCT_Control );
fbCmd.m_pFBFeature->m_audioChannelNumber = 2;
fbCmd.m_pFBFeature->m_controlSelector=FunctionBlockFeature::eCSE_Feature_LRBalance;
AVC::FunctionBlockFeatureLRBalance lr;
fbCmd.m_pFBFeature->m_pLRBalance = lr.clone();
fbCmd.m_pFBFeature->m_pLRBalance->m_lrBalance = pan;
fbCmd.setVerbose( bVerbose );
if (bVerbose) {
ieee1394service.setVerboseLevel( DEBUG_LEVEL_VERBOSE );
}
bool bStatus = fbCmd.fire();
if ( !bStatus ) {
printf( "cmd failed\n" );
}
if ( bVerbose ) {
CoutSerializer se;
fbCmd.serialize( se );
}
return bStatus;
}
bool
doApp( Ieee1394Service& ieee1394service, int node_id, int fb_id, int pan )
{
short int maxPan = getPan( ieee1394service, node_id, fb_id, FunctionBlockCmd::eCA_Maximum );
short int minPan = getPan( ieee1394service, node_id, fb_id, FunctionBlockCmd::eCA_Minimum );
short int curPan = getPan( ieee1394service, node_id, fb_id, FunctionBlockCmd::eCA_Current );
printf( "max pan value = %d\n", maxPan );
printf( "min pan value = %d\n", minPan );
printf( "old pan value = %d\n", curPan );
//setPan( ieee1394service, node_id, fb_id, pan );
curPan = getPan( ieee1394service, node_id, fb_id, FunctionBlockCmd::eCA_Current );
printf( "new pan value = %d\n", curPan );
return true;
}
///////////////////////////
// main
//////////////////////////
int
main(int argc, char **argv)
{
if (argc < 4) {
printf("usage: NODE_ID FB_ID PAN\n");
exit(0);
}
errno = 0;
char* tail;
int node_id = strtol( argv[1], &tail, 0 );
int fb_id = strtol( argv[2], &tail, 0 );
int pan = strtol( argv[3], &tail, 0 );
if (errno) {
perror("argument parsing failed:");
return -1;
}
Ieee1394Service ieee1394service;
if ( !ieee1394service.initialize( 0 ) ) {
fprintf( stderr, "could not set port on ieee1394service\n" );
return -1;
}
doApp( ieee1394service, node_id, fb_id, pan );
return 0;
}
|