Commit fb619a0c authored by Jean-Paul Saman's avatar Jean-Paul Saman

audio_output/amem.c: change "audio-delay" when amem-delay is set

Change audio-delay on when amem-delay is set. At the same time fix
a few bugs:
- free(aout->output.p_sys->psz_name);
- in windows code
parent a4339167
......@@ -35,6 +35,8 @@
#include <vlc_es.h>
#include <vlc_aout.h>
#include <vlc_playlist.h> /* changing audio delay */
#if defined(_WIN32_WINNT) || defined(WIN32)
# include <windows.h>
# include <conio.h>
......@@ -124,8 +126,6 @@ typedef struct
/* Private structure */
struct aout_sys_t
{
int i_delay;
#if defined(_WIN32_WINNT) || defined(WIN32)
HANDLE handle;
#else
......@@ -384,7 +384,8 @@ static void amem_shmem_close(aout_instance_t *aout)
amem_sem_destroy(&sys->header->sem);
#if defined(_WIN32_WINNT) || defined(WIN32)
UnmapViewOfFile(sys->header);
if (sys->header)
UnmapViewOfFile(sys->header);
CloseHandle(sys->handle);
#else
/* Determine shared memory size */
......@@ -418,10 +419,11 @@ static void amem_shmem_header(aout_instance_t *aout)
fourcc_to_wf_tag(aout->output.output.i_format, &tag);
header->wave.wFormatTag = tag;
header->wave.nChannels = aout->output.output.i_channels;
header->wave.nSamplesPerSec = aout->output.output.i_rate * aout->output.i_nb_samples;
//header->wave.nAvgBytesPerSec = ;
header->wave.nBlockAlign = aout->output.output.i_blockalign;
header->wave.wBitsPerSample = aout->output.output.i_bitspersample;
header->wave.nSamplesPerSec = header->i_rate * header->i_max_samples;
header->wave.wBitsPerSample = header->i_bitspersample;
//header->wave.nBlockAlign = header->i_blockalign;
header->wave.nBlockAlign = header->wave.wBitsPerSample / 8 * header->wave.nChannels;
header->wave.nAvgBytesPerSec = header->wave.nSamplesPerSec * header->wave.nBlockAlign;
header->wave.cbSize = 0; /* No additional format metadata */
#else
header->i_format = aout->output.output.i_format;
......@@ -519,7 +521,7 @@ vlc_module_begin()
change_integer_range( 0, CHANNELS_MAX )
add_integer( AMEM_CFG_PREFIX "samplerate", 44100, NULL, ARATE_TEXT,
ARATE_LONGTEXT, true )
add_integer( AMEM_CFG_PREFIX "delay", 0, NULL, ADELAY_TEXT,
add_integer( AMEM_CFG_PREFIX "delay", -1, NULL, ADELAY_TEXT,
ADELAY_TEXT, true )
set_callbacks(Open, Close)
......@@ -553,9 +555,6 @@ static int Open(vlc_object_t *p_this)
/* Audio sample rate */
aout->output.output.i_rate = var_CreateGetInteger(p_this, AMEM_CFG_PREFIX "samplerate");
/* Audio output delay */
sys->i_delay = var_CreateGetInteger(p_this, AMEM_CFG_PREFIX "delay");
/* Audio format */
psz_format = var_CreateGetString(p_this, AMEM_CFG_PREFIX "format");
......@@ -570,8 +569,8 @@ static int Open(vlc_object_t *p_this)
if (*ppsz_compare == NULL)
{
msg_Err(aout, "cannot understand the format string (%s)",
psz_format);
msg_Err(aout, "cannot understand the format string (%s)", psz_format);
free(aout->output.p_sys->psz_name);
free(aout->output.p_sys);
free(psz_format);
return VLC_EGENERIC;
......@@ -600,13 +599,35 @@ static int Open(vlc_object_t *p_this)
pi_channels_maps[i_channels];
}
/* Audio output buffers */
int i_buffers = var_CreateGetInteger(aout, AMEM_CFG_PREFIX "buffers");
if (i_buffers < 1)
{
msg_Err(aout, "insufficient shared audio buffers requested");
free(aout->output.p_sys->psz_name);
free(aout->output.p_sys);
return VLC_EGENERIC;
}
/* Audio output delay */
int64_t i_delay = var_CreateGetInteger(aout, AMEM_CFG_PREFIX "delay");
if (i_delay >= 0)
{
playlist_t *p_playlist = pl_Get(aout);
/* Update the input */
input_thread_t *p_input = playlist_CurrentInput(p_playlist);
if (p_input == NULL)
{
free(aout->output.p_sys->psz_name);
free(aout->output.p_sys);
return VLC_EGENERIC;
}
if (var_GetTime(p_input, "audio-delay") != i_delay)
var_SetTime(p_input, "audio-delay", i_delay);
vlc_object_release(p_input);
}
/* Setup shared memory connection */
if (SetupSharedMem(aout, i_buffers) != VLC_SUCCESS)
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment