[propput, helpstring("Returns/sets audio track used/to use.")]\r
HRESULT track([in] long track);\r
\r
- [propget, helpstring("Returns audio channel: reverse, stereo, left, right, dolby.")]\r
+ [propget, helpstring("Returns audio channel: reverse stereo, stereo, left, right, dolby.")]\r
HRESULT channel([out, retval] BSTR* channel);\r
- [propput, helpstring("Sets audio channel to: reverse, stereo, left, right, dolby.")]\r
+ [propput, helpstring("Sets audio channel to: reverse stereo, stereo, left, right, dolby.")]\r
HRESULT channel([in] BSTR channel);\r
};\r
\r
libvlc_exception_t ex;
libvlc_exception_init(&ex);
- *track = libvlc_audio_get_track(p_libvlc, &ex);
+ libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
+ *track = libvlc_audio_get_track(p_input, &ex);
+ libvlc_input_free(p_input);
if( libvlc_exception_raised(&ex) )
{
_p_instance->setErrorInfo(IID_IVLCAudio, libvlc_exception_get_message(&ex));
libvlc_exception_t ex;
libvlc_exception_init(&ex);
- libvlc_audio_set_track(p_libvlc, track, &ex);
+ libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
+ libvlc_audio_set_track(p_input, track, &ex);
+ libvlc_input_free(p_input);
if( libvlc_exception_raised(&ex) )
{
_p_instance->setErrorInfo(IID_IVLCAudio, libvlc_exception_get_message(&ex));
*channel = BSTRFromCStr(CP_UTF8, psz_channel);
free( psz_channel );
- return NOERROR;
+ psz_channel = NULL;
+ return (NULL == *channel) ? E_OUTOFMEMORY : NOERROR;
}
if( psz_channel ) free( psz_channel );
+ psz_channel = NULL;
_p_instance->setErrorInfo(IID_IVLCAudio,
libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return E_OUTOFMEMORY;
libvlc_audio_set_channel(p_libvlc, psz_channel, &ex);
-
CoTaskMemFree(psz_channel);
if( libvlc_exception_raised(&ex) )
{
if( NULL == psz_aspect )
return E_OUTOFMEMORY;
- *aspect = SysAllocStringByteLen(psz_aspect, strlen(psz_aspect));
+ *aspect = BSTRFromCStr(CP_UTF8, psz_aspect);
free( psz_aspect );
psz_aspect = NULL;
- return NOERROR;
+ return (NULL == *aspect) ? E_OUTOFMEMORY : NOERROR;
}
if( psz_aspect ) free( psz_aspect );
+ psz_aspect = NULL;
}
_p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
}
return E_OUTOFMEMORY;
};
-
void libvlc_audio_set_volume( libvlc_instance_t *, int, libvlc_exception_t *);
/**
- * Get current audio track
- * \param p_instance libvlc instance
- * \param p_exception an initialized exception
- * \return the audio track (int)
- */
-int libvlc_audio_get_track( libvlc_instance_t *, libvlc_exception_t * );
++ * Get current audio track
++ * \param p_input input instance
++ * \param p_exception an initialized exception
++ * \return the audio track (int)
++ */
+int libvlc_audio_get_track( libvlc_input_t *, libvlc_exception_t * );
/**
* Set current audio track
- * \param p_instance libvlc instance
+ * \param p_input input instance
* \param i_track the track (int)
* \param p_exception an initialized exception
* \return void
*/
-void libvlc_audio_set_track( libvlc_instance_t *, int, libvlc_exception_t * );
+void libvlc_audio_set_track( libvlc_input_t *, int, libvlc_exception_t * );
/**
* Get current audio channel
- * \param p_instance libvlc instance
+ * \param p_instance input instance
* \param p_exception an initialized exception
* \return the audio channel (char *)
*/
char *libvlc_audio_get_channel( libvlc_instance_t *, libvlc_exception_t * );
/**
- * Set current audio track
- * \param p_instance libvlc instance
+ * Set current audio channel
+ * \param p_instance input instance
* \param psz_channel the audio channel (char *)
* \param p_exception an initialized exception
* \return void
libvlc_exception_t ex;\r
libvlc_exception_init(&ex);\r
\r
+ libvlc_input_t *p_input = libvlc_playlist_get_input(p_plugin->getVLC(), &ex);\r
+ if( libvlc_exception_raised(&ex) )\r
+ {\r
+ NPN_SetException(this, libvlc_exception_get_message(&ex));\r
+ libvlc_exception_clear(&ex);\r
+ return INVOKERESULT_GENERIC_ERROR;\r
+ }\r
+\r
switch( index )\r
{\r
case ID_audio_mute:\r
{\r
vlc_bool_t muted = libvlc_audio_get_mute(p_plugin->getVLC(), &ex);\r
+ libvlc_input_free(p_input);\r
if( libvlc_exception_raised(&ex) )\r
{\r
NPN_SetException(this, libvlc_exception_get_message(&ex));\r
case ID_audio_volume:\r
{\r
int volume = libvlc_audio_get_volume(p_plugin->getVLC(), &ex);\r
+ libvlc_input_free(p_input);\r
if( libvlc_exception_raised(&ex) )\r
{\r
NPN_SetException(this, libvlc_exception_get_message(&ex));\r
}\r
case ID_audio_track:\r
{\r
- int track = libvlc_audio_get_track(p_plugin->getVLC(), &ex);\r
+ int track = libvlc_audio_get_track(p_input, &ex);\r
+ libvlc_input_free(p_input);\r
if( libvlc_exception_raised(&ex) )\r
{\r
NPN_SetException(this, libvlc_exception_get_message(&ex));\r
}\r
case ID_audio_channel:\r
{\r
- char *channel = libvlc_audio_get_channel(p_plugin->getVLC(), &ex);\r
+ NPUTF8 *psz_channel = libvlc_audio_get_channel(p_plugin->getVLC(), &ex);\r
+ libvlc_input_free(p_input);\r
if( libvlc_exception_raised(&ex) )\r
{\r
NPN_SetException(this, libvlc_exception_get_message(&ex));\r
libvlc_exception_clear(&ex);\r
return INVOKERESULT_GENERIC_ERROR;\r
}\r
- if( channel )\r
- {\r
- int len = strlen(channel);\r
- NPUTF8 *retval = (NPUTF8*)NPN_MemAlloc(len);\r
- if( retval )\r
- {\r
- memcpy(retval, channel, len);\r
- STRINGN_TO_NPVARIANT(retval, len, result);\r
- }\r
- else\r
- {\r
- NULL_TO_NPVARIANT(result);\r
- }\r
- free( channel );\r
- channel = NULL;\r
- return INVOKERESULT_NO_ERROR;\r
- }\r
- return INVOKERESULT_NO_SUCH_METHOD;\r
+ if( !psz_channel )\r
+ return INVOKERESULT_GENERIC_ERROR;\r
+\r
+ STRINGZ_TO_NPVARIANT(psz_channel, result);\r
+ return INVOKERESULT_NO_ERROR;\r
}\r
default:\r
;\r
}\r
+ libvlc_input_free(p_input);\r
}\r
return INVOKERESULT_GENERIC_ERROR;\r
}\r
libvlc_exception_t ex;\r
libvlc_exception_init(&ex);\r
\r
+ libvlc_input_t *p_input = libvlc_playlist_get_input(p_plugin->getVLC(), &ex);\r
+ if( libvlc_exception_raised(&ex) )\r
+ {\r
+ NPN_SetException(this, libvlc_exception_get_message(&ex));\r
+ libvlc_exception_clear(&ex);\r
+ return INVOKERESULT_GENERIC_ERROR;\r
+ }\r
+\r
switch( index )\r
{\r
case ID_audio_mute:\r
{\r
libvlc_audio_set_mute(p_plugin->getVLC(),\r
NPVARIANT_TO_BOOLEAN(value), &ex);\r
+ libvlc_input_free(p_input);\r
if( libvlc_exception_raised(&ex) )\r
{\r
NPN_SetException(this, libvlc_exception_get_message(&ex));\r
}\r
return INVOKERESULT_INVALID_VALUE;\r
case ID_audio_volume:\r
+ libvlc_input_free(p_input);\r
if( isNumberValue(value) )\r
{\r
libvlc_audio_set_volume(p_plugin->getVLC(),\r
case ID_audio_track:\r
if( isNumberValue(value) )\r
{\r
- libvlc_audio_set_track(p_plugin->getVLC(),\r
+ libvlc_audio_set_track(p_input,\r
numberValue(value), &ex);\r
+ libvlc_input_free(p_input);\r
if( libvlc_exception_raised(&ex) )\r
{\r
NPN_SetException(this, libvlc_exception_get_message(&ex));\r
}\r
return INVOKERESULT_NO_ERROR;\r
}\r
+ libvlc_input_free(p_input);\r
return INVOKERESULT_INVALID_VALUE;\r
case ID_audio_channel:\r
{\r
char *psz_channel = NULL;\r
\r
+ libvlc_input_free(p_input);\r
if( ! NPVARIANT_IS_STRING(value) )\r
- {\r
return INVOKERESULT_INVALID_VALUE;\r
- }\r
\r
psz_channel = stringValue(NPVARIANT_TO_STRING(value));\r
if( !psz_channel )\r
default:\r
;\r
}\r
+ libvlc_input_free(p_input);\r
}\r
return INVOKERESULT_GENERIC_ERROR;\r
}\r
\r
psz_aspect = stringValue(NPVARIANT_TO_STRING(value));\r
if( !psz_aspect )\r
+ {\r
+ libvlc_input_free(p_input);\r
return INVOKERESULT_GENERIC_ERROR;\r
+ }\r
\r
libvlc_video_set_aspect_ratio(p_input, psz_aspect, &ex);\r
if( psz_aspect )\r
\r
LibvlcInputNPObject(NPP instance, const NPClass *aClass) :\r
RuntimeNPObject(instance, aClass) {};\r
- \r
+\r
virtual ~LibvlcInputNPObject() {};\r
\r
static const int propertyCount;\r
\r
LibvlcMessageNPObject(NPP instance, const NPClass *aClass) :\r
RuntimeNPObject(instance, aClass) {};\r
- \r
+\r
virtual ~LibvlcMessageNPObject() {};\r
\r
static const int propertyCount;\r
\r
LibvlcMessagesNPObject(NPP instance, const NPClass *aClass) :\r
RuntimeNPObject(instance, aClass) {};\r
- \r
+\r
virtual ~LibvlcMessagesNPObject() {};\r
\r
static const int propertyCount;\r
#include "libvlc_internal.h"
#include <vlc/libvlc.h>
+#include <vlc_input.h>
#include <vlc_aout.h>
+/*
+ * Remember to release the returned input_thread_t since it is locked at
+ * the end of this function.
+ */
+static input_thread_t *GetInput( libvlc_input_t *p_input,
+ libvlc_exception_t *p_exception )
+{
+ input_thread_t *p_input_thread = NULL;
+
+ if( !p_input )
+ {
+ libvlc_exception_raise( p_exception, "Input is NULL" );
+ return NULL;
+ }
+
+ p_input_thread = (input_thread_t*)vlc_object_get(
+ p_input->p_instance->p_libvlc_int,
+ p_input->i_input_id );
+ if( !p_input_thread )
+ {
+ libvlc_exception_raise( p_exception, "Input does not exist" );
+ return NULL;
+ }
+
+ return p_input_thread;
+}
+
+/*
+ * Remember to release the returned aout_instance_t since it is locked at
+ * the end of this function.
+ */
+static aout_instance_t *GetAOut( libvlc_instance_t *p_instance,
+ libvlc_exception_t *p_exception )
+{
+ aout_instance_t * p_aout = NULL;
+
+ p_aout = vlc_object_find( p_instance->p_libvlc_int, VLC_OBJECT_AOUT, FIND_CHILD );
+ if( !p_aout )
+ {
+ libvlc_exception_raise( p_exception, "No active audio output" );
+ return NULL;
+ }
+
+ return p_aout;
+}
+
+
/*****************************************************************************
* libvlc_audio_get_mute : Get the volume state, true if muted
*****************************************************************************/
/*****************************************************************************
* libvlc_audio_get_track : Get the current audio track
*****************************************************************************/
-int libvlc_audio_get_track( libvlc_instance_t *p_instance,
+int libvlc_audio_get_track( libvlc_input_t *p_input,
libvlc_exception_t *p_e )
{
+ input_thread_t *p_input_thread = GetInput( p_input, p_e );
int i_track = 0;
- i_track = var_GetInteger( p_instance->p_libvlc_int, "audio-track" );
+ i_track = var_GetInteger( p_input_thread, "audio-es" );
+ vlc_object_release( p_input_thread );
return i_track;
}
/*****************************************************************************
* libvlc_audio_set_track : Set the current audio track
*****************************************************************************/
-void libvlc_audio_set_track( libvlc_instance_t *p_instance, int i_track,
+void libvlc_audio_set_track( libvlc_input_t *p_input, int i_track,
libvlc_exception_t *p_e )
{
+ input_thread_t *p_input_thread = GetInput( p_input, p_e );
+ vlc_value_t val_list;
int i_ret = -1;
+ int i;
- i_ret = var_SetInteger( p_instance->p_libvlc_int, "audio-track", i_track );
-
- if( i_ret < 0 )
+ var_Change( p_input_thread, "audio-es", VLC_VAR_GETCHOICES, &val_list, NULL );
+ for( i = 0; i < val_list.p_list->i_count; i++ )
{
- libvlc_exception_raise( p_e, "Setting audio track failed" );
+ vlc_value_t val = val_list.p_list->p_values[i];
+ if( i_track == val.i_int )
+ {
+ i_ret = var_SetInteger( p_input_thread, "audio-es", i_track );
+ if( i_ret < 0 )
+ {
+ libvlc_exception_raise( p_e, "Setting audio track failed" );
+ }
+ vlc_object_release( p_input_thread );
+ return;
+ }
}
+ libvlc_exception_raise( p_e, "Audio track out of range" );
+ vlc_object_release( p_input_thread );
}
/*****************************************************************************
char *libvlc_audio_get_channel( libvlc_instance_t *p_instance,
libvlc_exception_t *p_e )
{
+ aout_instance_t *p_aout = GetAOut( p_instance, p_e );
char *psz_channel = NULL;
- int i_channel = 0;
+ vlc_value_t val;
- i_channel = var_GetInteger( p_instance->p_libvlc_int, "audio-channel" );
- switch( i_channel )
+ var_Get( p_aout, "audio-channels", &val );
+ switch( val.i_int )
{
case AOUT_VAR_CHAN_RSTEREO:
- psz_channel = strdup("reverse");
+ psz_channel = strdup("reverse stereo");
break;
case AOUT_VAR_CHAN_STEREO:
psz_channel = strdup("stereo");
psz_channel = strdup("disabled");
break;
}
+ vlc_object_release( p_aout );
return psz_channel;
}
void libvlc_audio_set_channel( libvlc_instance_t *p_instance, char *psz_channel,
libvlc_exception_t *p_e )
{
- int i_ret = -1;
- int i_channel = 0;
+ aout_instance_t *p_aout = GetAOut( p_instance, p_e );
+ vlc_value_t val_list, text_list;
+ int i_ret = -1, i;
- if( !psz_channel )
+ i_ret = var_Change( p_aout, "audio-channels", VLC_VAR_GETCHOICES, &val_list, &text_list );
+ if( (i_ret < 0) || !psz_channel )
{
- libvlc_exception_raise( p_e, "Audio track out of range" );
+ libvlc_exception_raise( p_e, "Audio channel out of range" );
+ vlc_object_release( p_aout );
+ return;
}
- else
+
+ for( i = 0; i < val_list.p_list->i_count; i++ )
{
- if( strncmp( psz_channel, "reverse", 7 ) == 0 )
- i_channel = AOUT_VAR_CHAN_RSTEREO;
- else if( strncmp( psz_channel, "stereo", 6 ) == 0 )
- i_channel = AOUT_VAR_CHAN_STEREO;
- else if( strncmp( psz_channel, "left", 4 ) == 0 )
- i_channel = AOUT_VAR_CHAN_LEFT;
- else if( strncmp( psz_channel, "right", 5 ) == 0 )
- i_channel = AOUT_VAR_CHAN_RIGHT;
- else if( strncmp( psz_channel, "dolby", 5 ) == 0 )
- i_channel = AOUT_VAR_CHAN_DOLBYS;
-
- i_ret = var_SetInteger( p_instance->p_libvlc_int, "audio-channel", i_channel );
- if( i_ret < 0 )
+ vlc_value_t val = val_list.p_list->p_values[i];
+ vlc_value_t text = text_list.p_list->p_values[i];
+
+ if( strncasecmp( psz_channel, text.psz_string, strlen(text.psz_string) ) == 0 )
{
- libvlc_exception_raise( p_e, "Audio track out of range" );
+ i_ret = var_Set( p_aout, "audio-channels", val );
+ if( i_ret < 0 )
+ {
+ break;
+ }
}
}
+ libvlc_exception_raise( p_e, "Audio channel out of range" );
+ vlc_object_release( p_aout );
}
+
if ( libvlc_exception_raised( p_e ) )
{
if ( strcmp( "No active video output", libvlc_exception_get_message( p_e ) ) == 0 )
- {
- libvlc_exception_clear( p_e );
- }
- return VLC_FALSE;
+ {
+ libvlc_exception_clear( p_e );
+ }
+ return VLC_FALSE;
}
vlc_object_release( p_vout );
/// \todo: set exception
return 0;
}
-
+
vout_Control( p_vout , VOUT_REPARENT, d);
vlc_object_release( p_vout );